403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.220
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/yme/wp-content/plugins/google-sitemap-generator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/yme/wp-content/plugins/google-sitemap-generator/class-googlesitemapgeneratorindexnow.php
<?php
/* IndexNow class */

class GoogleSitemapGeneratorIndexNow {

    private $siteUrl;
    private $version;
    private $prefix = "gsg_indexnow-";

    public function start($indexUrl){
		$this->siteUrl = get_home_url();
		$this->version = $this->getVersion();
		$apiKey = $this->getApiKey();
		
		return $this->sendToIndex($this->siteUrl, $indexUrl, $apiKey, false);
    }

    public function getApiKey() {
		$meta_key = $this->prefix . "admin_api_key";
        $apiKey = is_multisite() ? get_site_option($meta_key) : get_option($meta_key);
        if ($apiKey) return base64_decode($apiKey);

		return false;
    }

    private function sendToIndex($site_url, $url, $api_key, $is_manual_submission){
        
        $data = json_encode(
			array(
				'host'         => $this->remove_scheme( $site_url ),
				'key'          => $api_key,
				'keyLocation'  => trailingslashit( $site_url ) . $api_key . '.txt',
				'urlList'     => array( $url ),
			)
		);

        $response = wp_remote_post(
            'https://api.indexnow.org/indexnow/',
            array(
                'body'    => $data,
                'headers' => array( 
                    'Content-Type'  => 'application/json',
                    'X-Source-Info' => 'https://wordpress.com/' . $this->version . '/' . $is_manual_submission
                ),
            )
        );

		if (is_wp_error( $response )) {
			if ( true === WP_DEBUG && true === WP_DEBUG_LOG) {
			    error_log(__METHOD__ . " error:WP_Error: ".$response->get_error_message()) ;
			}
			return "error:WP_Error";
		}
		if ( isset( $response['errors'] ) ) {
			return 'error:RequestFailed';
		}
		try {
			if (in_array($response['response']['code'], [200, 202])) {
				return 'success';
			} else {
				if ( 400 === $response['response']['code'] ) {
					return 'error:InvalidRequest';
				} else 
				 if ( 403 === $response['response']['code'] ) {
					 return 'error:InvalidApiKey';
				 } else 
				 if ( 422 === $response['response']['code'] ) {
					 return 'error:InvalidUrl';
				 }else 
				if ( 429 === $response['response']['code'] ) {
					return 'error:UnknownError';
				}else {
					return 'error: ' . $response['response']['message'];
					if ( true === WP_DEBUG && true === WP_DEBUG_LOG) {
						error_log(__METHOD__ . " body : ". json_decode($response['body'])->message) ;
					}
				}
			}
		} catch ( \Throwable $th ) {
			return 'error:RequestFailed';
		}

    }

    private function remove_scheme( $url ) {
		if ( 'http://' === substr( $url, 0, 7 ) ) {
			return substr( $url, 7 );
		}
		if ( 'https://' === substr( $url, 0, 8 ) ) {
			return substr( $url, 8 );
		}
		return $url;
	}

    private function getVersion(){
        if ( isset( $GLOBALS['sm_version']) ) {
            $this->version = $GLOBALS['sm_version'];
        } else {
            $this->version = '1.0.1';
        }
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit