403Webshell
Server IP : 172.67.158.161  /  Your IP : 3.144.100.245
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/cwd/wp-content/plugins/wordpress-seo/inc/endpoints/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/cwd/wp-content/plugins/wordpress-seo/inc/endpoints/class-myyoast-connect.php
<?php
/**
 * WPSEO plugin file.
 *
 * @package WPSEO\Endpoint
 */

/**
 * Represents an implementation of the WPSEO_Endpoint interface to register one or multiple endpoints.
 */
class WPSEO_Endpoint_MyYoast_Connect implements WPSEO_Endpoint {

	/**
	 * The namespace to use.
	 *
	 * @var string
	 */
	const REST_NAMESPACE = 'yoast/v1/myyoast';

	/**
	 * Registers the REST routes that are available on the endpoint.
	 *
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function register() {
		register_rest_route(
			self::REST_NAMESPACE,
			'connect',
			[
				'methods'             => 'POST',
				'callback'            => [ $this, 'handle_request' ],
				'permission_callback' => [ $this, 'can_retrieve_data' ],
			]
		);
	}

	/**
	 * Determines whether or not data can be retrieved for the registered endpoints.
	 *
	 * @param WP_REST_Request $request The current request.
	 *
	 * @return WP_REST_Response The response.
	 */
	public function handle_request( WP_REST_Request $request ) {
		if ( $request->get_param( 'url' ) !== $this->get_home_url() ) {
			return new WP_REST_Response(
				'Bad request: URL mismatch.',
				403
			);
		}

		if ( $request->get_param( 'clientId' ) !== $this->get_client_id() ) {
			return new WP_REST_Response(
				'Bad request: ClientID mismatch.',
				403
			);
		}

		$client_secret = $request->get_param( 'clientSecret' );
		if ( empty( $client_secret ) ) {
			return new WP_REST_Response(
				'Bad request: ClientSecret missing.',
				403
			);
		}

		$this->save_secret( $client_secret );

		return new WP_REST_Response( 'Connection successful established.' );
	}

	/**
	 * Determines whether or not data can be retrieved for the registered endpoints.
	 *
	 * @return bool Whether or not data can be retrieved.
	 */
	public function can_retrieve_data() {
		return true;
	}

	/**
	 * Saves the client secret.
	 *
	 * @codeCoverageIgnore
	 *
	 * @param string $client_secret The secret to save.
	 *
	 * @return void
	 */
	protected function save_secret( $client_secret ) {
		$this->get_client()->save_configuration(
			[
				'secret' => $client_secret,
			]
		);
	}

	/**
	 * Retrieves the current client ID.
	 *
	 * @codeCoverageIgnore
	 *
	 * @return array The client ID.
	 */
	protected function get_client_id() {
		$config = $this->get_client()->get_configuration();

		return $config['clientId'];
	}

	/**
	 * Retrieves an instance of the client.
	 *
	 * @codeCoverageIgnore
	 *
	 * @return WPSEO_MyYoast_Client Instance of client.
	 */
	protected function get_client() {
		static $client;

		if ( ! $client ) {
			$client = new WPSEO_MyYoast_Client();
		}

		return $client;
	}

	/**
	 * Wraps the method for retrieving the home URL.
	 *
	 * @codeCoverageIgnore
	 *
	 * @return string Home URL.
	 */
	protected function get_home_url() {
		return WPSEO_Utils::get_home_url();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit