403Webshell
Server IP : 192.64.118.117  /  Your IP : 3.137.189.49
Web Server : LiteSpeed
System : Linux premium56.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
User : thecgapy ( 1160)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/thecgapy/tcrgfinancesuite.com/wp-content/plugins/w3-total-cache/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/thecgapy/tcrgfinancesuite.com/wp-content/plugins/w3-total-cache/Extension_Swarmify_Widget.php
<?php
namespace W3TC;



class Extension_Swarmify_Widget {
	private $_config;

	static public function admin_init_w3tc_dashboard() {
		$o = new Extension_Swarmify_Widget();
		$o->_config = Dispatcher::config();

		add_action( 'w3tc_widget_setup', array( $o, 'wp_dashboard_setup' ), 150 );
		add_action( 'w3tc_network_dashboard_setup',
			array( $o, 'wp_dashboard_setup' ), 150 );

		wp_enqueue_style( 'w3tc-widget-swarmify',
			plugins_url( 'Extension_Swarmify_Widget_View.css', W3TC_FILE ),
			array(), W3TC_VERSION );
	}

	/**
	 * Dashboard setup action
	 */
	function wp_dashboard_setup() {
		Util_Widget::add( 'w3tc_swarmify',
			'<div class="w3tc-widget-swarmify-logo"></div>',
			array( $this, 'widget_swarmify' ),
			Util_Ui::admin_url( 'admin.php?page=w3tc_extensions&extension=swarmify&action=view' ),
			'normal' );
	}



	/**
	 * Loads and configured New Relic widget to be used in WP Dashboards.
	 *
	 * @param unknown $widget_id
	 * @param array   $form_inputs
	 */
	function widget_swarmify( $widget_id, $form_inputs = array() ) {
		$api_key = $this->_config->get_string( array( 'swarmify', 'api_key' ) );
		$configured = !empty( $api_key );

		$swarmify_signup_url = 'https://www.swarmify.com/landing/w3tc?return=' .
			urlencode( wp_nonce_url( Util_Ui::admin_url( 'admin.php' ),	'w3tc' ) .
				'&page=w3tc_extensions&w3tc_swarmify_set_key=set' );

		if ( $configured ) {
			include  W3TC_DIR . '/Extension_Swarmify_Widget_View_NotConfigured.php';
			return;
		} else {
			include  W3TC_DIR . '/Extension_Swarmify_Widget_View_NotConfigured.php';
		}
	}



	/**
	 * Gives data for widget content
	 */
	public function w3tc_ajax_newrelic_widgetdata_basic() {
		// cache status for some small time
		$response = get_transient( 'w3tc_nr_widgetdata_basic' );
		$response = @json_decode( $response, true );
		if ( is_array( $response ) && isset( $response['time'] ) &&
			$response['time'] >= time() - 60 ) {
			echo json_encode( $response );
			return;
		}

		$service = Dispatcher::component( 'Extension_NewRelic_Service' );
		$verify_running = $service->verify_running();

		$response = array(
			'time' => time()
		);

		if ( !is_array( $verify_running ) )
			$response['php_agent'] = '<span class="w3tc-enabled">enabled</span>';
		else
			$response['php_agent'] = '<span class="w3tc-disabled">disabled</span>';

		try {
			$subscription = $service->get_subscription();
			$response['subscription_level'] = $subscription['product-name'];

			$summary = $service->get_application_summary();
			$this->_fill( $response, 'apdex', $summary, 'Apdex' );
			$this->_fill( $response, 'application_busy', $summary,
				'Application Busy' );
			$this->_fill( $response, 'error_rate', $summary, 'Error Rate' );
			$this->_fill( $response, 'throughput', $summary, 'Throughput' );
			$this->_fill( $response, 'errors', $summary, 'Errors' );
			$this->_fill( $response, 'response_time', $summary, 'Response Time' );
			$this->_fill( $response, 'db', $summary, 'DB' );
			$this->_fill( $response, 'cpu', $summary, 'CPU' );
			$this->_fill( $response, 'memory', $summary, 'Memory' );

			$can_use_metrics = $service->can_get_metrics();
			if ( $can_use_metrics ) {
				$dashboard_metrics = $service->get_dashboard_metrics();
				$this->_fill_avg( $response, 'enduser', $dashboard_metrics,
					'EndUser' );
				$this->_fill_avg( $response, 'webtransaction', $dashboard_metrics,
					'WebTransaction' );
				$this->_fill_avg( $response, 'database', $dashboard_metrics,
					'Database' );
			}

			// load data for notification here too
			$pl = $service->get_frontend_response_time();
			update_option( 'w3tc_nr_frontend_response_time', $pl );
		} catch ( \Exception $ex ) {
		}

		set_transient( 'w3tc_nr_widgetdata_basic', json_encode( $response ), 60 );
		echo json_encode( $response );
	}



	public function w3tc_ajax_newrelic_widgetdata_pageloads() {
		$response = array(
			'content' => '<div class="w3tcnr_topfive_message">No data available</div>'
		);

		try {
			$service = Dispatcher::component( 'Extension_NewRelic_Service' );
			$can_use_metrics = $service->can_get_metrics();
			if ( $can_use_metrics ) {
				$metric_slow_pages = $service->get_slowest_page_load();
				if ( count( $metric_slow_pages ) > 0 ) {
					$s = '<table class="w3tcnr_slowest">';

					foreach ( $metric_slow_pages as $transaction => $time ) {
						$s .= '<tr><td><span>' . $transaction .
							'</span></td><td>' . Util_Ui::secs_to_time( $time ) .
							'</td></tr>';
					}

					$s .= '</table>';
					$response['content'] = $s;
				}
			}
		} catch ( \Exception $e ) {
			$response['content'] = '<div class="w3tcnr_topfive_message">Error occurred</div>';
		}

		echo json_encode( $response );
	}



	public function w3tc_ajax_newrelic_widgetdata_webtransactions() {
		$response = array(
			'content' => '<div class="w3tcnr_topfive_message">No data available</div>'
		);

		try {
			$service = Dispatcher::component( 'Extension_NewRelic_Service' );
			$can_use_metrics = $service->can_get_metrics();
			if ( $can_use_metrics ) {
				$metric_slow = $service->get_slowest_webtransactions();
				if ( count( $metric_slow ) > 0 ) {
					$s = '<table class="w3tcnr_slowest">';

					foreach ( $metric_slow as $transaction => $time ) {
						$s .= '<tr><td><span>' . $transaction .
							'</span></td><td>' . Util_Ui::secs_to_time( $time ) .
							'</td></tr>';
					}

					$s .= '</table>';
					$response['content'] = $s;
				}
			}
		} catch ( \Exception $e ) {
			$response['content'] = '<div class="w3tcnr_topfive_message">Error occurred</div>';
		}

		echo json_encode( $response );
	}




	public function w3tc_ajax_newrelic_widgetdata_dbtimes() {
		$response = array(
			'content' => '<div class="w3tcnr_topfive_message">No data available</div>'
		);

		try {
			$service = Dispatcher::component( 'Extension_NewRelic_Service' );
			$can_use_metrics = $service->can_get_metrics();
			if ( $can_use_metrics ) {
				$metric_slow = $service->get_slowest_database();
				if ( count( $metric_slow ) > 0 ) {
					$s = '<table class="w3tcnr_slowest">';

					foreach ( $metric_slow as $transaction => $time ) {
						$s .= '<tr><td><span>' . $transaction .
							'</span></td><td>' . Util_Ui::secs_to_time( $time ) .
							'</td></tr>';
					}

					$s .= '</table>';
					$response['content'] = $s;
				}
			}
		} catch ( \Exception $e ) {
			$response['content'] = '<div class="w3tcnr_topfive_message">Error occurred</div>';
		}

		echo json_encode( $response );
	}



	private function _fill( &$response, $response_key, $summary, $summary_key ) {
		if ( isset( $summary[$summary_key] ) )
			$response[$response_key] = $summary[$summary_key];
	}



	private function _fill_avg( &$response, $response_key, $metrics, $metric_key ) {
		if ( !isset( $metrics[$metric_key] ) )
			return;

		$data = $metrics[$metric_key];
		$response[$response_key] = Util_Ui::secs_to_time(
			array_shift( $data[0] )->average_response_time
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit