HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/hcv/wp-content/plugins/w3-total-cache/Extension_CloudFlare_Widget.php
<?php
namespace W3TC;

/**
 * widget with stats
 */
class Extension_CloudFlare_Widget {
	function init() {
		add_action( 'admin_print_styles-toplevel_page_w3tc_dashboard',
			array( $this, 'admin_print_styles_w3tc_dashboard' ) );
		add_action( 'admin_print_scripts-toplevel_page_w3tc_dashboard',
			array( $this, 'admin_print_scripts_w3tc_dashboard' ) );

		Util_Widget::add2( 'w3tc_cloudflare', 10000,
			'<div class="w3tc_cloudflare_widget_logo"></div>',
			array( $this, 'widget_form' ),
			Util_Ui::admin_url( 'admin.php?page=w3tc_general#cloudflare' ),
			'normal' );
	}



	function widget_form() {
		$api = Extension_CloudFlare_SettingsForUi::api();
		$c = Dispatcher::config();
		$interval = $c->get_integer( array( 'cloudflare', 'widget_interval' ) );

		$v = get_transient( 'w3tc_cloudflare_stats' );

		try {
			$key = 'dashboard-' . $interval;
			if ( !isset( $v[$key] ) ) {
				if ( !is_array( $v ) )
					$v = array();

				$v[$key] = $api->analytics_dashboard( $interval );
				set_transient( 'w3tc_cloudflare_stats', $v,
					$this->_cache_mins * 60 );
			}

			$stats = $v[$key];
		} catch ( \Exception $e ) {
			$stats = null;
		}

		include  W3TC_DIR . '/Extension_CloudFlare_Widget_View.php';
	}



	public function admin_print_styles_w3tc_dashboard() {
		wp_enqueue_style( 'w3tc-widget' );
		wp_enqueue_style( 'w3tc-cloudflare-widget',
			plugins_url( 'Extension_CloudFlare_Widget_View.css', W3TC_FILE ),
			array(), W3TC_VERSION );
	}



	public function admin_print_scripts_w3tc_dashboard() {
		wp_enqueue_script( 'w3tc-metadata' );
		wp_enqueue_script( 'w3tc-widget' );
	}



	private function v( $stats, $key1, $key2 ) {
		echo '<td class="cloudflare_td_value">';
		echo number_format( $this->value( $stats, 'totals', $key1, $key2 ) );
		echo "</td>\n";
	}



	private function value( $a, $k1, $k2, $k3 = null ) {
		$v = $a;
		if ( !is_null( $k1 ) )
			$v = isset( $v[$k1] ) ? $v[$k1] : null;
		if ( !is_null( $k2 ) )
			$v = isset( $v[$k2] ) ? $v[$k2] : null;
		if ( !is_null( $k3 ) )
			$v = isset( $v[$k3] ) ? $v[$k3] : null;

		return $v;
	}



	private function time( $a, $k1 ) {
		if ( !isset( $a['totals'][$k1] ) )
			return;

		echo date( 'm/d/Y H:i:s', strtotime( $a['totals'][$k1] ) );
	}



	private function time_mins( $a, $k1 ) {
		if ( !isset( $a['totals'][$k1] ) )
			return;

		echo date( 'm/d/Y H:i', strtotime( $a['totals'][$k1] ) );
	}
}