Sync plugins from current page
Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
		| @@ -0,0 +1,653 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Admin_Pages | ||||
|  */ | ||||
| class WP_Statistics_Admin_Pages { | ||||
|  | ||||
| 	//Transient For Show Notice Setting | ||||
| 	public static $setting_notice = '_show_notice_wp_statistics'; | ||||
|  | ||||
| 	/** | ||||
| 	 * Load Overview Page | ||||
| 	 */ | ||||
| 	static function overview() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Right side "wide" widgets | ||||
| 		if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 			add_meta_box( | ||||
| 				'wps_hits_postbox', | ||||
| 				__( 'Hit Statistics', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'hits' ) | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 			add_meta_box( | ||||
| 				'wps_top_visitors_postbox', | ||||
| 				__( 'Top Visitors', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'top.visitors' ) | ||||
| 			); | ||||
| 			add_meta_box( | ||||
| 				'wps_search_postbox', | ||||
| 				__( 'Search Engine Referrals', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'search' ) | ||||
| 			); | ||||
| 			add_meta_box( | ||||
| 				'wps_words_postbox', | ||||
| 				__( 'Latest Search Words', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'words' ) | ||||
| 			); | ||||
| 			add_meta_box( | ||||
| 				'wps_recent_postbox', | ||||
| 				__( 'Recent Visitors', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'recent' ) | ||||
| 			); | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 				add_meta_box( | ||||
| 					'wps_map_postbox', | ||||
| 					__( 'Today\'s Visitors Map', 'wp-statistics' ), | ||||
| 					'wp_statistics_generate_overview_postbox_contents', | ||||
| 					$WP_Statistics->menu_slugs['overview'], | ||||
| 					'normal', | ||||
| 					null, | ||||
| 					array( 'widget' => 'map' ) | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'pages' ) ) { | ||||
| 			add_meta_box( | ||||
| 				'wps_pages_postbox', | ||||
| 				__( 'Top 10 Pages', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'normal', | ||||
| 				null, | ||||
| 				array( 'widget' => 'pages' ) | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		// Left side "thin" widgets. | ||||
| 		if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 			add_meta_box( | ||||
| 				'wps_summary_postbox', | ||||
| 				__( 'Summary', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'side', | ||||
| 				null, | ||||
| 				array( 'widget' => 'summary' ) | ||||
| 			); | ||||
| 			add_meta_box( | ||||
| 				'wps_browsers_postbox', | ||||
| 				__( 'Browsers', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'side', | ||||
| 				null, | ||||
| 				array( 'widget' => 'browsers' ) | ||||
| 			); | ||||
| 			add_meta_box( | ||||
| 				'wps_referring_postbox', | ||||
| 				__( 'Top Referring Sites', 'wp-statistics' ), | ||||
| 				'wp_statistics_generate_overview_postbox_contents', | ||||
| 				$WP_Statistics->menu_slugs['overview'], | ||||
| 				'side', | ||||
| 				null, | ||||
| 				array( 'widget' => 'referring' ) | ||||
| 			); | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 				add_meta_box( | ||||
| 					'wps_countries_postbox', | ||||
| 					__( 'Top 10 Countries', 'wp-statistics' ), | ||||
| 					'wp_statistics_generate_overview_postbox_contents', | ||||
| 					$WP_Statistics->menu_slugs['overview'], | ||||
| 					'side', | ||||
| 					null, | ||||
| 					array( 'widget' => 'countries' ) | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Left Show User online table | ||||
| 		if ( $WP_Statistics->get_option( 'useronline' ) ) { | ||||
| 			add_meta_box( 'wps_users_online_postbox', __( 'Online Users', 'wp-statistics' ), 'wp_statistics_generate_overview_postbox_contents', $WP_Statistics->menu_slugs['overview'], 'side', null, array( 'widget' => 'users_online' ) ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Check in admin page | ||||
| 	 * | ||||
| 	 * @param $page | For Get List @see \WP_STATISTICS\WP_Statistics::$page | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public static function in_page( $page ) { | ||||
| 		global $pagenow; | ||||
|  | ||||
| 		//Check is custom page | ||||
| 		if ( $pagenow == "admin.php" and isset( $_REQUEST['page'] ) and $_REQUEST['page'] == WP_Statistics::$page[ $page ] ) { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Show Page title | ||||
| 	 * @param string $title | ||||
| 	 */ | ||||
| 	public static function show_page_title( $title = '' ) { | ||||
|  | ||||
| 		//Check if $title not Set | ||||
| 		if ( empty( $title ) and function_exists( 'get_admin_page_title' ) ) { | ||||
| 			$title = get_admin_page_title(); | ||||
| 		} | ||||
|  | ||||
| 		//show Page title | ||||
| 		echo '<img src="' . plugins_url( 'wp-statistics/assets/images/' ) . '/title-logo.png" class="wps_page_title"><h2 class="wps_title">' . $title . '</h2>'; | ||||
|  | ||||
| 		//do_action after wp_statistics | ||||
| 		do_action( 'wp_statistics_after_title' ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get Admin Url | ||||
| 	 * | ||||
| 	 * @param null $page | ||||
| 	 * @param array $arg | ||||
| 	 * @area is_admin | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function admin_url( $page = null, $arg = array() ) { | ||||
|  | ||||
| 		//Check If Pages is in Wp-statistics | ||||
| 		if ( array_key_exists( $page, WP_Statistics::$page ) ) { | ||||
| 			$page = WP_Statistics::$page[ $page ]; | ||||
| 		} | ||||
|  | ||||
| 		return add_query_arg( array_merge( array( 'page' => $page ), $arg ), admin_url( 'admin.php' ) ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Show MetaBox button Refresh/Direct Button Link in Top of Meta Box | ||||
| 	 * | ||||
| 	 * @param string $export | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function meta_box_button( $export = 'all' ) { | ||||
|  | ||||
| 		//Prepare button | ||||
| 		$refresh = '</button><button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '<span class="screen-reader-text">' . __( 'Reload', 'wp-statistics' ) . '</span></button>'; | ||||
| 		$more    = '<button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-external' ) . '<span class="screen-reader-text">' . __( 'More Details', 'wp-statistics' ) . '</span></button>'; | ||||
|  | ||||
| 		//Export | ||||
| 		if ( $export == 'all' ) { | ||||
| 			return $refresh . $more; | ||||
| 		} else { | ||||
| 			return $$export; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Show Loading Meta Box | ||||
| 	 */ | ||||
| 	public static function loading_meta_box() { | ||||
| 		$loading = '<div class="wps_loading_box"><img src=" ' . plugins_url( 'wp-statistics/assets/images/' ) . 'loading.svg" alt="' . __( 'Reloading...', 'wp-statistics' ) . '"></div>'; | ||||
| 		return $loading; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Sanitize Email Subject | ||||
| 	 * | ||||
| 	 * @param $subject | ||||
| 	 * @return string|string[]|null | ||||
| 	 */ | ||||
| 	public static function sanitize_mail_subject( $subject ) { | ||||
|  | ||||
| 		# Remove Special character | ||||
| 		$str = preg_replace( '/[\'^£$%&*()}{@#~?><>,|=+¬]/', '', $subject ); | ||||
|  | ||||
| 		# Replace sequences of spaces with hyphen | ||||
| 		$str = preg_replace( '/  */', '-', $str ); | ||||
|  | ||||
| 		# You may also want to try this alternative: | ||||
| 		$str = preg_replace( '/\\s+/', ' ', $str ); | ||||
|  | ||||
| 		return $str; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Plugins | ||||
| 	 */ | ||||
| 	static function plugins() { | ||||
| 		// Activate or deactivate the selected plugin | ||||
| 		if ( isset( $_GET['action'] ) ) { | ||||
| 			if ( $_GET['action'] == 'activate' ) { | ||||
| 				$result = activate_plugin( $_GET['plugin'] . '/' . $_GET['plugin'] . '.php' ); | ||||
| 				if ( is_wp_error( $result ) ) { | ||||
| 					wp_statistics_admin_notice_result( 'error', $result->get_error_message() ); | ||||
| 				} else { | ||||
| 					wp_statistics_admin_notice_result( 'success', __( 'Add-On activated.', 'wp-statistics' ) ); | ||||
| 				} | ||||
| 			} | ||||
| 			if ( $_GET['action'] == 'deactivate' ) { | ||||
| 				$result = deactivate_plugins( $_GET['plugin'] . '/' . $_GET['plugin'] . '.php' ); | ||||
| 				if ( is_wp_error( $result ) ) { | ||||
| 					wp_statistics_admin_notice_result( 'error', $result->get_error_message() ); | ||||
| 				} else { | ||||
| 					wp_statistics_admin_notice_result( 'success', __( 'Add-On deactivated.', 'wp-statistics' ) ); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$response      = wp_remote_get( 'https://wp-statistics.com/wp-json/plugin/addons' ); | ||||
| 		$response_code = wp_remote_retrieve_response_code( $response ); | ||||
| 		$error         = null; | ||||
| 		$plugins       = array(); | ||||
|  | ||||
| 		// Check response | ||||
| 		if ( is_wp_error( $response ) ) { | ||||
| 			$error = $response->get_error_message(); | ||||
| 		} else { | ||||
| 			if ( $response_code == '200' ) { | ||||
| 				$plugins = json_decode( $response['body'] ); | ||||
| 			} else { | ||||
| 				$error = $response['body']; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/plugins.php'; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Donate | ||||
| 	 */ | ||||
| 	static function donate() { | ||||
| 		echo "<script>window.location.href='http://wp-statistics.com/donate';</script>"; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Loads the optimization page code. | ||||
| 	 */ | ||||
| 	static function optimization() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// Check the current user has the rights to be here. | ||||
| 		if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ) ) ) { | ||||
| 			wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | ||||
| 		} | ||||
|  | ||||
| 		// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences | ||||
| 		// during the creation of the class.  Instead load them now that the user exists. | ||||
| 		$WP_Statistics->load_user_options(); | ||||
|  | ||||
| 		// Get the row count for each of the tables, we'll use this later on in the wps_optimization.php file. | ||||
| 		$list_table = wp_statistics_db_table( 'all' ); | ||||
| 		$result     = array(); | ||||
| 		foreach ( $list_table as $tbl_key => $tbl_name ) { | ||||
| 			$result[ $tbl_name ] = $wpdb->get_var( "SELECT COUNT(*) FROM `$tbl_name`" ); | ||||
| 		} | ||||
|  | ||||
| 		include WP_Statistics::$reg['plugin-dir'] . "includes/optimization/wps-optimization.php"; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This function displays the HTML for the settings page. | ||||
| 	 */ | ||||
| 	static function settings() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Check the current user has the rights to be here. | ||||
| 		if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_options' ) ) ) ) { | ||||
| 			wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | ||||
| 		} | ||||
|  | ||||
| 		// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences | ||||
| 		// during the creation of the class.  Instead load them now that the user exists. | ||||
| 		$WP_Statistics->load_user_options(); | ||||
|  | ||||
| 		// Check admin notices. | ||||
| 		if ( $WP_Statistics->get_option( 'admin_notices' ) == true ) { | ||||
| 			$WP_Statistics->update_option( 'disable_donation_nag', false ); | ||||
| 			$WP_Statistics->update_option( 'disable_suggestion_nag', false ); | ||||
| 		} | ||||
|  | ||||
| 		include WP_Statistics::$reg['plugin-dir'] . "includes/settings/wps-settings.php"; | ||||
|  | ||||
| 		// We could let the download happen at the end of the page, but this way we get to give some | ||||
| 		// feedback to the users about the result. | ||||
| 		if ( $WP_Statistics->get_option( 'geoip' ) and isset( $_POST['update_geoip'] ) and isset( $_POST['geoip_name'] ) ) { | ||||
|  | ||||
| 			//Check Geo ip Exist in Database | ||||
| 			if ( isset( WP_Statistics_Updates::$geoip[ $_POST['geoip_name'] ] ) ) { | ||||
| 				$result = WP_Statistics_Updates::download_geoip( $_POST['geoip_name'], "update" ); | ||||
|  | ||||
| 				if ( isset( $result['status'] ) and $result['status'] === false ) { | ||||
| 					add_filter( "wp_statistics_redirect_setting", function ( $redirect ) { | ||||
| 						$redirect = true; | ||||
| 						return $redirect; | ||||
| 					} ); | ||||
| 				} else { | ||||
| 					echo $result['notice']; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		//Enabled Geo ip Country Or City And download | ||||
| 		foreach ( array( "geoip" => "country", "geoip_city" => "city" ) as $geo_opt => $geo_name ) { | ||||
| 			if ( ! isset( $_POST['update_geoip'] ) and isset( $_POST[ 'wps_' . $geo_opt ] ) ) { | ||||
|  | ||||
| 				//Check File Not Exist | ||||
| 				$upload_dir = wp_upload_dir(); | ||||
| 				$file       = $upload_dir['basedir'] . '/wp-statistics/' . WP_Statistics_Updates::$geoip[ $geo_name ]['file'] . '.mmdb'; | ||||
| 				if ( ! file_exists( $file ) ) { | ||||
| 					$result = WP_Statistics_Updates::download_geoip( $geo_name ); | ||||
| 					if ( isset( $result['status'] ) and $result['status'] === false ) { | ||||
| 						add_filter( "wp_statistics_redirect_setting", function ( $redirect ) { | ||||
| 							$redirect = true; | ||||
| 							return $redirect; | ||||
| 						} ); | ||||
| 					} else { | ||||
| 						echo $result['notice']; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Redirect Set Setting | ||||
| 		self::wp_statistics_redirect_setting(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set Transient Notice | ||||
| 	 * | ||||
| 	 * @param $text | ||||
| 	 * @param string $type | ||||
| 	 */ | ||||
| 	public static function set_admin_notice( $text, $type = 'error' ) { | ||||
| 		$get = get_transient( WP_Statistics_Admin_Pages::$setting_notice ); | ||||
| 		if ( $get != false ) { | ||||
| 			$results = $get; | ||||
| 		} | ||||
| 		delete_transient( WP_Statistics_Admin_Pages::$setting_notice ); | ||||
| 		$results[] = array( "text" => $text, "type" => $type ); | ||||
| 		set_transient( WP_Statistics_Admin_Pages::$setting_notice, $results, 1 * HOUR_IN_SECONDS ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Notification Setting | ||||
| 	 */ | ||||
| 	public static function wp_statistics_notice_setting() { | ||||
| 		global $pagenow, $WP_Statistics; | ||||
|  | ||||
| 		//Show Notice By Plugin | ||||
| 		$get = get_transient( WP_Statistics_Admin_Pages::$setting_notice ); | ||||
| 		if ( $get != false ) { | ||||
| 			foreach ( $get as $item ) { | ||||
| 				wp_statistics_admin_notice_result( $item['type'], $item['text'] ); | ||||
| 			} | ||||
| 			delete_transient( WP_Statistics_Admin_Pages::$setting_notice ); | ||||
| 		} | ||||
|  | ||||
| 		//Check referring Spam Update | ||||
| 		if ( $pagenow == "admin.php" and isset( $_GET['page'] ) and $_GET['page'] == WP_Statistics::$page['settings'] and isset( $_GET['update-referrerspam'] ) ) { | ||||
|  | ||||
| 			// Update referrer spam | ||||
| 			$update_spam = WP_Statistics_Updates::download_referrerspam(); | ||||
| 			if ( $update_spam === true ) { | ||||
| 				wp_statistics_admin_notice_result( 'success', __( 'Updated Matomo Referrer Spam.', 'wp-statistics' ) ); | ||||
| 			} else { | ||||
| 				wp_statistics_admin_notice_result( 'error', __( 'error in get referrer spam list. please try again.', 'wp-statistics' ) ); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Redirect Jquery | ||||
| 	 * @param bool $redirect | ||||
| 	 */ | ||||
| 	public static function wp_statistics_redirect_setting( $redirect = false ) { | ||||
| 		$redirect = apply_filters( 'wp_statistics_redirect_setting', $redirect ); | ||||
| 		if ( $redirect === true ) { | ||||
| 			echo '<script>window.location.replace("' . ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" . '");</script>'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param string $log_type Log Type | ||||
| 	 */ | ||||
| 	static function log( $log_type = "" ) { | ||||
| 		global $wpdb, $WP_Statistics, $plugin_page; | ||||
|  | ||||
| 		switch ( $plugin_page ) { | ||||
| 			case WP_Statistics::$page['browser']: | ||||
| 				$log_type = 'all-browsers'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['countries']: | ||||
| 				$log_type = 'top-countries'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['exclusions']: | ||||
| 				$log_type = 'exclusions'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['hits']: | ||||
| 				$log_type = 'hit-statistics'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['online']: | ||||
| 				$log_type = 'online'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['pages']: | ||||
| 				$log_type = 'top-pages'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['categories']: | ||||
| 				$log_type = 'categories'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['tags']: | ||||
| 				$log_type = 'tags'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['authors']: | ||||
| 				$log_type = 'authors'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['referrers']: | ||||
| 				$log_type = 'top-referring-site'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['searches']: | ||||
| 				$log_type = 'search-statistics'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['words']: | ||||
| 				$log_type = 'last-all-search'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['top-visitors']: | ||||
| 				$log_type = 'top-visitors'; | ||||
|  | ||||
| 				break; | ||||
| 			case WP_Statistics::$page['visitors']: | ||||
| 				$log_type = 'last-all-visitor'; | ||||
|  | ||||
| 				break; | ||||
| 			default: | ||||
| 				$log_type = ""; | ||||
| 		} | ||||
|  | ||||
| 		// When we create $WP_Statistics the user has not been authenticated yet so we cannot load the user preferences | ||||
| 		// during the creation of the class.  Instead load them now that the user exists. | ||||
| 		$WP_Statistics->load_user_options(); | ||||
|  | ||||
| 		// We allow for a get style variable to be passed to define which function to use. | ||||
| 		if ( $log_type == "" && array_key_exists( 'type', $_GET ) ) { | ||||
| 			$log_type = $_GET['type']; | ||||
| 		} | ||||
|  | ||||
| 		// Verify the user has the rights to see the statistics. | ||||
| 		if ( ! current_user_can( | ||||
| 			wp_statistics_validate_capability( | ||||
| 				$WP_Statistics->get_option( | ||||
| 					'read_capability', | ||||
| 					'manage_option' | ||||
| 				) | ||||
| 			) | ||||
| 		) | ||||
| 		) { | ||||
| 			wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | ||||
| 		} | ||||
|  | ||||
| 		// We want to make sure the tables actually exist before we blindly start access them. | ||||
| 		$result = $wpdb->query( | ||||
| 			"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visitor' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visit' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_exclusions' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_historical' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_pages' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_useronline' OR `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_search'" | ||||
| 		); | ||||
|  | ||||
| 		if ( $result != 7 ) { | ||||
|  | ||||
| 			$get_bloginfo_url = WP_Statistics_Admin_Pages::admin_url( 'optimization', array( 'tab' => 'database' ) ); | ||||
| 			$missing_tables   = array(); | ||||
|  | ||||
| 			$result = $wpdb->query( | ||||
| 				"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visitor'" | ||||
| 			); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_visitor'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visit'" ); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_visit'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( | ||||
| 				"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_exclusions'" | ||||
| 			); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_exclusions'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( | ||||
| 				"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_historical'" | ||||
| 			); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_historical'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( | ||||
| 				"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_useronline'" | ||||
| 			); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_useronline'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_pages'" ); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_pages'; | ||||
| 			} | ||||
| 			$result = $wpdb->query( | ||||
| 				"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_search'" | ||||
| 			); | ||||
| 			if ( $result != 1 ) { | ||||
| 				$missing_tables[] = $wpdb->prefix . 'statistics_search'; | ||||
| 			} | ||||
|  | ||||
| 			wp_die( | ||||
| 				'<div class="error"><p>' . sprintf( | ||||
| 					__( | ||||
| 						'The following plugin table(s) do not exist in the database, please re-run the %s install routine %s:', | ||||
| 						'wp-statistics' | ||||
| 					), | ||||
| 					'<a href="' . $get_bloginfo_url . '">', | ||||
| 					'</a>' | ||||
| 				) . implode( ', ', $missing_tables ) . '</p></div>' | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		// Load the postbox script that provides the widget style boxes. | ||||
| 		wp_enqueue_script( 'common' ); | ||||
| 		wp_enqueue_script( 'wp-lists' ); | ||||
| 		wp_enqueue_script( 'postbox' ); | ||||
|  | ||||
| 		// Load the css we use for the statistics pages. | ||||
| 		wp_enqueue_style( 'wpstatistics-log-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/log.css', true, WP_Statistics::$reg['version'] ); | ||||
| 		wp_enqueue_style( 'wpstatistics-pagination-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/pagination.css', true, WP_Statistics::$reg['version'] ); | ||||
|  | ||||
| 		// The different pages have different files to load. | ||||
| 		switch ( $log_type ) { | ||||
| 			case 'all-browsers': | ||||
| 			case 'top-countries': | ||||
| 			case 'hit-statistics': | ||||
| 			case 'search-statistics': | ||||
| 			case 'exclusions': | ||||
| 			case 'online': | ||||
| 			case 'top-visitors': | ||||
| 			case 'categories': | ||||
| 			case 'tags': | ||||
| 			case 'authors': | ||||
| 				include WP_Statistics::$reg['plugin-dir'] . 'includes/log/' . $log_type . '.php'; | ||||
| 				break; | ||||
| 			case 'last-all-search': | ||||
| 				include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-search.php'; | ||||
|  | ||||
| 				break; | ||||
| 			case 'last-all-visitor': | ||||
| 				include WP_Statistics::$reg['plugin-dir'] . 'includes/log/last-visitor.php'; | ||||
|  | ||||
| 				break; | ||||
| 			case 'top-referring-site': | ||||
| 				include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-referring.php'; | ||||
|  | ||||
| 				break; | ||||
| 			case 'top-pages': | ||||
| 				// If we've been given a page id or uri to get statistics for, load the page stats, otherwise load the page stats overview page. | ||||
| 				if ( array_key_exists( 'page-id', $_GET ) || array_key_exists( 'page-uri', $_GET ) || array_key_exists( 'prepage', $_GET ) ) { | ||||
| 					include WP_Statistics::$reg['plugin-dir'] . 'includes/log/page-statistics.php'; | ||||
| 				} else { | ||||
| 					include WP_Statistics::$reg['plugin-dir'] . 'includes/log/top-pages.php'; | ||||
| 				} | ||||
|  | ||||
| 				break; | ||||
| 			default: | ||||
| 				if ( get_current_screen()->parent_base == WP_Statistics::$page['overview'] ) { | ||||
|  | ||||
| 					wp_enqueue_style( 'wpstatistics-jqvmap-css', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jqvmap.css', true, '1.5.1' ); | ||||
| 					wp_enqueue_script( 'wpstatistics-jquery-vmap', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jquery.vmap.js', true, '1.5.1' ); | ||||
| 					wp_enqueue_script( 'wpstatistics-jquery-vmap-world', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/maps/jquery.vmap.world.js', true, '1.5.1' ); | ||||
|  | ||||
| 					// Load our custom widgets handling javascript. | ||||
| 					wp_enqueue_script( 'wp_statistics_log', WP_Statistics::$reg['plugin-url'] . 'assets/js/log.js' ); | ||||
|  | ||||
| 					include WP_Statistics::$reg['plugin-dir'] . 'includes/log/log.php'; | ||||
| 				} | ||||
|  | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,702 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Admin | ||||
|  */ | ||||
| class WP_Statistics_Admin { | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Admin constructor. | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Check to see if we're installed and are the current version. | ||||
| 		WP_Statistics::$installed_version = get_option( 'wp_statistics_plugin_version' ); | ||||
| 		if ( WP_Statistics::$installed_version != WP_Statistics::$reg['version'] ) { | ||||
| 			new WP_Statistics_Install; | ||||
| 		} | ||||
|  | ||||
| 		// If we've been flagged to remove all of the data, then do so now. | ||||
| 		if ( get_option( 'wp_statistics_removal' ) == 'true' ) { | ||||
| 			new WP_Statistics_Uninstall; | ||||
| 		} | ||||
|  | ||||
| 		// If we've been removed, return without doing anything else. | ||||
| 		if ( get_option( 'wp_statistics_removal' ) == 'done' ) { | ||||
| 			add_action( 'admin_notices', array( $this, 'removal_admin_notice' ), 10, 2 ); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Show Admin Menu | ||||
| 		add_action( 'admin_menu', array( $this, 'menu' ) ); | ||||
| 		if ( is_multisite() ) { | ||||
| 			add_action( 'network_admin_menu', 'WP_Statistics_Network_Admin::menu' ); | ||||
| 		} | ||||
|  | ||||
| 		//Load Script in Admin Area | ||||
| 		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | ||||
|  | ||||
| 		//init Export Class | ||||
| 		new WP_Statistics_Export; | ||||
|  | ||||
| 		//init Ajax Class | ||||
| 		new WP_Statistics_Ajax; | ||||
|  | ||||
| 		//init Dashboard Widget | ||||
| 		new WP_Statistics_Dashboard; | ||||
|  | ||||
| 		//Add Custom MetaBox in Wp-statistics Admin Page | ||||
| 		add_action( 'add_meta_boxes', 'WP_Statistics_Editor::add_meta_box' ); | ||||
|  | ||||
| 		// Display the admin notices if we should. | ||||
| 		if ( isset( $pagenow ) && array_key_exists( 'page', $_GET ) ) { | ||||
| 			if ( $pagenow == "admin.php" && substr( $_GET['page'], 0, 14 ) == 'wp-statistics/' ) { | ||||
| 				add_action( 'admin_notices', array( $this, 'not_enable' ) ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Change Plugin Action link in Plugin.php admin | ||||
| 		add_filter( 'plugin_action_links_' . plugin_basename( WP_Statistics::$reg['main-file'] ), array( $this, 'settings_links' ), 10, 2 ); | ||||
| 		add_filter( 'plugin_row_meta', array( $this, 'add_meta_links' ), 10, 2 ); | ||||
|  | ||||
| 		//Add Column in Post Type Wp_List Table | ||||
| 		add_action( 'load-edit.php', array( $this, 'load_edit_init' ) ); | ||||
| 		if ( $WP_Statistics->get_option( 'pages' ) && $WP_Statistics->get_option( 'hit_post_metabox' ) ) { | ||||
| 			add_action( 'post_submitbox_misc_actions', array( $this, 'post_init' ) ); | ||||
| 		} | ||||
|  | ||||
| 		//init ShortCode | ||||
| 		add_action( 'admin_init', 'WP_Statistics_Shortcode::shortcake' ); | ||||
|  | ||||
| 		// WP-Statistics welcome page hooks | ||||
| 		add_action( 'admin_menu', 'WP_Statistics_Welcome::menu' ); | ||||
| 		add_action( 'upgrader_process_complete', 'WP_Statistics_Welcome::do_welcome', 10, 2 ); | ||||
| 		add_action( 'admin_init', 'WP_Statistics_Welcome::init' ); | ||||
|  | ||||
| 		// Runs some scripts at the end of the admin panel inside the body tag | ||||
| 		add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ) ); | ||||
|  | ||||
| 		// Load TinyMce Function | ||||
| 		new WP_Statistics_TinyMCE; | ||||
|  | ||||
| 		// Add Notice Use cache plugin | ||||
| 		add_action( 'admin_notices', array( $this, 'notification_use_cache_plugin' ) ); | ||||
|  | ||||
| 		//Admin Notice Setting | ||||
| 		add_action( 'admin_notices', 'WP_Statistics_Admin_Pages::wp_statistics_notice_setting' ); | ||||
|  | ||||
| 		//Add Visitors Log Table | ||||
| 		add_action( 'admin_init', array( $this, 'register_visitors_log_tbl' ) ); | ||||
|  | ||||
| 		// Add Overview Ads | ||||
| 		add_action( 'load-toplevel_page_' . WP_Statistics::$page['overview'], array( $this, 'overview_page_ads' ) ); | ||||
|  | ||||
| 		//Check Require update page type in database | ||||
| 		WP_Statistics_Install::_init_page_type_updater(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a New Table Visitors Log in mysql | ||||
| 	 */ | ||||
| 	public function register_visitors_log_tbl() { | ||||
|  | ||||
| 		//Add Visitor RelationShip Table | ||||
| 		if ( WP_Statistics_Admin_Pages::in_page( 'settings' ) and isset( $_POST['wps_visitors_log'] ) and $_POST['wps_visitors_log'] == 1 ) { | ||||
| 			WP_Statistics_Install::setup_visitor_relationship_table(); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This adds a row after WP Statistics in the plugin page | ||||
| 	 * IF we've been removed via the settings page. | ||||
| 	 */ | ||||
| 	public function removal_admin_notice() { | ||||
| 		$screen = get_current_screen(); | ||||
|  | ||||
| 		if ( 'plugins' !== $screen->id ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		?> | ||||
|         <div class="error"> | ||||
|             <p style="max-width:800px;"><?php | ||||
| 				echo '<p>' . __( 'WP Statistics has been removed, please disable and delete it.', 'wp-statistics' ) . '</p>'; | ||||
| 				?></p> | ||||
|         </div> | ||||
| 		<?php | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * OverView Page Ads | ||||
| 	 */ | ||||
| 	public function overview_page_ads() { | ||||
|  | ||||
| 		// Get Overview Ads | ||||
| 		$get_overview_ads = get_option( 'wp_statistics_overview_page_ads', false ); | ||||
|  | ||||
| 		// Check Expire or not exist | ||||
| 		if ( $get_overview_ads === false || ( is_array( $get_overview_ads ) and ( current_time( 'timestamp' ) >= ( $get_overview_ads['timestamp'] + WEEK_IN_SECONDS ) ) ) ) { | ||||
|  | ||||
| 			// Check Exist | ||||
| 			$overview_ads = ( $get_overview_ads === false ? array() : $get_overview_ads ); | ||||
|  | ||||
| 			// Get New Ads from API | ||||
| 			$request = wp_remote_get( 'https://wp-statistics.com/wp-json/ads/overview', array( 'timeout' => 30 ) ); | ||||
| 			if ( is_wp_error( $request ) ) { | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			// Get Json Data | ||||
| 			$data    = json_decode( wp_remote_retrieve_body( $request ), true ); | ||||
|  | ||||
| 			// Set new Timestamp | ||||
| 			$overview_ads['timestamp'] = current_time( 'timestamp' ); | ||||
|  | ||||
| 			// Set Ads | ||||
| 			$overview_ads['ads'] = ( empty( $data ) ? array( 'status' => 'no', 'ID' => 'none' ) : $data ); | ||||
|  | ||||
| 			// Set Last Viewed | ||||
| 			$overview_ads['view'] = ( isset( $get_overview_ads['view'] ) ? $get_overview_ads['view'] : '' ); | ||||
|  | ||||
| 			// Set Option | ||||
| 			update_option( 'wp_statistics_overview_page_ads', $overview_ads, 'no' ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This function outputs error messages in the admin interface | ||||
| 	 * if the primary components of WP Statistics are enabled. | ||||
| 	 */ | ||||
| 	public function not_enable() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// If the user had told us to be quite, do so. | ||||
| 		if ( ! $WP_Statistics->get_option( 'hide_notices' ) ) { | ||||
|  | ||||
| 			// Check to make sure the current user can manage WP Statistics, | ||||
| 			// if not there's no point displaying the warnings. | ||||
| 			$manage_cap = wp_statistics_validate_capability( | ||||
| 				$WP_Statistics->get_option( | ||||
| 					'manage_capability', | ||||
| 					'manage_options' | ||||
| 				) | ||||
| 			); | ||||
| 			if ( ! current_user_can( $manage_cap ) ) { | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			$get_bloginfo_url = WP_Statistics_Admin_Pages::admin_url( 'settings' ); | ||||
|  | ||||
| 			$itemstoenable = array(); | ||||
| 			if ( ! $WP_Statistics->get_option( 'useronline' ) ) { | ||||
| 				$itemstoenable[] = __( 'online user tracking', 'wp-statistics' ); | ||||
| 			} | ||||
| 			if ( ! $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 				$itemstoenable[] = __( 'hit tracking', 'wp-statistics' ); | ||||
| 			} | ||||
| 			if ( ! $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 				$itemstoenable[] = __( 'visitor tracking', 'wp-statistics' ); | ||||
| 			} | ||||
| 			if ( ! $WP_Statistics->get_option( 'geoip' ) && wp_statistics_geoip_supported() ) { | ||||
| 				$itemstoenable[] = __( 'geoip collection', 'wp-statistics' ); | ||||
| 			} | ||||
|  | ||||
| 			if ( count( $itemstoenable ) > 0 ) { | ||||
| 				echo '<div class="update-nag">' . sprintf( __( 'The following features are disabled, please go to %ssettings page%s and enable them: %s', 'wp-statistics' ), '<a href="' . $get_bloginfo_url . '">', '</a>', implode( __( ',', 'wp-statistics' ), $itemstoenable ) ) . '</div>'; | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			$get_bloginfo_url = WP_Statistics_Admin_Pages::admin_url( 'optimization', array( 'tab' => 'database' ) ); | ||||
| 			$dbupdatestodo    = array(); | ||||
|  | ||||
| 			if ( ! $WP_Statistics->get_option( 'search_converted' ) ) { | ||||
| 				$dbupdatestodo[] = __( 'search table', 'wp-statistics' ); | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if there are any database changes the user hasn't done yet. | ||||
| 			$dbupdates = $WP_Statistics->get_option( 'pending_db_updates', false ); | ||||
|  | ||||
| 			// The database updates are stored in an array so loop thorugh it and output some notices. | ||||
| 			if ( is_array( $dbupdates ) ) { | ||||
| 				$dbstrings = array( | ||||
| 					'date_ip_agent' => __( 'countries database index', 'wp-statistics' ), | ||||
| 					'unique_date'   => __( 'visit database index', 'wp-statistics' ), | ||||
| 				); | ||||
|  | ||||
| 				foreach ( $dbupdates as $key => $update ) { | ||||
| 					if ( $update == true ) { | ||||
| 						$dbupdatestodo[] = $dbstrings[ $key ]; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				if ( count( $dbupdatestodo ) > 0 ) { | ||||
| 					echo '<div class="update-nag">' . sprintf( __( 'Database updates are required, please go to %soptimization page%s and update the following: %s', 'wp-statistics' ), '<a href="' . $get_bloginfo_url . '">', '</a>', implode( __( ',', 'wp-statistics' ), $dbupdatestodo ) ) . '</div>'; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Check User Active A cache Plugin in Wordpress | ||||
| 	 */ | ||||
| 	static public function user_is_use_cache_plugin() { | ||||
| 		$use = array( 'status' => false, 'plugin' => '' ); | ||||
|  | ||||
| 		/* Wordpress core */ | ||||
| 		if ( defined( 'WP_CACHE' ) && WP_CACHE ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'core' ); | ||||
| 		} | ||||
|  | ||||
| 		/* WP Rocket */ | ||||
| 		if ( function_exists( 'get_rocket_cdn_url' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'WP Rocket' ); | ||||
| 		} | ||||
|  | ||||
| 		/* WP Super Cache */ | ||||
| 		if ( function_exists( 'wpsc_init' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'WP Super Cache' ); | ||||
| 		} | ||||
|  | ||||
| 		/* Comet Cache */ | ||||
| 		if ( function_exists( '___wp_php_rv_initialize' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'Comet Cache' ); | ||||
| 		} | ||||
|  | ||||
| 		/* WP Fastest Cache */ | ||||
| 		if ( class_exists( 'WpFastestCache' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'WP Fastest Cache' ); | ||||
| 		} | ||||
|  | ||||
| 		/* Cache Enabler */ | ||||
| 		if ( defined( 'CE_MIN_WP' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'Cache Enabler' ); | ||||
| 		} | ||||
|  | ||||
| 		/* W3 Total Cache */ | ||||
| 		if ( defined( 'W3TC' ) ) { | ||||
| 			return array( 'status' => true, 'plugin' => 'W3 Total Cache' ); | ||||
| 		} | ||||
|  | ||||
| 		return $use; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Show Notification Cache Plugin | ||||
| 	 */ | ||||
| 	static public function notification_use_cache_plugin() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		$screen = get_current_screen(); | ||||
|  | ||||
| 		if ( $screen->id == "toplevel_page_" . WP_Statistics::$page['overview'] or $screen->id == "statistics_page_" . WP_Statistics::$page['settings'] ) { | ||||
| 			$plugin = self::user_is_use_cache_plugin(); | ||||
|  | ||||
| 			if ( ! $WP_Statistics->get_option( 'use_cache_plugin' ) and $plugin['status'] === true ) { | ||||
| 				echo '<div class="notice notice-warning is-dismissible"><p>'; | ||||
|  | ||||
| 				$alert = sprintf( __( 'You Are Using %s Plugin in WordPress', 'wp-statistics' ), $plugin['plugin'] ); | ||||
| 				if ( $plugin['plugin'] == "core" ) { | ||||
| 					$alert = __( 'WP_CACHE is Enable in Your WordPress', 'wp-statistics' ); | ||||
| 				} | ||||
|  | ||||
| 				echo $alert . ", " . sprintf( __( 'Please enable %1$sCache Setting%2$s in WP Statistics.', 'wp-statistics' ), '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'settings' ) . '">', '</a>' ); | ||||
| 				echo '</p></div>'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Test Rest Api is Active for Cache | ||||
| 		if ( $WP_Statistics->use_cache and $screen->id == "statistics_page_" . WP_Statistics::$page['settings'] ) { | ||||
|  | ||||
| 			if ( false === ( $check_rest_api = get_transient( '_check_rest_api_wp_statistics' ) ) ) { | ||||
|  | ||||
| 				$set_transient = true; | ||||
| 				$alert         = '<div class="notice notice-warning is-dismissible"><p>' . sprintf( __( 'Here is an error associated with Connecting WordPress Rest API, Please Flushing rewrite rules or activate wp rest api for performance WP-Statistics Plugin Cache / Go %1$sSettings->Permalinks%2$s', 'wp-statistics' ), '<a href="' . esc_url( admin_url( 'options-permalink.php' ) ) . '">', '</a>' ) . '</div>'; | ||||
| 				$request       = wp_remote_post( path_join( get_rest_url(), WP_Statistics_Rest::route . '/' . WP_Statistics_Rest::func ), array( | ||||
| 					'method' => 'POST', | ||||
| 					'body'   => array( 'rest-api-wp-statistics' => 'wp-statistics' ) | ||||
| 				) ); | ||||
| 				if ( is_wp_error( $request ) ) { | ||||
| 					echo $alert; | ||||
| 					$set_transient = false; | ||||
| 				} | ||||
| 				$body = wp_remote_retrieve_body( $request ); | ||||
| 				$data = json_decode( $body, true ); | ||||
| 				if ( ! isset( $data['rest-api-wp-statistics'] ) and $set_transient === true ) { | ||||
| 					echo $alert; | ||||
| 					$set_transient = false; | ||||
| 				} | ||||
|  | ||||
| 				if ( $set_transient === true ) { | ||||
| 					set_transient( '_check_rest_api_wp_statistics', array( "rest-api-wp-statistics" => "OK" ), 2 * HOUR_IN_SECONDS ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a settings link to the plugin list. | ||||
| 	 * | ||||
| 	 * @param string $links Links | ||||
| 	 * @param string $file Not Used! | ||||
| 	 * | ||||
| 	 * @return string Links | ||||
| 	 */ | ||||
| 	public function settings_links( $links, $file ) { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			array_unshift( $links, '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'settings' ) . '">' . __( 'Settings', 'wp-statistics' ) . '</a>' ); | ||||
| 		} | ||||
|  | ||||
| 		return $links; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a WordPress plugin page and rating links to the meta information to the plugin list. | ||||
| 	 * | ||||
| 	 * @param string $links Links | ||||
| 	 * @param string $file File | ||||
| 	 * | ||||
| 	 * @return array Links | ||||
| 	 */ | ||||
| 	public function add_meta_links( $links, $file ) { | ||||
| 		if ( $file == plugin_basename( WP_Statistics::$reg['main-file'] ) ) { | ||||
| 			$plugin_url = 'http://wordpress.org/plugins/wp-statistics/'; | ||||
|  | ||||
| 			$links[]  = '<a href="' . $plugin_url . '" target="_blank" title="' . __( 'Click here to visit the plugin on WordPress.org', 'wp-statistics' ) . '">' . __( 'Visit WordPress.org page', 'wp-statistics' ) . '</a>'; | ||||
| 			$rate_url = 'https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post'; | ||||
| 			$links[]  = '<a href="' . $rate_url . '" target="_blank" title="' . __( 'Click here to rate and review this plugin on WordPress.org', 'wp-statistics' ) . '">' . __( 'Rate this plugin', 'wp-statistics' ) . '</a>'; | ||||
| 		} | ||||
|  | ||||
| 		return $links; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Call the add/render functions at the appropriate times. | ||||
| 	 */ | ||||
| 	public function load_edit_init() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		$read_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_options' ) ); | ||||
|  | ||||
| 		if ( current_user_can( $read_cap ) && $WP_Statistics->get_option( 'pages' ) && ! $WP_Statistics->get_option( 'disable_column' ) ) { | ||||
| 			$post_types = WP_Statistics_Editor::get_list_post_type(); | ||||
| 			foreach ( $post_types as $type ) { | ||||
| 				add_action( 'manage_' . $type . '_posts_columns', 'WP_Statistics_Admin::add_column', 10, 2 ); | ||||
| 				add_action( 'manage_' . $type . '_posts_custom_column', 'WP_Statistics_Admin::render_column', 10, 2 ); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add a custom column to post/pages for hit statistics. | ||||
| 	 * | ||||
| 	 * @param array $columns Columns | ||||
| 	 * | ||||
| 	 * @return array Columns | ||||
| 	 */ | ||||
| 	static function add_column( $columns ) { | ||||
| 		$columns['wp-statistics'] = __( 'Hits', 'wp-statistics' ); | ||||
|  | ||||
| 		return $columns; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Render the custom column on the post/pages lists. | ||||
| 	 * | ||||
| 	 * @param string $column_name Column Name | ||||
| 	 * @param string $post_id Post ID | ||||
| 	 */ | ||||
| 	static function render_column( $column_name, $post_id ) { | ||||
| 		if ( $column_name == 'wp-statistics' ) { | ||||
| 			echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'pages', array( 'page-id' => $post_id ) ) . "'>" . wp_statistics_pages( 'total', "", $post_id ) . "</a>"; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add the hit count to the publish widget in the post/pages editor. | ||||
| 	 */ | ||||
| 	public function post_init() { | ||||
| 		global $post; | ||||
|  | ||||
| 		$id = $post->ID; | ||||
| 		echo "<div class='misc-pub-section'>" . __( 'WP Statistics - Hits', 'wp-statistics' ) . ": <b><a href='" . WP_Statistics_Admin_Pages::admin_url( 'pages', array( 'page-id' => $id ) ) . "'>" . wp_statistics_pages( 'total', "", $id ) . "</a></b></div>"; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This function adds the primary menu to WordPress. | ||||
| 	 */ | ||||
| 	public function menu() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Get the read/write capabilities required to view/manage the plugin as set by the user. | ||||
| 		$read_cap   = wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_options' ) ); | ||||
| 		$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
|  | ||||
| 		/** | ||||
| 		 * List of WP-Statistics Admin Menu | ||||
| 		 * | ||||
| 		 * --- Array Arg ----- | ||||
| 		 * name       : Menu name | ||||
| 		 * title      : Page title / if not exist [title == name] | ||||
| 		 * cap        : min require capability @default $read_cap | ||||
| 		 * icon       : Wordpress DashIcon name | ||||
| 		 * method     : method that call in page @default log | ||||
| 		 * sub        : if sub menu , add main menu slug | ||||
| 		 * page_url   : link of Slug Url Page @see WP_Statistics::$page | ||||
| 		 * break      : add new line after sub menu if break key == true | ||||
| 		 * require    : the Condition From Wp-statistics Option if == true for show admin menu | ||||
| 		 * | ||||
| 		 */ | ||||
| 		$list = array( | ||||
| 			'top'          => array( | ||||
| 				'title'    => __( 'Statistics', 'wp-statistics' ), | ||||
| 				'page_url' => 'overview', | ||||
| 				'method'   => 'log', | ||||
| 				'icon'     => 'dashicons-chart-pie', | ||||
| 			), | ||||
| 			'overview'     => array( | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Overview', 'wp-statistics' ), | ||||
| 				'page_url' => 'overview', | ||||
| 			), | ||||
| 			'hits'         => array( | ||||
| 				'require'  => array( 'visits' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Hits', 'wp-statistics' ), | ||||
| 				'page_url' => 'hits', | ||||
| 			), | ||||
| 			'online'       => array( | ||||
| 				'require'  => array( 'useronline' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Online', 'wp-statistics' ), | ||||
| 				'page_url' => 'online', | ||||
| 			), | ||||
| 			'referrers'    => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Referrers', 'wp-statistics' ), | ||||
| 				'page_url' => 'referrers', | ||||
| 			), | ||||
| 			'words'        => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Search Words', 'wp-statistics' ), | ||||
| 				'page_url' => 'words', | ||||
| 			), | ||||
| 			'searches'     => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Search Engines', 'wp-statistics' ), | ||||
| 				'page_url' => 'searches', | ||||
| 			), | ||||
| 			'pages'        => array( | ||||
| 				'require'  => array( 'pages' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Pages', 'wp-statistics' ), | ||||
| 				'page_url' => 'pages', | ||||
| 			), | ||||
| 			'visitors'     => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Visitors', 'wp-statistics' ), | ||||
| 				'page_url' => 'visitors', | ||||
| 			), | ||||
| 			'countries'    => array( | ||||
| 				'require'  => array( 'geoip', 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Countries', 'wp-statistics' ), | ||||
| 				'page_url' => 'countries', | ||||
| 			), | ||||
| 			'categories'   => array( | ||||
| 				'require'  => array( 'pages' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Categories', 'wp-statistics' ), | ||||
| 				'page_url' => 'categories', | ||||
| 			), | ||||
| 			'tags'         => array( | ||||
| 				'require'  => array( 'pages' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Tags', 'wp-statistics' ), | ||||
| 				'page_url' => 'tags', | ||||
| 			), | ||||
| 			'authors'      => array( | ||||
| 				'require'  => array( 'pages' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Authors', 'wp-statistics' ), | ||||
| 				'page_url' => 'authors', | ||||
| 			), | ||||
| 			'browsers'     => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Browsers', 'wp-statistics' ), | ||||
| 				'page_url' => 'browser', | ||||
| 			), | ||||
| 			'top.visotors' => array( | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Top Visitors Today', 'wp-statistics' ), | ||||
| 				'page_url' => 'top-visitors', | ||||
| 			), | ||||
| 			'exclusions'   => array( | ||||
| 				'require'  => array( 'record_exclusions' ), | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Exclusions', 'wp-statistics' ), | ||||
| 				'page_url' => 'exclusions', | ||||
| 				'break'    => true, | ||||
| 			), | ||||
| 			'optimize'     => array( | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Optimization', 'wp-statistics' ), | ||||
| 				'cap'      => $manage_cap, | ||||
| 				'page_url' => 'optimization', | ||||
| 				'method'   => 'optimization' | ||||
| 			), | ||||
| 			'settings'     => array( | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Settings', 'wp-statistics' ), | ||||
| 				'cap'      => $manage_cap, | ||||
| 				'page_url' => 'settings', | ||||
| 				'method'   => 'settings' | ||||
| 			), | ||||
| 			'plugins'      => array( | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Add-Ons', 'wp-statistics' ), | ||||
| 				'name'     => '<span class="wps-text-warning">' . __( 'Add-Ons', 'wp-statistics' ) . '</span>', | ||||
| 				'page_url' => 'plugins', | ||||
| 				'method'   => 'plugins' | ||||
| 			), | ||||
| 			'donate'       => array( | ||||
| 				'sub'      => 'overview', | ||||
| 				'title'    => __( 'Donate', 'wp-statistics' ), | ||||
| 				'name'     => '<span class="wps-text-success">' . __( 'Donate', 'wp-statistics' ) . '</span>', | ||||
| 				'page_url' => 'donate', | ||||
| 				'method'   => 'donate' | ||||
| 			) | ||||
| 		); | ||||
|  | ||||
| 		//Show Admin Menu List | ||||
| 		foreach ( $list as $key => $menu ) { | ||||
|  | ||||
| 			//Check Default variable | ||||
| 			$capability = $read_cap; | ||||
| 			$method     = 'log'; | ||||
| 			$name       = $menu['title']; | ||||
| 			if ( array_key_exists( 'cap', $menu ) ) { | ||||
| 				$capability = $menu['cap']; | ||||
| 			} | ||||
| 			if ( array_key_exists( 'method', $menu ) ) { | ||||
| 				$method = $menu['method']; | ||||
| 			} | ||||
| 			if ( array_key_exists( 'name', $menu ) ) { | ||||
| 				$name = $menu['name']; | ||||
| 			} | ||||
|  | ||||
| 			//Check if SubMenu or Main Menu | ||||
| 			if ( array_key_exists( 'sub', $menu ) ) { | ||||
|  | ||||
| 				//Check Conditions For Show Menu | ||||
| 				if ( wp_statistics_check_option_require( $menu ) === true ) { | ||||
| 					$WP_Statistics->menu_slugs[ $key ] = add_submenu_page( WP_Statistics::$page[ $menu['sub'] ], $menu['title'], $name, $capability, WP_Statistics::$page[ $menu['page_url'] ], 'WP_Statistics_Admin_Pages::' . $method ); | ||||
| 				} | ||||
|  | ||||
| 				//Check if add Break Line | ||||
| 				if ( array_key_exists( 'break', $menu ) ) { | ||||
| 					$WP_Statistics->menu_slugs[ 'break_' . $key ] = add_submenu_page( WP_Statistics::$page[ $menu['sub'] ], '', '', $capability, 'wps_break_menu', 'WP_Statistics_Admin_Pages::' . $method ); | ||||
| 				} | ||||
| 			} else { | ||||
| 				$WP_Statistics->menu_slugs[ $key ] = add_menu_page( $menu['title'], $name, $capability, WP_Statistics::$page[ $menu['page_url'] ], "WP_Statistics_Admin_Pages::" . $method, $menu['icon'] ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Add action to load the meta boxes to the overview page. | ||||
| 		add_action( 'load-' . $WP_Statistics->menu_slugs['overview'], 'WP_Statistics_Admin_Pages::overview' ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Enqueue Scripts in Admin Area | ||||
| 	 */ | ||||
| 	public function enqueue_scripts() { | ||||
| 		global $pagenow, $WP_Statistics; | ||||
|  | ||||
| 		// Load our CSS to be used. | ||||
| 		wp_enqueue_style( 'wpstatistics-admin-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/admin.css', true, WP_Statistics::$reg['version'] ); | ||||
| 		if ( is_rtl() ) { | ||||
| 			wp_enqueue_style( 'rtl-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/rtl.css', true, WP_Statistics::$reg['version'] ); | ||||
| 		} | ||||
|  | ||||
| 		//Load Admin Js | ||||
| 		wp_enqueue_script( 'wp-statistics-admin-js', WP_Statistics::$reg['plugin-url'] . 'assets/js/admin.js', array( 'jquery' ), WP_Statistics::$reg['version'] ); | ||||
|  | ||||
| 		//Load Chart Js | ||||
| 		$load_in_footer = false; | ||||
| 		$load_chart     = false; | ||||
|  | ||||
| 		//Load in Setting Page | ||||
| 		$pages_required_chart = array( | ||||
| 			'wps_overview_page', | ||||
| 			'wps_browsers_page', | ||||
| 			'wps_hits_page', | ||||
| 			'wps_pages_page', | ||||
| 			'wps_categories_page', | ||||
| 			'wps_tags_page', | ||||
| 			'wps_authors_page', | ||||
| 			'wps_searches_page', | ||||
| 		); | ||||
| 		if ( isset( $_GET['page'] ) and array_search( $_GET['page'], $pages_required_chart ) !== false ) { | ||||
| 			$load_chart = true; | ||||
| 		} | ||||
|  | ||||
| 		//Load in Post Page | ||||
| 		if ( $pagenow == "post.php" and $WP_Statistics->get_option( 'hit_post_metabox' ) ) { | ||||
| 			$load_chart = true; | ||||
| 		} | ||||
|  | ||||
| 		if ( $load_chart === true ) { | ||||
| 			wp_enqueue_script( 'wp-statistics-chart-js', WP_Statistics::$reg['plugin-url'] . 'assets/js/Chart.bundle.min.js', false, '2.7.3', $load_in_footer ); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Admin footer scripts | ||||
| 	 */ | ||||
| 	public function admin_footer_scripts() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Check to see if the GeoIP database needs to be downloaded and do so if required. | ||||
| 		if ( $WP_Statistics->get_option( 'update_geoip' ) ) { | ||||
| 			foreach ( WP_Statistics_Updates::$geoip as $geoip_name => $geoip_array ) { | ||||
| 				WP_Statistics_Updates::download_geoip( $geoip_name, "update" ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Check to see if the referrer spam database needs to be downloaded and do so if required. | ||||
| 		if ( $WP_Statistics->get_option( 'update_referrerspam' ) ) { | ||||
| 			WP_Statistics_Updates::download_referrerspam(); | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'send_upgrade_email' ) ) { | ||||
| 			$WP_Statistics->update_option( 'send_upgrade_email', false ); | ||||
|  | ||||
| 			$blogname  = get_bloginfo( 'name' ); | ||||
| 			$blogemail = get_bloginfo( 'admin_email' ); | ||||
|  | ||||
| 			$headers[] = "From: $blogname <$blogemail>"; | ||||
| 			$headers[] = "MIME-Version: 1.0"; | ||||
| 			$headers[] = "Content-type: text/html; charset=utf-8"; | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 				$WP_Statistics->update_option( 'email_list', $blogemail ); | ||||
| 			} | ||||
|  | ||||
| 			wp_mail( $WP_Statistics->get_option( 'email_list' ), sprintf( __( 'WP Statistics %s installed on', 'wp-statistics' ), WP_Statistics::$reg['version'] ) . ' ' . $blogname, __( 'Installation/upgrade complete!', 'wp-statistics' ), $headers ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,435 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Ajax | ||||
|  */ | ||||
| class WP_Statistics_Ajax { | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Ajax constructor. | ||||
| 	 */ | ||||
| 	function __construct() { | ||||
|  | ||||
| 		/** | ||||
| 		 * List Of Setup Ajax request in Wordpress | ||||
| 		 */ | ||||
| 		$list = array( | ||||
| 			'close_notice', | ||||
| 			'close_overview_ads', | ||||
| 			'delete_agents', | ||||
| 			'delete_platforms', | ||||
| 			'delete_ip', | ||||
| 			'empty_table', | ||||
| 			'purge_data', | ||||
| 			'purge_visitor_hits', | ||||
| 			'get_widget_contents' | ||||
| 		); | ||||
| 		foreach ( $list as $method ) { | ||||
| 			add_action( 'wp_ajax_wp_statistics_' . $method, array( $this, $method . '_action_callback' ) ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to close the notice on the overview page. | ||||
| 	 */ | ||||
| 	public function close_notice_action_callback() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'manage_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) and isset( $_REQUEST['notice'] ) ) { | ||||
| 			switch ( $_REQUEST['notice'] ) { | ||||
| 				case 'donate': | ||||
| 					$WP_Statistics->update_option( 'disable_donation_nag', true ); | ||||
| 					break; | ||||
|  | ||||
| 				case 'suggestion': | ||||
| 					$WP_Statistics->update_option( 'disable_suggestion_nag', true ); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			$WP_Statistics->update_option( 'admin_notices', false ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Close Overview Ads | ||||
| 	 */ | ||||
| 	public function close_overview_ads_action_callback() { | ||||
| 		if ( wp_doing_ajax() and isset( $_REQUEST['ads_id'] ) ) { | ||||
|  | ||||
| 			// Check Security Nonce | ||||
| 			check_ajax_referer( 'overview_ads_nonce', 'wps_nonce' ); | ||||
|  | ||||
| 			// Update Option | ||||
| 			$get_opt         = get_option( 'wp_statistics_overview_page_ads' ); | ||||
| 			$get_opt['view'] = $_REQUEST['ads_id']; | ||||
| 			update_option( 'wp_statistics_overview_page_ads', $get_opt, 'no' ); | ||||
| 		} | ||||
| 		exit; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to delete an agent in the optimization page. | ||||
| 	 */ | ||||
| 	public function delete_agents_action_callback() { | ||||
| 		global $WP_Statistics, $wpdb; | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'manage_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			$agent = $_POST['agent-name']; | ||||
|  | ||||
| 			if ( $agent ) { | ||||
|  | ||||
| 				$result = $wpdb->query( | ||||
| 					$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `agent` = %s", $agent ) | ||||
| 				); | ||||
|  | ||||
| 				if ( $result ) { | ||||
| 					echo sprintf( | ||||
| 						__( '%s agent data deleted successfully.', 'wp-statistics' ), | ||||
| 						'<code>' . $agent . '</code>' | ||||
| 					); | ||||
| 				} else { | ||||
| 					_e( 'No agent data found to remove!', 'wp-statistics' ); | ||||
| 				} | ||||
|  | ||||
| 			} else { | ||||
| 				_e( 'Please select the desired items.', 'wp-statistics' ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to delete a platform in the optimization page. | ||||
| 	 */ | ||||
| 	public function delete_platforms_action_callback() { | ||||
| 		global $WP_Statistics, $wpdb; | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'manage_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			$platform = $_POST['platform-name']; | ||||
|  | ||||
| 			if ( $platform ) { | ||||
|  | ||||
| 				$result = $wpdb->query( | ||||
| 					$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `platform` = %s", $platform ) | ||||
| 				); | ||||
|  | ||||
| 				if ( $result ) { | ||||
| 					echo sprintf( | ||||
| 						__( '%s platform data deleted successfully.', 'wp-statistics' ), | ||||
| 						'<code>' . htmlentities( $platform, ENT_QUOTES ) . '</code>' | ||||
| 					); | ||||
| 				} else { | ||||
| 					_e( 'No platform data found to remove!', 'wp-statistics' ); | ||||
| 				} | ||||
| 			} else { | ||||
| 				_e( 'Please select the desired items.', 'wp-statistics' ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to delete a ip in the optimization page. | ||||
| 	 */ | ||||
| 	public function delete_ip_action_callback() { | ||||
| 		global $WP_Statistics, $wpdb; | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'manage_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			$ip_address = sanitize_text_field( $_POST['ip-address'] ); | ||||
|  | ||||
| 			if ( $ip_address ) { | ||||
|  | ||||
| 				$result = $wpdb->query( | ||||
| 					$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `ip` = %s", $ip_address ) | ||||
| 				); | ||||
|  | ||||
| 				if ( $result ) { | ||||
| 					echo sprintf( | ||||
| 						__( '%s IP data deleted successfully.', 'wp-statistics' ), | ||||
| 						'<code>' . htmlentities( $ip_address, ENT_QUOTES ) . '</code>' | ||||
| 					); | ||||
| 				} else { | ||||
| 					_e( 'No IP address data found to remove!', 'wp-statistics' ); | ||||
| 				} | ||||
| 			} else { | ||||
| 				_e( 'Please select the desired items.', 'wp-statistics' ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to empty a table in the optimization page. | ||||
| 	 */ | ||||
| 	public function empty_table_action_callback() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Check isset Table-post | ||||
| 		if ( ! isset( $_POST['table-name'] ) ) { | ||||
| 			_e( 'Please select the desired items.', 'wp-statistics' ); | ||||
| 			exit; | ||||
| 		} | ||||
|  | ||||
| 		//Check Valid Table name | ||||
| 		$table_name    = sanitize_text_field( $_POST['table-name'] ); | ||||
| 		$list_db_table = wp_statistics_db_table( 'all', 'historical' ); | ||||
| 		if ( ! array_key_exists( $table_name, $list_db_table ) ) { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 			exit; | ||||
| 		} | ||||
|  | ||||
| 		//Check User Cap | ||||
| 		$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
|  | ||||
| 			if ( $table_name == "all" ) { | ||||
| 				$x_tbl = 1; | ||||
| 				foreach ( $list_db_table as $tbl_key => $tbl_name ) { | ||||
| 					echo ( $x_tbl > 1 ? '<br>' : '' ) . wp_statitiscs_empty_table( $tbl_name ); | ||||
| 					$x_tbl ++; | ||||
| 				} | ||||
| 			} else { | ||||
| 				echo wp_statitiscs_empty_table( wp_statistics_db_table( $table_name ) ); | ||||
| 			} | ||||
|  | ||||
| 			$WP_Statistics->Primary_Values(); | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to purge old data in the optimization page. | ||||
| 	 */ | ||||
| 	public function purge_data_action_callback() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' ); | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			$purge_days = 0; | ||||
|  | ||||
| 			if ( array_key_exists( 'purge-days', $_POST ) ) { | ||||
| 				// Get the number of days to purge data before. | ||||
| 				$purge_days = intval( $_POST['purge-days'] ); | ||||
| 			} | ||||
|  | ||||
| 			echo wp_statistics_purge_data( $purge_days ); | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to purge visitors with more than a defined number of hits. | ||||
| 	 */ | ||||
| 	public function purge_visitor_hits_action_callback() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' ); | ||||
|  | ||||
| 		$manage_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'manage_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $manage_cap ) ) { | ||||
| 			$purge_hits = 10; | ||||
|  | ||||
| 			if ( array_key_exists( 'purge-hits', $_POST ) ) { | ||||
| 				// Get the number of days to purge data before. | ||||
| 				$purge_hits = intval( $_POST['purge-hits'] ); | ||||
| 			} | ||||
|  | ||||
| 			if ( $purge_hits < 10 ) { | ||||
| 				_e( 'Number of hits must be greater than or equal to 10!', 'wp-statistics' ); | ||||
| 			} else { | ||||
| 				echo wp_statistics_purge_visitor_hits( $purge_hits ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an AJAX action to purge visitors with more than a defined number of hits. | ||||
| 	 */ | ||||
| 	public function get_widget_contents_action_callback() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		$widgets = array( | ||||
| 			'about', | ||||
| 			'users_online', | ||||
| 			'browsers', | ||||
| 			'map', | ||||
| 			'countries', | ||||
| 			'hits', | ||||
| 			'hitsmap', | ||||
| 			'page', | ||||
| 			'pages', | ||||
| 			'quickstats', | ||||
| 			'recent', | ||||
| 			'referring', | ||||
| 			'search', | ||||
| 			'summary', | ||||
| 			'top.visitors', | ||||
| 			'words' | ||||
| 		); | ||||
|  | ||||
| 		if ( array_key_exists( 'format', $_POST ) and $_POST['format'] == 'dashboard' ) { | ||||
| 			$size = 220; | ||||
| 			$days = 10; | ||||
| 		} else { | ||||
| 			$size = 110; | ||||
| 			$days = 20; | ||||
| 		} | ||||
|  | ||||
| 		$view_cap = wp_statistics_validate_capability( | ||||
| 			$WP_Statistics->get_option( 'read_capability', 'manage_options' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( current_user_can( $view_cap ) ) { | ||||
| 			$widget = ''; | ||||
|  | ||||
| 			if ( array_key_exists( 'widget', $_POST ) ) { | ||||
| 				// Get the widget we're going to display. | ||||
|  | ||||
| 				if ( in_array( $_POST['widget'], $widgets ) ) { | ||||
| 					$widget = $_POST['widget']; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ( $_POST['widget'] == "top_visitors" ) { | ||||
| 				$widget = 'top.visitors'; | ||||
| 			} | ||||
|  | ||||
| 			if ( 'map' == $widget || 'hitsmap' == $widget ) { | ||||
| 				$widget = 'jqv.map'; | ||||
| 			} | ||||
|  | ||||
| 			if ( '' == $widget ) { | ||||
| 				_e( 'No matching widget found!', 'wp-statistics' ); | ||||
| 				wp_die(); | ||||
| 			} | ||||
|  | ||||
| 			$ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
| 			$search_engines = wp_statistics_searchengine_list(); | ||||
|  | ||||
| 			require( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/' . $widget . '.php' ); | ||||
|  | ||||
| 			switch ( $widget ) { | ||||
| 				case 'summary': | ||||
| 					wp_statistics_generate_summary_postbox_content( $search_engines ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'quickstats': | ||||
| 					wp_statistics_generate_quickstats_postbox_content( $search_engines ); | ||||
|  | ||||
| 					break; | ||||
|  | ||||
| 				case 'browsers': | ||||
| 					wp_statistics_generate_browsers_postbox_content(); | ||||
|  | ||||
| 					break; | ||||
| 				case 'referring': | ||||
| 					wp_statistics_generate_referring_postbox_content(); | ||||
|  | ||||
| 					break; | ||||
| 				case 'countries': | ||||
| 					wp_statistics_generate_countries_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'jqv.map': | ||||
| 					wp_statistics_generate_map_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'hits': | ||||
| 					wp_statistics_generate_hits_postbox_content( $size, $days ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'search': | ||||
| 					wp_statistics_generate_search_postbox_content( $search_engines, $size, $days ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'words': | ||||
| 					wp_statistics_generate_words_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'page': | ||||
| 					if ( array_key_exists( 'page-id', $_POST ) ) { | ||||
| 						$pageid = (int) $_POST['page-id']; | ||||
|  | ||||
| 						wp_statistics_generate_page_postbox_content( null, $pageid ); | ||||
| 					} | ||||
|  | ||||
| 					break; | ||||
| 				case 'pages': | ||||
| 					wp_statistics_generate_pages_postbox_content(); | ||||
|  | ||||
| 					break; | ||||
| 				case 'recent': | ||||
| 					wp_statistics_generate_recent_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'top.visitors': | ||||
| 					$format = null; | ||||
|  | ||||
| 					if ( array_key_exists( 'format', $_POST ) ) { | ||||
| 						$format = 'compact'; | ||||
| 					} | ||||
|  | ||||
| 					wp_statistics_generate_top_visitors_postbox_content( $ISOCountryCode, 'today', 10, $format ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'users_online': | ||||
| 					wp_statistics_generate_users_online_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'about': | ||||
| 					wp_statistics_generate_about_postbox_content( $ISOCountryCode ); | ||||
|  | ||||
| 					break; | ||||
| 				default: | ||||
| 					_e( 'ERROR: Widget not found!', 'wp-statistics' ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			_e( 'Access denied!', 'wp-statistics' ); | ||||
| 		} | ||||
|  | ||||
| 		wp_die(); | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,341 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Dashboard | ||||
|  */ | ||||
| class WP_Statistics_Dashboard { | ||||
|  | ||||
| 	/** | ||||
| 	 * User Meta Set Dashboard Option name | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	public static $dashboard_set = 'dashboard_set'; | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Dashboard constructor. | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
|  | ||||
| 		//Register Dashboard Widget | ||||
| 		add_action( 'wp_dashboard_setup', array( $this, 'load_dashboard_widget' ) ); | ||||
|  | ||||
| 		//Add Inline Script in Admin Footer | ||||
| 		add_action( 'admin_footer', array( $this, 'inline_javascript' ) ); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Widget Setup Key | ||||
| 	 * | ||||
| 	 * @param $key | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public static function widget_setup_key( $key ) { | ||||
| 		return 'wp-statistics-' . $key . '-widget'; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get Widget List | ||||
| 	 * | ||||
| 	 * @param bool $widget | ||||
| 	 * @return array|mixed | ||||
| 	 */ | ||||
| 	public static function widget_list( $widget = false ) { | ||||
|  | ||||
| 		/** | ||||
| 		 * List of WP-Statistics Widget | ||||
| 		 * | ||||
| 		 * --- Array Arg ----- | ||||
| 		 * page_url : link of Widget Page @see WP_Statistics::$page | ||||
| 		 * name     : Name Of Widget Box | ||||
| 		 * require  : the Condition From Wp-statistics Option if == true | ||||
| 		 * hidden   : if set true , Default Hidden Dashboard in Wordpress Admin | ||||
| 		 * | ||||
| 		 */ | ||||
| 		$list = array( | ||||
| 			'quickstats'       => array( | ||||
| 				'page_url' => 'overview', | ||||
| 				'name'     => __( 'Quick Stats', 'wp-statistics' ) | ||||
| 			), | ||||
| 			'summary'          => array( | ||||
| 				'name'   => __( 'Summary', 'wp-statistics' ), | ||||
| 				'hidden' => true | ||||
| 			), | ||||
| 			'browsers'         => array( | ||||
| 				'page_url' => 'browser', | ||||
| 				'name'     => __( 'Top 10 Browsers', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'countries'        => array( | ||||
| 				'page_url' => 'countries', | ||||
| 				'name'     => __( 'Top 10 Countries', 'wp-statistics' ), | ||||
| 				'require'  => array( 'geoip', 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'hits'             => array( | ||||
| 				'page_url' => 'hits', | ||||
| 				'name'     => __( 'Hit Statistics', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visits' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'pages'            => array( | ||||
| 				'page_url' => 'pages', | ||||
| 				'name'     => __( 'Top 10 Pages', 'wp-statistics' ), | ||||
| 				'require'  => array( 'pages' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'referring'        => array( | ||||
| 				'page_url' => 'referrers', | ||||
| 				'name'     => __( 'Top Referring Sites', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'search'           => array( | ||||
| 				'page_url' => 'searches', | ||||
| 				'name'     => __( 'Search Engine Referrals', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'words'            => array( | ||||
| 				'page_url' => 'words', | ||||
| 				'name'     => __( 'Latest Search Words', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'top-visitors'     => array( | ||||
| 				'page_url' => 'top-visitors', | ||||
| 				'name'     => __( 'Top 10 Visitors Today', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'recent'           => array( | ||||
| 				'page_url' => 'visitors', | ||||
| 				'name'     => __( 'Recent Visitors', 'wp-statistics' ), | ||||
| 				'require'  => array( 'visitors' ), | ||||
| 				'hidden'   => true | ||||
| 			), | ||||
| 			'hitsmap'          => array( | ||||
| 				'name'    => __( 'Today\'s Visitors Map', 'wp-statistics' ), | ||||
| 				'require' => array( 'visitors' ), | ||||
| 				'hidden'  => true | ||||
| 			) | ||||
| 		); | ||||
|  | ||||
| 		//Print List of Dashboard | ||||
| 		if ( $widget === false ) { | ||||
| 			return $list; | ||||
| 		} else { | ||||
| 			if ( array_key_exists( $widget, $list ) ) { | ||||
| 				return $list[ $widget ]; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return array(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This function Register Wp-statistics Dashboard to wordpress Admin | ||||
| 	 */ | ||||
| 	public static function register_dashboard_widget() { | ||||
|  | ||||
| 		//Check Dashboard Widget | ||||
| 		if ( ! function_exists( 'wp_add_dashboard_widget' ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Get List Of Wp-statistics Dashboard Widget | ||||
| 		$list = self::widget_list(); | ||||
| 		foreach ( $list as $widget_key => $dashboard ) { | ||||
|  | ||||
| 			//Register Dashboard Widget | ||||
| 			if ( wp_statistics_check_option_require( $dashboard ) === true ) { | ||||
| 				wp_add_dashboard_widget( self::widget_setup_key( $widget_key ), $dashboard['name'], 'WP_Statistics_Dashboard::generate_postbox_contents', $control_callback = null, array( 'widget' => $widget_key ) ); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Load Dashboard Widget | ||||
| 	 * This Function add_action to `wp_dashboard_setup` | ||||
| 	 */ | ||||
| 	static function load_dashboard_widget() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Load User Options | ||||
| 		$WP_Statistics->load_user_options(); | ||||
|  | ||||
| 		// If the user does not have at least read access to the status plugin, just return without adding the widgets. | ||||
| 		if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_option' ) ) ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Check Hidden User Dashboard Option | ||||
| 		$user_dashboard = $WP_Statistics->get_user_option( self::$dashboard_set ); | ||||
| 		if ( $user_dashboard === false || $user_dashboard != WP_Statistics::$reg['version'] ) { | ||||
| 			self::set_user_hidden_dashboard_option(); | ||||
| 		} | ||||
|  | ||||
| 		// If the admin has disabled the widgets, don't display them. | ||||
| 		if ( ! $WP_Statistics->get_option( 'disable_dashboard' ) ) { | ||||
| 			self::register_dashboard_widget(); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set Default Hidden Dashboard User Option | ||||
| 	 */ | ||||
| 	public static function set_user_hidden_dashboard_option() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Get List Of Wp-statistics Dashboard Widget | ||||
| 		$dashboard_list = self::widget_list(); | ||||
| 		$hidden_opt     = 'metaboxhidden_dashboard'; | ||||
|  | ||||
| 		//Create Empty Option and save in User meta | ||||
| 		$WP_Statistics->update_user_option( self::$dashboard_set, WP_Statistics::$reg['version'] ); | ||||
|  | ||||
| 		//Get Dashboard Option User Meta | ||||
| 		$hidden_widgets = get_user_meta( $WP_Statistics->user_id, $hidden_opt, true ); | ||||
| 		if ( ! is_array( $hidden_widgets ) ) { | ||||
| 			$hidden_widgets = array(); | ||||
| 		} | ||||
|  | ||||
| 		//Set Default Hidden Dashboard in Admin Wordpress | ||||
| 		foreach ( $dashboard_list as $widget => $dashboard ) { | ||||
| 			if ( array_key_exists( 'hidden', $dashboard ) ) { | ||||
| 				$hidden_widgets[] = self::widget_setup_key( $widget ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		update_user_meta( $WP_Statistics->user_id, $hidden_opt, $hidden_widgets ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Load Widget Script/style | ||||
| 	 */ | ||||
| 	static function load_widget_css_and_scripts() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Load the css we use for the statistics pages. | ||||
| 		wp_enqueue_style( 'wpstatistics-log-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/log.css', true, '1.2' ); | ||||
|  | ||||
| 		// Load the map code. | ||||
| 		if ( ! $WP_Statistics->get_option( 'disable_dashboard' ) ) { | ||||
| 			wp_enqueue_style( 'jqvmap-css', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jqvmap.css', true, '1.5.1' ); | ||||
| 			wp_enqueue_script( 'jquery-vmap', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/jquery.vmap.js', true, '1.5.1' ); | ||||
| 			wp_enqueue_script( 'jquery-vmap-world', WP_Statistics::$reg['plugin-url'] . 'assets/jqvmap/maps/jquery.vmap.world.js', true, '1.5.1' ); | ||||
| 		} | ||||
|  | ||||
| 		// Load chart library | ||||
| 		if ( ! isset( $_GET['post'] ) ) { | ||||
| 			wp_enqueue_script( 'wp-statistics-chart-js', WP_Statistics::$reg['plugin-url'] . 'assets/js/Chart.bundle.min.js', false, '2.7.3', false ); | ||||
| 		} | ||||
|  | ||||
| 		//Get current screen page | ||||
| 		$screen = get_current_screen(); | ||||
|  | ||||
| 		// Load our custom widgets handling javascript. | ||||
| 		if ( 'post' == $screen->id || 'page' == $screen->id ) { | ||||
| 			wp_enqueue_script( 'wp_statistics_editor', WP_Statistics::$reg['plugin-url'] . 'assets/js/editor.js' ); | ||||
| 		} else { | ||||
| 			wp_enqueue_script( 'wp_statistics_dashboard', WP_Statistics::$reg['plugin-url'] . 'assets/js/dashboard.js' ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Add inline Script | ||||
| 	 * For Add button Refresh/Direct Button Link in Top of Meta Box | ||||
| 	 */ | ||||
| 	static function inline_javascript() { | ||||
|  | ||||
| 		//if not Dashboard Page | ||||
| 		$screen = get_current_screen(); | ||||
| 		if ( 'dashboard' != $screen->id ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Load Of Require Jquery Library Function | ||||
| 		WP_Statistics_Dashboard::load_widget_css_and_scripts(); | ||||
|  | ||||
| 		//Prepare List Of Dashboard | ||||
| 		$page_urls  = array(); | ||||
| 		$dashboards = self::widget_list(); | ||||
| 		foreach ( $dashboards as $widget_key => $dashboard ) { | ||||
| 			if ( array_key_exists( 'page_url', $dashboard ) ) { | ||||
| 				$page_urls[ 'wp-statistics-' . $widget_key . '-widget_more_button' ] = WP_Statistics_Admin_Pages::admin_url( $dashboard['page_url'] ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Add Extra Pages For Overview Page | ||||
| 		foreach ( array( 'exclusions' => 'exclusions', 'users_online' => 'online' ) as $p_key => $p_link ) { | ||||
| 			$page_urls[ 'wp-statistics-' . $p_key . '-widget_more_button' ] = WP_Statistics_Admin_Pages::admin_url( $p_link ); | ||||
| 		} | ||||
|  | ||||
| 		?> | ||||
|         <script type="text/javascript"> | ||||
|             var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>; | ||||
|             var wp_statistics_loading_image = '<?php echo WP_Statistics_Admin_Pages::loading_meta_box(); ?>'; | ||||
|  | ||||
|             function wp_statistics_wait_for_postboxes() { | ||||
|  | ||||
|                 if (!jQuery('#show-settings-link').is(':visible')) { | ||||
|                     setTimeout(wp_statistics_wait_for_postboxes, 500); | ||||
|                 } | ||||
|  | ||||
|                 jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget); | ||||
|                 jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more); | ||||
|  | ||||
|                 jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget); | ||||
|             } | ||||
|  | ||||
|             jQuery(document).ready(function () { | ||||
|  | ||||
|                 // Add the "more" and "refresh" buttons. | ||||
|                 jQuery('.postbox').each(function () { | ||||
|                     var temp = jQuery(this); | ||||
|                     var temp_id = temp.attr('id'); | ||||
|  | ||||
|                     if (temp_id.substr(0, 14) != 'wp-statistics-') { | ||||
|                         return; | ||||
|                     } | ||||
|  | ||||
|                     var temp_html = temp.html(); | ||||
|                     if (temp_id == '<?php echo self::widget_setup_key( 'summary' ); ?>') { | ||||
|                         new_text = '<?php echo WP_Statistics_Admin_Pages::meta_box_button( 'refresh' );?>'; | ||||
|                         new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button'); | ||||
|                         temp_html = temp_html.replace('</button>', new_text); | ||||
|                     } else { | ||||
|                         new_text = '<?php echo WP_Statistics_Admin_Pages::meta_box_button();?>'; | ||||
|                         new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button'); | ||||
|                         new_text = new_text.replace('{{moreid}}', temp_id + '_more_button'); | ||||
|                         temp_html = temp_html.replace('</button>', new_text); | ||||
|                     } | ||||
|                     temp.html(temp_html); | ||||
|                 }); | ||||
|  | ||||
|                 // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code. | ||||
|                 // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once. | ||||
|                 setTimeout(wp_statistics_wait_for_postboxes, 100); | ||||
|             }); | ||||
|         </script> | ||||
| 		<?php | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Generate widget Post Box | ||||
| 	 * | ||||
| 	 * @param $post | ||||
| 	 * @param $args | ||||
| 	 */ | ||||
| 	static function generate_postbox_contents( $post, $args ) { | ||||
| 		$widget       = $args['args']['widget']; | ||||
| 		$container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div'; | ||||
|  | ||||
| 		echo '<div id="' . $container_id . '">' . WP_Statistics_Admin_Pages::loading_meta_box() . '</div>'; | ||||
| 		wp_statistics_generate_widget_load_javascript( $widget, $container_id ); | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,201 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Editor | ||||
|  */ | ||||
| class WP_Statistics_Editor { | ||||
|  | ||||
| 	/** | ||||
| 	 * Adds a box to the main column on the Post and Page edit screens. | ||||
| 	 */ | ||||
| 	static function add_meta_box() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Load All User Options | ||||
| 		$WP_Statistics->load_user_options(); | ||||
|  | ||||
| 		// We need to fudge the display settings for first time users so not all of the widgets are displayed, we only want to do this on | ||||
| 		// the first time they visit the dashboard though so check to see if we've been here before. | ||||
| 		if ( ! $WP_Statistics->get_user_option( 'editor_set' ) ) { | ||||
| 			$WP_Statistics->update_user_option( 'editor_set', WP_Statistics::$reg['version'] ); | ||||
|  | ||||
| 			$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', true ); | ||||
| 			if ( ! is_array( $hidden_widgets ) ) { | ||||
| 				$hidden_widgets = array(); | ||||
| 			} | ||||
|  | ||||
| 			if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) { | ||||
| 				$hidden_widgets[] = 'wp_statistics_editor_meta_box'; | ||||
| 			} | ||||
|  | ||||
| 			update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_post', $hidden_widgets ); | ||||
|  | ||||
| 			$hidden_widgets = get_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', true ); | ||||
| 			if ( ! is_array( $hidden_widgets ) ) { | ||||
| 				$hidden_widgets = array(); | ||||
| 			} | ||||
|  | ||||
| 			if ( ! in_array( 'wp_statistics_editor_meta_box', $hidden_widgets ) ) { | ||||
| 				$hidden_widgets[] = 'wp_statistics_editor_meta_box'; | ||||
| 			} | ||||
|  | ||||
| 			update_user_meta( $WP_Statistics->user_id, 'metaboxhidden_page', $hidden_widgets ); | ||||
| 		} | ||||
|  | ||||
| 		// If the user does not have at least read access to the status plugin, just return without adding the widgets. | ||||
| 		if ( ! current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_option' ) ) ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// If the admin has disabled the widgets don't display them. | ||||
| 		if ( $WP_Statistics->get_option( 'disable_editor' ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// If the admin has disabled the Hit Post MetaBox. | ||||
| 		if ( ! $WP_Statistics->get_option( 'hit_post_metabox' ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Show Hit Column in All Post Type in Wordpress | ||||
| 		$screens = self::get_list_post_type(); | ||||
| 		foreach ( $screens as $screen ) { | ||||
| 			add_meta_box( 'wp_statistics_editor_meta_box', __( 'Hit Statistics', 'wp-statistics' ), 'WP_Statistics_Editor::meta_box', $screen, 'normal', 'high', | ||||
| 				array( | ||||
| 					'__block_editor_compatible_meta_box' => true, | ||||
| 					'__back_compat_meta_box'             => false, | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	static function meta_box( $post ) { | ||||
| 		// If the post isn't published yet, don't output the stats as they take too much memory and CPU to compute for no reason. | ||||
| 		if ( $post->post_status != 'publish' && $post->post_status != 'private' ) { | ||||
| 			_e( 'This post is not yet published.', 'wp-statistics' ); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		add_action( 'admin_footer', 'WP_Statistics_Editor::inline_javascript' ); | ||||
| 		WP_Statistics_Editor::generate_postbox_contents( $post->ID, array( 'args' => array( 'widget' => 'page' ) ) ); | ||||
| 	} | ||||
|  | ||||
| 	static function generate_postbox_contents( $post, $args ) { | ||||
| 		if ( self::is_gutenberg() ) { | ||||
| 			//If Gutenberg Editor | ||||
| 			if ( isset( $_GET['post'] ) and ! empty( $_GET['post'] ) ) { | ||||
| 				echo '<div class="wps-gutenberg-chart-js">'; | ||||
| 				require( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/page.php' ); | ||||
| 				wp_statistics_generate_page_postbox_content( null, $_GET['post'] ); | ||||
| 				echo '</div>'; | ||||
| 				echo '<style>button#wp_statistics_editor_meta_box_more_button { z-index: 9999;position: absolute;top: 1px;right: 3%;}</style>'; | ||||
| 			} | ||||
| 		} else { | ||||
| 			$widget       = $args['args']['widget']; | ||||
| 			$container_id = 'wp-statistics-' . str_replace( '.', '-', $widget ) . '-div'; | ||||
| 			echo '<div id="' . $container_id . '">' . WP_Statistics_Admin_Pages::loading_meta_box() . '</div>'; | ||||
| 			echo '<script type="text/javascript">var wp_statistics_current_id = \'' . $post . '\';</script>'; | ||||
| 			wp_statistics_generate_widget_load_javascript( $widget, $container_id ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	static function inline_javascript() { | ||||
| 		$screen = get_current_screen(); | ||||
|  | ||||
| 		$screens = self::get_list_post_type(); | ||||
| 		if ( ! in_array( $screen->id, $screens ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		WP_Statistics_Dashboard::load_widget_css_and_scripts(); | ||||
| 		$loading_img = WP_Statistics_Admin_Pages::loading_meta_box(); | ||||
| 		$new_buttons = '</button>'; | ||||
|  | ||||
| 		//If Classic Editor | ||||
| 		if ( self::is_gutenberg() === false ) { | ||||
| 			$new_buttons .= '<button class="handlediv button-link wps-refresh" type="button" id="{{refreshid}}">' . wp_statistics_icons( 'dashicons-update' ) . '<span class="screen-reader-text">' . __( 'Reload', 'wp-statistics' ) . '</span></button>'; | ||||
| 		} | ||||
| 		$new_buttons .= '<button class="handlediv button-link wps-more" type="button" id="{{moreid}}">' . wp_statistics_icons( 'dashicons-external' ) . '<span class="screen-reader-text">' . __( 'More Details', 'wp-statistics' ) . '</span></button>'; | ||||
|  | ||||
|  | ||||
| 		$admin_url                                              = get_admin_url() . "/admin.php?page="; | ||||
| 		$page_urls                                              = array(); | ||||
| 		$page_urls['wp_statistics_editor_meta_box_more_button'] = $admin_url . WP_Statistics::$page['pages'] . '&page-id='; | ||||
|  | ||||
| 		//Button for Gutenberg | ||||
| 		$btn_more_action = 'wp_statistics_goto_more'; | ||||
| 		if ( self::is_gutenberg() ) { | ||||
| 			$btn_more_action = "function () { window.location.href = '" . wp_normalize_path( $page_urls['wp_statistics_editor_meta_box_more_button'] . ( isset( $_GET['post'] ) === true ? $_GET['post'] : '' ) ) . "';}"; | ||||
| 		} | ||||
|  | ||||
| 		?> | ||||
|         <script type="text/javascript"> | ||||
|             var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>; | ||||
|             var wp_statistics_loading_image = '<?php echo $loading_img; ?>'; | ||||
|  | ||||
|             function wp_statistics_wait_for_postboxes() { | ||||
|  | ||||
|                 if (!jQuery('#show-settings-link').is(':visible')) { | ||||
|                     setTimeout(wp_statistics_wait_for_postboxes, 500); | ||||
|                 } | ||||
|  | ||||
|                 jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget); | ||||
|                 jQuery('.wps-more').unbind('click').on('click', <?php echo $btn_more_action; ?>); | ||||
|                 jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget); | ||||
|             } | ||||
|  | ||||
|             jQuery(document).ready(function () { | ||||
|  | ||||
|                 // Add the "more" and "refresh" buttons. | ||||
|                 jQuery('.postbox').each(function () { | ||||
|                     var temp = jQuery(this); | ||||
|                     var temp_id = temp.attr('id'); | ||||
|  | ||||
|                     if (temp_id == 'wp_statistics_editor_meta_box') { | ||||
|  | ||||
|                         var temp_html = temp.html(); | ||||
|  | ||||
|                         new_text = '<?php echo $new_buttons;?>'; | ||||
|                         new_text = new_text.replace('{{refreshid}}', temp_id + '_refresh_button'); | ||||
|                         new_text = new_text.replace('{{moreid}}', temp_id + '_more_button'); | ||||
|  | ||||
|                         temp_html = temp_html.replace('</button>', new_text); | ||||
|  | ||||
|                         temp.html(temp_html); | ||||
|                     } | ||||
|                 }); | ||||
|  | ||||
|                 // We have use a timeout here because we don't now what order this code will run in comparison to the postbox code. | ||||
|                 // Any timeout value should work as the timeout won't run until the rest of the javascript as run through once. | ||||
|                 setTimeout(wp_statistics_wait_for_postboxes, 100); | ||||
|             }); | ||||
|         </script> | ||||
| 		<?php | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get List Post Type | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public static function get_list_post_type() { | ||||
| 		$post_types     = array( 'post', 'page' ); | ||||
| 		$get_post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' ); | ||||
| 		foreach ( $get_post_types as $name ) { | ||||
| 			$post_types[] = $name; | ||||
| 		} | ||||
|  | ||||
| 		return $post_types; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check Is Gutenberg Editor | ||||
| 	 */ | ||||
| 	public static function is_gutenberg() { | ||||
| 		$current_screen = get_current_screen(); | ||||
| 		if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) || ( function_exists( 'is_gutenberg_page' ) ) && is_gutenberg_page() ) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,343 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Export | ||||
|  */ | ||||
| class WP_Statistics_Export { | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an Export Report Class | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
|  | ||||
| 		//Export Data | ||||
| 		add_action( 'admin_init', array( $this, 'export_data' ), 9 ); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the headers to download the export file and then stop running WordPress. | ||||
| 	 */ | ||||
| 	public function export_data() { | ||||
| 		if ( isset( $_POST['wps_export'] ) ) { | ||||
| 			global $WP_Statistics, $wpdb; | ||||
|  | ||||
| 			//Set Time Limit Script Run | ||||
| 			set_time_limit( 0 ); | ||||
|  | ||||
| 			//Check Wp Nonce and Require Field | ||||
| 			if ( ! isset( $_POST['table-to-export'] ) || ! isset( $_POST['export-file-type'] ) || ! isset( $_POST['wps_export_file'] ) || ! wp_verify_nonce( $_POST['wps_export_file'], 'wp_statistics_export_nonce' ) ) { | ||||
| 				exit; | ||||
| 			} | ||||
|  | ||||
| 			//Check Current User Capability | ||||
| 			$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
| 			if ( current_user_can( $manage_cap ) ) { | ||||
| 				$table = $_POST['table-to-export']; | ||||
| 				$type  = $_POST['export-file-type']; | ||||
|  | ||||
| 				// Validate the table name the user passed to us. | ||||
| 				$allow_tbl = array( "useronline", "visit", "visitor", "exclusions", "pages", "search" ); | ||||
| 				if ( ! in_array( $table, $allow_tbl ) ) { | ||||
| 					$table = false; | ||||
| 				} | ||||
|  | ||||
| 				// Validate the file type the user passed to us. | ||||
| 				if ( ! ( $type == "xml" || $type == "csv" || $type == "tsv" ) ) { | ||||
| 					$table = false; | ||||
| 				} | ||||
|  | ||||
| 				if ( $table && $type ) { | ||||
| 					$file_name = 'wp-statistics' . '-' . $WP_Statistics->Current_Date( 'Y-m-d-H-i' ); | ||||
|  | ||||
| 					switch ( $type ) { | ||||
| 						case 'xml': | ||||
| 							$exporter = new ExportDataExcel( 'browser', "{$file_name}.xml" ); | ||||
| 							break; | ||||
| 						case 'csv': | ||||
| 							$exporter = new ExportDataCSV( 'browser', "{$file_name}.csv" ); | ||||
| 							break; | ||||
| 						case 'tsv': | ||||
| 							$exporter = new ExportDataTSV( 'browser', "{$file_name}.tsv" ); | ||||
| 							break; | ||||
| 					} | ||||
|  | ||||
| 					$exporter->initialize(); | ||||
|  | ||||
| 					// We need to limit the number of results we retrieve to ensure we don't run out of memory | ||||
| 					$query_base = "SELECT * FROM {$wpdb->prefix}statistics_{$table}"; | ||||
| 					$query      = $query_base . ' LIMIT 0,1000'; | ||||
|  | ||||
| 					$i            = 1; | ||||
| 					$more_results = true; | ||||
| 					$result       = $wpdb->get_results( $query, ARRAY_A ); | ||||
|  | ||||
| 					// If we didn't get any rows, don't output anything. | ||||
| 					if ( count( $result ) < 1 ) { | ||||
| 						echo "No data in table!"; | ||||
| 						exit; | ||||
| 					} | ||||
|  | ||||
| 					if ( isset( $_POST['export-headers'] ) and $_POST['export-headers'] ) { | ||||
| 						foreach ( $result[0] as $key => $col ) { | ||||
| 							$columns[] = $key; | ||||
| 						} | ||||
| 						$exporter->addRow( $columns ); | ||||
| 					} | ||||
|  | ||||
| 					while ( $more_results ) { | ||||
| 						foreach ( $result as $row ) { | ||||
| 							$exporter->addRow( $row ); | ||||
|  | ||||
| 							// Make sure we've flushed the output buffer so we don't run out of memory on large exports. | ||||
| 							ob_flush(); | ||||
| 							flush(); | ||||
| 						} | ||||
|  | ||||
| 						unset( $result ); | ||||
| 						$wpdb->flush(); | ||||
|  | ||||
| 						$query  = $query_base . ' LIMIT ' . ( $i * 1000 ) . ',1000'; | ||||
| 						$result = $wpdb->get_results( $query, ARRAY_A ); | ||||
|  | ||||
| 						if ( count( $result ) == 0 ) { | ||||
| 							$more_results = false; | ||||
| 						} | ||||
|  | ||||
| 						$i ++; | ||||
| 					} | ||||
|  | ||||
| 					$exporter->finalize(); | ||||
| 					exit; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * ExportData is the base class for exporters to specific file formats. See other | ||||
|  * classes below. | ||||
|  */ | ||||
| abstract class ExportData { | ||||
| 	protected $exportTo; // Set in constructor to one of 'browser', 'file', 'string' | ||||
| 	protected $stringData; // stringData so far, used if export string mode | ||||
| 	protected $tempFile; // handle to temp file (for export file mode) | ||||
| 	protected $tempFilename; // temp file name and path (for export file mode) | ||||
| 	public $filename; // file mode: the output file name; browser mode: file name for download; string mode: not used | ||||
|  | ||||
| 	public function __construct( $exportTo = "browser", $filename = "exportdata" ) { | ||||
| 		if ( ! in_array( $exportTo, array( 'browser', 'file', 'string' ) ) ) { | ||||
| 			throw new Exception( "$exportTo is not a valid ExportData export type" ); | ||||
| 		} | ||||
| 		$this->exportTo = $exportTo; | ||||
| 		$this->filename = $filename; | ||||
| 	} | ||||
|  | ||||
| 	public function initialize() { | ||||
|  | ||||
| 		switch ( $this->exportTo ) { | ||||
| 			case 'browser': | ||||
| 				$this->sendHttpHeaders(); | ||||
| 				break; | ||||
| 			case 'string': | ||||
| 				$this->stringData = ''; | ||||
| 				break; | ||||
| 			case 'file': | ||||
| 				$this->tempFilename = tempnam( sys_get_temp_dir(), 'exportdata' ); | ||||
| 				$this->tempFile     = fopen( $this->tempFilename, "w" ); | ||||
| 				break; | ||||
| 		} | ||||
|  | ||||
| 		$this->write( $this->generateHeader() ); | ||||
| 	} | ||||
|  | ||||
| 	public function addRow( $row ) { | ||||
| 		$this->write( $this->generateRow( $row ) ); | ||||
| 	} | ||||
|  | ||||
| 	public function finalize() { | ||||
|  | ||||
| 		$this->write( $this->generateFooter() ); | ||||
|  | ||||
| 		switch ( $this->exportTo ) { | ||||
| 			case 'browser': | ||||
| 				flush(); | ||||
| 				break; | ||||
| 			case 'string': | ||||
| 				// do nothing | ||||
| 				break; | ||||
| 			case 'file': | ||||
| 				// close temp file and move it to correct location | ||||
| 				fclose( $this->tempFile ); | ||||
| 				rename( $this->tempFilename, $this->filename ); | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function getString() { | ||||
| 		return $this->stringData; | ||||
| 	} | ||||
|  | ||||
| 	abstract public function sendHttpHeaders(); | ||||
|  | ||||
| 	protected function write( $data ) { | ||||
| 		switch ( $this->exportTo ) { | ||||
| 			case 'browser': | ||||
| 				echo $data; | ||||
| 				break; | ||||
| 			case 'string': | ||||
| 				$this->stringData .= $data; | ||||
| 				break; | ||||
| 			case 'file': | ||||
| 				fwrite( $this->tempFile, $data ); | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	protected function generateHeader() { | ||||
| 		// can be overridden by subclass to return any data that goes at the top of the exported file | ||||
| 	} | ||||
|  | ||||
| 	protected function generateFooter() { | ||||
| 		// can be overridden by subclass to return any data that goes at the bottom of the exported file | ||||
| 	} | ||||
|  | ||||
| 	// In subclasses generateRow will take $row array and return string of it formatted for export type | ||||
| 	abstract protected function generateRow( $row ); | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * ExportDataTSV - Exports to TSV (tab separated value) format. | ||||
|  */ | ||||
| class ExportDataTSV extends ExportData { | ||||
|  | ||||
| 	function generateRow( $row ) { | ||||
| 		foreach ( $row as $key => $value ) { | ||||
| 			// Escape inner quotes and wrap all contents in new quotes. | ||||
| 			// Note that we are using \" to escape double quote not "" | ||||
| 			$row[ $key ] = '"' . str_replace( '"', '\"', $value ) . '"'; | ||||
| 		} | ||||
| 		return implode( "\t", $row ) . "\n"; | ||||
| 	} | ||||
|  | ||||
| 	function sendHttpHeaders() { | ||||
| 		header( "Content-type: text/tab-separated-values" ); | ||||
| 		header( "Content-Disposition: attachment; filename=" . basename( $this->filename ) ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * ExportDataCSV - Exports to CSV (comma separated value) format. | ||||
|  */ | ||||
| class ExportDataCSV extends ExportData { | ||||
|  | ||||
| 	function generateRow( $row ) { | ||||
| 		foreach ( $row as $key => $value ) { | ||||
| 			// Escape inner quotes and wrap all contents in new quotes. | ||||
| 			// Note that we are using \" to escape double quote not "" | ||||
| 			$row[ $key ] = '"' . str_replace( '"', '\"', $value ) . '"'; | ||||
| 		} | ||||
| 		return implode( ",", $row ) . "\n"; | ||||
| 	} | ||||
|  | ||||
| 	function sendHttpHeaders() { | ||||
| 		header( "Content-type: text/csv" ); | ||||
| 		header( "Content-Disposition: attachment; filename=" . basename( $this->filename ) ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Class ExportDataExcel | ||||
|  */ | ||||
| class ExportDataExcel extends ExportData { | ||||
|  | ||||
| 	const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">"; | ||||
| 	const XmlFooter = "</Workbook>"; | ||||
|  | ||||
| 	public $encoding = 'UTF-8'; // encoding type to specify in file. | ||||
| 	// Note that you're on your own for making sure your data is actually encoded to this encoding | ||||
|  | ||||
| 	public $title = 'Sheet1'; // title for Worksheet | ||||
|  | ||||
| 	function generateHeader() { | ||||
|  | ||||
| 		// workbook header | ||||
| 		$output = stripslashes( sprintf( self::XmlHeader, $this->encoding ) ) . "\n"; | ||||
|  | ||||
| 		// Set up styles | ||||
| 		$output .= "<Styles>\n"; | ||||
| 		$output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n"; | ||||
| 		$output .= "</Styles>\n"; | ||||
|  | ||||
| 		// worksheet header | ||||
| 		$output .= sprintf( "<Worksheet ss:Name=\"%s\">\n    <Table>\n", htmlentities( $this->title ) ); | ||||
|  | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
| 	function generateFooter() { | ||||
| 		$output = ''; | ||||
|  | ||||
| 		// worksheet footer | ||||
| 		$output .= "    </Table>\n</Worksheet>\n"; | ||||
|  | ||||
| 		// workbook footer | ||||
| 		$output .= self::XmlFooter; | ||||
|  | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
| 	function generateRow( $row ) { | ||||
| 		$output = ''; | ||||
| 		$output .= "        <Row>\n"; | ||||
| 		foreach ( $row as $k => $v ) { | ||||
| 			$output .= $this->generateCell( $v ); | ||||
| 		} | ||||
| 		$output .= "        </Row>\n"; | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
| 	private function generateCell( $item ) { | ||||
| 		$output = ''; | ||||
| 		$style  = ''; | ||||
|  | ||||
| 		// Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep | ||||
| 		// as text if number is longer than that. | ||||
| 		if ( preg_match( "/^-?\d+(?:[.,]\d+)?$/", $item ) && ( strlen( $item ) < 15 ) ) { | ||||
| 			$type = 'Number'; | ||||
| 		} | ||||
| 		// Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can | ||||
| 		// also have an optional time after the date. | ||||
| 		// | ||||
| 		// Note we want to be very strict in what we consider a date. There is the possibility | ||||
| 		// of really screwing up the data if we try to reformat a string that was not actually | ||||
| 		// intended to represent a date. | ||||
| 		elseif ( preg_match( "/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item ) && | ||||
| 		         ( $timestamp = strtotime( $item ) ) && | ||||
| 		         ( $timestamp > 0 ) && | ||||
| 		         ( $timestamp < strtotime( '+500 years' ) ) ) { | ||||
| 			$type  = 'DateTime'; | ||||
| 			$item  = strftime( "%Y-%m-%dT%H:%M:%S", $timestamp ); | ||||
| 			$style = 'sDT'; // defined in header; tells excel to format date for display | ||||
| 		} else { | ||||
| 			$type = 'String'; | ||||
| 		} | ||||
|  | ||||
| 		$item   = str_replace( ''', ''', htmlspecialchars( $item, ENT_QUOTES ) ); | ||||
| 		$output .= "            "; | ||||
| 		$output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>"; | ||||
| 		$output .= sprintf( "<Data ss:Type=\"%s\">%s</Data>", $type, $item ); | ||||
| 		$output .= "</Cell>\n"; | ||||
|  | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
| 	function sendHttpHeaders() { | ||||
| 		header( "Content-Type: application/vnd.ms-excel; charset=" . $this->encoding ); | ||||
| 		header( "Content-Disposition: inline; filename=\"" . basename( $this->filename ) . "\"" ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,303 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Frontend | ||||
|  */ | ||||
| class WP_Statistics_Frontend { | ||||
|  | ||||
| 	public function __construct() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Enable Shortcode in Widget | ||||
| 		add_filter( 'widget_text', 'do_shortcode' ); | ||||
|  | ||||
| 		// Add the honey trap code in the footer. | ||||
| 		add_action( 'wp_footer', array( $this, 'add_honeypot' ) ); | ||||
|  | ||||
| 		// Enqueue scripts & styles | ||||
| 		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | ||||
|  | ||||
| 		//Get Visitor information and Save To Database | ||||
| 		add_action( 'wp', array( $this, 'init' ) ); | ||||
|  | ||||
| 		//Add inline Rest Request | ||||
| 		add_action( 'wp_head', array( $this, 'add_inline_rest_js' ) ); | ||||
|  | ||||
| 		//Add Html Comment in head | ||||
| 		if ( ! $WP_Statistics->use_cache ) { | ||||
| 			add_action( 'wp_head', array( $this, 'html_comment' ) ); | ||||
| 		} | ||||
|  | ||||
| 		// Check to show hits in posts/pages | ||||
| 		if ( $WP_Statistics->get_option( 'show_hits' ) ) { | ||||
| 			add_filter( 'the_content', array( $this, 'show_hits' ) ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Create Comment support Wappalyzer | ||||
| 	 */ | ||||
| 	public function html_comment() { | ||||
| 		echo '<!-- Analytics by WP-Statistics v' . WP_Statistics::$reg['version'] . ' - ' . WP_Statistics::$reg['plugin-data']['PluginURI'] . ' -->' . "\n"; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Footer Action | ||||
| 	 */ | ||||
| 	public function add_honeypot() { | ||||
| 		global $WP_Statistics; | ||||
| 		if ( $WP_Statistics->get_option( 'use_honeypot' ) && $WP_Statistics->get_option( 'honeypot_postid' ) > 0 ) { | ||||
| 			$post_url = get_permalink( $WP_Statistics->get_option( 'honeypot_postid' ) ); | ||||
| 			echo '<a href="' . $post_url . '" style="display: none;"> </a>'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Enqueue Scripts | ||||
| 	 */ | ||||
| 	public function enqueue_scripts() { | ||||
|  | ||||
| 		// Load our CSS to be used. | ||||
| 		if ( is_admin_bar_showing() ) { | ||||
| 			wp_enqueue_style( 'wpstatistics-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/frontend.css', true, WP_Statistics::$reg['version'] ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Inline Js | ||||
| 	 */ | ||||
| 	public function add_inline_rest_js() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		if ( $WP_Statistics->use_cache ) { | ||||
|  | ||||
| 			// Wp-Statistics HTML comment | ||||
| 			$this->html_comment(); | ||||
|  | ||||
| 			// Prepare Params | ||||
| 			$params = array_merge( array( | ||||
| 				'_'                           => time(), | ||||
| 				'_wpnonce'                    => wp_create_nonce( 'wp_rest' ), | ||||
| 				WP_Statistics_Rest::_Argument => 'yes', | ||||
| 			), self::set_default_params() ); | ||||
|  | ||||
| 			// Return to Page | ||||
| 			echo '<script>var WP_Statistics_http = new XMLHttpRequest();WP_Statistics_http.open(\'GET\', \'' . add_query_arg( $params, path_join( get_rest_url(), WP_Statistics_Rest::route . '/' . WP_Statistics_Rest::func ) ) . '\', true);WP_Statistics_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");WP_Statistics_http.send(null);</script>' . "\n"; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Set Default Params Rest Api | ||||
| 	 */ | ||||
| 	static public function set_default_params() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		/* | ||||
| 		 * Load Rest Api JavaScript | ||||
| 		 */ | ||||
| 		$params = array(); | ||||
|  | ||||
| 		//Set Browser | ||||
| 		$result             = $WP_Statistics->get_UserAgent(); | ||||
| 		$params['browser']  = $result['browser']; | ||||
| 		$params['platform'] = $result['platform']; | ||||
| 		$params['version']  = $result['version']; | ||||
|  | ||||
| 		//set referred | ||||
| 		$params['referred'] = $WP_Statistics->get_Referred(); | ||||
|  | ||||
| 		//Set ip | ||||
| 		$params['ip'] = esc_html( $WP_Statistics->get_IP() ); | ||||
|  | ||||
| 		//exclude | ||||
| 		$check_exclude            = new WP_Statistics_Hits(); | ||||
| 		$params['exclude']        = $check_exclude->exclusion_match; | ||||
| 		$params['exclude_reason'] = $check_exclude->exclusion_reason; | ||||
|  | ||||
| 		//User Agent String | ||||
| 		$params['ua'] = ''; | ||||
| 		if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) { | ||||
| 			$params['ua'] = esc_html( $_SERVER['HTTP_USER_AGENT'] ); | ||||
| 		} | ||||
|  | ||||
| 		//track all page | ||||
| 		$params['track_all'] = 0; | ||||
| 		if ( WP_Statistics_Hits::is_track_page() === true ) { | ||||
| 			$params['track_all'] = 1; | ||||
| 		} | ||||
|  | ||||
| 		//timestamp | ||||
| 		$params['timestamp'] = $WP_Statistics->current_date( 'U' ); | ||||
|  | ||||
| 		//Wp_query | ||||
| 		$get_page_type               = WP_Statistics_Frontend::get_page_type(); | ||||
| 		$params['search_query']      = ''; | ||||
| 		$params['current_page_type'] = $get_page_type['type']; | ||||
| 		$params['current_page_id']   = $get_page_type['id']; | ||||
|  | ||||
| 		if ( array_key_exists( "search_query", $get_page_type ) ) { | ||||
| 			$params['search_query'] = esc_html( $get_page_type['search_query'] ); | ||||
| 		} | ||||
|  | ||||
| 		//page url | ||||
| 		$params['page_uri'] = wp_statistics_get_uri(); | ||||
|  | ||||
| 		//Get User id | ||||
| 		$params['user_id'] = 0; | ||||
| 		if ( is_user_logged_in() ) { | ||||
| 			$params['user_id'] = get_current_user_id(); | ||||
| 		} | ||||
|  | ||||
| 		return $params; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Shutdown Action | ||||
| 	 */ | ||||
| 	public function init() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// If something has gone horribly wrong and $WP_Statistics isn't an object, bail out. | ||||
| 		// This seems to happen sometimes with WP Cron calls. | ||||
| 		if ( ! is_object( $WP_Statistics ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//Disable if User Active cache Plugin | ||||
| 		if ( ! $WP_Statistics->use_cache ) { | ||||
|  | ||||
| 			$h = new WP_Statistics_GEO_IP_Hits; | ||||
|  | ||||
| 			// Call the online users tracking code. | ||||
| 			if ( $WP_Statistics->get_option( 'useronline' ) ) { | ||||
| 				$h->Check_online(); | ||||
| 			} | ||||
|  | ||||
| 			// Call the visitor tracking code. | ||||
| 			if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 				$h->Visitors(); | ||||
| 			} | ||||
|  | ||||
| 			// Call the visit tracking code. | ||||
| 			if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 				$h->Visits(); | ||||
| 			} | ||||
|  | ||||
| 			// Call the page tracking code. | ||||
| 			if ( $WP_Statistics->get_option( 'pages' ) ) { | ||||
| 				$h->Pages(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param $content | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function show_hits( $content ) { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Get post ID | ||||
| 		$post_id = get_the_ID(); | ||||
|  | ||||
| 		// Check post ID | ||||
| 		if ( ! $post_id ) { | ||||
| 			return $content; | ||||
| 		} | ||||
|  | ||||
| 		// Get post hits | ||||
| 		$hits      = wp_statistics_pages( 'total', "", $post_id ); | ||||
| 		$hits_html = '<p>' . sprintf( __( 'Hits: %s', 'wp-statistics' ), $hits ) . '</p>'; | ||||
|  | ||||
| 		// Check hits position | ||||
| 		if ( $WP_Statistics->get_option( 'display_hits_position' ) == 'before_content' ) { | ||||
| 			return $hits_html . $content; | ||||
| 		} elseif ( $WP_Statistics->get_option( 'display_hits_position' ) == 'after_content' ) { | ||||
| 			return $content . $hits_html; | ||||
| 		} else { | ||||
| 			return $content; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get Page Type | ||||
| 	 */ | ||||
| 	public static function get_page_type() { | ||||
|  | ||||
| 		//Set Default Option | ||||
| 		$result = array( "type" => "unknown", "id" => 0 ); | ||||
|  | ||||
| 		//Check Query object | ||||
| 		$id = get_queried_object_id(); | ||||
| 		if ( is_numeric( $id ) and $id > 0 ) { | ||||
| 			$result['id'] = $id; | ||||
| 		} | ||||
|  | ||||
| 		//WooCommerce Product | ||||
| 		if ( class_exists( 'WooCommerce' ) ) { | ||||
| 			if ( is_product() ) { | ||||
| 				return wp_parse_args( array( "type" => "product" ), $result ); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Home Page or Front Page | ||||
| 		if ( is_front_page() || is_home() ) { | ||||
| 			return wp_parse_args( array( "type" => "home" ), $result ); | ||||
| 		} | ||||
|  | ||||
| 		//attachment View | ||||
| 		if ( is_attachment() ) { | ||||
| 			$result['type'] = "attachment"; | ||||
| 		} | ||||
|  | ||||
| 		//is Archive Page | ||||
| 		if ( is_archive() ) { | ||||
| 			$result['type'] = "archive"; | ||||
| 		} | ||||
|  | ||||
| 		//Single Post Fro All Post Type | ||||
| 		if ( is_singular() ) { | ||||
| 			$result['type'] = "post"; | ||||
| 		} | ||||
|  | ||||
| 		//Single Page | ||||
| 		if ( is_page() ) { | ||||
| 			$result['type'] = "page"; | ||||
| 		} | ||||
|  | ||||
| 		//Category Page | ||||
| 		if ( is_category() ) { | ||||
| 			$result['type'] = "category"; | ||||
| 		} | ||||
|  | ||||
| 		//Tag Page | ||||
| 		if ( is_tag() ) { | ||||
| 			$result['type'] = "post_tag"; | ||||
| 		} | ||||
|  | ||||
| 		//is Custom Term From Taxonomy | ||||
| 		if ( is_tax() ) { | ||||
| 			$result['type'] = "tax"; | ||||
| 		} | ||||
|  | ||||
| 		//is Author Page | ||||
| 		if ( is_author() ) { | ||||
| 			$result['type'] = "author"; | ||||
| 		} | ||||
|  | ||||
| 		//is search page | ||||
| 		$search_query = filter_var( get_search_query( false ), FILTER_SANITIZE_STRING ); | ||||
| 		if ( trim( $search_query ) != "" ) { | ||||
| 			return array( "type" => "search", "id" => 0, "search_query" => $search_query ); | ||||
| 		} | ||||
|  | ||||
| 		//is 404 Page | ||||
| 		if ( is_404() ) { | ||||
| 			$result['type'] = "404"; | ||||
| 		} | ||||
|  | ||||
| 		return $result; | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,73 @@ | ||||
| <?php | ||||
| /* | ||||
| 	This is the class for recording GeoIP information for hits on the WordPress site.  It extends the Hits class. | ||||
| */ | ||||
|  | ||||
| // Load the classes. | ||||
| use GeoIp2\Database\Reader; | ||||
|  | ||||
| class WP_Statistics_GEO_IP_Hits extends WP_Statistics_Hits { | ||||
| 	public function __construct() { | ||||
| 		global $WP_Statistics; | ||||
| 		// Call the parent constructor (WP_Statistics::__constructor). | ||||
| 		parent::__construct(); | ||||
|  | ||||
| 		// We may have set the location based on a private IP address in the hits class, if so, don't bother looking it up again. | ||||
| 		if ( $this->location == '000' ) { | ||||
|  | ||||
| 			// Now get the location information from the MaxMind database. | ||||
| 			try { | ||||
| 				// Get the WordPress upload directory information, which is where we have stored the MaxMind database. | ||||
| 				$upload_dir = wp_upload_dir(); | ||||
|  | ||||
| 				// Create a new Reader and point it to the database. | ||||
| 				$reader = new Reader( $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb' ); | ||||
|  | ||||
| 				// Look up the IP address | ||||
| 				$record = $reader->country( $WP_Statistics->ip ); | ||||
|  | ||||
| 				// Get the location. | ||||
| 				$location = $record->country->isoCode; | ||||
|  | ||||
| 				// MaxMind returns a blank for location if it can't find it, but we want to use 000 so replace it. | ||||
| 				if ( $location == "" ) { | ||||
| 					$location = "000"; | ||||
| 				} | ||||
| 			} catch ( Exception $e ) { | ||||
| 				$location = "000"; | ||||
| 			} | ||||
|  | ||||
| 			// Store the location in the protected $location variable from the parent class. | ||||
| 			$this->location = $location; | ||||
| 		} | ||||
|  | ||||
| 		// Check to see if we are excluded by the GeoIP rules. | ||||
| 		if ( ! $this->exclusion_match ) { | ||||
| 			// Grab the excluded/included countries lists, force the country codes to be in upper case to match what the GeoIP code uses. | ||||
| 			$excluded_countries        = explode( | ||||
| 				"\n", | ||||
| 				strtoupper( str_replace( "\r\n", "\n", $WP_Statistics->get_option( 'excluded_countries' ) ) ) | ||||
| 			); | ||||
| 			$included_countries_string = trim( | ||||
| 				strtoupper( str_replace( "\r\n", "\n", $WP_Statistics->get_option( 'included_countries' ) ) ) | ||||
| 			); | ||||
|  | ||||
| 			// We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none. | ||||
| 			if ( $included_countries_string == '' ) { | ||||
| 				$included_countries = array(); | ||||
| 			} else { | ||||
| 				$included_countries = explode( "\n", $included_countries_string ); | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if the current location is in the excluded countries list. | ||||
| 			if ( in_array( $this->location, $excluded_countries ) ) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = "geoip"; | ||||
| 			} // Check to see if the current location is not the included countries list. | ||||
| 			else if ( ! in_array( $this->location, $included_countries ) && count( $included_countries ) > 0 ) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = "geoip"; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,814 @@ | ||||
| <?php | ||||
| /* | ||||
| 	This is the primary class for recording hits on the WordPress site.  It extends the WP_Statistics class and is itself extended by the GEO_IP_Hits class. | ||||
| 	This class handles; visits, visitors and pages. | ||||
| */ | ||||
|  | ||||
| use Jaybizzle\CrawlerDetect\CrawlerDetect; | ||||
| use IPTools\IP; | ||||
| use IPTools\Network; | ||||
| use IPTools\Range; | ||||
|  | ||||
| class WP_Statistics_Hits { | ||||
|  | ||||
| 	// Setup our public/private/protected variables. | ||||
| 	public $result = null; | ||||
|  | ||||
| 	protected $location = '000'; | ||||
| 	public $exclusion_match = false; | ||||
| 	public $exclusion_reason = ''; | ||||
|  | ||||
| 	public $exclusion_record = false; | ||||
| 	private $timestamp; | ||||
| 	private $current_page_id; | ||||
| 	private $current_page_type; | ||||
| 	public $current_visitor_id = 0; | ||||
|  | ||||
| 	// Construction function. | ||||
| 	public function __construct() { | ||||
| 		global $wp_version, $WP_Statistics; | ||||
|  | ||||
| 		// Set the timestamp value. | ||||
| 		$this->timestamp = $WP_Statistics->current_date( 'U' ); | ||||
| 		if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 			$this->timestamp = WP_Statistics_Rest::params( 'timestamp' ); | ||||
| 		} | ||||
|  | ||||
| 		// Check to see if the user wants us to record why we're excluding hits. | ||||
| 		if ( $WP_Statistics->get_option( 'record_exclusions' ) ) { | ||||
| 			$this->exclusion_record = true; | ||||
| 		} | ||||
|  | ||||
| 		// Create a IP Tools instance from the current IP address for use later. | ||||
| 		// Fall back to the localhost if it can't be parsed. | ||||
| 		try { | ||||
| 			$ip = new IP( $WP_Statistics->ip ); | ||||
| 		} catch ( Exception $e ) { | ||||
| 			$ip = new IP( '127.0.0.1' ); | ||||
| 		} | ||||
|  | ||||
| 		// Let's check to see if our subnet matches a private IP address range, if so go ahead and set the location information now. | ||||
| 		if ( $WP_Statistics->get_option( 'private_country_code' ) != '000' && | ||||
| 		     $WP_Statistics->get_option( 'private_country_code' ) != '' | ||||
| 		) { | ||||
| 			$private_subnets = array( '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.1/24', 'fc00::/7' ); | ||||
|  | ||||
| 			foreach ( $private_subnets as $psub ) { | ||||
|  | ||||
| 				try { | ||||
| 					$contains_ip = Range::parse( $psub )->contains( $ip ); | ||||
| 				} catch ( Exception $e ) { | ||||
| 					$contains_ip = false; | ||||
| 				} | ||||
|  | ||||
| 				if ( $contains_ip ) { | ||||
| 					$this->location = $WP_Statistics->get_option( 'private_country_code' ); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		/* | ||||
| 		 * The follow exclusion checks are done during the class construction so we don't have to execute them twice if we're tracking visits and visitors. | ||||
| 		 * | ||||
| 		 * Order of exclusion checks is: | ||||
| 		 *		1 - AJAX calls | ||||
| 		 * 		2 - CronJob | ||||
| 		 *		3 - Robots | ||||
| 		 * 		4 - IP/Subnets | ||||
| 		 *		5 - Self Referrals, Referrer Spam & login page | ||||
| 		 *		6 - User roles | ||||
| 		 *		7 - Host name list | ||||
| 		 *      8 - Broken link file | ||||
| 		 * | ||||
| 		 * The GoeIP exclusions will be processed in the GeoIP hits class constructor. | ||||
| 		 * | ||||
| 		 * Note that we stop processing as soon as a match is made by executing a `return` from the function constructor. | ||||
| 		 * | ||||
| 		 */ | ||||
| 		if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 			$this->exclusion_match  = ( WP_Statistics_Rest::params( 'exclude' ) == 1 ? true : false ); | ||||
| 			$this->exclusion_reason = WP_Statistics_Rest::params( 'exclude_reason' ); | ||||
|  | ||||
| 			if ( $this->exclusion_match === true ) { | ||||
| 				return; | ||||
| 			} | ||||
| 		} else { | ||||
|  | ||||
| 			// Detect if we're running an ajax request. | ||||
| 			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = 'ajax'; | ||||
|  | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			if ( ( defined( 'DOING_CRON' ) && DOING_CRON === true ) || ( function_exists( 'wp_doing_cron' ) && wp_doing_cron() === true ) ) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = 'cronjob'; | ||||
|  | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			$crawler   = false; | ||||
| 			$ua_string = ''; | ||||
|  | ||||
| 			if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) { | ||||
| 				$ua_string = $_SERVER['HTTP_USER_AGENT']; | ||||
| 			} | ||||
|  | ||||
| 			/* | ||||
| 			 * Check Is robot | ||||
| 			 */ | ||||
| 			$CrawlerDetect = new CrawlerDetect; | ||||
| 			if ( $CrawlerDetect->isCrawler() ) { | ||||
| 				$crawler = true; | ||||
| 			} | ||||
|  | ||||
| 			// If we're a crawler as per whichbrowser, exclude us, otherwise double check based on the WP Statistics robot list. | ||||
| 			if ( $crawler == true ) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = 'CrawlerDetect'; | ||||
|  | ||||
| 				return; | ||||
| 			} else { | ||||
| 				// Pull the robots from the database. | ||||
| 				$robots = explode( "\n", $WP_Statistics->get_option( 'robotlist' ) ); | ||||
|  | ||||
| 				// Check to see if we match any of the robots. | ||||
| 				foreach ( $robots as $robot ) { | ||||
| 					$robot = trim( $robot ); | ||||
|  | ||||
| 					// If the match case is less than 4 characters long, it might match too much so don't execute it. | ||||
| 					if ( strlen( $robot ) > 3 ) { | ||||
| 						if ( stripos( $ua_string, $robot ) !== false ) { | ||||
| 							$this->exclusion_match  = true; | ||||
| 							$this->exclusion_reason = 'robot'; | ||||
|  | ||||
| 							return; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				// Finally check to see if we have corrupt header information. | ||||
| 				if ( ! $this->exclusion_match && $WP_Statistics->get_option( 'corrupt_browser_info' ) ) { | ||||
| 					if ( $ua_string == '' || $WP_Statistics->ip == '' ) { | ||||
| 						$this->exclusion_match  = true; | ||||
| 						$this->exclusion_reason = 'robot'; | ||||
|  | ||||
| 						return; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			//Check Broken Link File | ||||
| 			if ( is_404() ) { | ||||
|  | ||||
| 				//Check Current Page | ||||
| 				if ( isset( $_SERVER["HTTP_HOST"] ) and isset( $_SERVER["REQUEST_URI"] ) ) { | ||||
|  | ||||
| 					//Get Full Url Page | ||||
| 					$page_url = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://{$_SERVER["HTTP_HOST"]}{$_SERVER["REQUEST_URI"]}"; | ||||
|  | ||||
| 					//Check Link file | ||||
| 					$page_url = parse_url( $page_url, PHP_URL_PATH ); | ||||
| 					$ext      = pathinfo( $page_url, PATHINFO_EXTENSION ); | ||||
| 					if ( ! empty( $ext ) and $ext != 'php' ) { | ||||
| 						$this->exclusion_match  = true; | ||||
| 						$this->exclusion_reason = 'BrokenFile'; | ||||
|  | ||||
| 						return; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Pull the subnets from the database. | ||||
| 			$subnets = explode( "\n", $WP_Statistics->get_option( 'exclude_ip' ) ); | ||||
|  | ||||
| 			// Check to see if we match any of the excluded addresses. | ||||
| 			foreach ( $subnets as $subnet ) { | ||||
| 				$subnet = trim( $subnet ); | ||||
|  | ||||
| 				// The shortest ip address is 1.1.1.1, anything less must be a malformed entry. | ||||
| 				if ( strlen( $subnet ) > 6 ) { | ||||
| 					$range_prased = false; | ||||
|  | ||||
| 					try { | ||||
| 						$range_prased = Range::parse( $subnet )->contains( $ip ); | ||||
| 					} catch ( Exception $e ) { | ||||
| 						$range_parased = false; | ||||
| 					} | ||||
|  | ||||
| 					if ( $range_prased ) { | ||||
| 						$this->exclusion_match  = true; | ||||
| 						$this->exclusion_reason = 'ip match'; | ||||
|  | ||||
| 						return; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we are being referred to ourselves. | ||||
| 			if ( $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url( null, '/' ) || | ||||
| 			     $ua_string == 'WordPress/' . $wp_version . '; ' . get_home_url() | ||||
| 			) { | ||||
| 				$this->exclusion_match  = true; | ||||
| 				$this->exclusion_reason = 'self referral'; | ||||
|  | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding the login page. | ||||
| 			if ( $WP_Statistics->get_option( 'exclude_loginpage' ) ) { | ||||
| 				$protocol = strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 'https' ) === false ? 'http' : 'https'; | ||||
| 				$host     = $_SERVER['HTTP_HOST']; | ||||
| 				$script   = $_SERVER['SCRIPT_NAME']; | ||||
|  | ||||
| 				$currentURL = $protocol . '://' . $host . $script; | ||||
| 				$loginURL   = wp_login_url(); | ||||
|  | ||||
| 				if ( $currentURL == $loginURL ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = 'login page'; | ||||
|  | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding the Admin page. | ||||
| 			if ( $WP_Statistics->get_option( 'exclude_adminpage' ) ) { | ||||
| 				if ( stristr( $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], "wp-admin" ) ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = 'admin page'; | ||||
|  | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding referrer spam. | ||||
| 			if ( $WP_Statistics->get_option( 'referrerspam' ) ) { | ||||
| 				$referrer = $WP_Statistics->get_Referred(); | ||||
|  | ||||
| 				// Pull the referrer spam list from the database. | ||||
| 				$referrerspamlist = explode( "\n", $WP_Statistics->get_option( 'referrerspamlist' ) ); | ||||
|  | ||||
| 				// Check to see if we match any of the robots. | ||||
| 				foreach ( $referrerspamlist as $item ) { | ||||
| 					$item = trim( $item ); | ||||
|  | ||||
| 					// If the match case is less than 4 characters long, it might match too much so don't execute it. | ||||
| 					if ( strlen( $item ) > 3 ) { | ||||
| 						if ( stripos( $referrer, $item ) !== false ) { | ||||
| 							$this->exclusion_match  = true; | ||||
| 							$this->exclusion_reason = 'referrer_spam'; | ||||
|  | ||||
| 							return; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding RSS feeds. | ||||
| 			if ( $WP_Statistics->get_option( 'exclude_feeds' ) ) { | ||||
| 				if ( is_feed() ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = 'feed'; | ||||
|  | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding 404 pages. | ||||
| 			if ( $WP_Statistics->get_option( 'exclude_404s' ) ) { | ||||
| 				if ( is_404() ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = '404'; | ||||
|  | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we're excluding the current page url. | ||||
| 			if ( $WP_Statistics->get_option( 'excluded_urls' ) ) { | ||||
| 				$script    = $_SERVER['REQUEST_URI']; | ||||
| 				$delimiter = strpos( $script, '?' ); | ||||
| 				if ( $delimiter > 0 ) { | ||||
| 					$script = substr( $script, 0, $delimiter ); | ||||
| 				} | ||||
|  | ||||
| 				$excluded_urls = explode( "\n", $WP_Statistics->get_option( 'excluded_urls' ) ); | ||||
|  | ||||
| 				foreach ( $excluded_urls as $url ) { | ||||
| 					$this_url = trim( $url ); | ||||
|  | ||||
| 					if ( strlen( $this_url ) > 2 ) { | ||||
| 						if ( stripos( $script, $this_url ) === 0 ) { | ||||
| 							$this->exclusion_match  = true; | ||||
| 							$this->exclusion_reason = 'excluded url'; | ||||
|  | ||||
| 							return; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we are excluding based on the user role. | ||||
| 			if ( is_user_logged_in() ) { | ||||
| 				$current_user = wp_get_current_user(); | ||||
|  | ||||
| 				foreach ( $current_user->roles as $role ) { | ||||
| 					$option_name = 'exclude_' . str_replace( ' ', '_', strtolower( $role ) ); | ||||
| 					if ( $WP_Statistics->get_option( $option_name ) == true ) { | ||||
| 						$this->exclusion_match  = true; | ||||
| 						$this->exclusion_reason = 'user role'; | ||||
|  | ||||
| 						return; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if we are excluded by the host name. | ||||
| 			if ( ! $this->exclusion_match ) { | ||||
| 				$excluded_host = explode( "\n", $WP_Statistics->get_option( 'excluded_hosts' ) ); | ||||
|  | ||||
| 				// If there's nothing in the excluded host list, don't do anything. | ||||
| 				if ( count( $excluded_host ) > 0 ) { | ||||
| 					$transient_name = 'wps_excluded_hostname_to_ip_cache'; | ||||
|  | ||||
| 					// Get the transient with the hostname cache. | ||||
| 					$hostname_cache = get_transient( $transient_name ); | ||||
|  | ||||
| 					// If the transient has expired (or has never been set), create one now. | ||||
| 					if ( $hostname_cache === false ) { | ||||
| 						// Flush the failed cache variable. | ||||
| 						$hostname_cache = array(); | ||||
|  | ||||
| 						// Loop through the list of hosts and look them up. | ||||
| 						foreach ( $excluded_host as $host ) { | ||||
| 							if ( strpos( $host, '.' ) > 0 ) { | ||||
| 								// We add the extra period to the end of the host name to make sure we don't append the local dns suffix to the resolution cycle. | ||||
| 								$hostname_cache[ $host ] = gethostbyname( $host . '.' ); | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 						// Set the transient and store it for 1 hour. | ||||
| 						set_transient( $transient_name, $hostname_cache, 360 ); | ||||
| 					} | ||||
|  | ||||
| 					// Check if the current IP address matches one of the ones in the excluded hosts list. | ||||
| 					if ( in_array( $WP_Statistics->ip, $hostname_cache ) ) { | ||||
| 						$this->exclusion_match  = true; | ||||
| 						$this->exclusion_reason = 'hostname'; | ||||
|  | ||||
| 						return; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// This function records visits to the site. | ||||
| 	public function Visits() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// If we're a webcrawler or referral from ourselves or an excluded address don't record the visit. | ||||
| 		if ( ! $this->exclusion_match ) { | ||||
|  | ||||
| 			// Check to see if we're a returning visitor. | ||||
| 			$this->result = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}statistics_visit ORDER BY `{$wpdb->prefix}statistics_visit`.`ID` DESC" ); | ||||
|  | ||||
| 			// If we're a returning visitor, update the current record in the database, otherwise, create a new one. | ||||
| 			if ( $this->result->last_counter != $WP_Statistics->Current_Date( 'Y-m-d' ) ) { | ||||
|  | ||||
| 				// We'd normally use the WordPress insert function, but since we may run in to a race condition where another hit to the site has already created a new entry in the database | ||||
| 				// for this IP address we want to do an "INSERT ... ON DUPLICATE KEY" which WordPress doesn't support. | ||||
| 				$sqlstring = $wpdb->prepare( | ||||
| 					'INSERT INTO ' . $wpdb->prefix . 'statistics_visit (last_visit, last_counter, visit) VALUES ( %s, %s, %d) ON DUPLICATE KEY UPDATE visit = visit + ' . $WP_Statistics->coefficient, | ||||
| 					$WP_Statistics->Current_Date(), | ||||
| 					$WP_Statistics->Current_date( 'Y-m-d' ), | ||||
| 					$WP_Statistics->coefficient | ||||
| 				); | ||||
|  | ||||
| 				$wpdb->query( $sqlstring ); | ||||
| 			} else { | ||||
| 				$sqlstring = $wpdb->prepare( | ||||
| 					'UPDATE ' . $wpdb->prefix . 'statistics_visit SET `visit` = `visit` + %d, `last_visit` = %s WHERE `last_counter` = %s', | ||||
| 					$WP_Statistics->coefficient, | ||||
| 					$WP_Statistics->Current_Date(), | ||||
| 					$this->result->last_counter | ||||
| 				); | ||||
|  | ||||
| 				$wpdb->query( $sqlstring ); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	//Get current Page detail | ||||
| 	public function get_page_detail() { | ||||
|  | ||||
| 		//if is Cache enable | ||||
| 		if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 			$this->current_page_id   = WP_Statistics_Rest::params( 'current_page_id' ); | ||||
| 			$this->current_page_type = WP_Statistics_Rest::params( 'current_page_type' ); | ||||
| 		} else { | ||||
| 			//Get Page Type | ||||
| 			$get_page_type           = WP_Statistics_Frontend::get_page_type(); | ||||
| 			$this->current_page_id   = $get_page_type['id']; | ||||
| 			$this->current_page_type = $get_page_type['type']; | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	// This function records unique visitors to the site. | ||||
| 	public function Visitors() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		//Get Current Page detail | ||||
| 		$this->get_page_detail(); | ||||
|  | ||||
| 		//Check honeypot Page | ||||
| 		if ( $WP_Statistics->get_option( 'use_honeypot' ) && $WP_Statistics->get_option( 'honeypot_postid' ) > 0 && $WP_Statistics->get_option( 'honeypot_postid' ) == $this->current_page_id && $this->current_page_id > 0 ) { | ||||
| 			$this->exclusion_match  = true; | ||||
| 			$this->exclusion_reason = 'honeypot'; | ||||
| 		} | ||||
|  | ||||
| 		// If we're a webcrawler or referral from ourselves or an excluded address don't record the visit. | ||||
| 		// The exception here is if we've matched a honey page, we want to lookup the user and flag them | ||||
| 		// as having been trapped in the honey pot for later exclusions. | ||||
| 		if ( $this->exclusion_reason == 'honeypot' || ! $this->exclusion_match ) { | ||||
|  | ||||
| 			// Check to see if we already have an entry in the database. | ||||
| 			$check_ip_db = $WP_Statistics->store_ip_to_db(); | ||||
| 			if ( $WP_Statistics->ip_hash != false ) { | ||||
| 				$check_ip_db = $WP_Statistics->ip_hash; | ||||
| 			} | ||||
|  | ||||
| 			//Check Exist This User in Current Day | ||||
| 			$this->result = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d')}' AND `ip` = '{$check_ip_db}'" ); | ||||
|  | ||||
| 			// Check to see if this is a visit to the honey pot page, flag it when we create the new entry. | ||||
| 			$honeypot = 0; | ||||
| 			if ( $this->exclusion_reason == 'honeypot' ) { | ||||
| 				$honeypot = 1; | ||||
| 			} | ||||
|  | ||||
| 			// If we don't create a new one, otherwise update the old one. | ||||
| 			if ( ! $this->result ) { | ||||
|  | ||||
| 				// If we've been told to store the entire user agent, do so. | ||||
| 				if ( $WP_Statistics->get_option( 'store_ua' ) == true ) { | ||||
| 					if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 						$ua = WP_Statistics_Rest::params( 'ua' ); | ||||
| 					} else { | ||||
| 						$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '' ); | ||||
| 					} | ||||
| 				} else { | ||||
| 					$ua = ''; | ||||
| 				} | ||||
|  | ||||
| 				// Store the result. | ||||
| 				add_filter( 'query', 'wp_statistics_ignore_insert', 10 ); | ||||
| 				$wpdb->insert( | ||||
| 					$wpdb->prefix . 'statistics_visitor', | ||||
| 					array( | ||||
| 						'last_counter' => $WP_Statistics->Current_date( 'Y-m-d' ), | ||||
| 						'referred'     => $WP_Statistics->get_Referred(), | ||||
| 						'agent'        => $WP_Statistics->agent['browser'], | ||||
| 						'platform'     => $WP_Statistics->agent['platform'], | ||||
| 						'version'      => $WP_Statistics->agent['version'], | ||||
| 						'ip'           => $WP_Statistics->ip_hash ? $WP_Statistics->ip_hash : $WP_Statistics->store_ip_to_db(), | ||||
| 						'location'     => $this->location, | ||||
| 						'UAString'     => $ua, | ||||
| 						'hits'         => 1, | ||||
| 						'honeypot'     => $honeypot, | ||||
| 					), | ||||
| 					array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s' ) | ||||
| 				); | ||||
| 				$this->current_visitor_id = $wpdb->insert_id; | ||||
| 				remove_filter( 'query', 'wp_statistics_ignore_insert', 10 ); | ||||
|  | ||||
| 				// Now parse the referrer and store the results in the search table if the database has been converted. | ||||
| 				// Also make sure we actually inserted a row on the INSERT IGNORE above or we'll create duplicate entries. | ||||
| 				if ( $wpdb->insert_id ) { | ||||
|  | ||||
| 					$search_engines = wp_statistics_searchengine_list(); | ||||
| 					if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 						$referred = WP_Statistics_Rest::params( 'referred' ); | ||||
| 					} else { | ||||
| 						$referred = $WP_Statistics->get_Referred(); | ||||
| 					} | ||||
|  | ||||
| 					// Parse the URL in to it's component parts. | ||||
| 					if ( wp_http_validate_url( $referred ) ) { | ||||
| 						$parts = parse_url( $referred ); | ||||
|  | ||||
| 						// Loop through the SE list until we find which search engine matches. | ||||
| 						foreach ( $search_engines as $key => $value ) { | ||||
| 							$search_regex = wp_statistics_searchengine_regex( $key ); | ||||
|  | ||||
| 							preg_match( '/' . $search_regex . '/', $parts['host'], $matches ); | ||||
|  | ||||
| 							if ( isset( $matches[1] ) ) { | ||||
| 								$data['last_counter'] = $WP_Statistics->Current_date( 'Y-m-d' ); | ||||
| 								$data['engine']       = $key; | ||||
| 								$data['words']        = $WP_Statistics->Search_Engine_QueryString( $referred ); | ||||
| 								$data['host']         = $parts['host']; | ||||
| 								$data['visitor']      = $wpdb->insert_id; | ||||
|  | ||||
| 								if ( $data['words'] == 'No search query found!' ) { | ||||
| 									$data['words'] = ''; | ||||
| 								} | ||||
|  | ||||
| 								$wpdb->insert( $wpdb->prefix . 'statistics_search', $data ); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} else { | ||||
|  | ||||
| 				// Normally we've done all of our exclusion matching during the class creation, however for the robot threshold is calculated here to avoid another call the database. | ||||
| 				if ( $WP_Statistics->get_option( 'robot_threshold' ) > 0 && $this->result->hits + 1 > $WP_Statistics->get_option( 'robot_threshold' ) ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = 'robot_threshold'; | ||||
| 				} else if ( $this->result->honeypot ) { | ||||
| 					$this->exclusion_match  = true; | ||||
| 					$this->exclusion_reason = 'honeypot'; | ||||
| 				} else { | ||||
|  | ||||
| 					//Get Current Visitors ID | ||||
| 					$this->current_visitor_id = $this->result->ID; | ||||
|  | ||||
| 					$sqlstring = $wpdb->prepare( | ||||
| 						'UPDATE `' . $wpdb->prefix . 'statistics_visitor` SET `hits` = `hits` + %d, `honeypot` = %d WHERE `ID` = %d', | ||||
| 						1, | ||||
| 						$honeypot, | ||||
| 						$this->result->ID | ||||
| 					); | ||||
|  | ||||
| 					$wpdb->query( $sqlstring ); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ( $this->exclusion_match ) { | ||||
| 			$this->RecordExclusion(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	private function RecordExclusion() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
| 		// If we're not storing exclusions, just return. | ||||
| 		if ( $this->exclusion_record != true ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		$this->result = $wpdb->query( "UPDATE {$wpdb->prefix}statistics_exclusions SET `count` = `count` + 1 WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' AND `reason` = '{$this->exclusion_reason}'" ); | ||||
| 		if ( ! $this->result ) { | ||||
| 			$wpdb->insert( | ||||
| 				$wpdb->prefix . 'statistics_exclusions', | ||||
| 				array( | ||||
| 					'date'   => $WP_Statistics->Current_date( 'Y-m-d' ), | ||||
| 					'reason' => $this->exclusion_reason, | ||||
| 					'count'  => 1, | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Check is Track All Page | ||||
| 	static public function is_track_page() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		//Check if Track All | ||||
| 		if ( $WP_Statistics->get_option( 'track_all_pages' ) || is_single() || is_page() || is_front_page() ) { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	// This function records page hits. | ||||
| 	public function Pages() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// If we're a web crawler or referral from ourselves or an excluded address don't record the page hit. | ||||
| 		if ( ! $this->exclusion_match ) { | ||||
|  | ||||
| 			// Don't track anything but actual pages and posts, unless we've been told to. | ||||
| 			$is_track_all = false; | ||||
| 			if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 				if ( WP_Statistics_Rest::params( 'track_all' ) == 1 ) { | ||||
| 					$is_track_all = true; | ||||
| 				} | ||||
| 			} else { | ||||
| 				if ( self::is_track_page() ) { | ||||
| 					$is_track_all = true; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ( $is_track_all === true ) { | ||||
|  | ||||
| 				// Get the pages or posts ID if it exists and we haven't set it in the visitors code. | ||||
| 				$this->get_page_detail(); | ||||
|  | ||||
| 				// If we didn't find a page id, we don't have anything else to do. | ||||
| 				if ( $this->current_page_type == "unknown" ) { | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
| 				// Get the current page URI. | ||||
| 				if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 					$page_uri = WP_Statistics_Rest::params( 'page_uri' ); | ||||
| 				} else { | ||||
| 					$page_uri = wp_statistics_get_uri(); | ||||
| 				} | ||||
|  | ||||
| 				//Get String Search Wordpress | ||||
| 				$is_search = false; | ||||
| 				if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 					if ( WP_Statistics_Rest::params( 'search_query' ) != "" ) { | ||||
| 						$page_uri  = "?s=" . WP_Statistics_Rest::params( 'search_query' ); | ||||
| 						$is_search = true; | ||||
| 					} | ||||
| 				} else { | ||||
| 					$get_page_type = WP_Statistics_Frontend::get_page_type(); | ||||
| 					if ( array_key_exists( "search_query", $get_page_type ) ) { | ||||
| 						$page_uri  = "?s=" . $get_page_type['search_query']; | ||||
| 						$is_search = true; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				if ( $WP_Statistics->get_option( 'strip_uri_parameters' ) and $is_search === false ) { | ||||
| 					$temp = explode( '?', $page_uri ); | ||||
| 					if ( $temp !== false ) { | ||||
| 						$page_uri = $temp[0]; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				// Limit the URI length to 255 characters, otherwise we may overrun the SQL field size. | ||||
| 				$page_uri = substr( $page_uri, 0, 255 ); | ||||
|  | ||||
| 				// If we have already been to this page today (a likely scenario), just update the count on the record. | ||||
| 				$exist = $wpdb->get_row( "SELECT `page_id` FROM {$wpdb->prefix}statistics_pages WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' " . ( $is_search === true ? "AND `uri` = '" . esc_sql( $page_uri ) . "'" : "" ) . "AND `type` = '{$this->current_page_type}' AND `id` = {$this->current_page_id}", ARRAY_A ); | ||||
| 				if ( null !== $exist ) { | ||||
| 					$sql          = $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_pages SET `count` = `count` + 1 WHERE `date` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}' " . ( $is_search === true ? "AND `uri` = '" . esc_sql( $page_uri ) . "'" : "" ) . "AND `type` = '{$this->current_page_type}' AND `id` = %d", $this->current_page_id ); | ||||
| 					$this->result = $wpdb->query( $sql ); | ||||
| 					$page_id      = $exist['page_id']; | ||||
|  | ||||
| 				} else { | ||||
| 					add_filter( 'query', 'wp_statistics_ignore_insert', 10 ); | ||||
| 					$wpdb->insert( | ||||
| 						$wpdb->prefix . 'statistics_pages', | ||||
| 						array( | ||||
| 							'uri'   => $page_uri, | ||||
| 							'date'  => $WP_Statistics->Current_date( 'Y-m-d' ), | ||||
| 							'count' => 1, | ||||
| 							'id'    => $this->current_page_id, | ||||
| 							'type'  => $this->current_page_type | ||||
| 						) | ||||
| 					); | ||||
| 					$page_id = $wpdb->insert_id; | ||||
| 					remove_filter( 'query', 'wp_statistics_ignore_insert', 10 ); | ||||
| 				} | ||||
|  | ||||
| 				//Set Visitor Relationships | ||||
| 				if ( $WP_Statistics->get_option( 'visitors' ) == true and $WP_Statistics->get_option( 'visitors_log' ) == true and $this->current_visitor_id > 0 ) { | ||||
| 					$this->visitors_relationships( $page_id, $this->current_visitor_id ); | ||||
| 				} | ||||
|  | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	//Set Visitor Relationships | ||||
| 	public function visitors_relationships( $page_id, $visitor_id ) { | ||||
| 		global $wpdb; | ||||
| 		$wpdb->insert( | ||||
| 			$wpdb->prefix . 'statistics_visitor_relationships', | ||||
| 			array( | ||||
| 				'visitor_id' => $visitor_id, | ||||
| 				'page_id'    => $page_id, | ||||
| 				'date'       => current_time( 'mysql' ) | ||||
| 			), | ||||
| 			array( '%d', '%d', '%s' ) | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	// This function checks to see if the current user (as defined by their IP address) has an entry in the database. | ||||
| 	// Note we set the $this->result variable so we don't have to re-execute the query when we do the user update. | ||||
| 	public function Is_user() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// Check to see if we already have an entry in the database. | ||||
| 		$check_ip_db = $WP_Statistics->store_ip_to_db(); | ||||
| 		if ( $WP_Statistics->ip_hash != false ) { | ||||
| 			$check_ip_db = $WP_Statistics->ip_hash; | ||||
| 		} | ||||
|  | ||||
| 		//Check Exist | ||||
| 		$this->result = $wpdb->query( "SELECT * FROM {$wpdb->prefix}statistics_useronline WHERE `ip` = '{$check_ip_db}'" ); | ||||
|  | ||||
| 		if ( $this->result ) { | ||||
| 			return true; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// This function add/update/delete the online users in the database. | ||||
| 	public function Check_online() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// If we're a web crawler or referral from ourselves or an excluded address don't record the user as online, unless we've been told to anyway. | ||||
| 		if ( ! $this->exclusion_match || $WP_Statistics->get_option( 'all_online' ) ) { | ||||
|  | ||||
| 			// If the current user exists in the database already, | ||||
| 			// Just update them, otherwise add them | ||||
| 			if ( $this->Is_user() ) { | ||||
| 				$this->Update_user(); | ||||
| 			} else { | ||||
| 				$this->Add_user(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	// This function adds a user to the database. | ||||
| 	public function Add_user() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		//Check is User | ||||
| 		if ( ! $this->Is_user() ) { | ||||
|  | ||||
| 			// Get the pages or posts ID if it exists and we haven't set it in the visitors code. | ||||
| 			$this->get_page_detail(); | ||||
|  | ||||
| 			// Insert the user in to the database. | ||||
| 			$wpdb->insert( | ||||
| 				$wpdb->prefix . 'statistics_useronline', | ||||
| 				array( | ||||
| 					'ip'        => $WP_Statistics->ip_hash ? $WP_Statistics->ip_hash : $WP_Statistics->store_ip_to_db(), | ||||
| 					'timestamp' => $this->timestamp, | ||||
| 					'created'   => $this->timestamp, | ||||
| 					'date'      => $WP_Statistics->Current_Date(), | ||||
| 					'referred'  => $WP_Statistics->get_Referred(), | ||||
| 					'agent'     => $WP_Statistics->agent['browser'], | ||||
| 					'platform'  => $WP_Statistics->agent['platform'], | ||||
| 					'version'   => $WP_Statistics->agent['version'], | ||||
| 					'location'  => $this->location, | ||||
| 					'user_id'   => self::get_user_id(), | ||||
| 					'page_id'   => $this->current_page_id, | ||||
| 					'type'      => $this->current_page_type | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get User ID | ||||
| 	 */ | ||||
| 	public static function get_user_id() { | ||||
|  | ||||
| 		//create Empty | ||||
| 		$user_id = 0; | ||||
|  | ||||
| 		//if Rest Request | ||||
| 		if ( WP_Statistics_Rest::is_rest() ) { | ||||
| 			if ( WP_Statistics_Rest::params( 'user_id' ) != "" ) { | ||||
| 				$user_id = WP_Statistics_Rest::params( 'user_id' ); | ||||
| 			} | ||||
| 		} else { | ||||
| 			if ( is_user_logged_in() ) { | ||||
| 				return get_current_user_id(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $user_id; | ||||
| 	} | ||||
|  | ||||
| 	// This function updates a user in the database. | ||||
| 	public function Update_user() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// Make sure we found the user earlier when we called Is_user(). | ||||
| 		if ( $this->result ) { | ||||
|  | ||||
| 			// Get the pages or posts ID if it exists and we haven't set it in the visitors code. | ||||
| 			$this->get_page_detail(); | ||||
|  | ||||
| 			// Update the database with the new information. | ||||
| 			$wpdb->update( | ||||
| 				$wpdb->prefix . 'statistics_useronline', | ||||
| 				array( | ||||
| 					'timestamp' => $this->timestamp, | ||||
| 					'date'      => $WP_Statistics->Current_Date(), | ||||
| 					'referred'  => $WP_Statistics->get_Referred(), | ||||
| 					'user_id'   => self::get_user_id(), | ||||
| 					'page_id'   => $this->current_page_id, | ||||
| 					'type'      => $this->current_page_type | ||||
| 				), | ||||
| 				array( 'ip' => $WP_Statistics->ip_hash ? $WP_Statistics->ip_hash : $WP_Statistics->store_ip_to_db() ) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,741 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Install | ||||
|  */ | ||||
| class WP_Statistics_Install { | ||||
|  | ||||
| 	/** | ||||
| 	 * List Of wp-statistics Mysql Table | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	public static $db_table = array( 'useronline', 'visit', 'visitor', 'exclusions', 'pages', 'search', 'historical', 'visitor_relationships' ); | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Install constructor. | ||||
| 	 * | ||||
| 	 * @internal param $WP_Statistics | ||||
| 	 */ | ||||
| 	function __construct() { | ||||
| 		global $WP_Statistics, $wpdb; | ||||
| 		if ( is_admin() ) { | ||||
|  | ||||
| 			// The follow variables are used to define the table structure for new and upgrade installations. | ||||
| 			$create_useronline_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_useronline ( | ||||
| 						ID int(11) NOT NULL AUTO_INCREMENT, | ||||
| 	  					ip varchar(60) NOT NULL, | ||||
| 						created int(11), | ||||
| 						timestamp int(10) NOT NULL, | ||||
| 						date datetime NOT NULL, | ||||
| 						referred text CHARACTER SET utf8 NOT NULL, | ||||
| 						agent varchar(255) NOT NULL, | ||||
| 						platform varchar(255), | ||||
| 						version varchar(255), | ||||
| 						location varchar(10), | ||||
| 						PRIMARY KEY  (ID) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_visit_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_visit ( | ||||
| 						ID int(11) NOT NULL AUTO_INCREMENT, | ||||
| 						last_visit datetime NOT NULL, | ||||
| 						last_counter date NOT NULL, | ||||
| 						visit int(10) NOT NULL, | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						UNIQUE KEY unique_date (last_counter) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_visitor_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_visitor ( | ||||
| 						ID int(11) NOT NULL AUTO_INCREMENT, | ||||
| 						last_counter date NOT NULL, | ||||
| 						referred text NOT NULL, | ||||
| 						agent varchar(255) NOT NULL, | ||||
| 						platform varchar(255), | ||||
| 						version varchar(255), | ||||
| 						UAString varchar(255), | ||||
| 						ip varchar(60) NOT NULL, | ||||
| 						location varchar(10), | ||||
| 						hits int(11), | ||||
| 						honeypot int(11), | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						UNIQUE KEY date_ip_agent (last_counter,ip,agent(75),platform(75),version(75)), | ||||
| 						KEY agent (agent), | ||||
| 						KEY platform (platform), | ||||
| 						KEY version (version), | ||||
| 						KEY location (location) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_visitor_table_old = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_visitor ( | ||||
| 						ID int(11) NOT NULL AUTO_INCREMENT, | ||||
| 						last_counter date NOT NULL, | ||||
| 						referred text NOT NULL, | ||||
| 						agent varchar(255) NOT NULL, | ||||
| 						platform varchar(255), | ||||
| 						version varchar(255), | ||||
| 						UAString varchar(255), | ||||
| 						ip varchar(60) NOT NULL, | ||||
| 						location varchar(10), | ||||
| 						hits int(11), | ||||
| 						honeypot int(11), | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						UNIQUE KEY date_ip_agent (last_counter,ip,agent (75),platform (75),version (75)), | ||||
| 						KEY agent (agent), | ||||
| 						KEY platform (platform), | ||||
| 						KEY version (version), | ||||
| 						KEY location (location) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_exclusion_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_exclusions ( | ||||
| 						ID int(11) NOT NULL AUTO_INCREMENT, | ||||
| 						date date NOT NULL, | ||||
| 						reason varchar(255) DEFAULT NULL, | ||||
| 						count bigint(20) NOT NULL, | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						KEY date (date), | ||||
| 						KEY reason (reason) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_pages_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_pages ( | ||||
| 						uri varchar(255) NOT NULL, | ||||
| 						type varchar(255) NOT NULL, | ||||
| 						date date NOT NULL, | ||||
| 						count int(11) NOT NULL, | ||||
| 						id int(11) NOT NULL, | ||||
| 						UNIQUE KEY date_2 (date,uri), | ||||
| 						KEY url (uri), | ||||
| 						KEY date (date), | ||||
| 						KEY id (id), | ||||
| 						KEY `uri` (`uri`,`count`,`id`) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_historical_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_historical ( | ||||
| 						ID bigint(20) NOT NULL AUTO_INCREMENT, | ||||
| 						category varchar(25) NOT NULL, | ||||
| 						page_id bigint(20) NOT NULL, | ||||
| 						uri varchar(255) NOT NULL, | ||||
| 						value bigint(20) NOT NULL, | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						KEY category (category), | ||||
| 						UNIQUE KEY page_id (page_id), | ||||
| 						UNIQUE KEY uri (uri) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			$create_search_table = ( " | ||||
| 					CREATE TABLE {$wpdb->prefix}statistics_search ( | ||||
| 						ID bigint(20) NOT NULL AUTO_INCREMENT, | ||||
| 						last_counter date NOT NULL, | ||||
| 						engine varchar(64) NOT NULL, | ||||
| 						host varchar(255), | ||||
| 						words varchar(255), | ||||
| 						visitor bigint(20), | ||||
| 						PRIMARY KEY  (ID), | ||||
| 						KEY last_counter (last_counter), | ||||
| 						KEY engine (engine), | ||||
| 						KEY host (host) | ||||
| 					) CHARSET=utf8" ); | ||||
|  | ||||
| 			// Check to see if the historical table exists yet, aka if this is a upgrade instead of a first install. | ||||
| 			$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_historical'" ); | ||||
|  | ||||
| 			if ( $result == 1 ) { | ||||
| 				// Before we update the historical table, check to see if it exists with the old keys | ||||
| 				$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_historical LIKE 'key'" ); | ||||
|  | ||||
| 				if ( $result > 0 ) { | ||||
| 					$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `id` `page_id` bigint(20)" ); | ||||
| 					$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `key` `ID` bigint(20)" ); | ||||
| 					$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_historical` CHANGE `type` `category` varchar(25)" ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// This includes the dbDelta function from WordPress. | ||||
| 			if ( ! function_exists( 'dbDelta' ) ) { | ||||
| 				require( ABSPATH . 'wp-admin/includes/upgrade.php' ); | ||||
| 			} | ||||
|  | ||||
| 			// Create/update the plugin tables. | ||||
| 			dbDelta( $create_useronline_table ); | ||||
| 			dbDelta( $create_visit_table ); | ||||
| 			dbDelta( $create_visitor_table ); | ||||
| 			dbDelta( $create_exclusion_table ); | ||||
| 			dbDelta( $create_pages_table ); | ||||
| 			dbDelta( $create_historical_table ); | ||||
| 			dbDelta( $create_search_table ); | ||||
|  | ||||
| 			// Some old versions (in the 5.0.x line) of MySQL have issue with the compound index on the visitor table | ||||
| 			// so let's make sure it was created, if not, use the older format to create the table manually instead of | ||||
| 			// using the dbDelta() call. | ||||
| 			$result = $wpdb->query( "SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` = '{$wpdb->prefix}statistics_visitor'" ); | ||||
|  | ||||
| 			if ( $result != 1 ) { | ||||
| 				$wpdb->query( $create_visitor_table_old ); | ||||
| 			} | ||||
|  | ||||
| 			// Check to see if the date_ip index still exists, if so get rid of it. | ||||
| 			$result = $wpdb->query( "SHOW INDEX FROM {$wpdb->prefix}statistics_visitor WHERE Key_name = 'date_ip'" ); | ||||
|  | ||||
| 			// Note, the result will be the number of fields contained in the index. | ||||
| 			if ( $result > 1 ) { | ||||
| 				$wpdb->query( "DROP INDEX `date_ip` ON {$wpdb->prefix}statistics_visitor" ); | ||||
| 			} | ||||
|  | ||||
| 			// One final database change, drop the 'AString' column from visitors if it exists as it's a typo from an old version. | ||||
| 			$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_visitor LIKE 'AString'" ); | ||||
|  | ||||
| 			if ( $result > 0 ) { | ||||
| 				$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_visitor` DROP `AString`" ); | ||||
| 			} | ||||
|  | ||||
| 			//Added page_id column in statistics_pages if not exist | ||||
| 			$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_pages LIKE 'page_id'" ); | ||||
| 			if ( $result == 0 ) { | ||||
| 				$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_pages` ADD `page_id` BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`page_id`);" ); | ||||
| 			} | ||||
|  | ||||
| 			//Added User_id and Page_id in user online table | ||||
| 			$result = $wpdb->query( "SHOW COLUMNS FROM {$wpdb->prefix}statistics_useronline LIKE 'user_id'" ); | ||||
| 			if ( $result == 0 ) { | ||||
| 				$wpdb->query( "ALTER TABLE `{$wpdb->prefix}statistics_useronline` ADD `user_id` BIGINT(48) NOT NULL AFTER `location`, ADD `page_id` BIGINT(48) NOT NULL AFTER `user_id`, ADD `type` VARCHAR(100) NOT NULL AFTER `page_id`;" ); | ||||
| 				$wpdb->query( "DELETE FROM `{$wpdb->prefix}usermeta` WHERE `meta_key` = 'meta-box-order_toplevel_page_wps_overview_page';" ); | ||||
| 			} | ||||
|  | ||||
| 			// Store the new version information. | ||||
| 			update_option( 'wp_statistics_plugin_version', WP_Statistics::$reg['version'] ); | ||||
| 			update_option( 'wp_statistics_db_version', WP_Statistics::$reg['version'] ); | ||||
|  | ||||
| 			// Now check to see what database updates may be required and record them for a user notice later. | ||||
| 			$dbupdates = array( 'date_ip_agent' => false, 'unique_date' => false ); | ||||
|  | ||||
| 			// Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 			$result = $wpdb->query( "SHOW INDEX FROM {$wpdb->prefix}statistics_visitor WHERE Key_name = 'date_ip_agent'" ); | ||||
|  | ||||
| 			// Note, the result will be the number of fields contained in the index, so in our case 5. | ||||
| 			if ( $result != 5 ) { | ||||
| 				$dbupdates['date_ip_agent'] = true; | ||||
| 			} | ||||
|  | ||||
| 			// Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 			$result = $wpdb->query( "SHOW INDEX FROM {$wpdb->prefix}statistics_visit WHERE Key_name = 'unique_date'" ); | ||||
|  | ||||
| 			// Note, the result will be the number of fields contained in the index, so in our case 1. | ||||
| 			if ( $result != 1 ) { | ||||
| 				$dbupdates['unique_date'] = true; | ||||
| 			} | ||||
|  | ||||
| 			$WP_Statistics->update_option( 'pending_db_updates', $dbupdates ); | ||||
|  | ||||
| 			$default_options = $WP_Statistics->Default_Options(); | ||||
|  | ||||
| 			if ( WP_Statistics::$installed_version == false ) { | ||||
|  | ||||
| 				// If this is a first time install, we just need to setup the primary values in the tables. | ||||
| 				$WP_Statistics->Primary_Values(); | ||||
|  | ||||
| 				// By default, on new installs, use the new search table. | ||||
| 				$WP_Statistics->update_option( 'search_converted', 1 ); | ||||
|  | ||||
| 			} else { | ||||
|  | ||||
| 				// If this is an upgrade, we need to check to see if we need to convert anything from old to new formats. | ||||
| 				// Check to see if the "new" settings code is in place or not, if not, upgrade the old settings to the new system. | ||||
| 				if ( get_option( 'wp_statistics' ) === false ) { | ||||
| 					$core_options   = array( | ||||
| 						'wps_disable_map', | ||||
| 						'wps_map_location', | ||||
| 						'wps_google_coordinates', | ||||
| 						'wps_schedule_dbmaint', | ||||
| 						'wps_schedule_dbmaint_days', | ||||
| 						'wps_geoip', | ||||
| 						'wps_update_geoip', | ||||
| 						'wps_schedule_geoip', | ||||
| 						'wps_last_geoip_dl', | ||||
| 						'wps_auto_pop', | ||||
| 						'wps_useronline', | ||||
| 						'wps_check_online', | ||||
| 						'wps_visits', | ||||
| 						'wps_visitors', | ||||
| 						'wps_visitors_log', | ||||
| 						'wps_store_ua', | ||||
| 						'wps_coefficient', | ||||
| 						'wps_pages', | ||||
| 						'wps_track_all_pages', | ||||
| 						'wps_use_cache_plugin', | ||||
| 						'wps_geoip_city', | ||||
| 						'wps_disable_column', | ||||
| 						'wps_hit_post_metabox', | ||||
| 						'wps_menu_bar', | ||||
| 						'wps_hide_notices', | ||||
| 						'wps_chart_totals', | ||||
| 						'wps_stats_report', | ||||
| 						'wps_time_report', | ||||
| 						'wps_send_report', | ||||
| 						'wps_content_report', | ||||
| 						'wps_read_capability', | ||||
| 						'wps_manage_capability', | ||||
| 						'wps_record_exclusions', | ||||
| 						'wps_robotlist', | ||||
| 						'wps_exclude_ip', | ||||
| 						'wps_exclude_loginpage', | ||||
| 						'wps_exclude_adminpage', | ||||
| 					); | ||||
| 					$var_options    = array( 'wps_disable_se_%', 'wps_exclude_%' ); | ||||
| 					$widget_options = array( | ||||
| 						'name_widget', | ||||
| 						'useronline_widget', | ||||
| 						'tvisit_widget', | ||||
| 						'tvisitor_widget', | ||||
| 						'yvisit_widget', | ||||
| 						'yvisitor_widget', | ||||
| 						'wvisit_widget', | ||||
| 						'mvisit_widget', | ||||
| 						'ysvisit_widget', | ||||
| 						'ttvisit_widget', | ||||
| 						'ttvisitor_widget', | ||||
| 						'tpviews_widget', | ||||
| 						'ser_widget', | ||||
| 						'select_se', | ||||
| 						'tp_widget', | ||||
| 						'tpg_widget', | ||||
| 						'tc_widget', | ||||
| 						'ts_widget', | ||||
| 						'tu_widget', | ||||
| 						'ap_widget', | ||||
| 						'ac_widget', | ||||
| 						'au_widget', | ||||
| 						'lpd_widget', | ||||
| 						'select_lps', | ||||
| 					); | ||||
|  | ||||
| 					// Handle the core options, we're going to strip off the 'wps_' header as we store them in the new settings array. | ||||
| 					foreach ( $core_options as $option ) { | ||||
| 						$new_name = substr( $option, 4 ); | ||||
| 						$WP_Statistics->store_option( $new_name, get_option( $option ) ); | ||||
| 						delete_option( $option ); | ||||
| 					} | ||||
|  | ||||
| 					$widget = array(); | ||||
|  | ||||
| 					// Handle the widget options, we're going to store them in a sub-array. | ||||
| 					foreach ( $widget_options as $option ) { | ||||
| 						$widget[ $option ] = get_option( $option ); | ||||
|  | ||||
| 						delete_option( $option ); | ||||
| 					} | ||||
|  | ||||
| 					$WP_Statistics->store_option( 'widget', $widget ); | ||||
|  | ||||
| 					foreach ( $var_options as $option ) { | ||||
| 						// Handle the special variables options. | ||||
| 						$result = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_name LIKE '{$option}'" ); | ||||
|  | ||||
| 						foreach ( $result as $opt ) { | ||||
| 							$new_name = substr( $opt->option_name, 4 ); | ||||
| 							$WP_Statistics->store_option( $new_name, $opt->option_value ); | ||||
| 							delete_option( $opt->option_name ); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					$WP_Statistics->save_options(); | ||||
| 				} | ||||
|  | ||||
| 				// If the robot list is empty, fill in the defaults. | ||||
| 				$wps_temp_robotslist = $WP_Statistics->get_option( 'robotlist' ); | ||||
|  | ||||
| 				if ( trim( $wps_temp_robotslist ) == "" || $WP_Statistics->get_option( 'force_robot_update' ) == true ) { | ||||
| 					$WP_Statistics->update_option( 'robotlist', $default_options['robotlist'] ); | ||||
| 				} | ||||
|  | ||||
| 				// WP Statistics V4.2 and below automatically exclude the administrator for statistics collection | ||||
| 				// newer versions allow the option to be set for any role in WordPress, however we should mimic | ||||
| 				// 4.2 behaviour when we upgrade, so see if the option exists in the database and if not, set it. | ||||
| 				// This will not work correctly on a WordPress install that has removed the administrator role. | ||||
| 				// However that seems VERY unlikely. | ||||
| 				$exclude_admins = $WP_Statistics->get_option( 'exclude_administrator', '2' ); | ||||
| 				if ( $exclude_admins == '2' ) { | ||||
| 					$WP_Statistics->update_option( 'exclude_administrator', '1' ); | ||||
| 				} | ||||
|  | ||||
| 				// WordPress 4.3 broke the diplay of the sidebar widget because it no longer accepted a null value | ||||
| 				// to be returned from the widget update function, let's look to see if we need to update any | ||||
| 				// occurances in the options table. | ||||
| 				$widget_options = get_option( 'widget_wpstatistics_widget' ); | ||||
| 				if ( is_array( $widget_options ) ) { | ||||
| 					foreach ( $widget_options as $key => $value ) { | ||||
| 						// We want to update all null array keys that are integers. | ||||
| 						if ( $value === null && is_int( $key ) ) { | ||||
| 							$widget_options[ $key ] = array(); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					// Store the widget options back to the database. | ||||
| 					update_option( 'widget_wpstatistics_widget', $widget_options ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// We've already handled some of the default or need to do more logic checks on them so create a list to exclude from the next loop. | ||||
| 			$excluded_defaults = array( 'force_robot_update', 'robot_list' ); | ||||
|  | ||||
| 			// If this is a first time install or an upgrade and we've added options, set some intelligent defaults. | ||||
| 			foreach ( $default_options as $key => $value ) { | ||||
| 				if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) { | ||||
| 					$WP_Statistics->store_option( $key, $value ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ( WP_Statistics::$installed_version == false ) { | ||||
| 				// We now need to set the robot list to update during the next release.  This is only done for new installs to ensure we don't overwrite existing custom robot lists. | ||||
| 				$WP_Statistics->store_option( 'force_robot_update', true ); | ||||
| 			} | ||||
|  | ||||
| 			// Save the settings now that we've set them. | ||||
| 			$WP_Statistics->save_options(); | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'upgrade_report' ) == true ) { | ||||
| 				$WP_Statistics->update_option( 'send_upgrade_email', true ); | ||||
| 			} | ||||
|  | ||||
| 			// Handle multi site implementations | ||||
| 			if ( is_multisite() ) { | ||||
| 				$current_blog = get_current_blog_id(); | ||||
|  | ||||
| 				// Loop through each of the sites. | ||||
| 				$sites = $WP_Statistics->get_wp_sites_list(); | ||||
| 				foreach ( $sites as $blog_id ) { | ||||
|  | ||||
| 					// Since we've just upgraded/installed the current blog, don't execute a remote call for us. | ||||
| 					if ( $blog_id != $current_blog ) { | ||||
|  | ||||
| 						// Get the admin url for the current site. | ||||
| 						$url = get_admin_url( $blog_id ); | ||||
|  | ||||
| 						// Go and visit the admin url of the site, this will rerun the install script for each site. | ||||
| 						// We turn blocking off because we don't really care about the response so why wait for it. | ||||
| 						wp_remote_request( $url, array( 'blocking' => false ) ); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup Visitor RelationShip Table | ||||
| 	 */ | ||||
| 	public static function setup_visitor_relationship_table() { | ||||
| 		global $wpdb; | ||||
|  | ||||
| 		$table_name = $wpdb->prefix . 'statistics_visitor_relationships'; | ||||
| 		if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) { | ||||
|  | ||||
| 			// This includes the dbDelta function from WordPress. | ||||
| 			if ( ! function_exists( 'dbDelta' ) ) { | ||||
| 				require( ABSPATH . 'wp-admin/includes/upgrade.php' ); | ||||
| 			} | ||||
|  | ||||
| 			$create_visitor_relationships_table = | ||||
| 				"CREATE TABLE IF NOT EXISTS $table_name ( | ||||
| 				`ID` bigint(20) NOT NULL AUTO_INCREMENT, | ||||
| 				`visitor_id` bigint(20) NOT NULL, | ||||
| 				`page_id` bigint(20) NOT NULL, | ||||
| 				`date` datetime NOT NULL, | ||||
| 				PRIMARY KEY  (ID), | ||||
| 				KEY visitor_id (visitor_id), | ||||
| 				KEY page_id (page_id) | ||||
| 			) ENGINE=MyISAM DEFAULT CHARSET=utf8"; | ||||
|  | ||||
| 			dbDelta( $create_visitor_relationships_table ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Update WordPress Page Type for older wp-statistics Version | ||||
| 	 * | ||||
| 	 * @since 12.6 | ||||
| 	 * | ||||
| 	 * -- List Methods --- | ||||
| 	 * _init_page_type_updater        -> define WordPress Hook | ||||
| 	 * _get_require_number_update     -> Get number of rows that require update page type | ||||
| 	 * _is_require_update_page        -> Check Wp-statistics require update page table | ||||
| 	 * _get_page_type_by_obj          -> Get Page Type by information | ||||
| 	 */ | ||||
| 	public static function _init_page_type_updater() { | ||||
|  | ||||
| 		# Check Require Admin Process | ||||
| 		if ( self::_is_require_update_page() === true ) { | ||||
|  | ||||
| 			# Add Admin Notice | ||||
| 			add_action( 'admin_notices', function () { | ||||
| 				echo '<div class="notice notice-info is-dismissible" id="wp-statistics-update-page-area" style="display: none;">'; | ||||
| 				echo '<p style="margin-top: 17px; float:' . ( is_rtl() ? 'right' : 'left' ) . '">'; | ||||
| 				echo __( 'WP-Statistics database requires upgrade.', 'wp-statistics' ); | ||||
| 				echo '</p>'; | ||||
| 				echo '<div style="float:' . ( is_rtl() ? 'left' : 'right' ) . '">'; | ||||
| 				echo '<button type="button" id="wps-upgrade-db" class="button button-primary" style="padding: 20px;line-height: 0px;box-shadow: none !important;border: 0px !important;margin: 10px 0;"/>' . __( 'Upgrade Database', 'wp-statistics' ) . '</button>'; | ||||
| 				echo '</div>'; | ||||
| 				echo '<div style="clear:both;"></div>'; | ||||
| 				echo '</div>'; | ||||
| 			} ); | ||||
|  | ||||
| 			# Add Script | ||||
| 			add_action( 'admin_footer', function () { | ||||
| 				?> | ||||
|                 <script> | ||||
|                     jQuery(document).ready(function () { | ||||
|  | ||||
|                         // Check Page is complete Loaded | ||||
|                         jQuery(window).load(function () { | ||||
|                             jQuery("#wp-statistics-update-page-area").fadeIn(2000); | ||||
|                             jQuery("#wp-statistics-update-page-area button.notice-dismiss").hide(); | ||||
|                         }); | ||||
|  | ||||
|                         // Update Page type function | ||||
|                         function wp_statistics_update_page_type() { | ||||
|  | ||||
|                             //Complete Progress | ||||
|                             let wps_end_progress = `<div id="wps_end_process" style="display:none;">`; | ||||
|                             wps_end_progress += `<p>`; | ||||
|                             wps_end_progress += `<?php _e( 'Database upgrade operation completed!', 'wp-statistics' ); ?>`; | ||||
|                             wps_end_progress += `</p>`; | ||||
|                             wps_end_progress += `</div>`; | ||||
|                             wps_end_progress += `<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>`; | ||||
|  | ||||
|                             //new Ajax Request | ||||
|                             jQuery.ajax({ | ||||
|                                 url: ajaxurl, | ||||
|                                 type: 'get', | ||||
|                                 dataType: "json", | ||||
|                                 cache: false, | ||||
|                                 data: { | ||||
|                                     'action': 'wp_statistics_update_post_type_db', | ||||
|                                     'number_all': <?php echo self::_get_require_number_update(); ?> | ||||
|                                 }, | ||||
|                                 success: function (data) { | ||||
|                                     if (data.process_status === "complete") { | ||||
|  | ||||
|                                         // Get Process Area | ||||
|                                         let wps_notice_area = jQuery("#wp-statistics-update-page-area"); | ||||
|                                         //Add Html Content | ||||
|                                         wps_notice_area.html(wps_end_progress); | ||||
|                                         //Fade in content | ||||
|                                         jQuery("#wps_end_process").fadeIn(2000); | ||||
|                                         //enable demiss button | ||||
|                                         wps_notice_area.removeClass('notice-info').addClass('notice-success'); | ||||
|                                     } else { | ||||
|  | ||||
|                                         //Get number Process | ||||
|                                         jQuery("span#wps_num_page_process").html(data.number_process); | ||||
|                                         //Get process Percentage | ||||
|                                         jQuery("progress#wps_upgrade_html_progress").attr("value", data.percentage); | ||||
|                                         jQuery("span#wps_num_percentage").html(data.percentage); | ||||
|                                         //again request | ||||
|                                         wp_statistics_update_page_type(); | ||||
|                                     } | ||||
|                                 }, | ||||
|                                 error: function () { | ||||
|                                     jQuery("#wp-statistics-update-page-area").html('<p><?php _e( 'Error occurred during operation. Please refresh the page.', 'wp-statistics' ); ?></p>'); | ||||
|                                 } | ||||
|                             }); | ||||
|                         } | ||||
|  | ||||
|                         //Click Start Progress | ||||
|                         jQuery(document).on('click', 'button#wps-upgrade-db', function (e) { | ||||
|                             e.preventDefault(); | ||||
|  | ||||
|                             // Added Progress Html | ||||
|                             let wps_progress = `<div id="wps_process_upgrade" style="display:none;"><p>`; | ||||
|                             wps_progress += `<?php _e( 'Please don\'t close the browser window until the database operation was completed.', 'wp-statistic' ); ?>`; | ||||
|                             wps_progress += `</p><p><b>`; | ||||
|                             wps_progress += `<?php echo __( 'Item processed', 'wp-statistics' ); ?>`; | ||||
|                             wps_progress += ` : <span id="wps_num_page_process">0</span> / <?php echo number_format( self::_get_require_number_update() ); ?>  <span class="wps-text-warning">(<span id="wps_num_percentage">0</span>%)</span></b></p>`; | ||||
|                             wps_progress += '<p><progress id="wps_upgrade_html_progress" value="0" max="100" style="height: 20px;width: 100%;"></progress></p></div>'; | ||||
|  | ||||
|                             // set new Content | ||||
|                             jQuery("#wp-statistics-update-page-area").html(wps_progress); | ||||
|                             jQuery("#wps_process_upgrade").fadeIn(2000); | ||||
|  | ||||
|                             // Run WordPress Ajax Updator | ||||
|                             wp_statistics_update_page_type(); | ||||
|                         }); | ||||
|  | ||||
|                         //Remove Notice event | ||||
|                         jQuery(document).on('click', '#wp-statistics-update-page-area button.notice-dismiss', function (e) { | ||||
|                             e.preventDefault(); | ||||
|                             jQuery("#wp-statistics-update-page-area").fadeOut('normal'); | ||||
|                         }); | ||||
|                     }); | ||||
|                 </script> | ||||
| 				<?php | ||||
| 			} ); | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		# Add Admin Ajax Process | ||||
| 		add_action( 'wp_ajax_wp_statistics_update_post_type_db', function () { | ||||
| 			global $wpdb; | ||||
|  | ||||
| 			# Create Default Obj | ||||
| 			$return = array( 'process_status' => 'complete', 'number_process' => 0, 'percentage' => 0 ); | ||||
|  | ||||
| 			# Check is Ajax WordPress | ||||
| 			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { | ||||
|  | ||||
| 				# Check Status Of Process | ||||
| 				if ( self::_is_require_update_page() === true ) { | ||||
|  | ||||
| 					# Number Process Per Query | ||||
| 					$number_per_query = 80; | ||||
|  | ||||
| 					# Check Number Process | ||||
| 					$number_process = self::_get_require_number_update(); | ||||
| 					$i              = 0; | ||||
| 					if ( $number_process > 0 ) { | ||||
|  | ||||
| 						# Start Query | ||||
| 						$query = $wpdb->get_results( "SELECT * FROM `" . wp_statistics_db_table( 'pages' ) . "` WHERE `type` = '' ORDER BY `page_id` DESC LIMIT 0,{$number_per_query}", ARRAY_A ); | ||||
| 						foreach ( $query as $row ) { | ||||
|  | ||||
| 							# Get Page Type | ||||
| 							$page_type = self::_get_page_type_by_obj( $row['id'], $row['uri'] ); | ||||
|  | ||||
| 							# Update Table | ||||
| 							$wpdb->update( | ||||
| 								wp_statistics_db_table( 'pages' ), | ||||
| 								array( | ||||
| 									'type' => $page_type | ||||
| 								), | ||||
| 								array( 'page_id' => $row['page_id'] ) | ||||
| 							); | ||||
|  | ||||
| 							$i ++; | ||||
| 						} | ||||
|  | ||||
| 						if ( $_GET['number_all'] > $number_per_query ) { | ||||
| 							# calculate number process | ||||
| 							$return['number_process'] = $_GET['number_all'] - ( $number_process - $i ); | ||||
|  | ||||
| 							# Calculate Per | ||||
| 							$return['percentage'] = round( ( $return['number_process'] / $_GET['number_all'] ) * 100 ); | ||||
|  | ||||
| 							# Set Process | ||||
| 							$return['process_status'] = 'incomplete'; | ||||
|  | ||||
| 						} else { | ||||
|  | ||||
| 							$return['number_process'] = $_GET['number_all']; | ||||
| 							$return['percentage']     = 100; | ||||
| 							update_option( 'wp_statistics_update_page_type', 'yes' ); | ||||
| 						} | ||||
| 					} | ||||
| 				} else { | ||||
|  | ||||
| 					# Closed Process | ||||
| 					update_option( 'wp_statistics_update_page_type', 'yes' ); | ||||
| 				} | ||||
|  | ||||
| 				# Export Data | ||||
| 				wp_send_json( $return ); | ||||
| 				exit; | ||||
| 			} | ||||
| 		} ); | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function _get_require_number_update() { | ||||
| 		global $wpdb; | ||||
| 		return $wpdb->get_var( "SELECT COUNT(*) FROM `" . wp_statistics_db_table( 'pages' ) . "` WHERE `type` = ''" ); | ||||
| 	} | ||||
|  | ||||
| 	public static function _is_require_update_page() { | ||||
|  | ||||
| 		# require update option name | ||||
| 		$opt_name = 'wp_statistics_update_page_type'; | ||||
|  | ||||
| 		# Check exist option | ||||
| 		$get_opt = get_option( $opt_name ); | ||||
| 		if ( ! empty( $get_opt ) ) { | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		# Check number require row | ||||
| 		if ( self::_get_require_number_update() > 0 ) { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function _get_page_type_by_obj( $obj_ID, $page_url ) { | ||||
|  | ||||
| 		//Default page type | ||||
| 		$page_type = 'unknown'; | ||||
|  | ||||
| 		//check if Home Page | ||||
| 		if ( $page_url == "/" ) { | ||||
| 			return 'home'; | ||||
|  | ||||
| 		} else { | ||||
|  | ||||
| 			// Page url | ||||
| 			$page_url = ltrim( $page_url, "/" ); | ||||
| 			$page_url = trim( get_bloginfo( 'url' ), "/" ) . "/" . $page_url; | ||||
|  | ||||
| 			// Check Page Path is exist | ||||
| 			$exist_page = url_to_postid( $page_url ); | ||||
|  | ||||
| 			//Check Post Exist | ||||
| 			if ( $exist_page > 0 ) { | ||||
|  | ||||
| 				# Get Post Type | ||||
| 				$p_type = get_post_type( $exist_page ); | ||||
|  | ||||
| 				# Check Post Type | ||||
| 				if ( $p_type == "product" ) { | ||||
| 					$page_type = 'product'; | ||||
| 				} elseif ( $p_type == "page" ) { | ||||
| 					$page_type = 'page'; | ||||
| 				} elseif ( $p_type == "attachment" ) { | ||||
| 					$page_type = 'attachment'; | ||||
| 				} else { | ||||
| 					$page_type = 'post'; | ||||
| 				} | ||||
|  | ||||
| 			} else { | ||||
|  | ||||
| 				# Check is Term | ||||
| 				$term = get_term( $obj_ID ); | ||||
| 				if ( is_wp_error( get_term_link( $term ) ) === true ) { | ||||
| 					//Don't Stuff | ||||
| 				} else { | ||||
| 					//Which Taxonomy | ||||
| 					$taxonomy = $term->taxonomy; | ||||
|  | ||||
| 					//Check Url is contain | ||||
| 					$term_link = get_term_link( $term ); | ||||
| 					$term_link = ltrim( str_ireplace( get_bloginfo( 'url' ), "", $term_link ), "/" ); | ||||
| 					if ( stristr( $page_url, $term_link ) === false ) { | ||||
| 						//Return Unknown | ||||
| 					} else { | ||||
| 						//Check Type of taxonomy | ||||
| 						if ( $taxonomy == "category" ) { | ||||
| 							$page_type = 'category'; | ||||
| 						} elseif ( $taxonomy == "post_tag" ) { | ||||
| 							$page_type = 'post_tag'; | ||||
| 						} else { | ||||
| 							$page_type = 'tax'; | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $page_type; | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,127 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Network_Admin | ||||
|  */ | ||||
| class WP_Statistics_Network_Admin { | ||||
|  | ||||
| 	/** | ||||
| 	 * This function adds the primary menu to WordPress network. | ||||
| 	 */ | ||||
| 	static function menu() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Get the read/write capabilities required to view/manage the plugin as set by the user. | ||||
| 		$read_cap   = wp_statistics_validate_capability( $WP_Statistics->get_option( 'read_capability', 'manage_options' ) ); | ||||
| 		$manage_cap = wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ); | ||||
|  | ||||
| 		// Add the top level menu. | ||||
| 		add_menu_page( __( 'Statistics', 'wp-statistics' ), __( 'Statistics', 'wp-statistics' ), $read_cap, WP_Statistics::$reg['main-file'], 'WP_Statistics_Network_Admin::overview', 'dashicons-chart-pie' ); | ||||
|  | ||||
| 		// Add the sub items. | ||||
| 		add_submenu_page( WP_Statistics::$reg['main-file'], __( 'Overview', 'wp-statistics' ), __( 'Overview', 'wp-statistics' ), $read_cap, WP_Statistics::$reg['main-file'], 'WP_Statistics_Network_Admin::overview' ); | ||||
|  | ||||
| 		$count = 0; | ||||
| 		$sites = $WP_Statistics->get_wp_sites_list(); | ||||
|  | ||||
| 		foreach ( $sites as $blog_id ) { | ||||
| 			$details = get_blog_details( $blog_id ); | ||||
| 			add_submenu_page( WP_Statistics::$reg['main-file'], $details->blogname, $details->blogname, $manage_cap, 'wp_statistics_blogid_' . $blog_id, 'WP_Statistics_Network_Admin::goto_blog' ); | ||||
|  | ||||
| 			$count ++; | ||||
| 			if ( $count > 15 ) { | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Network Overview | ||||
| 	 */ | ||||
| 	static function overview() { | ||||
| 		global $WP_Statistics; | ||||
| 		?> | ||||
|         <div id="wrap wps-wrap"> | ||||
|             <br/> | ||||
|             <table class="widefat wp-list-table" style="width: auto;"> | ||||
|                 <thead> | ||||
|                 <tr> | ||||
|                     <th style='text-align: left'><?php _e( 'Site', 'wp-statistics' ); ?></th> | ||||
|                     <th style='text-align: left'><?php _e( 'Options', 'wp-statistics' ); ?></th> | ||||
|                 </tr> | ||||
|                 </thead> | ||||
|                 <tbody> | ||||
| 				<?php | ||||
| 				$i = 0; | ||||
|  | ||||
| 				$options = array( | ||||
| 					__( 'Overview', 'wp-statistics' )           => WP_Statistics::$page['overview'], | ||||
| 					__( 'Hits', 'wp-statistics' )               => WP_Statistics::$page['hits'], | ||||
| 					__( 'Online', 'wp-statistics' )             => WP_Statistics::$page['online'], | ||||
| 					__( 'Referrers', 'wp-statistics' )          => WP_Statistics::$page['referrers'], | ||||
| 					__( 'Search Words', 'wp-statistics' )       => WP_Statistics::$page['words'], | ||||
| 					__( 'Searches', 'wp-statistics' )           => WP_Statistics::$page['searches'], | ||||
| 					__( 'Pages', 'wp-statistics' )              => WP_Statistics::$page['pages'], | ||||
| 					__( 'Visitors', 'wp-statistics' )           => WP_Statistics::$page['visitors'], | ||||
| 					__( 'Countries', 'wp-statistics' )          => WP_Statistics::$page['countries'], | ||||
| 					__( 'Browsers', 'wp-statistics' )           => WP_Statistics::$page['browser'], | ||||
| 					__( 'Top Visitors Today', 'wp-statistics' ) => WP_Statistics::$page['top-visitors'], | ||||
| 					__( 'Exclusions', 'wp-statistics' )         => WP_Statistics::$page['exclusions'], | ||||
| 					__( 'Optimization', 'wp-statistics' )       => WP_Statistics::$page['optimization'], | ||||
| 					__( 'Settings', 'wp-statistics' )           => WP_Statistics::$page['settings'], | ||||
| 				); | ||||
|  | ||||
| 				$sites = $WP_Statistics->get_wp_sites_list(); | ||||
|  | ||||
| 				foreach ( $sites as $blog_id ) { | ||||
| 					$details   = get_blog_details( $blog_id ); | ||||
| 					$url       = get_admin_url( $blog_id, '/' ) . 'admin.php?page='; | ||||
| 					$alternate = ''; | ||||
|  | ||||
| 					if ( $i % 2 == 0 ) { | ||||
| 						$alternate = ' class="alternate"'; | ||||
| 					} | ||||
| 					?> | ||||
|  | ||||
|                     <tr<?php echo $alternate; ?>> | ||||
|                         <td style='text-align: left'> | ||||
| 							<?php echo $details->blogname; ?> | ||||
|                         </td> | ||||
|                         <td style='text-align: left'> | ||||
| 							<?php | ||||
| 							$options_len = count( $options ); | ||||
| 							$j           = 0; | ||||
|  | ||||
| 							foreach ( $options as $key => $value ) { | ||||
| 								echo '<a href="' . $url . $value . '">' . $key . '</a>'; | ||||
| 								$j ++; | ||||
| 								if ( $j < $options_len ) { | ||||
| 									echo ' - '; | ||||
| 								} | ||||
| 							} | ||||
| 							?> | ||||
|                         </td> | ||||
|                     </tr> | ||||
| 					<?php | ||||
| 					$i ++; | ||||
| 				} | ||||
| 				?> | ||||
|                 </tbody> | ||||
|             </table> | ||||
|         </div> | ||||
| 		<?php | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Goto Network Blog | ||||
| 	 */ | ||||
| 	static function goto_blog() { | ||||
| 		global $plugin_page; | ||||
|  | ||||
| 		$blog_id = str_replace( 'wp_statistics_blogid_', '', $plugin_page ); | ||||
| 		// Get the admin url for the current site. | ||||
| 		$url = get_admin_url( $blog_id ) . '/admin.php?page=' . WP_Statistics::$page['overview']; | ||||
| 		echo "<script>window.location.href = '$url';</script>"; | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,156 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Rest | ||||
|  */ | ||||
| class WP_Statistics_Rest { | ||||
|  | ||||
| 	// Set Default namespace | ||||
| 	const route = 'wpstatistics/v1'; | ||||
|  | ||||
| 	// Set Default Statistic Save method | ||||
| 	const func = 'hit'; | ||||
|  | ||||
| 	// Set Default Name | ||||
| 	const _Argument = 'wp_statistics_hit_rest'; | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an Wordpress REst Api action. | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		/* | ||||
| 		 * add Router Rest Api | ||||
| 		 */ | ||||
| 		if ( isset( $WP_Statistics ) and $WP_Statistics->use_cache ) { | ||||
| 			add_action( 'rest_api_init', array( $this, 'register_routes' ) ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * List Of Required Params | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public static function require_params_hit() { | ||||
| 		return array( | ||||
| 			'browser', | ||||
| 			'platform', | ||||
| 			'version', | ||||
| 			'ip', | ||||
| 			'track_all', | ||||
| 			'timestamp', | ||||
| 			'page_uri', | ||||
| 			'user_id', | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Endpoint Route | ||||
| 	 */ | ||||
| 	public function register_routes() { | ||||
|  | ||||
| 		// Create Require Params | ||||
| 		$params = array(); | ||||
| 		foreach ( self::require_params_hit() as $p ) { | ||||
| 			$params[ $p ] = array( 'required' => true ); | ||||
| 		} | ||||
|  | ||||
| 		// Get Hit | ||||
| 		register_rest_route( self::route, '/' . self::func, array( | ||||
| 			'methods'             => \WP_REST_Server::READABLE, | ||||
| 			'permission_callback' => function () { | ||||
| 				global $WP_Statistics; | ||||
| 				return ( $WP_Statistics->get_option( 'use_cache_plugin' ) == 1 ? true : false ); | ||||
| 			}, | ||||
| 			'callback'            => array( $this, 'hit' ), | ||||
| 			'args'                => array_merge( | ||||
| 				array( '_wpnonce' => array( | ||||
| 					'required'          => true, | ||||
| 					'validate_callback' => function ( $value ) { | ||||
| 						return wp_verify_nonce( $value, 'wp_rest' ); | ||||
| 					} | ||||
| 				) ), $params ) | ||||
| 		) ); | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Wp Statistic Hit Save | ||||
| 	 */ | ||||
| 	public function hit() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		/* | ||||
| 		 * Check Is Test Service Request | ||||
| 		 */ | ||||
| 		if ( isset( $_REQUEST['rest-api-wp-statistics'] ) ) { | ||||
| 			return array( "rest-api-wp-statistics" => "OK" ); | ||||
| 		} | ||||
|  | ||||
| 		// Check Isset global | ||||
| 		if ( ! is_object( $WP_Statistics ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		$h = new WP_Statistics_GEO_IP_Hits; | ||||
|  | ||||
| 		// Call the online users tracking code. | ||||
| 		if ( $WP_Statistics->get_option( 'useronline' ) ) { | ||||
| 			$h->Check_online(); | ||||
| 		} | ||||
|  | ||||
| 		// Call the visitor tracking code. | ||||
| 		if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 			$h->Visitors(); | ||||
| 		} | ||||
|  | ||||
| 		// Call the visit tracking code. | ||||
| 		if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 			$h->Visits(); | ||||
| 		} | ||||
|  | ||||
| 		// Call the page tracking code. | ||||
| 		if ( $WP_Statistics->get_option( 'pages' ) ) { | ||||
| 			$h->Pages(); | ||||
| 		} | ||||
|  | ||||
| 		// Set Return | ||||
| 		return new \WP_REST_Response( array( 'status' => true, 'message' => __( 'Visitor Hit was recorded successfully.', 'wp-statistics' ) ) ); | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Check is Rest Request | ||||
| 	 */ | ||||
| 	static public function is_rest() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		if ( isset( $WP_Statistics ) and defined( 'REST_REQUEST' ) && REST_REQUEST and $WP_Statistics->use_cache ) { | ||||
| 			if ( isset( $_REQUEST[ self::_Argument ] ) ) { | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Get Params Request | ||||
| 	 */ | ||||
| 	static public function params( $params ) { | ||||
| 		if ( defined( 'REST_REQUEST' ) && REST_REQUEST and isset( $_REQUEST[ self::_Argument ] ) ) { | ||||
| 			$data = array(); | ||||
| 			foreach ( $_REQUEST as $key => $value ) { | ||||
| 				if ( ! in_array( $key, array( '_', '_wpnonce' ) ) ) { | ||||
| 					$data[ $key ] = trim( $value ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ( isset( $data[ $params ] ) ) { | ||||
| 				return $data[ $params ]; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,251 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Schedule | ||||
|  */ | ||||
| class WP_Statistics_Schedule { | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Schedule constructor. | ||||
| 	 * | ||||
| 	 * @param $WP_Statistics | ||||
| 	 */ | ||||
| 	function __construct() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// before construct | ||||
| 		add_filter( 'cron_schedules', 'WP_Statistics_Schedule::addcron' ); | ||||
|  | ||||
| 		//Run This Method Only Admin Area | ||||
| 		if ( is_admin() ) { | ||||
|  | ||||
| 			//Disable Run to Ajax | ||||
| 			if ( ! wp_doing_ajax() ) { | ||||
|  | ||||
| 				// Add the GeoIP update schedule if it doesn't exist and it should be. | ||||
| 				if ( ! wp_next_scheduled( 'wp_statistics_geoip_hook' ) && $WP_Statistics->get_option( 'schedule_geoip' ) && $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 					wp_schedule_event( time(), 'daily', 'wp_statistics_geoip_hook' ); | ||||
| 				} | ||||
|  | ||||
| 				// Remove the GeoIP update schedule if it does exist and it should shouldn't. | ||||
| 				if ( wp_next_scheduled( 'wp_statistics_geoip_hook' ) && ( ! $WP_Statistics->get_option( 'schedule_geoip' ) || ! $WP_Statistics->get_option( 'geoip' ) ) ) { | ||||
| 					wp_unschedule_event( wp_next_scheduled( 'wp_statistics_geoip_hook' ), 'wp_statistics_geoip_hook' ); | ||||
| 				} | ||||
|  | ||||
| 				//Construct Event | ||||
| 				add_action( 'wp_statistics_geoip_hook', array( $this, 'geoip_event' ) ); | ||||
| 			} | ||||
|  | ||||
| 		} else { | ||||
|  | ||||
| 			// Add the report schedule if it doesn't exist and is enabled. | ||||
| 			if ( ! wp_next_scheduled( 'report_hook' ) && $WP_Statistics->get_option( 'stats_report' ) ) { | ||||
| 				wp_schedule_event( time(), $WP_Statistics->get_option( 'time_report' ), 'report_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Remove the report schedule if it does exist and is disabled. | ||||
| 			if ( wp_next_scheduled( 'report_hook' ) && ! $WP_Statistics->get_option( 'stats_report' ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'report_hook' ), 'report_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Add the referrerspam update schedule if it doesn't exist and it should be. | ||||
| 			if ( ! wp_next_scheduled( 'wp_statistics_referrerspam_hook' ) && $WP_Statistics->get_option( 'schedule_referrerspam' ) ) { | ||||
| 				wp_schedule_event( time(), 'weekly', 'wp_statistics_referrerspam_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Remove the referrerspam update schedule if it does exist and it should shouldn't. | ||||
| 			if ( wp_next_scheduled( 'wp_statistics_referrerspam_hook' ) && ! $WP_Statistics->get_option( 'schedule_referrerspam' ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'wp_statistics_referrerspam_hook' ), 'wp_statistics_referrerspam_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Add the database maintenance schedule if it doesn't exist and it should be. | ||||
| 			if ( ! wp_next_scheduled( 'wp_statistics_dbmaint_hook' ) && $WP_Statistics->get_option( 'schedule_dbmaint' ) ) { | ||||
| 				wp_schedule_event( time(), 'daily', 'wp_statistics_dbmaint_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Remove the database maintenance schedule if it does exist and it shouldn't. | ||||
| 			if ( wp_next_scheduled( 'wp_statistics_dbmaint_hook' ) && ( ! $WP_Statistics->get_option( 'schedule_dbmaint' ) ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'wp_statistics_dbmaint_hook' ), 'wp_statistics_dbmaint_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Add the visitor database maintenance schedule if it doesn't exist and it should be. | ||||
| 			if ( ! wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ) && $WP_Statistics->get_option( 'schedule_dbmaint_visitor' ) ) { | ||||
| 				wp_schedule_event( time(), 'daily', 'wp_statistics_dbmaint_visitor_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Remove the visitor database maintenance schedule if it does exist and it shouldn't. | ||||
| 			if ( wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ) && ( ! $WP_Statistics->get_option( 'schedule_dbmaint_visitor' ) ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'wp_statistics_dbmaint_visitor_hook' ), 'wp_statistics_dbmaint_visitor_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Remove the add visit row schedule if it does exist and it shouldn't. | ||||
| 			if ( wp_next_scheduled( 'wp_statistics_add_visit_hook' ) && ( ! $WP_Statistics->get_option( 'visits' ) ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'wp_statistics_add_visit_hook' ), 'wp_statistics_add_visit_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Add the add visit table row schedule if it does exist and it should. | ||||
| 			if ( ! wp_next_scheduled( 'wp_statistics_add_visit_hook' ) && $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 				wp_schedule_event( time(), 'daily', 'wp_statistics_add_visit_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			//after construct | ||||
| 			add_action( 'wp_statistics_add_visit_hook', array( $this, 'add_visit_event' ) ); | ||||
| 			add_action( 'wp_statistics_dbmaint_hook', array( $this, 'dbmaint_event' ) ); | ||||
| 			add_action( 'wp_statistics_dbmaint_visitor_hook', array( $this, 'dbmaint_visitor_event' ) ); | ||||
| 			add_action( 'report_hook', array( $this, 'send_report' ) ); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param array $schedules | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	static function addcron( $schedules ) { | ||||
| 		// Adds once weekly to the existing schedules. | ||||
| 		if ( ! array_key_exists( 'weekly', $schedules ) ) { | ||||
| 			$schedules['weekly'] = array( | ||||
| 				'interval' => 604800, | ||||
| 				'display'  => __( 'Once Weekly' ), | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		if ( ! array_key_exists( 'biweekly', $schedules ) ) { | ||||
| 			$schedules['biweekly'] = array( | ||||
| 				'interval' => 1209600, | ||||
| 				'display'  => __( 'Once Every 2 Weeks' ), | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		if ( ! array_key_exists( '4weeks', $schedules ) ) { | ||||
| 			$schedules['4weeks'] = array( | ||||
| 				'interval' => 2419200, | ||||
| 				'display'  => __( 'Once Every 4 Weeks' ), | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		return $schedules; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * adds a record for tomorrow to the visit table to avoid a race condition. | ||||
| 	 * | ||||
| 	 */ | ||||
| 	public function add_visit_event() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		$wpdb->insert( | ||||
| 			$wpdb->prefix . 'statistics_visit', | ||||
| 			array( | ||||
| 				'last_visit'   => $WP_Statistics->Current_Date( null, '+1' ), | ||||
| 				'last_counter' => $WP_Statistics->Current_date( 'Y-m-d', '+1' ), | ||||
| 				'visit'        => 0, | ||||
| 			), | ||||
| 			array( '%s', '%s', '%d' ) | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Updates the GeoIP database from MaxMind. | ||||
| 	 */ | ||||
| 	public function geoip_event() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// Maxmind updates the geoip database on the first Tuesday of the month, to make sure we don't update before they post | ||||
| 		// the update, download it two days later. | ||||
| 		$thisupdate = strtotime( __( 'First Tuesday of this month', 'wp-statistics' ) ) + ( 86400 * 2 ); | ||||
|  | ||||
| 		$lastupdate = $WP_Statistics->get_option( 'last_geoip_dl' ); | ||||
|  | ||||
| 		$upload_dir = wp_upload_dir(); | ||||
|  | ||||
| 		// We're also going to look to see if our filesize is to small, this means the plugin stub still exists and should | ||||
| 		// be replaced with a proper file. | ||||
| 		$is_require_update = false; | ||||
| 		foreach ( WP_Statistics_Updates::$geoip as $geoip_name => $geoip_array ) { | ||||
| 			$file_path = $upload_dir['basedir'] . '/wp-statistics/' . WP_Statistics_Updates::$geoip[ $geoip_name ]['file'] . '.mmdb'; | ||||
| 			if ( file_exists( $file_path ) ) { | ||||
| 				if ( $lastupdate < $thisupdate ) { | ||||
| 					$is_require_update = true; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		if ( $is_require_update === true ) { | ||||
|  | ||||
| 			// We can't fire the download function directly here as we rely on some functions that haven't been loaded yet | ||||
| 			// in WordPress, so instead just set the flag in the options table and the shutdown hook will take care of the | ||||
| 			// actual download at the end of the page. | ||||
| 			$WP_Statistics->update_option( 'update_geoip', true ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Purges old records on a schedule based on age. | ||||
| 	 */ | ||||
| 	public function dbmaint_event() { | ||||
| 		global $WP_Statistics; | ||||
| 		if ( ! function_exists( 'wp_statistics_purge_data' ) ) { | ||||
| 			require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge.php' ); | ||||
| 		} | ||||
| 		$purge_days = intval( $WP_Statistics->get_option( 'schedule_dbmaint_days', false ) ); | ||||
| 		wp_statistics_purge_data( $purge_days ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Purges visitors with more than a defined number of hits in a day. | ||||
| 	 */ | ||||
| 	public function dbmaint_visitor_event() { | ||||
| 		global $WP_Statistics; | ||||
| 		if ( ! function_exists( 'wp_statistics_purge_visitor_hits' ) ) { | ||||
| 			require( WP_Statistics::$reg['plugin-dir'] . 'includes/functions/purge-hits.php' ); | ||||
| 		} | ||||
| 		$purge_hits = intval( $WP_Statistics->get_option( 'schedule_dbmaint_visitor_hits', false ) ); | ||||
| 		wp_statistics_purge_visitor_hits( $purge_hits ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Sends the statistics report to the selected users. | ||||
| 	 */ | ||||
| 	public function send_report() { | ||||
| 		global $WP_Statistics, $sms; | ||||
|  | ||||
| 		// Retrieve the template from the options. | ||||
| 		$final_text_report = $WP_Statistics->get_option( 'content_report' ); | ||||
|  | ||||
| 		// Process shortcodes in the template.  Note that V8.0 upgrade script replaced the old %option% codes with the appropriate short codes. | ||||
| 		$final_text_report = do_shortcode( $final_text_report ); | ||||
| 		$final_text_report = apply_filters( 'wp_statistics_final_text_report_email', $final_text_report ); | ||||
|  | ||||
| 		// Send the report through the selected transport agent. | ||||
| 		if ( $WP_Statistics->get_option( 'send_report' ) == 'mail' ) { | ||||
|  | ||||
| 			$blogname  = get_bloginfo( 'name' ); | ||||
| 			$blogemail = get_bloginfo( 'admin_email' ); | ||||
|  | ||||
| 			$headers[] = "From: $blogname <$blogemail>"; | ||||
| 			$headers[] = "MIME-Version: 1.0"; | ||||
| 			$headers[] = "Content-type: text/html; charset=utf-8"; | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 				$WP_Statistics->update_option( 'email_list', $blogemail ); | ||||
| 			} | ||||
|  | ||||
| 			wp_mail( $WP_Statistics->get_option( 'email_list' ), __( 'Statistical reporting', 'wp-statistics' ), $final_text_report, $headers ); | ||||
|  | ||||
| 		} else if ( $WP_Statistics->get_option( 'send_report' ) == 'sms' ) { | ||||
|  | ||||
| 			if ( class_exists( get_option( 'wp_webservice' ) ) ) { | ||||
|  | ||||
| 				$sms->to  = array( get_option( 'wp_admin_mobile' ) ); | ||||
| 				$sms->msg = $final_text_report; | ||||
| 				$sms->SendSMS(); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,223 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Shortcode | ||||
|  */ | ||||
| class WP_Statistics_Shortcode { | ||||
|  | ||||
| 	/** | ||||
| 	 * @param $atts | ||||
| 	 * | ||||
| 	 * WP-Statistics shortcode is in the format of: | ||||
| 	 * [wpstatistics stat=xxx time=xxxx provider=xxxx format=xxxxxx id=xxx] | ||||
| 	 * Where: | ||||
| 	 * stat = the statistic you want. | ||||
| 	 * time = is the timeframe, strtotime() (http://php.net/manual/en/datetime.formats.php) will be used to calculate | ||||
| 	 * it. provider = the search provider to get stats on. format = i18n, english, none. id = the page/post id to get | ||||
| 	 * stats on. | ||||
| 	 * | ||||
| 	 * @return array|false|int|null|object|string|void | ||||
| 	 */ | ||||
| 	static function shortcodes( $atts ) { | ||||
|  | ||||
| 		if ( ! is_array( $atts ) ) { | ||||
| 			return; | ||||
| 		} | ||||
| 		if ( ! array_key_exists( 'stat', $atts ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if ( ! array_key_exists( 'time', $atts ) ) { | ||||
| 			$atts['time'] = null; | ||||
| 		} | ||||
| 		if ( ! array_key_exists( 'provider', $atts ) ) { | ||||
| 			$atts['provider'] = 'all'; | ||||
| 		} | ||||
| 		if ( ! array_key_exists( 'format', $atts ) ) { | ||||
| 			$atts['format'] = null; | ||||
| 		} | ||||
| 		if ( ! array_key_exists( 'id', $atts ) ) { | ||||
| 			$atts['id'] = - 1; | ||||
| 		} | ||||
|  | ||||
| 		$formatnumber = array_key_exists( 'format', $atts ); | ||||
|  | ||||
| 		switch ( $atts['stat'] ) { | ||||
| 			case 'usersonline': | ||||
| 				$result = wp_statistics_useronline(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'visits': | ||||
| 				$result = wp_statistics_visit( $atts['time'] ); | ||||
| 				break; | ||||
|  | ||||
| 			case 'visitors': | ||||
| 				$result = wp_statistics_visitor( $atts['time'], null, true ); | ||||
| 				break; | ||||
|  | ||||
| 			case 'pagevisits': | ||||
| 				$result = wp_statistics_pages( $atts['time'], null, $atts['id'] ); | ||||
| 				break; | ||||
|  | ||||
| 			case 'searches': | ||||
| 				$result = wp_statistics_searchengine( $atts['provider'], $atts['time'] ); | ||||
| 				break; | ||||
|  | ||||
|             case 'referrer': | ||||
|                 $result = wp_statistics_referrer(  $atts['time']  ); | ||||
|                 break; | ||||
|  | ||||
| 			case 'postcount': | ||||
| 				$result = wp_statistics_countposts(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'pagecount': | ||||
| 				$result = wp_statistics_countpages(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'commentcount': | ||||
| 				$result = wp_statistics_countcomment(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'spamcount': | ||||
| 				$result = wp_statistics_countspam(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'usercount': | ||||
| 				$result = wp_statistics_countusers(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'postaverage': | ||||
| 				$result = wp_statistics_average_post(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'commentaverage': | ||||
| 				$result = wp_statistics_average_comment(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'useraverage': | ||||
| 				$result = wp_statistics_average_registeruser(); | ||||
| 				break; | ||||
|  | ||||
| 			case 'lpd': | ||||
| 				$result       = wp_statistics_lastpostdate(); | ||||
| 				$formatnumber = false; | ||||
| 				break; | ||||
| 		} | ||||
|  | ||||
| 		if ( $formatnumber ) { | ||||
| 			switch ( strtolower( $atts['format'] ) ) { | ||||
| 				case 'i18n': | ||||
| 					$result = number_format_i18n( $result ); | ||||
|  | ||||
| 					break; | ||||
| 				case 'english': | ||||
| 					$result = number_format( $result ); | ||||
|  | ||||
| 					break; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $result; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * | ||||
| 	 */ | ||||
| 	static function shortcake() { | ||||
| 		// ShortCake support if loaded. | ||||
| 		if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) { | ||||
| 			$se_list = wp_statistics_searchengine_list(); | ||||
|  | ||||
| 			$se_options = array( '' => 'None' ); | ||||
|  | ||||
| 			foreach ( $se_list as $se ) { | ||||
| 				$se_options[ $se['tag'] ] = $se['translated']; | ||||
| 			} | ||||
|  | ||||
| 			shortcode_ui_register_for_shortcode( | ||||
| 				'wpstatistics', | ||||
| 				array( | ||||
|  | ||||
| 					// Display label. String. Required. | ||||
| 					'label'         => 'WP Statistics', | ||||
|  | ||||
| 					// Icon/image for shortcode. Optional. src or dashicons-$icon. Defaults to carrot. | ||||
| 					'listItemImage' => '<img src="' . | ||||
| 					                   WP_Statistics::$reg['plugin-url'] . | ||||
| 					                   'assets/images/logo-250.png" width="128" height="128">', | ||||
|  | ||||
| 					// Available shortcode attributes and default values. Required. Array. | ||||
| 					// Attribute model expects 'attr', 'type' and 'label' | ||||
| 					// Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date. | ||||
| 					'attrs'         => array( | ||||
| 						array( | ||||
| 							'label'       => __( 'Statistic', 'wp-statistics' ), | ||||
| 							'attr'        => 'stat', | ||||
| 							'type'        => 'select', | ||||
| 							'description' => __( 'Select the statistic you wish to display.', 'wp-statistics' ), | ||||
| 							'value'       => 'usersonline', | ||||
| 							'options'     => array( | ||||
| 								'usersonline'    => __( 'Online Users', 'wp-statistics' ), | ||||
| 								'visits'         => __( 'Visits', 'wp-statistics' ), | ||||
| 								'visitors'       => __( 'Visitors', 'wp-statistics' ), | ||||
| 								'pagevisits'     => __( 'Page Visits', 'wp-statistics' ), | ||||
| 								'searches'       => __( 'Searches', 'wp-statistics' ), | ||||
| 								'postcount'      => __( 'Post Count', 'wp-statistics' ), | ||||
| 								'pagecount'      => __( 'Page Count', 'wp-statistics' ), | ||||
| 								'commentcount'   => __( 'Comment Count', 'wp-statistics' ), | ||||
| 								'spamcount'      => __( 'Spam Count', 'wp-statistics' ), | ||||
| 								'usercount'      => __( 'User Count', 'wp-statistics' ), | ||||
| 								'postaverage'    => __( 'Post Average', 'wp-statistics' ), | ||||
| 								'commentaverage' => __( 'Comment Average', 'wp-statistics' ), | ||||
| 								'useraverage'    => __( 'User Average', 'wp-statistics' ), | ||||
| 								'lpd'            => __( 'Last Post Date', 'wp-statistics' ), | ||||
| 								'referrer'            => __( 'Referrer', 'wp-statistics' ), | ||||
| 							), | ||||
| 						), | ||||
| 						array( | ||||
| 							'label'       => __( 'Time Frame', 'wp-statistics' ), | ||||
| 							'attr'        => 'time', | ||||
| 							'type'        => 'url', | ||||
| 							'description' => __( | ||||
| 								'The time frame to get the statistic for, strtotime() (http://php.net/manual/en/datetime.formats.php) will be used to calculate it. Use "total" to get all recorded dates.', | ||||
| 								'wp-statistics' | ||||
| 							), | ||||
| 							'meta'        => array( 'size' => '10' ), | ||||
| 						), | ||||
| 						array( | ||||
| 							'label'       => __( 'Search Provider', 'wp-statistics' ), | ||||
| 							'attr'        => 'provider', | ||||
| 							'type'        => 'select', | ||||
| 							'description' => __( 'The search provider to get statistics on.', 'wp-statistics' ), | ||||
| 							'options'     => $se_options, | ||||
| 						), | ||||
| 						array( | ||||
| 							'label'       => __( 'Number Format', 'wp-statistics' ), | ||||
| 							'attr'        => 'format', | ||||
| 							'type'        => 'select', | ||||
| 							'description' => __( | ||||
| 								'The format to display numbers in: i18n, english, none.', | ||||
| 								'wp-statistics' | ||||
| 							), | ||||
| 							'value'       => 'none', | ||||
| 							'options'     => array( | ||||
| 								'none'    => __( 'None', 'wp-statistics' ), | ||||
| 								'english' => __( 'English', 'wp-statistics' ), | ||||
| 								'i18n'    => __( 'International', 'wp-statistics' ), | ||||
| 							), | ||||
| 						), | ||||
| 						array( | ||||
| 							'label'       => __( 'Post/Page ID', 'wp-statistics' ), | ||||
| 							'attr'        => 'id', | ||||
| 							'type'        => 'number', | ||||
| 							'description' => __( 'The post/page ID to get page statistics on.', 'wp-statistics' ), | ||||
| 							'meta'        => array( 'size' => '5' ), | ||||
| 						), | ||||
| 					), | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,150 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_TinyMCE | ||||
|  */ | ||||
| class WP_Statistics_TinyMCE { | ||||
|  | ||||
| 	/** | ||||
| 	 * Setup an TinyMCE action to close the notice on the overview page. | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
| 		// Add Filter TinyMce Editor | ||||
| 		add_action( 'admin_head', array( $this, 'wp_statistic_add_my_tc_button' ) ); | ||||
|  | ||||
| 		//Load Text Widget Button | ||||
| 		add_action( 'admin_enqueue_scripts', array( $this, 'load_tinymcejs_widget_wp_admin_style' ) ); | ||||
|  | ||||
| 		// Add TextLang | ||||
| 		add_action( 'admin_footer-widgets.php', array( $this, 'my_post_edit_page_footer' ), 999 ); | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Language List Text Domain | ||||
| 	 */ | ||||
| 	static public function lang() { | ||||
| 		if ( ! class_exists( '_WP_Editors' ) ) { | ||||
| 			require( ABSPATH . WPINC . '/class-wp-editor.php' ); | ||||
| 		} | ||||
|  | ||||
| 		$strings = array( | ||||
| 			'insert'         => __( 'WP Statistics Shortcodes', 'wp-statistics' ), | ||||
| 			'stat'           => __( 'Stat', 'wp-statistics' ), | ||||
| 			'usersonline'    => __( 'Online Users', 'wp-statistics' ), | ||||
| 			'visits'         => __( 'Visits', 'wp-statistics' ), | ||||
| 			'visitors'       => __( 'Visitors', 'wp-statistics' ), | ||||
| 			'pagevisits'     => __( 'Page Visits', 'wp-statistics' ), | ||||
| 			'searches'       => __( 'Searches', 'wp-statistics' ), | ||||
| 			'postcount'      => __( 'Post Count', 'wp-statistics' ), | ||||
| 			'pagecount'      => __( 'Page Count', 'wp-statistics' ), | ||||
| 			'commentcount'   => __( 'Comment Count', 'wp-statistics' ), | ||||
| 			'spamcount'      => __( 'Spam Count', 'wp-statistics' ), | ||||
| 			'usercount'      => __( 'User Count', 'wp-statistics' ), | ||||
| 			'postaverage'    => __( 'Post Average', 'wp-statistics' ), | ||||
| 			'commentaverage' => __( 'Comment Average', 'wp-statistics' ), | ||||
| 			'useraverage'    => __( 'User Average', 'wp-statistics' ), | ||||
| 			'lpd'            => __( 'Last Post Date', 'wp-statistics' ), | ||||
| 			'referrer'       => __( 'Referrer', 'wp-statistics' ), | ||||
| 			'help_stat'      => __( 'The statistics you want, see the next table for available options.', 'wp-statistics' ), | ||||
| 			'time'           => __( 'Time', 'wp-statistics' ), | ||||
| 			'se'             => __( 'Select item ...', 'wp-statistics' ), | ||||
| 			'today'          => __( 'Today', 'wp-statistics' ), | ||||
| 			'yesterday'      => __( 'Yesterday', 'wp-statistics' ), | ||||
| 			'week'           => __( 'Week', 'wp-statistics' ), | ||||
| 			'month'          => __( 'Month', 'wp-statistics' ), | ||||
| 			'year'           => __( 'Year', 'wp-statistics' ), | ||||
| 			'total'          => __( 'Total', 'wp-statistics' ), | ||||
| 			'help_time'      => __( 'Is the time frame (time periods) for the statistic', 'wp-statistics' ), | ||||
| 			'provider'       => __( 'Provider', 'wp-statistics' ), | ||||
| 			'help_provider'  => __( 'The search provider to get statistics on.', 'wp-statistics' ), | ||||
| 			'format'         => __( 'Format', 'wp-statistics' ), | ||||
| 			'help_format'    => __( 'The format to display numbers in: i18n, english, none.', 'wp-statistics' ), | ||||
| 			'id'             => __( 'ID', 'wp-statistics' ), | ||||
| 			'help_id'        => __( 'The post/page ID to get page statistics on.', 'wp-statistics' ), | ||||
| 		); | ||||
|  | ||||
| 		$locale     = _WP_Editors::$mce_locale; | ||||
| 		$translated = 'tinyMCE.addI18n("' . $locale . '.wp_statistic_tinymce_plugin", ' . json_encode( $strings ) . ");\n"; | ||||
|  | ||||
| 		return array( 'locale' => $locale, 'translate' => $translated ); | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Filter TinyMCE | ||||
| 	 */ | ||||
| 	public function wp_statistic_add_my_tc_button() { | ||||
| 		global $typenow; | ||||
|  | ||||
| 		// check user permissions | ||||
| 		if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// verify the post type | ||||
| 		if ( ! in_array( $typenow, array( 'post', 'page' ) ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// check if WYSIWYG is enabled | ||||
| 		if ( get_user_option( 'rich_editing' ) == 'true' ) { | ||||
| 			add_filter( "mce_external_plugins", array( $this, 'wp_statistic_add_tinymce_plugin' ) ); | ||||
| 			add_filter( 'mce_buttons', array( $this, 'wp_statistic_register_my_tc_button' ) ); | ||||
| 			add_filter( 'mce_external_languages', array( $this, 'wp_statistic_tinymce_plugin_add_locale' ) ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Js Bottun to Editor | ||||
| 	 */ | ||||
| 	public function wp_statistic_add_tinymce_plugin( $plugin_array ) { | ||||
| 		$plugin_array['wp_statistic_tc_button'] = WP_Statistics::$reg['plugin-url'] . 'assets/js/tinymce.js'; | ||||
|  | ||||
| 		return $plugin_array; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Push Button to TinyMCE Advance | ||||
| 	 */ | ||||
| 	public function wp_statistic_register_my_tc_button( $buttons ) { | ||||
| 		array_push( $buttons, "wp_statistic_tc_button" ); | ||||
|  | ||||
| 		return $buttons; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Lang Text Domain | ||||
| 	 */ | ||||
| 	public function wp_statistic_tinymce_plugin_add_locale( $locales ) { | ||||
| 		$locales ['wp-statistic-tinymce-plugin'] = WP_Statistics::$reg['plugin-dir'] . 'includes/functions/tinymce.php'; | ||||
|  | ||||
| 		return $locales; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Button For Text Widget | ||||
| 	 */ | ||||
| 	public function load_tinymcejs_widget_wp_admin_style() { | ||||
| 		global $pagenow; | ||||
| 		if ( $pagenow == "widgets.php" ) { | ||||
| 			wp_enqueue_script( 'add_wp_statistic_button_for_widget_text', WP_Statistics::$reg['plugin-url'] . 'assets/js/tinymce.js' ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Add Lang for Text Widget | ||||
| 	 */ | ||||
| 	public function my_post_edit_page_footer() { | ||||
| 		echo ' | ||||
|         <script type="text/javascript"> | ||||
|         jQuery( document ).on( \'tinymce-editor-setup\', function( event, editor ) { | ||||
|                 editor.settings.toolbar1 += \',wp_statistic_tc_button\'; | ||||
|         }); | ||||
|         '; | ||||
| 		$lang = WP_Statistics_TinyMCE::lang(); | ||||
| 		echo $lang['translate']; | ||||
| 		echo ' | ||||
|         tinyMCEPreInit.load_ext("' . rtrim( WP_Statistics::$reg['plugin-url'], "/" ) . '", "' . $lang['locale'] . '"); | ||||
|         </script> | ||||
|     '; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,58 @@ | ||||
| <?php | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Uninstall | ||||
|  */ | ||||
| class WP_Statistics_Uninstall { | ||||
|  | ||||
| 	/** | ||||
| 	 * WP_Statistics_Uninstall constructor. | ||||
| 	 */ | ||||
| 	function __construct() { | ||||
| 		if ( is_admin() ) { | ||||
| 			global $WP_Statistics; | ||||
|  | ||||
| 			// Handle multi site implementations | ||||
| 			if ( is_multisite() ) { | ||||
|  | ||||
| 				// Loop through each of the sites. | ||||
| 				$sites = $WP_Statistics->get_wp_sites_list(); | ||||
| 				foreach ( $sites as $blog_id ) { | ||||
| 					switch_to_blog( $blog_id ); | ||||
| 					$this->wp_statistics_site_removal(); | ||||
| 				} | ||||
| 				restore_current_blog(); | ||||
| 			} else { | ||||
| 				$this->wp_statistics_site_removal(); | ||||
|  | ||||
| 			} | ||||
| 			// Make sure we don't try and remove the data more than once. | ||||
| 			update_option( 'wp_statistics_removal', 'done' ); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Removes database options, user meta keys & tables | ||||
| 	 */ | ||||
| 	public function wp_statistics_site_removal() { | ||||
| 		global $wpdb; | ||||
|  | ||||
| 		// Delete the options from the WordPress options table. | ||||
| 		delete_option( 'wp_statistics' ); | ||||
| 		delete_option( 'wp_statistics_db_version' ); | ||||
| 		delete_option( 'wp_statistics_plugin_version' ); | ||||
| 		delete_option( 'wp_statistics_overview_page_ads' ); | ||||
|  | ||||
| 		// Delete the transients. | ||||
| 		delete_transient( 'wps_top_referring' ); | ||||
| 		delete_transient( 'wps_excluded_hostname_to_ip_cache' ); | ||||
|  | ||||
| 		// Delete the user options. | ||||
| 		$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" ); | ||||
|  | ||||
| 		// Drop the tables | ||||
| 		$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}statistics_useronline, {$wpdb->prefix}statistics_visit, {$wpdb->prefix}statistics_visitor, {$wpdb->prefix}statistics_exclusions, {$wpdb->prefix}statistics_pages, {$wpdb->prefix}statistics_historical, {$wpdb->prefix}statistics_search" ); | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,299 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Updates | ||||
|  */ | ||||
| class WP_Statistics_Updates { | ||||
|  | ||||
| 	//List Geo ip Library | ||||
| 	public static $geoip = array( | ||||
| 		'country' => array( | ||||
| 			'cdn'    => 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz', | ||||
| 			'github' => 'https://raw.githubusercontent.com/wp-statistics/GeoLite2-Country/master/GeoLite2-Country.mmdb.gz', | ||||
| 			'file'   => 'GeoLite2-Country', | ||||
| 			'opt'    => 'geoip' | ||||
| 		), | ||||
| 		'city'    => array( | ||||
| 			'cdn'    => 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', | ||||
| 			'github' => 'https://raw.githubusercontent.com/wp-statistics/GeoLite2-City/master/GeoLite2-City.mmdb.gz', | ||||
| 			'file'   => 'GeoLite2-City', | ||||
| 			'opt'    => 'geoip_city' | ||||
| 		) | ||||
| 	); | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Update option process. | ||||
| 	 */ | ||||
| 	static function do_upgrade() { | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * This function downloads the GeoIP database from MaxMind. | ||||
| 	 * | ||||
| 	 * @param $pack | ||||
| 	 * @param string $type | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	static function download_geoip( $pack, $type = "enable" ) { | ||||
| 		GLOBAL $WP_Statistics; | ||||
|  | ||||
| 		//Create Empty Return Function | ||||
| 		$result["status"] = false; | ||||
|  | ||||
| 		// We need the download_url() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out. | ||||
| 		if ( ! function_exists( 'download_url' ) ) { | ||||
| 			include( ABSPATH . 'wp-admin/includes/file.php' ); | ||||
| 		} | ||||
|  | ||||
| 		// We need the wp_generate_password() function. | ||||
| 		if ( ! function_exists( 'wp_generate_password' ) ) { | ||||
| 			include( ABSPATH . 'wp-includes/pluggable.php' ); | ||||
| 		} | ||||
|  | ||||
| 		// We need the gzopen() function, it should exists on virtually all installs of PHP, but if it doesn't for some reason, bail out. | ||||
| 		// Also stop trying to update the database as it just won't work :) | ||||
| 		if ( false === function_exists( 'gzopen' ) ) { | ||||
| 			if ( $type == "enable" ) { | ||||
| 				$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 			} | ||||
|  | ||||
| 			$result["notice"] = __( 'Error the gzopen() function do not exist!', 'wp-statistics' ); | ||||
| 			WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
|  | ||||
| 			return $result; | ||||
| 		} | ||||
|  | ||||
| 		// If GeoIP is disabled, bail out. | ||||
| 		if ( $type == "update" and $WP_Statistics->get_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'] ) == '' ) { | ||||
| 			return ''; | ||||
| 		} | ||||
|  | ||||
| 		// This is the location of the file to download. | ||||
| 		$download_url = WP_Statistics_Updates::$geoip[ $pack ]['cdn']; | ||||
| 		$response     = wp_remote_get( $download_url ); | ||||
|  | ||||
| 		// Change download url if the maxmind.com doesn't response. | ||||
| 		if ( wp_remote_retrieve_response_code( $response ) != '200' ) { | ||||
| 			$download_url = WP_Statistics_Updates::$geoip[ $pack ]['github']; | ||||
| 		} | ||||
|  | ||||
| 		// Get the upload directory from WordPress. | ||||
| 		$upload_dir = wp_upload_dir(); | ||||
|  | ||||
| 		// Create a variable with the name of the database file to download. | ||||
| 		$DBFile = $upload_dir['basedir'] . '/wp-statistics/' . WP_Statistics_Updates::$geoip[ $pack ]['file'] . '.mmdb'; | ||||
|  | ||||
| 		// Check to see if the subdirectory we're going to upload to exists, if not create it. | ||||
| 		if ( ! file_exists( $upload_dir['basedir'] . '/wp-statistics' ) ) { | ||||
| 			if ( ! @mkdir( $upload_dir['basedir'] . '/wp-statistics', 0755 ) ) { | ||||
| 				if ( $type == "enable" ) { | ||||
| 					$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 				} | ||||
|  | ||||
| 				$result["notice"] = sprintf( __( 'Error creating GeoIP database directory, make sure your web server has permissions to create directories in: %s', 'wp-statistics' ), $upload_dir['basedir'] ); | ||||
| 				WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
|  | ||||
| 				return $result; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ( ! is_writable( $upload_dir['basedir'] . '/wp-statistics' ) ) { | ||||
| 			if ( $type == "enable" ) { | ||||
| 				$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 			} | ||||
|  | ||||
| 			$result["notice"] = sprintf( __( 'Error setting permissions of the GeoIP database directory, make sure your web server has permissions to write to directories in : %s', 'wp-statistics' ), | ||||
| 				$upload_dir['basedir'] | ||||
| 			); | ||||
| 			WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
|  | ||||
| 			return $result; | ||||
| 		} | ||||
|  | ||||
| 		// Download the file from MaxMind, this places it in a temporary location. | ||||
| 		$TempFile = download_url( $download_url ); | ||||
|  | ||||
| 		// If we failed, through a message, otherwise proceed. | ||||
| 		if ( is_wp_error( $TempFile ) ) { | ||||
| 			if ( $type == "enable" ) { | ||||
| 				$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 			} | ||||
|  | ||||
| 			$result["notice"] = sprintf( __( 'Error downloading GeoIP database from: %s - %s', 'wp-statistics' ), $download_url, $TempFile->get_error_message() ); | ||||
| 			WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
| 		} else { | ||||
| 			// Open the downloaded file to unzip it. | ||||
| 			$ZipHandle = gzopen( $TempFile, 'rb' ); | ||||
|  | ||||
| 			// Create th new file to unzip to. | ||||
| 			$DBfh = fopen( $DBFile, 'wb' ); | ||||
|  | ||||
| 			// If we failed to open the downloaded file, through an error and remove the temporary file.  Otherwise do the actual unzip. | ||||
| 			if ( ! $ZipHandle ) { | ||||
| 				if ( $type == "enable" ) { | ||||
| 					$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 				} | ||||
|  | ||||
| 				$result["notice"] = sprintf( | ||||
| 					__( 'Error could not open downloaded GeoIP database for reading: %s', 'wp-statistics' ), | ||||
| 					$TempFile | ||||
| 				); | ||||
| 				WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
|  | ||||
| 				unlink( $TempFile ); | ||||
| 			} else { | ||||
| 				// If we failed to open the new file, throw and error and remove the temporary file.  Otherwise actually do the unzip. | ||||
| 				if ( ! $DBfh ) { | ||||
| 					if ( $type == "enable" ) { | ||||
| 						$WP_Statistics->update_option( WP_Statistics_Updates::$geoip[ $pack ]['opt'], '' ); | ||||
| 					} | ||||
|  | ||||
| 					$result["notice"] = sprintf( __( 'Error could not open destination GeoIP database for writing %s', 'wp-statistics' ), $DBFile ); | ||||
| 					WP_Statistics_Admin_Pages::set_admin_notice( $result["notice"], $type = 'error' ); | ||||
|  | ||||
| 					unlink( $TempFile ); | ||||
| 				} else { | ||||
| 					while ( ( $data = gzread( $ZipHandle, 4096 ) ) != false ) { | ||||
| 						fwrite( $DBfh, $data ); | ||||
| 					} | ||||
|  | ||||
| 					// Close the files. | ||||
| 					gzclose( $ZipHandle ); | ||||
| 					fclose( $DBfh ); | ||||
|  | ||||
| 					// Delete the temporary file. | ||||
| 					unlink( $TempFile ); | ||||
|  | ||||
| 					// Display the success message. | ||||
| 					$result["status"] = true; | ||||
| 					$result["notice"] = "<div class='updated settings-error'><p><strong>" . __( 'GeoIP Database updated successfully!', 'wp-statistics' ) . "</strong></p></div>"; | ||||
|  | ||||
| 					// Update the options to reflect the new download. | ||||
| 					if ( $type == "update" ) { | ||||
| 						$WP_Statistics->update_option( 'last_geoip_dl', time() ); | ||||
| 						$WP_Statistics->update_option( 'update_geoip', false ); | ||||
| 					} | ||||
|  | ||||
| 					// Populate any missing GeoIP information if the user has selected the option. | ||||
| 					if ( $pack == "country" ) { | ||||
| 						if ( $WP_Statistics->get_option( 'geoip' ) && | ||||
| 						     wp_statistics_geoip_supported() && | ||||
| 						     $WP_Statistics->get_option( 'auto_pop' ) | ||||
| 						) { | ||||
| 							WP_Statistics_Updates::populate_geoip_info(); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'geoip_report' ) == true ) { | ||||
| 			$blogname  = get_bloginfo( 'name' ); | ||||
| 			$blogemail = get_bloginfo( 'admin_email' ); | ||||
|  | ||||
| 			$headers[] = "From: $blogname <$blogemail>"; | ||||
| 			$headers[] = "MIME-Version: 1.0"; | ||||
| 			$headers[] = "Content-type: text/html; charset=utf-8"; | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 				$WP_Statistics->update_option( 'email_list', $blogemail ); | ||||
| 			} | ||||
|  | ||||
| 			wp_mail( $WP_Statistics->get_option( 'email_list' ), __( 'GeoIP update on', 'wp-statistics' ) . ' ' . WP_Statistics_Admin_Pages::sanitize_mail_subject( $blogname ), $result['notice'], $headers ); | ||||
| 		} | ||||
|  | ||||
| 		// All of the messages displayed above are stored in a string, now it's time to actually output the messages. | ||||
| 		return $result; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Downloads the referrer spam database from https://github.com/matomo-org/referrer-spam-blacklist. | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	static function download_referrerspam() { | ||||
| 		global $WP_Statistics; | ||||
|  | ||||
| 		// If referrer spam is disabled, bail out. | ||||
| 		if ( $WP_Statistics->get_option( 'referrerspam' ) == false ) { | ||||
| 			return ''; | ||||
| 		} | ||||
|  | ||||
| 		// This is the location of the file to download. | ||||
| 		$download_url = 'https://raw.githubusercontent.com/matomo-org/referrer-spam-blacklist/master/spammers.txt'; | ||||
|  | ||||
| 		// Download the file from MaxMind, this places it in a temporary location. | ||||
| 		$response = wp_remote_get( $download_url, array( 'timeout' => 30 ) ); | ||||
| 		if ( is_wp_error( $response ) ) { | ||||
| 			return false; | ||||
| 		} | ||||
| 		$referrerspamlist = wp_remote_retrieve_body( $response ); | ||||
| 		if ( is_wp_error( $referrerspamlist ) ) { | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		if ( $referrerspamlist != '' || $WP_Statistics->get_option( 'referrerspamlist' ) != '' ) { | ||||
| 			$WP_Statistics->update_option( 'referrerspamlist', $referrerspamlist ); | ||||
| 		} | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Populate GeoIP information in to the database. | ||||
| 	 * It is used in two different parts of the plugin; | ||||
| 	 * When a user manual requests the update to happen and after a new GeoIP database has been download | ||||
| 	 * (if the option is selected). | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	static function populate_geoip_info() { | ||||
| 		global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 		// Find all rows in the table that currently don't have GeoIP info or have an unknown ('000') location. | ||||
| 		$result = $wpdb->get_results( "SELECT id,ip FROM `{$wpdb->prefix}statistics_visitor` WHERE location = '' or location = '000' or location IS NULL" ); | ||||
|  | ||||
| 		// Try create a new reader instance. | ||||
| 		$reader = false; | ||||
| 		if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 			$reader = $WP_Statistics::geoip_loader( 'country' ); | ||||
| 		} | ||||
|  | ||||
| 		if ( $reader === false ) { | ||||
| 			$text_error = __( 'Unable to load the GeoIP database, make sure you have downloaded it in the settings page.', 'wp-statistics' ); | ||||
| 			WP_Statistics_Admin_Pages::set_admin_notice( $text_error, $type = 'error' ); | ||||
| 		} | ||||
|  | ||||
| 		$count = 0; | ||||
|  | ||||
| 		// Loop through all the missing rows and update them if we find a location for them. | ||||
| 		foreach ( $result as $item ) { | ||||
| 			$count ++; | ||||
|  | ||||
| 			// If the IP address is only a hash, don't bother updating the record. | ||||
| 			if ( substr( $item->ip, 0, 6 ) != '#hash#' and $reader != false ) { | ||||
| 				try { | ||||
| 					$record   = $reader->country( $item->ip ); | ||||
| 					$location = $record->country->isoCode; | ||||
| 					if ( $location == "" ) { | ||||
| 						$location = "000"; | ||||
| 					} | ||||
| 				} catch ( Exception $e ) { | ||||
| 					$location = "000"; | ||||
| 				} | ||||
|  | ||||
| 				// Update the row in the database. | ||||
| 				$wpdb->update( | ||||
| 					$wpdb->prefix . "statistics_visitor", | ||||
| 					array( 'location' => $location ), | ||||
| 					array( 'id' => $item->id ) | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return "<div class='updated settings-error'><p><strong>" . sprintf( __( 'Updated %s GeoIP records in the visitors database.', 'wp-statistics' ), $count ) . "</strong></p></div>"; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,102 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * Class WP_Statistics_Welcome | ||||
|  */ | ||||
| class WP_Statistics_Welcome { | ||||
| 	/** | ||||
| 	 * Initial | ||||
| 	 */ | ||||
| 	public static function init() { | ||||
| 		global $WP_Statistics; | ||||
| 		if ( $WP_Statistics->get_option( 'show_welcome_page', false ) and ( strpos( $_SERVER['REQUEST_URI'], '/wp-admin/index.php' ) !== false or ( isset( $_GET['page'] ) and $_GET['page'] == 'wps_overview_page' ) ) ) { | ||||
| 			// Disable show welcome page | ||||
| 			$WP_Statistics->update_option( 'first_show_welcome_page', true ); | ||||
| 			$WP_Statistics->update_option( 'show_welcome_page', false ); | ||||
|  | ||||
| 			// Redirect to welcome page | ||||
| 			wp_redirect( WP_Statistics_Admin_Pages::admin_url( 'wps_welcome' ) ); | ||||
| 		} | ||||
|  | ||||
| 		if ( ! $WP_Statistics->get_option( 'first_show_welcome_page', false ) ) { | ||||
| 			$WP_Statistics->update_option( 'show_welcome_page', true ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register menu | ||||
| 	 */ | ||||
| 	public static function menu() { | ||||
| 		add_submenu_page( __( 'WP-Statistics Welcome', 'wp-statistics' ), __( 'WP-Statistics Welcome', 'wp-statistics' ), __( 'WP-Statistics Welcome', 'wp-statistics' ), 'administrator', 'wps_welcome', 'WP_Statistics_Welcome::page_callback' ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Welcome page | ||||
| 	 */ | ||||
| 	public static function page_callback() { | ||||
|  | ||||
| 		// Create Default Variable | ||||
| 		$error   = null; | ||||
| 		$plugins = array(); | ||||
|  | ||||
| 		// Check List Plugins if in Plugins Tab | ||||
| 		if ( isset( $_GET['tab'] ) and $_GET['tab'] == "addons" ) { | ||||
| 			$response      = wp_remote_get( 'https://wp-statistics.com/wp-json/plugin/addons' ); | ||||
| 			$response_code = wp_remote_retrieve_response_code( $response ); | ||||
| 			if ( is_wp_error( $response ) ) { | ||||
| 				$error = $response->get_error_message(); | ||||
| 			} else { | ||||
| 				if ( $response_code == '200' ) { | ||||
| 					$plugins = json_decode( $response['body'] ); | ||||
| 				} else { | ||||
| 					$error = $response['body']; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		include( WP_Statistics::$reg['plugin-dir'] . "includes/templates/welcome.php" ); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param $upgrader_object | ||||
| 	 * @param $options | ||||
| 	 */ | ||||
| 	public static function do_welcome( $upgrader_object, $options ) { | ||||
| 		$current_plugin_path_name = 'wp-statistics/wp-statistics.php'; | ||||
|  | ||||
| 		if ( isset( $options['action'] ) and $options['action'] == 'update' and isset( $options['type'] ) and $options['type'] == 'plugin' and isset( $options['plugins'] ) ) { | ||||
| 			foreach ( $options['plugins'] as $each_plugin ) { | ||||
| 				if ( $each_plugin == $current_plugin_path_name ) { | ||||
| 					global $WP_Statistics; | ||||
|  | ||||
| 					// Enable welcome page in database | ||||
| 					$WP_Statistics->update_option( 'show_welcome_page', true ); | ||||
|  | ||||
| 					// Run the upgrader | ||||
| 					WP_Statistics_Updates::do_upgrade(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Show change log | ||||
| 	 */ | ||||
| 	public static function show_change_log() { | ||||
| 		$response = wp_remote_get( 'https://api.github.com/repos/wp-statistics/wp-statistics/releases/latest' ); | ||||
|  | ||||
| 		// Check response | ||||
| 		if ( is_wp_error( $response ) ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		$response_code = wp_remote_retrieve_response_code( $response ); | ||||
|  | ||||
| 		if ( $response_code == '200' ) { | ||||
| 			$data      = json_decode( $response['body'] ); | ||||
| 			$Parsedown = new Parsedown(); | ||||
|  | ||||
| 			echo $Parsedown->text( nl2br( $data->body ) ); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,435 @@ | ||||
| <?php | ||||
|  | ||||
| class WP_Statistics_Widget extends WP_Widget { | ||||
|  | ||||
| 	/** | ||||
| 	 * Sets up the widgets name etc | ||||
| 	 */ | ||||
| 	public function __construct() { | ||||
| 		parent::__construct( | ||||
| 			'WP_Statistics_Widget', // Base ID | ||||
| 			__( 'Statistics', 'wp-statistics' ), // Name | ||||
| 			array( 'description' => __( 'Show site stats in sidebar.', 'wp-statistics' ) ) // Args | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Outputs the content of the widget | ||||
| 	 * | ||||
| 	 * @param array $args | ||||
| 	 * @param array $instance | ||||
| 	 */ | ||||
| 	public function widget( $args, $instance ) { | ||||
| 		global $WP_Statistics; | ||||
| 		extract( $args ); | ||||
| 		$widget_options = $WP_Statistics->get_option( 'widget' ); | ||||
|  | ||||
| 		echo $before_widget; | ||||
| 		echo $before_title . $widget_options['name_widget'] . $after_title; | ||||
| 		echo '<ul>'; | ||||
|  | ||||
| 		if ( $widget_options['useronline_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Online Users', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_useronline() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Today\'s Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'today' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tvisitor_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Today\'s Visitors', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visitor( 'today', null, true ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['yvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Yesterday\'s Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'yesterday' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['yvisitor_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Yesterday\'s Visitors', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['wvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Last 7 Days Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'week' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['mvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Last 30 Days Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'month' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ysvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Last 365 Days Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'year' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ttvisit_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Visits', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visit( 'total' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ttvisitor_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Visitors', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_visitor( 'total', null, true ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tpviews_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Page Views', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_pages( 'total' ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ser_widget'] ) { | ||||
|  | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Search Engine Referrals', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_searchengine( $widget_options['select_se'] ) ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tp_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Posts', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_countposts() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tpg_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Pages', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_countpages() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tc_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Comments', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_countcomment() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ts_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Spams', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo wp_statistics_countspam(); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['tu_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Total Users', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_countusers() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ap_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Post Average', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_average_post() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['ac_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Comment Average', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_average_comment() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['au_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'User Average', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo number_format_i18n( wp_statistics_average_registeruser() ); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		if ( $widget_options['lpd_widget'] ) { | ||||
| 			echo '<li>'; | ||||
| 			echo '<label>' . __( 'Last Post Date', 'wp-statistics' ) . ': </label>'; | ||||
| 			echo wp_statistics_lastpostdate(); | ||||
| 			echo '</li>'; | ||||
| 		} | ||||
|  | ||||
| 		echo '</ul>'; | ||||
| 		echo $after_widget; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Processing widget options on save | ||||
| 	 * | ||||
| 	 * @param array $new_instance The new options | ||||
| 	 * @param array $old_instance The previous options | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function update( $new_instance, $old_instance ) { | ||||
| 		GLOBAL $WP_Statistics; | ||||
|  | ||||
| 		if ( array_key_exists( 'wp_statistics_control_widget_submit', $_POST ) ) { | ||||
| 			$keys = array( | ||||
| 				'name_widget'       => 'name_widget', | ||||
| 				'useronline_widget' => 'useronline_widget', | ||||
| 				'tvisit_widget'     => 'tvisit_widget', | ||||
| 				'tvisitor_widget'   => 'tvisitor_widget', | ||||
| 				'yvisit_widget'     => 'yvisit_widget', | ||||
| 				'yvisitor_widget'   => 'yvisitor_widget', | ||||
| 				'wvisit_widget'     => 'wvisit_widget', | ||||
| 				'mvisit_widget'     => 'mvisit_widget', | ||||
| 				'ysvisit_widget'    => 'ysvisit_widget', | ||||
| 				'ttvisit_widget'    => 'ttvisit_widget', | ||||
| 				'ttvisitor_widget'  => 'ttvisitor_widget', | ||||
| 				'tpviews_widget'    => 'tpviews_widget', | ||||
| 				'ser_widget'        => 'ser_widget', | ||||
| 				'select_se'         => 'select_se', | ||||
| 				'tp_widget'         => 'tp_widget', | ||||
| 				'tpg_widget'        => 'tpg_widget', | ||||
| 				'tc_widget'         => 'tc_widget', | ||||
| 				'ts_widget'         => 'ts_widget', | ||||
| 				'tu_widget'         => 'tu_widget', | ||||
| 				'ap_widget'         => 'ap_widget', | ||||
| 				'ac_widget'         => 'ac_widget', | ||||
| 				'au_widget'         => 'au_widget', | ||||
| 				'lpd_widget'        => 'lpd_widget', | ||||
| 				'select_lps'        => 'select_lps', | ||||
| 			); | ||||
|  | ||||
| 			foreach ( $keys as $key => $post ) { | ||||
| 				if ( array_key_exists( $post, $_POST ) ) { | ||||
| 					$widget_options[ $key ] = $_POST[ $post ]; | ||||
| 				} else { | ||||
| 					$widget_options[ $key ] = ''; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			$WP_Statistics->update_option( 'widget', $widget_options ); | ||||
| 		} | ||||
|  | ||||
| 		return array(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Outputs the options form on admin | ||||
| 	 * | ||||
| 	 * @param array $instance The widget options | ||||
| 	 * | ||||
| 	 * @return string|void | ||||
| 	 */ | ||||
| 	public function form( $instance ) { | ||||
| 		GLOBAL $WP_Statistics; | ||||
| 		$widget_options = $WP_Statistics->get_option( 'widget' ); | ||||
| 		?> | ||||
|         <p> | ||||
|             <label for="name_widget"><?php _e( 'Name', 'wp-statistics' ); ?>: | ||||
|                 <input id="name_widget" name="name_widget" type="text" | ||||
|                        value="<?php echo $widget_options['name_widget']; ?>"/> | ||||
|             </label> | ||||
|         </p> | ||||
|  | ||||
| 		<?php _e( 'Items', 'wp-statistics' ); ?>:<br/> | ||||
|         <ul> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'useronline_widget' ) ); ?>" name="useronline_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['useronline_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'useronline_widget' ) ); ?>"><?php _e( 'Online Users', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tvisit_widget' ) ); ?>" name="tvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tvisit_widget' ) ); ?>"><?php _e( 'Today\'s Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tvisitor_widget' ) ); ?>" name="tvisitor_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tvisitor_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tvisitor_widget' ) ); ?>"><?php _e( 'Today\'s Visitors', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'yvisit_widget' ) ); ?>" name="yvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['yvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'yvisit_widget' ) ); ?>"><?php _e( 'Yesterday\'s Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'yvisitor_widget' ) ); ?>" name="yvisitor_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['yvisitor_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'yvisitor_widget' ) ); ?>"><?php _e( 'Yesterday\'s Visitors', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'wvisit_widget' ) ); ?>" name="wvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['wvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'wvisit_widget' ) ); ?>"><?php _e( 'Last 7 Days Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'mvisit_widget' ) ); ?>" name="mvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['mvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'mvisit_widget' ) ); ?>"><?php _e( 'Last 30 Days Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ysvisit_widget' ) ); ?>" name="ysvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ysvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ysvisit_widget' ) ); ?>"><?php _e( 'Last 365 Days Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ttvisit_widget' ) ); ?>" name="ttvisit_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ttvisit_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ttvisit_widget' ) ); ?>"><?php _e( 'Total Visits', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ttvisitor_widget' ) ); ?>" name="ttvisitor_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ttvisitor_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ttvisitor_widget' ) ); ?>"><?php _e( 'Total Visitors', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tpviews_widget' ) ); ?>" name="tpviews_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tpviews_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tpviews_widget' ) ); ?>"><?php _e( 'Total Page Views', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ser_widget' ) ); ?>" class="ser_widget" name="ser_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ser_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ser_widget' ) ); ?>"><?php _e( 'Search Engine Referrals', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p id="ser_option" style="<?php if ( ! $widget_options['ser_widget'] ) { | ||||
| 					echo "display: none;"; | ||||
| 				} ?>"> | ||||
| 					<?php _e( 'Select type of search engine', 'wp-statistics' ); ?>:<br/> | ||||
| 					<?php | ||||
| 					$search_engines = wp_statistics_searchengine_list(); | ||||
|  | ||||
| 					foreach ( $search_engines as $se ) { | ||||
| 						echo '		<input type="radio" id="select_' . | ||||
| 						     $se['tag'] . | ||||
| 						     '" name="select_se" value="' . | ||||
| 						     $se['tag'] . | ||||
| 						     '" '; | ||||
| 						checked( $se['tag'], $widget_options['select_se'] ); | ||||
| 						echo "/>\n"; | ||||
| 						echo '		<label for="' . $se['name'] . '">' . $se['translated'] . "</label>\n"; | ||||
| 						echo "\n"; | ||||
| 					} | ||||
| 					?> | ||||
|                     <input type="radio" id="select_all" name="select_se" value="all" <?php checked( | ||||
| 						'all', | ||||
| 						$widget_options['select_se'] | ||||
| 					); ?>/> | ||||
|                     <label for="select_all"><?php _e( 'All', 'wp-statistics' ); ?></label> | ||||
|                 </p> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tp_widget' ) ); ?>" name="tp_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tp_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tp_widget' ) ); ?>"><?php _e( 'Total Posts', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tpg_widget' ) ); ?>" name="tpg_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tpg_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tpg_widget' ) ); ?>"><?php _e( 'Total Pages', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tc_widget' ) ); ?>" name="tc_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tc_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tc_widget' ) ); ?>"><?php _e( 'Total Comments', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ts_widget' ) ); ?>" name="ts_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ts_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ts_widget' ) ); ?>"><?php _e( 'Total Spams', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'tu_widget' ) ); ?>" name="tu_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['tu_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'tu_widget' ) ); ?>"><?php _e( 'Total Users', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ap_widget' ) ); ?>" name="ap_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ap_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ap_widget' ) ); ?>"><?php _e( 'Post Average', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'ac_widget' ) ); ?>" name="ac_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['ac_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'ac_widget' ) ); ?>"><?php _e( 'Comment Average', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'au_widget' ) ); ?>" name="au_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['au_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'au_widget' ) ); ?>"><?php _e( 'User Average', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|             <li> | ||||
|                 <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'lpd_widget' ) ); ?>" class="lpd_widget" name="lpd_widget" <?php checked( | ||||
| 					'on', | ||||
| 					$widget_options['lpd_widget'] | ||||
| 				); ?>/> | ||||
|                 <label for="<?php echo esc_attr( $this->get_field_id( 'lpd_widget' ) ); ?>"><?php _e( 'Last Post Date', 'wp-statistics' ); ?></label> | ||||
|             </li> | ||||
|         </ul> | ||||
|  | ||||
|         <input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'wp_statistics_control_widget_submit' ) ); ?>" name="wp_statistics_control_widget_submit" | ||||
|                value="1"/> | ||||
| 		<?php | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,2 @@ | ||||
| Please add "WP_Statistics_" before any class name | ||||
| This is for an internal rule to load classes fast! | ||||
| @@ -0,0 +1,287 @@ | ||||
| <?php | ||||
| /* | ||||
| 	This is a list of all known country codes and their country names. | ||||
|  | ||||
| 	It is used in several places in the plugin and is therefore centralized here for ease of update. | ||||
| */ | ||||
| $ISOCountryCode['000'] = _x( 'Unknown', 'Country', 'wp-statistics' ); | ||||
| $ISOCountryCode['AF']  = "Afghanistan"; | ||||
| $ISOCountryCode['AX']  = "Åland Islands"; | ||||
| $ISOCountryCode['AL']  = "Albania"; | ||||
| $ISOCountryCode['DZ']  = "Algeria"; | ||||
| $ISOCountryCode['AS']  = "American Samoa"; | ||||
| $ISOCountryCode['AD']  = "Andorra"; | ||||
| $ISOCountryCode['AO']  = "Angola"; | ||||
| $ISOCountryCode['AI']  = "Anguilla"; | ||||
| $ISOCountryCode['AQ']  = "Antarctica"; | ||||
| $ISOCountryCode['AG']  = "Antigua and Barbuda"; | ||||
| $ISOCountryCode['AR']  = "Argentina"; | ||||
| $ISOCountryCode['AM']  = "Armenia"; | ||||
| $ISOCountryCode['AW']  = "Aruba"; | ||||
| $ISOCountryCode['AU']  = "Australia"; | ||||
| $ISOCountryCode['AT']  = "Austria"; | ||||
| $ISOCountryCode['AZ']  = "Azerbaijan"; | ||||
| $ISOCountryCode['BS']  = "Bahamas"; | ||||
| $ISOCountryCode['BH']  = "Bahrain"; | ||||
| $ISOCountryCode['BD']  = "Bangladesh"; | ||||
| $ISOCountryCode['BB']  = "Barbados"; | ||||
| $ISOCountryCode['BY']  = "Belarus"; | ||||
| $ISOCountryCode['BE']  = "Belgium"; | ||||
| $ISOCountryCode['BZ']  = "Belize"; | ||||
| $ISOCountryCode['BJ']  = "Benin"; | ||||
| $ISOCountryCode['BM']  = "Bermuda"; | ||||
| $ISOCountryCode['BT']  = "Bhutan"; | ||||
| $ISOCountryCode['BO']  = "Bolivia, Plurinational State of"; | ||||
| $ISOCountryCode['BQ']  = "Bonaire, Sint Eustatius and Saba"; | ||||
| $ISOCountryCode['BA']  = "Bosnia and Herzegovina"; | ||||
| $ISOCountryCode['BW']  = "Botswana"; | ||||
| $ISOCountryCode['BV']  = "Bouvet Island"; | ||||
| $ISOCountryCode['BR']  = "Brazil"; | ||||
| $ISOCountryCode['BQ']  = "British Antarctic Territory"; | ||||
| $ISOCountryCode['IO']  = "British Indian Ocean Territory"; | ||||
| $ISOCountryCode['BN']  = "Brunei Darussalam"; | ||||
| $ISOCountryCode['BG']  = "Bulgaria"; | ||||
| $ISOCountryCode['BF']  = "Burkina Faso"; | ||||
| $ISOCountryCode['BU']  = "Burma"; | ||||
| $ISOCountryCode['BI']  = "Burundi"; | ||||
| $ISOCountryCode['BY']  = "Belarus"; | ||||
| $ISOCountryCode['KH']  = "Cambodia"; | ||||
| $ISOCountryCode['CM']  = "Cameroon"; | ||||
| $ISOCountryCode['CA']  = "Canada"; | ||||
| $ISOCountryCode['CT']  = "Canton and Enderbury Islands"; | ||||
| $ISOCountryCode['CV']  = "Cape Verde"; | ||||
| $ISOCountryCode['KY']  = "Cayman Islands"; | ||||
| $ISOCountryCode['CF']  = "Central African Republic"; | ||||
| $ISOCountryCode['TD']  = "Chad"; | ||||
| $ISOCountryCode['CL']  = "Chile"; | ||||
| $ISOCountryCode['CN']  = "China"; | ||||
| $ISOCountryCode['CX']  = "Christmas Island"; | ||||
| $ISOCountryCode['CC']  = "Cocos (Keeling) Islands"; | ||||
| $ISOCountryCode['CO']  = "Colombia"; | ||||
| $ISOCountryCode['KM']  = "Comoros"; | ||||
| $ISOCountryCode['CG']  = "Congo"; | ||||
| $ISOCountryCode['CD']  = "Congo (the Democratic Republic of the)"; | ||||
| $ISOCountryCode['CK']  = "Cook Islands"; | ||||
| $ISOCountryCode['CR']  = "Costa Rica"; | ||||
| $ISOCountryCode['CI']  = "Côte d’Ivoire"; | ||||
| $ISOCountryCode['HR']  = "Croatia"; | ||||
| $ISOCountryCode['CU']  = "Cuba"; | ||||
| $ISOCountryCode['CW']  = "Curaçao"; | ||||
| $ISOCountryCode['CY']  = "Cyprus"; | ||||
| $ISOCountryCode['CZ']  = "Czech Republic"; | ||||
| $ISOCountryCode['CS']  = "Czechoslovakia"; | ||||
| $ISOCountryCode['DY']  = "Dahomey"; | ||||
| $ISOCountryCode['DK']  = "Denmark"; | ||||
| $ISOCountryCode['DJ']  = "Djibouti"; | ||||
| $ISOCountryCode['DM']  = "Dominica"; | ||||
| $ISOCountryCode['DO']  = "Dominican Republic"; | ||||
| $ISOCountryCode['NQ']  = "Dronning Maud Land"; | ||||
| $ISOCountryCode['TP']  = "East Timor"; | ||||
| $ISOCountryCode['EC']  = "Ecuador"; | ||||
| $ISOCountryCode['EG']  = "Egypt"; | ||||
| $ISOCountryCode['SV']  = "El Salvador"; | ||||
| $ISOCountryCode['GQ']  = "Equatorial Guinea"; | ||||
| $ISOCountryCode['ER']  = "Eritrea"; | ||||
| $ISOCountryCode['EE']  = "Estonia"; | ||||
| $ISOCountryCode['ET']  = "Ethiopia"; | ||||
| $ISOCountryCode['FK']  = "Falkland Islands [Malvinas]"; | ||||
| $ISOCountryCode['FO']  = "Faroe Islands"; | ||||
| $ISOCountryCode['FJ']  = "Fiji"; | ||||
| $ISOCountryCode['FI']  = "Finland"; | ||||
| $ISOCountryCode['FR']  = "France"; | ||||
| $ISOCountryCode['FX']  = "France, Metropolitan"; | ||||
| $ISOCountryCode['AI']  = "French Afars and Issas"; | ||||
| $ISOCountryCode['GF']  = "French Guiana"; | ||||
| $ISOCountryCode['PF']  = "French Polynesia"; | ||||
| $ISOCountryCode['FQ']  = "French Southern and Antarctic Territories"; | ||||
| $ISOCountryCode['TF']  = "French Southern Territories"; | ||||
| $ISOCountryCode['GA']  = "Gabon"; | ||||
| $ISOCountryCode['GM']  = "Gambia"; | ||||
| $ISOCountryCode['GE']  = "Georgia"; | ||||
| $ISOCountryCode['DD']  = "German Democratic Republic"; | ||||
| $ISOCountryCode['DE']  = "Germany"; | ||||
| $ISOCountryCode['GH']  = "Ghana"; | ||||
| $ISOCountryCode['GI']  = "Gibraltar"; | ||||
| $ISOCountryCode['GR']  = "Greece"; | ||||
| $ISOCountryCode['GL']  = "Greenland"; | ||||
| $ISOCountryCode['GD']  = "Grenada"; | ||||
| $ISOCountryCode['GP']  = "Guadeloupe"; | ||||
| $ISOCountryCode['GU']  = "Guam"; | ||||
| $ISOCountryCode['GT']  = "Guatemala"; | ||||
| $ISOCountryCode['GG']  = "Guernsey"; | ||||
| $ISOCountryCode['GN']  = "Guinea"; | ||||
| $ISOCountryCode['GW']  = "Guinea-Bissau"; | ||||
| $ISOCountryCode['GY']  = "Guyana"; | ||||
| $ISOCountryCode['HT']  = "Haiti"; | ||||
| $ISOCountryCode['HM']  = "Heard Island and McDonald Islands"; | ||||
| $ISOCountryCode['VA']  = "Holy See [Vatican City State]"; | ||||
| $ISOCountryCode['HN']  = "Honduras"; | ||||
| $ISOCountryCode['HK']  = "Hong Kong"; | ||||
| $ISOCountryCode['HU']  = "Hungary"; | ||||
| $ISOCountryCode['IS']  = "Iceland"; | ||||
| $ISOCountryCode['IN']  = "India"; | ||||
| $ISOCountryCode['ID']  = "Indonesia"; | ||||
| $ISOCountryCode['IR']  = "Iran"; | ||||
| $ISOCountryCode['IQ']  = "Iraq"; | ||||
| $ISOCountryCode['IE']  = "Ireland"; | ||||
| $ISOCountryCode['IM']  = "Isle of Man"; | ||||
| $ISOCountryCode['IL']  = "Israel"; | ||||
| $ISOCountryCode['IT']  = "Italy"; | ||||
| $ISOCountryCode['JM']  = "Jamaica"; | ||||
| $ISOCountryCode['JP']  = "Japan"; | ||||
| $ISOCountryCode['JE']  = "Jersey"; | ||||
| $ISOCountryCode['JT']  = "Johnston Island"; | ||||
| $ISOCountryCode['JO']  = "Jordan"; | ||||
| $ISOCountryCode['KZ']  = "Kazakhstan"; | ||||
| $ISOCountryCode['KE']  = "Kenya"; | ||||
| $ISOCountryCode['KI']  = "Kiribati"; | ||||
| $ISOCountryCode['KP']  = "Korea (the Democratic People's Republic of)"; | ||||
| $ISOCountryCode['KR']  = "Korea (the Republic of)"; | ||||
| $ISOCountryCode['KW']  = "Kuwait"; | ||||
| $ISOCountryCode['KG']  = "Kyrgyzstan"; | ||||
| $ISOCountryCode['LA']  = "Lao People's Democratic Republic"; | ||||
| $ISOCountryCode['LV']  = "Latvia"; | ||||
| $ISOCountryCode['LB']  = "Lebanon"; | ||||
| $ISOCountryCode['LS']  = "Lesotho"; | ||||
| $ISOCountryCode['LR']  = "Liberia"; | ||||
| $ISOCountryCode['LY']  = "Libya"; | ||||
| $ISOCountryCode['LI']  = "Liechtenstein"; | ||||
| $ISOCountryCode['LT']  = "Lithuania"; | ||||
| $ISOCountryCode['LU']  = "Luxembourg"; | ||||
| $ISOCountryCode['MO']  = "Macao"; | ||||
| $ISOCountryCode['MK']  = "Macedonia (the former Yugoslav Republic of)"; | ||||
| $ISOCountryCode['MG']  = "Madagascar"; | ||||
| $ISOCountryCode['MW']  = "Malawi"; | ||||
| $ISOCountryCode['MY']  = "Malaysia"; | ||||
| $ISOCountryCode['MV']  = "Maldives"; | ||||
| $ISOCountryCode['ML']  = "Mali"; | ||||
| $ISOCountryCode['MT']  = "Malta"; | ||||
| $ISOCountryCode['MH']  = "Marshall Islands"; | ||||
| $ISOCountryCode['MQ']  = "Martinique"; | ||||
| $ISOCountryCode['MR']  = "Mauritania"; | ||||
| $ISOCountryCode['MU']  = "Mauritius"; | ||||
| $ISOCountryCode['YT']  = "Mayotte"; | ||||
| $ISOCountryCode['MX']  = "Mexico"; | ||||
| $ISOCountryCode['FM']  = "Micronesia (the Federated States of)"; | ||||
| $ISOCountryCode['MI']  = "Midway Islands"; | ||||
| $ISOCountryCode['MD']  = "Moldova (the Republic of)"; | ||||
| $ISOCountryCode['MC']  = "Monaco"; | ||||
| $ISOCountryCode['MN']  = "Mongolia"; | ||||
| $ISOCountryCode['ME']  = "Montenegro"; | ||||
| $ISOCountryCode['MS']  = "Montserrat"; | ||||
| $ISOCountryCode['MA']  = "Morocco"; | ||||
| $ISOCountryCode['MZ']  = "Mozambique"; | ||||
| $ISOCountryCode['MM']  = "Myanmar"; | ||||
| $ISOCountryCode['NA']  = "Namibia"; | ||||
| $ISOCountryCode['NR']  = "Nauru"; | ||||
| $ISOCountryCode['NP']  = "Nepal"; | ||||
| $ISOCountryCode['NL']  = "Netherlands"; | ||||
| $ISOCountryCode['AN']  = "Netherlands Antilles"; | ||||
| $ISOCountryCode['NT']  = "Neutral Zone"; | ||||
| $ISOCountryCode['NC']  = "New Caledonia"; | ||||
| $ISOCountryCode['NH']  = "New Hebrides"; | ||||
| $ISOCountryCode['NZ']  = "New Zealand"; | ||||
| $ISOCountryCode['NI']  = "Nicaragua"; | ||||
| $ISOCountryCode['NE']  = "Niger"; | ||||
| $ISOCountryCode['NG']  = "Nigeria"; | ||||
| $ISOCountryCode['NU']  = "Niue"; | ||||
| $ISOCountryCode['NF']  = "Norfolk Island"; | ||||
| $ISOCountryCode['MP']  = "Northern Mariana Islands"; | ||||
| $ISOCountryCode['NO']  = "Norway"; | ||||
| $ISOCountryCode['OM']  = "Oman"; | ||||
| $ISOCountryCode['PC']  = "Pacific Islands (Trust Territory)"; | ||||
| $ISOCountryCode['PK']  = "Pakistan"; | ||||
| $ISOCountryCode['PW']  = "Palau"; | ||||
| $ISOCountryCode['PS']  = "Palestine, State of"; | ||||
| $ISOCountryCode['PA']  = "Panama"; | ||||
| $ISOCountryCode['PZ']  = "Panama Canal Zone"; | ||||
| $ISOCountryCode['PG']  = "Papua New Guinea"; | ||||
| $ISOCountryCode['PY']  = "Paraguay"; | ||||
| $ISOCountryCode['PE']  = "Peru"; | ||||
| $ISOCountryCode['PH']  = "Philippines"; | ||||
| $ISOCountryCode['PN']  = "Pitcairn"; | ||||
| $ISOCountryCode['PL']  = "Poland"; | ||||
| $ISOCountryCode['PT']  = "Portugal"; | ||||
| $ISOCountryCode['PR']  = "Puerto Rico"; | ||||
| $ISOCountryCode['QA']  = "Qatar"; | ||||
| $ISOCountryCode['RE']  = "Réunion"; | ||||
| $ISOCountryCode['RO']  = "Romania"; | ||||
| $ISOCountryCode['RU']  = "Russian Federation"; | ||||
| $ISOCountryCode['RW']  = "Rwanda"; | ||||
| $ISOCountryCode['BL']  = "Saint Barthélemy"; | ||||
| $ISOCountryCode['SH']  = "Saint Helena, Ascension and Tristan da Cunha"; | ||||
| $ISOCountryCode['KN']  = "Saint Kitts and Nevis"; | ||||
| $ISOCountryCode['LC']  = "Saint Lucia"; | ||||
| $ISOCountryCode['MF']  = "Saint Martin (French part)"; | ||||
| $ISOCountryCode['PM']  = "Saint Pierre and Miquelon"; | ||||
| $ISOCountryCode['VC']  = "Saint Vincent and the Grenadines"; | ||||
| $ISOCountryCode['WS']  = "Samoa"; | ||||
| $ISOCountryCode['SM']  = "San Marino"; | ||||
| $ISOCountryCode['ST']  = "Sao Tome and Principe"; | ||||
| $ISOCountryCode['SA']  = "Saudi Arabia"; | ||||
| $ISOCountryCode['SN']  = "Senegal"; | ||||
| $ISOCountryCode['RS']  = "Serbia"; | ||||
| $ISOCountryCode['CS']  = "Serbia and Montenegro"; | ||||
| $ISOCountryCode['SC']  = "Seychelles"; | ||||
| $ISOCountryCode['SL']  = "Sierra Leone"; | ||||
| $ISOCountryCode['SK']  = "Sikkim"; | ||||
| $ISOCountryCode['SG']  = "Singapore"; | ||||
| $ISOCountryCode['SX']  = "Sint Maarten (Dutch part)"; | ||||
| $ISOCountryCode['SK']  = "Slovakia"; | ||||
| $ISOCountryCode['SI']  = "Slovenia"; | ||||
| $ISOCountryCode['SB']  = "Solomon Islands"; | ||||
| $ISOCountryCode['SO']  = "Somalia"; | ||||
| $ISOCountryCode['ZA']  = "South Africa"; | ||||
| $ISOCountryCode['GS']  = "South Georgia and the South Sandwich Islands"; | ||||
| $ISOCountryCode['SS']  = "South Sudan "; | ||||
| $ISOCountryCode['RH']  = "Southern Rhodesia"; | ||||
| $ISOCountryCode['ES']  = "Spain"; | ||||
| $ISOCountryCode['LK']  = "Sri Lanka"; | ||||
| $ISOCountryCode['SD']  = "Sudan"; | ||||
| $ISOCountryCode['SR']  = "Suriname"; | ||||
| $ISOCountryCode['SJ']  = "Svalbard and Jan Mayen"; | ||||
| $ISOCountryCode['SZ']  = "Swaziland"; | ||||
| $ISOCountryCode['SE']  = "Sweden"; | ||||
| $ISOCountryCode['CH']  = "Switzerland"; | ||||
| $ISOCountryCode['SY']  = "Syrian Arab Republic"; | ||||
| $ISOCountryCode['TW']  = "Taiwan"; | ||||
| $ISOCountryCode['TJ']  = "Tajikistan"; | ||||
| $ISOCountryCode['TZ']  = "Tanzania, United Republic of"; | ||||
| $ISOCountryCode['TH']  = "Thailand"; | ||||
| $ISOCountryCode['TL']  = "Timor-Leste"; | ||||
| $ISOCountryCode['TG']  = "Togo"; | ||||
| $ISOCountryCode['TK']  = "Tokelau"; | ||||
| $ISOCountryCode['TO']  = "Tonga"; | ||||
| $ISOCountryCode['TT']  = "Trinidad and Tobago"; | ||||
| $ISOCountryCode['TN']  = "Tunisia"; | ||||
| $ISOCountryCode['TR']  = "Turkey"; | ||||
| $ISOCountryCode['TM']  = "Turkmenistan"; | ||||
| $ISOCountryCode['TC']  = "Turks and Caicos Islands"; | ||||
| $ISOCountryCode['TV']  = "Tuvalu"; | ||||
| $ISOCountryCode['UG']  = "Uganda"; | ||||
| $ISOCountryCode['UA']  = "Ukraine"; | ||||
| $ISOCountryCode['AE']  = "United Arab Emirates"; | ||||
| $ISOCountryCode['GB']  = "United Kingdom"; | ||||
| $ISOCountryCode['US']  = "United States"; | ||||
| $ISOCountryCode['UM']  = "United States Minor Outlying Islands"; | ||||
| $ISOCountryCode['PU']  = "United States Miscellaneous Pacific Islands"; | ||||
| $ISOCountryCode['HV']  = "Upper Volta"; | ||||
| $ISOCountryCode['UY']  = "Uruguay"; | ||||
| $ISOCountryCode['SU']  = "USSR"; | ||||
| $ISOCountryCode['UZ']  = "Uzbekistan"; | ||||
| $ISOCountryCode['VU']  = "Vanuatu"; | ||||
| $ISOCountryCode['VE']  = "Venezuela, Bolivarian Republic of "; | ||||
| $ISOCountryCode['VN']  = "Viet Nam"; | ||||
| $ISOCountryCode['VD']  = "Viet-Nam, Democratic Republic of"; | ||||
| $ISOCountryCode['VG']  = "Virgin Islands (British)"; | ||||
| $ISOCountryCode['VI']  = "Virgin Islands (U.S.)"; | ||||
| $ISOCountryCode['WK']  = "Wake Island"; | ||||
| $ISOCountryCode['WF']  = "Wallis and Futuna"; | ||||
| $ISOCountryCode['EH']  = "Western Sahara"; | ||||
| $ISOCountryCode['XK']  = "Kosovo"; | ||||
| $ISOCountryCode['YE']  = "Yemen"; | ||||
| $ISOCountryCode['YD']  = "Yemen, Democratic"; | ||||
| $ISOCountryCode['YU']  = "Yugoslavia"; | ||||
| $ISOCountryCode['ZR']  = "Zaire"; | ||||
| $ISOCountryCode['ZM']  = "Zambia"; | ||||
| $ISOCountryCode['ZW']  = "Zimbabwe"; | ||||
| @@ -0,0 +1,249 @@ | ||||
| <?php | ||||
| /* | ||||
| 	This is a list of all known country codes and their latitue/longitude values. | ||||
| 	 | ||||
| 	It is used for the map in the overview page. | ||||
| */ | ||||
| $CountryCoordinates["AF"] = array( "lat" => "33", "lng" => "65" ); | ||||
| $CountryCoordinates["AL"] = array( "lat" => "41", "lng" => "20" ); | ||||
| $CountryCoordinates["DZ"] = array( "lat" => "28", "lng" => "3" ); | ||||
| $CountryCoordinates["AS"] = array( "lat" => "-14.3333", "lng" => "-170" ); | ||||
| $CountryCoordinates["AD"] = array( "lat" => "42.5", "lng" => "1.6" ); | ||||
| $CountryCoordinates["AO"] = array( "lat" => "-12.5", "lng" => "18.5" ); | ||||
| $CountryCoordinates["AI"] = array( "lat" => "18.25", "lng" => "-63.1667" ); | ||||
| $CountryCoordinates["AQ"] = array( "lat" => "-90", "lng" => "0" ); | ||||
| $CountryCoordinates["AG"] = array( "lat" => "17.05", "lng" => "-61.8" ); | ||||
| $CountryCoordinates["AR"] = array( "lat" => "-34", "lng" => "-64" ); | ||||
| $CountryCoordinates["AM"] = array( "lat" => "40", "lng" => "45" ); | ||||
| $CountryCoordinates["AW"] = array( "lat" => "12.5", "lng" => "-69.9667" ); | ||||
| $CountryCoordinates["AU"] = array( "lat" => "-27", "lng" => "133" ); | ||||
| $CountryCoordinates["AT"] = array( "lat" => "47.3333", "lng" => "13.3333" ); | ||||
| $CountryCoordinates["AZ"] = array( "lat" => "40.5", "lng" => "47.5" ); | ||||
| $CountryCoordinates["BS"] = array( "lat" => "24.25", "lng" => "-76" ); | ||||
| $CountryCoordinates["BH"] = array( "lat" => "26", "lng" => "50.55" ); | ||||
| $CountryCoordinates["BD"] = array( "lat" => "24", "lng" => "90" ); | ||||
| $CountryCoordinates["BB"] = array( "lat" => "13.1667", "lng" => "-59.5333" ); | ||||
| $CountryCoordinates["BY"] = array( "lat" => "53", "lng" => "28" ); | ||||
| $CountryCoordinates["BE"] = array( "lat" => "50.8333", "lng" => "4" ); | ||||
| $CountryCoordinates["BZ"] = array( "lat" => "17.25", "lng" => "-88.75" ); | ||||
| $CountryCoordinates["BJ"] = array( "lat" => "9.5", "lng" => "2.25" ); | ||||
| $CountryCoordinates["BM"] = array( "lat" => "32.3333", "lng" => "-64.75" ); | ||||
| $CountryCoordinates["BT"] = array( "lat" => "27.5", "lng" => "90.5" ); | ||||
| $CountryCoordinates["BO"] = array( "lat" => "-17", "lng" => "-65" ); | ||||
| $CountryCoordinates["BA"] = array( "lat" => "44", "lng" => "18" ); | ||||
| $CountryCoordinates["BW"] = array( "lat" => "-22", "lng" => "24" ); | ||||
| $CountryCoordinates["BV"] = array( "lat" => "-54.4333", "lng" => "3.4" ); | ||||
| $CountryCoordinates["BR"] = array( "lat" => "-10", "lng" => "-55" ); | ||||
| $CountryCoordinates["IO"] = array( "lat" => "-6", "lng" => "71.5" ); | ||||
| $CountryCoordinates["BN"] = array( "lat" => "4.5", "lng" => "114.6667" ); | ||||
| $CountryCoordinates["BG"] = array( "lat" => "43", "lng" => "25" ); | ||||
| $CountryCoordinates["BF"] = array( "lat" => "13", "lng" => "-2" ); | ||||
| $CountryCoordinates["BI"] = array( "lat" => "-3.5", "lng" => "30" ); | ||||
| $CountryCoordinates["KH"] = array( "lat" => "13", "lng" => "105" ); | ||||
| $CountryCoordinates["CM"] = array( "lat" => "6", "lng" => "12" ); | ||||
| $CountryCoordinates["CA"] = array( "lat" => "60", "lng" => "-95" ); | ||||
| $CountryCoordinates["CV"] = array( "lat" => "16", "lng" => "-24" ); | ||||
| $CountryCoordinates["KY"] = array( "lat" => "19.5", "lng" => "-80.5" ); | ||||
| $CountryCoordinates["CF"] = array( "lat" => "7", "lng" => "21" ); | ||||
| $CountryCoordinates["TD"] = array( "lat" => "15", "lng" => "19" ); | ||||
| $CountryCoordinates["CL"] = array( "lat" => "-30", "lng" => "-71" ); | ||||
| $CountryCoordinates["CN"] = array( "lat" => "35", "lng" => "105" ); | ||||
| $CountryCoordinates["CX"] = array( "lat" => "-10.5", "lng" => "105.6667" ); | ||||
| $CountryCoordinates["CC"] = array( "lat" => "-12.5", "lng" => "96.8333" ); | ||||
| $CountryCoordinates["CO"] = array( "lat" => "4", "lng" => "-72" ); | ||||
| $CountryCoordinates["KM"] = array( "lat" => "-12.1667", "lng" => "44.25" ); | ||||
| $CountryCoordinates["CG"] = array( "lat" => "-1", "lng" => "15" ); | ||||
| $CountryCoordinates["CD"] = array( "lat" => "0", "lng" => "25" ); | ||||
| $CountryCoordinates["CK"] = array( "lat" => "-21.2333", "lng" => "-159.7667" ); | ||||
| $CountryCoordinates["CR"] = array( "lat" => "10", "lng" => "-84" ); | ||||
| $CountryCoordinates["CI"] = array( "lat" => "8", "lng" => "-5" ); | ||||
| $CountryCoordinates["HR"] = array( "lat" => "45.1667", "lng" => "15.5" ); | ||||
| $CountryCoordinates["CU"] = array( "lat" => "21.5", "lng" => "-80" ); | ||||
| $CountryCoordinates["CY"] = array( "lat" => "35", "lng" => "33" ); | ||||
| $CountryCoordinates["CZ"] = array( "lat" => "49.75", "lng" => "15.5" ); | ||||
| $CountryCoordinates["DK"] = array( "lat" => "56", "lng" => "10" ); | ||||
| $CountryCoordinates["DJ"] = array( "lat" => "11.5", "lng" => "43" ); | ||||
| $CountryCoordinates["DM"] = array( "lat" => "15.4167", "lng" => "-61.3333" ); | ||||
| $CountryCoordinates["DO"] = array( "lat" => "19", "lng" => "-70.6667" ); | ||||
| $CountryCoordinates["EC"] = array( "lat" => "-2", "lng" => "-77.5" ); | ||||
| $CountryCoordinates["EG"] = array( "lat" => "27", "lng" => "30" ); | ||||
| $CountryCoordinates["SV"] = array( "lat" => "13.8333", "lng" => "-88.9167" ); | ||||
| $CountryCoordinates["GQ"] = array( "lat" => "2", "lng" => "10" ); | ||||
| $CountryCoordinates["ER"] = array( "lat" => "15", "lng" => "39" ); | ||||
| $CountryCoordinates["EE"] = array( "lat" => "59", "lng" => "26" ); | ||||
| $CountryCoordinates["ET"] = array( "lat" => "8", "lng" => "38" ); | ||||
| $CountryCoordinates["FK"] = array( "lat" => "-51.75", "lng" => "-59" ); | ||||
| $CountryCoordinates["FO"] = array( "lat" => "62", "lng" => "-7" ); | ||||
| $CountryCoordinates["FJ"] = array( "lat" => "-18", "lng" => "175" ); | ||||
| $CountryCoordinates["FI"] = array( "lat" => "64", "lng" => "26" ); | ||||
| $CountryCoordinates["FR"] = array( "lat" => "46", "lng" => "2" ); | ||||
| $CountryCoordinates["GF"] = array( "lat" => "4", "lng" => "-53" ); | ||||
| $CountryCoordinates["PF"] = array( "lat" => "-15", "lng" => "-140" ); | ||||
| $CountryCoordinates["TF"] = array( "lat" => "-43", "lng" => "67" ); | ||||
| $CountryCoordinates["GA"] = array( "lat" => "-1", "lng" => "11.75" ); | ||||
| $CountryCoordinates["GM"] = array( "lat" => "13.4667", "lng" => "-16.5667" ); | ||||
| $CountryCoordinates["GE"] = array( "lat" => "42", "lng" => "43.5" ); | ||||
| $CountryCoordinates["DE"] = array( "lat" => "51", "lng" => "9" ); | ||||
| $CountryCoordinates["GH"] = array( "lat" => "8", "lng" => "-2" ); | ||||
| $CountryCoordinates["GI"] = array( "lat" => "36.1833", "lng" => "-5.3667" ); | ||||
| $CountryCoordinates["GR"] = array( "lat" => "39", "lng" => "22" ); | ||||
| $CountryCoordinates["GL"] = array( "lat" => "72", "lng" => "-40" ); | ||||
| $CountryCoordinates["GD"] = array( "lat" => "12.1167", "lng" => "-61.6667" ); | ||||
| $CountryCoordinates["GP"] = array( "lat" => "16.25", "lng" => "-61.5833" ); | ||||
| $CountryCoordinates["GU"] = array( "lat" => "13.4667", "lng" => "144.7833" ); | ||||
| $CountryCoordinates["GT"] = array( "lat" => "15.5", "lng" => "-90.25" ); | ||||
| $CountryCoordinates["GG"] = array( "lat" => "49.5", "lng" => "-2.56" ); | ||||
| $CountryCoordinates["GN"] = array( "lat" => "11", "lng" => "-10" ); | ||||
| $CountryCoordinates["GW"] = array( "lat" => "12", "lng" => "-15" ); | ||||
| $CountryCoordinates["GY"] = array( "lat" => "5", "lng" => "-59" ); | ||||
| $CountryCoordinates["HT"] = array( "lat" => "19", "lng" => "-72.4167" ); | ||||
| $CountryCoordinates["HM"] = array( "lat" => "-53.1", "lng" => "72.5167" ); | ||||
| $CountryCoordinates["VA"] = array( "lat" => "41.9", "lng" => "12.45" ); | ||||
| $CountryCoordinates["HN"] = array( "lat" => "15", "lng" => "-86.5" ); | ||||
| $CountryCoordinates["HK"] = array( "lat" => "22.25", "lng" => "114.1667" ); | ||||
| $CountryCoordinates["HU"] = array( "lat" => "47", "lng" => "20" ); | ||||
| $CountryCoordinates["IS"] = array( "lat" => "65", "lng" => "-18" ); | ||||
| $CountryCoordinates["IN"] = array( "lat" => "20", "lng" => "77" ); | ||||
| $CountryCoordinates["ID"] = array( "lat" => "-5", "lng" => "120" ); | ||||
| $CountryCoordinates["IR"] = array( "lat" => "32", "lng" => "53" ); | ||||
| $CountryCoordinates["IQ"] = array( "lat" => "33", "lng" => "44" ); | ||||
| $CountryCoordinates["IE"] = array( "lat" => "53", "lng" => "-8" ); | ||||
| $CountryCoordinates["IM"] = array( "lat" => "54.23", "lng" => "-4.55" ); | ||||
| $CountryCoordinates["IL"] = array( "lat" => "31.5", "lng" => "34.75" ); | ||||
| $CountryCoordinates["IT"] = array( "lat" => "42.8333", "lng" => "12.8333" ); | ||||
| $CountryCoordinates["JM"] = array( "lat" => "18.25", "lng" => "-77.5" ); | ||||
| $CountryCoordinates["JP"] = array( "lat" => "36", "lng" => "138" ); | ||||
| $CountryCoordinates["JE"] = array( "lat" => "49.21", "lng" => "-2.13" ); | ||||
| $CountryCoordinates["JO"] = array( "lat" => "31", "lng" => "36" ); | ||||
| $CountryCoordinates["KZ"] = array( "lat" => "48", "lng" => "68" ); | ||||
| $CountryCoordinates["KE"] = array( "lat" => "1", "lng" => "38" ); | ||||
| $CountryCoordinates["KI"] = array( "lat" => "1.4167", "lng" => "173" ); | ||||
| $CountryCoordinates["KP"] = array( "lat" => "40", "lng" => "127" ); | ||||
| $CountryCoordinates["KR"] = array( "lat" => "37", "lng" => "127.5" ); | ||||
| $CountryCoordinates["KW"] = array( "lat" => "29.3375", "lng" => "47.6581" ); | ||||
| $CountryCoordinates["KG"] = array( "lat" => "41", "lng" => "75" ); | ||||
| $CountryCoordinates["LA"] = array( "lat" => "18", "lng" => "105" ); | ||||
| $CountryCoordinates["LV"] = array( "lat" => "57", "lng" => "25" ); | ||||
| $CountryCoordinates["LB"] = array( "lat" => "33.8333", "lng" => "35.8333" ); | ||||
| $CountryCoordinates["LS"] = array( "lat" => "-29.5", "lng" => "28.5" ); | ||||
| $CountryCoordinates["LR"] = array( "lat" => "6.5", "lng" => "-9.5" ); | ||||
| $CountryCoordinates["LY"] = array( "lat" => "25", "lng" => "17" ); | ||||
| $CountryCoordinates["LI"] = array( "lat" => "47.1667", "lng" => "9.5333" ); | ||||
| $CountryCoordinates["LT"] = array( "lat" => "56", "lng" => "24" ); | ||||
| $CountryCoordinates["LU"] = array( "lat" => "49.75", "lng" => "6.1667" ); | ||||
| $CountryCoordinates["MO"] = array( "lat" => "22.1667", "lng" => "113.55" ); | ||||
| $CountryCoordinates["MK"] = array( "lat" => "41.8333", "lng" => "22" ); | ||||
| $CountryCoordinates["MG"] = array( "lat" => "-20", "lng" => "47" ); | ||||
| $CountryCoordinates["MW"] = array( "lat" => "-13.5", "lng" => "34" ); | ||||
| $CountryCoordinates["MY"] = array( "lat" => "2.5", "lng" => "112.5" ); | ||||
| $CountryCoordinates["MV"] = array( "lat" => "3.25", "lng" => "73" ); | ||||
| $CountryCoordinates["ML"] = array( "lat" => "17", "lng" => "-4" ); | ||||
| $CountryCoordinates["MT"] = array( "lat" => "35.8333", "lng" => "14.5833" ); | ||||
| $CountryCoordinates["MH"] = array( "lat" => "9", "lng" => "168" ); | ||||
| $CountryCoordinates["MQ"] = array( "lat" => "14.6667", "lng" => "-61" ); | ||||
| $CountryCoordinates["MR"] = array( "lat" => "20", "lng" => "-12" ); | ||||
| $CountryCoordinates["MU"] = array( "lat" => "-20.2833", "lng" => "57.55" ); | ||||
| $CountryCoordinates["YT"] = array( "lat" => "-12.8333", "lng" => "45.1667" ); | ||||
| $CountryCoordinates["MX"] = array( "lat" => "23", "lng" => "-102" ); | ||||
| $CountryCoordinates["FM"] = array( "lat" => "6.9167", "lng" => "158.25" ); | ||||
| $CountryCoordinates["MD"] = array( "lat" => "47", "lng" => "29" ); | ||||
| $CountryCoordinates["MC"] = array( "lat" => "43.7333", "lng" => "7.4" ); | ||||
| $CountryCoordinates["MN"] = array( "lat" => "46", "lng" => "105" ); | ||||
| $CountryCoordinates["ME"] = array( "lat" => "42", "lng" => "19" ); | ||||
| $CountryCoordinates["MS"] = array( "lat" => "16.75", "lng" => "-62.2" ); | ||||
| $CountryCoordinates["MA"] = array( "lat" => "32", "lng" => "-5" ); | ||||
| $CountryCoordinates["MZ"] = array( "lat" => "-18.25", "lng" => "35" ); | ||||
| $CountryCoordinates["MM"] = array( "lat" => "22", "lng" => "98" ); | ||||
| $CountryCoordinates["NA"] = array( "lat" => "-22", "lng" => "17" ); | ||||
| $CountryCoordinates["NR"] = array( "lat" => "-0.5333", "lng" => "166.9167" ); | ||||
| $CountryCoordinates["NP"] = array( "lat" => "28", "lng" => "84" ); | ||||
| $CountryCoordinates["NL"] = array( "lat" => "52.5", "lng" => "5.75" ); | ||||
| $CountryCoordinates["AN"] = array( "lat" => "12.25", "lng" => "-68.75" ); | ||||
| $CountryCoordinates["NC"] = array( "lat" => "-21.5", "lng" => "165.5" ); | ||||
| $CountryCoordinates["NZ"] = array( "lat" => "-41", "lng" => "174" ); | ||||
| $CountryCoordinates["NI"] = array( "lat" => "13", "lng" => "-85" ); | ||||
| $CountryCoordinates["NE"] = array( "lat" => "16", "lng" => "8" ); | ||||
| $CountryCoordinates["NG"] = array( "lat" => "10", "lng" => "8" ); | ||||
| $CountryCoordinates["NU"] = array( "lat" => "-19.0333", "lng" => "-169.8667" ); | ||||
| $CountryCoordinates["NF"] = array( "lat" => "-29.0333", "lng" => "167.95" ); | ||||
| $CountryCoordinates["MP"] = array( "lat" => "15.2", "lng" => "145.75" ); | ||||
| $CountryCoordinates["NO"] = array( "lat" => "62", "lng" => "10" ); | ||||
| $CountryCoordinates["OM"] = array( "lat" => "21", "lng" => "57" ); | ||||
| $CountryCoordinates["PK"] = array( "lat" => "30", "lng" => "70" ); | ||||
| $CountryCoordinates["PW"] = array( "lat" => "7.5", "lng" => "134.5" ); | ||||
| $CountryCoordinates["PS"] = array( "lat" => "32", "lng" => "35.25" ); | ||||
| $CountryCoordinates["PA"] = array( "lat" => "9", "lng" => "-80" ); | ||||
| $CountryCoordinates["PG"] = array( "lat" => "-6", "lng" => "147" ); | ||||
| $CountryCoordinates["PY"] = array( "lat" => "-23", "lng" => "-58" ); | ||||
| $CountryCoordinates["PE"] = array( "lat" => "-10", "lng" => "-76" ); | ||||
| $CountryCoordinates["PH"] = array( "lat" => "13", "lng" => "122" ); | ||||
| $CountryCoordinates["PN"] = array( "lat" => "-24.7", "lng" => "-127.4" ); | ||||
| $CountryCoordinates["PL"] = array( "lat" => "52", "lng" => "20" ); | ||||
| $CountryCoordinates["PT"] = array( "lat" => "39.5", "lng" => "-8" ); | ||||
| $CountryCoordinates["PR"] = array( "lat" => "18.25", "lng" => "-66.5" ); | ||||
| $CountryCoordinates["QA"] = array( "lat" => "25.5", "lng" => "51.25" ); | ||||
| $CountryCoordinates["RE"] = array( "lat" => "-21.1", "lng" => "55.6" ); | ||||
| $CountryCoordinates["RO"] = array( "lat" => "46", "lng" => "25" ); | ||||
| $CountryCoordinates["RU"] = array( "lat" => "60", "lng" => "100" ); | ||||
| $CountryCoordinates["RW"] = array( "lat" => "-2", "lng" => "30" ); | ||||
| $CountryCoordinates["SH"] = array( "lat" => "-15.9333", "lng" => "-5.7" ); | ||||
| $CountryCoordinates["KN"] = array( "lat" => "17.3333", "lng" => "-62.75" ); | ||||
| $CountryCoordinates["LC"] = array( "lat" => "13.8833", "lng" => "-61.1333" ); | ||||
| $CountryCoordinates["PM"] = array( "lat" => "46.8333", "lng" => "-56.3333" ); | ||||
| $CountryCoordinates["VC"] = array( "lat" => "13.25", "lng" => "-61.2" ); | ||||
| $CountryCoordinates["WS"] = array( "lat" => "-13.5833", "lng" => "-172.3333" ); | ||||
| $CountryCoordinates["SM"] = array( "lat" => "43.7667", "lng" => "12.4167" ); | ||||
| $CountryCoordinates["ST"] = array( "lat" => "1", "lng" => "7" ); | ||||
| $CountryCoordinates["SA"] = array( "lat" => "25", "lng" => "45" ); | ||||
| $CountryCoordinates["SN"] = array( "lat" => "14", "lng" => "-14" ); | ||||
| $CountryCoordinates["RS"] = array( "lat" => "44", "lng" => "21" ); | ||||
| $CountryCoordinates["SC"] = array( "lat" => "-4.5833", "lng" => "55.6667" ); | ||||
| $CountryCoordinates["SL"] = array( "lat" => "8.5", "lng" => "-11.5" ); | ||||
| $CountryCoordinates["SG"] = array( "lat" => "1.3667", "lng" => "103.8" ); | ||||
| $CountryCoordinates["SK"] = array( "lat" => "48.6667", "lng" => "19.5" ); | ||||
| $CountryCoordinates["SI"] = array( "lat" => "46", "lng" => "15" ); | ||||
| $CountryCoordinates["SB"] = array( "lat" => "-8", "lng" => "159" ); | ||||
| $CountryCoordinates["SO"] = array( "lat" => "10", "lng" => "49" ); | ||||
| $CountryCoordinates["ZA"] = array( "lat" => "-29", "lng" => "24" ); | ||||
| $CountryCoordinates["GS"] = array( "lat" => "-54.5", "lng" => "-37" ); | ||||
| $CountryCoordinates["ES"] = array( "lat" => "40", "lng" => "-4" ); | ||||
| $CountryCoordinates["LK"] = array( "lat" => "7", "lng" => "81" ); | ||||
| $CountryCoordinates["SD"] = array( "lat" => "15", "lng" => "30" ); | ||||
| $CountryCoordinates["SR"] = array( "lat" => "4", "lng" => "-56" ); | ||||
| $CountryCoordinates["SJ"] = array( "lat" => "78", "lng" => "20" ); | ||||
| $CountryCoordinates["SZ"] = array( "lat" => "-26.5", "lng" => "31.5" ); | ||||
| $CountryCoordinates["SE"] = array( "lat" => "62", "lng" => "15" ); | ||||
| $CountryCoordinates["CH"] = array( "lat" => "47", "lng" => "8" ); | ||||
| $CountryCoordinates["SY"] = array( "lat" => "35", "lng" => "38" ); | ||||
| $CountryCoordinates["TW"] = array( "lat" => "23.5", "lng" => "121" ); | ||||
| $CountryCoordinates["TJ"] = array( "lat" => "39", "lng" => "71" ); | ||||
| $CountryCoordinates["TZ"] = array( "lat" => "-6", "lng" => "35" ); | ||||
| $CountryCoordinates["TH"] = array( "lat" => "15", "lng" => "100" ); | ||||
| $CountryCoordinates["TL"] = array( "lat" => "-8.55", "lng" => "125.5167" ); | ||||
| $CountryCoordinates["TG"] = array( "lat" => "8", "lng" => "1.1667" ); | ||||
| $CountryCoordinates["TK"] = array( "lat" => "-9", "lng" => "-172" ); | ||||
| $CountryCoordinates["TO"] = array( "lat" => "-20", "lng" => "-175" ); | ||||
| $CountryCoordinates["TT"] = array( "lat" => "11", "lng" => "-61" ); | ||||
| $CountryCoordinates["TN"] = array( "lat" => "34", "lng" => "9" ); | ||||
| $CountryCoordinates["TR"] = array( "lat" => "39", "lng" => "35" ); | ||||
| $CountryCoordinates["TM"] = array( "lat" => "40", "lng" => "60" ); | ||||
| $CountryCoordinates["TC"] = array( "lat" => "21.75", "lng" => "-71.5833" ); | ||||
| $CountryCoordinates["TV"] = array( "lat" => "-8", "lng" => "178" ); | ||||
| $CountryCoordinates["UG"] = array( "lat" => "1", "lng" => "32" ); | ||||
| $CountryCoordinates["UA"] = array( "lat" => "49", "lng" => "32" ); | ||||
| $CountryCoordinates["AE"] = array( "lat" => "24", "lng" => "54" ); | ||||
| $CountryCoordinates["GB"] = array( "lat" => "54", "lng" => "-2" ); | ||||
| $CountryCoordinates["US"] = array( "lat" => "38", "lng" => "-97" ); | ||||
| $CountryCoordinates["UM"] = array( "lat" => "19.2833", "lng" => "166.6" ); | ||||
| $CountryCoordinates["UY"] = array( "lat" => "-33", "lng" => "-56" ); | ||||
| $CountryCoordinates["UZ"] = array( "lat" => "41", "lng" => "64" ); | ||||
| $CountryCoordinates["VU"] = array( "lat" => "-16", "lng" => "167" ); | ||||
| $CountryCoordinates["VE"] = array( "lat" => "8", "lng" => "-66" ); | ||||
| $CountryCoordinates["VN"] = array( "lat" => "16", "lng" => "106" ); | ||||
| $CountryCoordinates["VG"] = array( "lat" => "18.5", "lng" => "-64.5" ); | ||||
| $CountryCoordinates["VI"] = array( "lat" => "18.3333", "lng" => "-64.8333" ); | ||||
| $CountryCoordinates["WF"] = array( "lat" => "-13.3", "lng" => "-176.2" ); | ||||
| $CountryCoordinates["EH"] = array( "lat" => "24.5", "lng" => "-13" ); | ||||
| $CountryCoordinates["YE"] = array( "lat" => "15", "lng" => "48" ); | ||||
| $CountryCoordinates["ZM"] = array( "lat" => "-15", "lng" => "30" ); | ||||
| $CountryCoordinates["ZW"] = array( "lat" => "-20", "lng" => "30" ); | ||||
							
								
								
									
										2264
									
								
								wp-content/plugins/wp-statistics/includes/functions/functions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2264
									
								
								wp-content/plugins/wp-statistics/includes/functions/functions.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,67 @@ | ||||
| <?php | ||||
| function wp_statistics_purge_visitor_hits( $purge_hits ) { | ||||
| 	GLOBAL $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	// If it's less than 10 hits, don't do anything. | ||||
| 	if ( $purge_hits > 9 ) { | ||||
| 		// Purge the visitor's with more than the defined hits. | ||||
| 		$result = $wpdb->get_results( | ||||
| 			$wpdb->prepare( "SELECT * FROM {$wpdb->prefix}statistics_visitor WHERE `hits` > %s", $purge_hits ) | ||||
| 		); | ||||
|  | ||||
| 		$to_delete = array(); | ||||
|  | ||||
| 		// Loop through the results and store the requried information in an array.  We don't just process it now as deleting | ||||
| 		// the rows from the visitor table will mess up the results from our first query. | ||||
| 		foreach ( $result as $row ) { | ||||
| 			$to_delete[] = array( $row->ID, $row->last_counter, $row->hits ); | ||||
| 		} | ||||
| 		if ( count( $to_delete ) > 0 ) { | ||||
| 			foreach ( $to_delete as $item ) { | ||||
| 				// First update the daily hit count. | ||||
| 				$wpdb->query( | ||||
| 					$wpdb->prepare( | ||||
| 						"UPDATE {$wpdb->prefix}statistics_visit SET `visit` = `visit` - %d WHERE `last_counter` = %s;", | ||||
| 						$item[2], | ||||
| 						$item[1] | ||||
| 					) | ||||
| 				); | ||||
| 				// Next remove the visitor.  Note we can't do both in a single query, looks like $wpdb doesn't like executing them together. | ||||
| 				$wpdb->query( | ||||
| 					$wpdb->prepare( "DELETE FROM {$wpdb->prefix}statistics_visitor WHERE `id` = %s;", $item[0] ) | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			$result_string = sprintf( | ||||
| 				__( '%s records purged successfully.', 'wp-statistics' ), | ||||
| 				'<code>' . count( $to_delete ) . '</code>' | ||||
| 			); | ||||
| 		} else { | ||||
| 			$result_string = __( 'No visitors found to purge.', 'wp-statistics' ); | ||||
| 		} | ||||
| 	} else { | ||||
| 		$result_string = __( 'Number of hits must be greater than or equal to 10!', 'wp-statistics' ); | ||||
| 	} | ||||
|  | ||||
| 	if ( $WP_Statistics->get_option( 'prune_report' ) == true ) { | ||||
| 		$blogname  = get_bloginfo( 'name' ); | ||||
| 		$blogemail = get_bloginfo( 'admin_email' ); | ||||
|  | ||||
| 		$headers[] = "From: $blogname <$blogemail>"; | ||||
| 		$headers[] = "MIME-Version: 1.0"; | ||||
| 		$headers[] = "Content-type: text/html; charset=utf-8"; | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 			$WP_Statistics->update_option( 'email_list', $blogemail ); | ||||
| 		} | ||||
|  | ||||
| 		wp_mail( | ||||
| 			$WP_Statistics->get_option( 'email_list' ), | ||||
| 			__( 'Database pruned on', 'wp-statistics' ) . ' ' . $blogname, | ||||
| 			$result_string, | ||||
| 			$headers | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	return $result_string; | ||||
| } | ||||
							
								
								
									
										154
									
								
								wp-content/plugins/wp-statistics/includes/functions/purge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								wp-content/plugins/wp-statistics/includes/functions/purge.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,154 @@ | ||||
| <?php | ||||
| function wp_statistics_purge_data( $purge_days ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	// If it's less than 30 days, don't do anything. | ||||
| 	if ( $purge_days > 30 ) { | ||||
| 		// Purge the visit data. | ||||
| 		$table_name  = $wpdb->prefix . 'statistics_visit'; | ||||
| 		$date_string = $WP_Statistics->current_date( 'Y-m-d', '-' . $purge_days ); | ||||
|  | ||||
| 		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) ); | ||||
|  | ||||
| 		if ( $result ) { | ||||
| 			// Update the historical count with what we purged. | ||||
| 			$historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visits'", $result ) ); | ||||
| 			if ( $historical_result == 0 ) { | ||||
| 				$wpdb->insert( | ||||
| 					$wpdb->prefix . "statistics_historical", | ||||
| 					array( | ||||
| 						'value'    => $result, | ||||
| 						'category' => 'visits', | ||||
| 						'page_id'  => - 2, | ||||
| 						'uri'      => '-2', | ||||
| 					) | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			$result_string = sprintf( __( '%s data older than %s days purged successfully.', 'wp-statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' ); | ||||
| 		} else { | ||||
| 			$result_string = sprintf( __( 'No records found to purge from %s!', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); | ||||
| 		} | ||||
|  | ||||
| 		// Purge the visitors data. | ||||
| 		$table_name = $wpdb->prefix . 'statistics_visitor'; | ||||
|  | ||||
| 		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) ); | ||||
|  | ||||
| 		if ( $result ) { | ||||
| 			// Update the historical count with what we purged. | ||||
| 			$historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visitors'", $result ) ); | ||||
| 			if ( $historical_result == 0 ) { | ||||
| 				$wpdb->insert( | ||||
| 					$wpdb->prefix . "statistics_historical", | ||||
| 					array( | ||||
| 						'value'    => $result, | ||||
| 						'category' => 'visitors', | ||||
| 						'page_id'  => - 1, | ||||
| 						'uri'      => '-1', | ||||
| 					) | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			$result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp-statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' ); | ||||
| 		} else { | ||||
| 			$result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); | ||||
| 		} | ||||
|  | ||||
| 		// Purge the exclusions data. | ||||
| 		$table_name = $wpdb->prefix . 'statistics_exclusions'; | ||||
|  | ||||
| 		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) ); | ||||
|  | ||||
| 		if ( $result ) { | ||||
| 			$result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp-statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' ); | ||||
| 		} else { | ||||
| 			$result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); | ||||
| 		} | ||||
|  | ||||
| 		// Purge the search data. | ||||
| 		$table_name = $wpdb->prefix . 'statistics_search'; | ||||
| 		$result     = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) ); | ||||
|  | ||||
| 		if ( $result ) { | ||||
| 			$result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp-statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' ); | ||||
| 		} else { | ||||
| 			$result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); | ||||
| 		} | ||||
|  | ||||
| 		// Purge the pages data, this is more complex as we want to save the historical data per page. | ||||
| 		$table_name = $wpdb->prefix . 'statistics_pages'; | ||||
| 		$historical = 0; | ||||
|  | ||||
| 		// The first thing we need to do is update the historical data by finding all the unique pages. | ||||
| 		$result = $wpdb->get_results( | ||||
| 			$wpdb->prepare( "SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string ) | ||||
| 		); | ||||
|  | ||||
| 		// If we have a result, let's store the historical data. | ||||
| 		if ( $result ) { | ||||
| 			// Loop through all the unique rows that were returned. | ||||
| 			foreach ( $result as $row ) { | ||||
| 				// Use the unique rows to get a total count from the database of all the data from the given URIs/Pageids that we're going to delete later. | ||||
| 				$historical = $wpdb->get_var( | ||||
| 					$wpdb->prepare( | ||||
| 						"SELECT sum(count) FROM {$table_name} WHERE `uri` = %s AND `date` < %s", | ||||
| 						$row->uri, | ||||
| 						$date_string | ||||
| 					) | ||||
| 				); | ||||
|  | ||||
| 				// Do an update of the historical data. | ||||
| 				$uresult = $wpdb->query( | ||||
| 					$wpdb->prepare( | ||||
| 						"UPDATE {$wpdb->prefix}statistics_historical SET `value` = value + %d WHERE `uri` = %s AND `category` = 'uri'", | ||||
| 						$historical, | ||||
| 						$row->uri, | ||||
| 						$date_string | ||||
| 					) | ||||
| 				); | ||||
|  | ||||
| 				// If we failed it's because this is the first time we've seen this URI/pageid so let's create a historical row for it. | ||||
| 				if ( $uresult == 0 ) { | ||||
| 					$wpdb->insert( | ||||
| 						$wpdb->prefix . "statistics_historical", | ||||
| 						array( | ||||
| 							'value'    => $historical, | ||||
| 							'category' => 'uri', | ||||
| 							'uri'      => $row->uri, | ||||
| 							'page_id'  => wp_statistics_uri_to_id( $row->uri ), | ||||
| 						) | ||||
| 					); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Now that we've done all of the required historical data storage, we can actually delete the data from the database. | ||||
| 		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) ); | ||||
|  | ||||
| 		if ( $result ) { | ||||
| 			$result_string .= '<br>' . sprintf( __( '%s data older than %s days purged successfully.', 'wp-statistics' ), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>' ); | ||||
| 		} else { | ||||
| 			$result_string .= '<br>' . sprintf( __( 'No records found to purge from %s!', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'prune_report' ) == true ) { | ||||
| 			$blogname  = get_bloginfo( 'name' ); | ||||
| 			$blogemail = get_bloginfo( 'admin_email' ); | ||||
|  | ||||
| 			$headers[] = "From: $blogname <$blogemail>"; | ||||
| 			$headers[] = "MIME-Version: 1.0"; | ||||
| 			$headers[] = "Content-type: text/html; charset=utf-8"; | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 				$WP_Statistics->update_option( 'email_list', $blogemail ); | ||||
| 			} | ||||
|  | ||||
| 			wp_mail( $WP_Statistics->get_option( 'email_list' ), __( 'Database pruned on', 'wp-statistics' ) . ' ' . WP_Statistics_Admin_Pages::sanitize_mail_subject( $blogname ), $result_string, $headers ); | ||||
| 		} | ||||
|  | ||||
| 		return $result_string; | ||||
| 	} else { | ||||
| 		return __( 'Please select a value over 30 days.', 'wp-statistics' ); | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,10 @@ | ||||
| <?php | ||||
| if ( ! defined( 'ABSPATH' ) ) | ||||
|     exit; | ||||
|  | ||||
| function wp_statistic_tinymce_plugin_translation() { | ||||
|     $lang = WP_Statistics_TinyMCE::lang(); | ||||
|     $translated = $lang['translate']; | ||||
|     return $translated; | ||||
| } | ||||
| $strings = wp_statistic_tinymce_plugin_translation(); | ||||
							
								
								
									
										2
									
								
								wp-content/plugins/wp-statistics/includes/index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								wp-content/plugins/wp-statistics/includes/index.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| <?php | ||||
| # Silence is golden. | ||||
							
								
								
									
										313
									
								
								wp-content/plugins/wp-statistics/includes/log/all-browsers.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										313
									
								
								wp-content/plugins/wp-statistics/includes/log/all-browsers.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,313 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
|  | ||||
| $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime ); | ||||
| $rangeenddate   = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime ); | ||||
|  | ||||
| // Browsers | ||||
| $Browsers = wp_statistics_ua_list(); | ||||
| if ( ! is_array( $Browsers ) ) { | ||||
| 	$Browsers = array(); | ||||
| } | ||||
|  | ||||
| natcasesort( $Browsers ); | ||||
| $BrowserVisits = array(); | ||||
| $total         = 0; | ||||
| foreach ( $Browsers as $Browser ) { | ||||
| 	//Get List Of count Visitor By Agent | ||||
| 	$BrowserVisits[ $Browser ] = wp_statistics_useragent( $Browser, $rangestartdate, $rangeenddate ); | ||||
| 	//Sum This agent | ||||
| 	$total += $BrowserVisits[ $Browser ]; | ||||
| } | ||||
|  | ||||
| //Add Unknown Agent to total | ||||
| $total += $other_agent_count = $wpdb->get_var( 'SELECT COUNT(*) FROM `' . $wpdb->prefix . 'statistics_visitor` WHERE `last_counter` BETWEEN \'' . $rangestartdate . '\' AND \'' . $rangeenddate . '\' AND `agent` NOT IN (\'' . implode( "','", $Browsers ) . '\')' ); | ||||
|  | ||||
| $browser_name  = array(); | ||||
| $i             = 0; | ||||
| $browser_value = array(); | ||||
| $browser_color = array(); | ||||
|  | ||||
| foreach ( $BrowserVisits as $key => $value ) { | ||||
| 	if ( $value > 0 ) { | ||||
| 		$i ++; | ||||
| 		$browser_name[]  = "'" . wp_statistics_get_browser_list( strtolower( $key ) ) . "'"; | ||||
| 		$browser_value[] = $value; | ||||
| 		$browser_color[] = wp_statistics_generate_rgba_color( $i, '0.4' ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //Add Unknown Agent | ||||
| if ( $other_agent_count > 0 ) { | ||||
| 	$browser_name[]  = "'" . __( 'Other', 'wp-statistics' ) . "'"; | ||||
| 	$browser_value[] = $other_agent_count; | ||||
| 	$browser_color[] = wp_statistics_generate_rgba_color( 10, '0.4' ); | ||||
| } | ||||
|  | ||||
| // Platforms | ||||
| $Platforms = wp_statistics_platform_list( null, $rangestartdate, $rangeenddate ); | ||||
| if ( ! is_array( $Platforms ) ) { | ||||
| 	$Platforms = array(); | ||||
| } | ||||
|  | ||||
| natcasesort( $Platforms ); | ||||
| $PlatformVisits = array(); | ||||
| foreach ( $Platforms as $Platform ) { | ||||
| 	$PlatformVisits[ $Platform ] = wp_statistics_platform( $Platform ); | ||||
| } | ||||
|  | ||||
| $i = 0; | ||||
| foreach ( $PlatformVisits as $key => $value ) { | ||||
| 	$i ++; | ||||
| 	$platform_name[]  = "'" . $key . "'"; | ||||
| 	$platform_value[] = $value; | ||||
| 	$platform_color[] = wp_statistics_generate_rgba_color( $i, '0.4' ); | ||||
| } | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Browser Statistics', 'wp-statistics' ) ); ?> | ||||
|     <div><?php wp_statistics_date_range_selector( WP_Statistics::$page['browser'], $daysToDisplay ); ?></div> | ||||
|     <div class="postbox-container" style="width: 48%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Browsers', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="browsers-log" height="200"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("browsers-log").getContext('2d'); | ||||
|                             <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'pie', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $browser_name ); ?>], | ||||
|                                     datasets: [{ | ||||
|                                         label: '<?php _e( 'Browsers', 'wp-statistics' ); ?>', | ||||
|                                         data: [<?php echo implode( ', ', $browser_value ); ?>], | ||||
|                                         backgroundColor: [<?php echo implode( ', ', $browser_color ); ?>], | ||||
|                                     }] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         callbacks: { | ||||
|                                             label: function (tooltipItem, data) { | ||||
|                                                 var dataset = data.datasets[tooltipItem.datasetIndex]; | ||||
|                                                 var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) { | ||||
|                                                     return previousValue + currentValue; | ||||
|                                                 }); | ||||
|                                                 var currentValue = dataset.data[tooltipItem.index]; | ||||
|                                                 var precentage = Math.floor(((currentValue / total) * 100) + 0.5); | ||||
|                                                 return precentage + "% - " + data.labels[tooltipItem.index]; | ||||
|                                             } | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 48%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Platform', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="platforms-log" height="200"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("platforms-log").getContext('2d'); | ||||
|                             <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'pie', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $platform_name ); ?>], | ||||
|                                     datasets: [{ | ||||
|                                         label: '<?php _e( 'Platforms', 'wp-statistics' ); ?>', | ||||
|                                         data: [<?php echo implode( ', ', $platform_value ); ?>], | ||||
|                                         backgroundColor: [<?php echo implode( ', ', $platform_color ); ?>], | ||||
|                                     }] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         callbacks: { | ||||
|                                             label: function (tooltipItem, data) { | ||||
|                                                 var dataset = data.datasets[tooltipItem.datasetIndex]; | ||||
|                                                 var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) { | ||||
|                                                     return previousValue + currentValue; | ||||
|                                                 }); | ||||
|                                                 var currentValue = dataset.data[tooltipItem.index]; | ||||
|                                                 var precentage = Math.floor(((currentValue / total) * 100) + 0.5); | ||||
|                                                 return precentage + "% - " + data.labels[tooltipItem.index]; | ||||
|                                             } | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div style="width: 100%; clear: both;"> | ||||
|         <hr/> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
| 				<?php | ||||
| 				$BrowsersCount = count( $Browsers ); | ||||
| 				for ( $BrowserCount = 0; $BrowserCount < $BrowsersCount; $BrowserCount ++ ) { | ||||
| 					if ( $BrowserCount % 3 == 0 ) { | ||||
| 						wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate ); | ||||
| 					} | ||||
| 				} | ||||
| 				?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 30%; float: left; margin-right: 20px;"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
| 				<?php | ||||
| 				for ( $BrowserCount = 0; $BrowserCount < $BrowsersCount; $BrowserCount ++ ) { | ||||
| 					if ( $BrowserCount % 3 == 1 ) { | ||||
| 						wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate ); | ||||
| 					} | ||||
| 				} | ||||
| 				?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 30%; float: left"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
| 				<?php | ||||
| 				for ( $BrowserCount = 0; $BrowserCount < $BrowsersCount; $BrowserCount ++ ) { | ||||
| 					if ( $BrowserCount % 3 == 2 ) { | ||||
| 						wp_statistics_browser_version_stats( $Browsers[ $BrowserCount ], $rangestartdate, $rangeenddate ); | ||||
| 					} | ||||
| 				} | ||||
| 				?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| <?php | ||||
| function wp_statistics_browser_version_stats( $Browser, $rangestartdate, $rangeenddate ) { | ||||
| 	$id            = 'browser-stats-' . $Browser; | ||||
| 	$browser_tag   = strtolower( preg_replace( '/[^a-zA-Z]/', '', $Browser ) ); | ||||
| 	$versions      = wp_statistics_agent_version_list( $Browser, $rangestartdate, $rangeenddate ); | ||||
| 	$version_name  = array(); | ||||
| 	$version_value = array(); | ||||
| 	$browser_color = array(); | ||||
| 	$i             = 0; | ||||
|  | ||||
| 	if ( count( $versions ) < 10 ) { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $versions as $key => $value ) { | ||||
| 		$i ++; | ||||
| 		$version_value[ $value ] = wp_statistics_agent_version( $Browser, $value, $rangestartdate, $rangeenddate ); | ||||
| 		$version_color[]         = wp_statistics_generate_rgba_color( $i, '0.4' ); | ||||
| 	} | ||||
|  | ||||
| 	natcasesort( $version_value ); | ||||
| 	$version_value = array_slice( $version_value, - 20 ); | ||||
|  | ||||
| 	foreach ( $version_value as $key => $value ) { | ||||
| 		$version_name[] = "'" . $key . "'"; | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox"> | ||||
| 		<?php $paneltitle = sprintf( __( '%s Version', 'wp-statistics' ), wp_statistics_get_browser_list( strtolower( $Browser ) ) ); ?> | ||||
|         <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 			<span class="screen-reader-text"><?php printf( | ||||
| 					__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 					$paneltitle | ||||
| 				); ?></span> | ||||
|             <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|         </button> | ||||
|         <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|         <div class="inside"> | ||||
|             <canvas id="<?php echo $id; ?>" height="250"></canvas> | ||||
|             <script> | ||||
|                 var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d'); | ||||
|                 <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                 var ChartJs = new Chart(ctx, { | ||||
|                     type: 'doughnut', | ||||
|                     data: { | ||||
|                         labels: [<?php echo implode( ', ', $version_name ); ?>], | ||||
|                         datasets: [{ | ||||
|                             label: '<?php _e( 'Platforms', 'wp-statistics' ); ?>', | ||||
|                             data: [<?php echo implode( ', ', $version_value ); ?>], | ||||
|                             backgroundColor: [<?php echo implode( ', ', $version_color ); ?>], | ||||
|                         }] | ||||
|                     }, | ||||
|                     options: { | ||||
|                         responsive: true, | ||||
|                         legend: { | ||||
|                             display: false, | ||||
|                         }, | ||||
|                         tooltips: { | ||||
|                             callbacks: { | ||||
|                                 label: function (tooltipItem, data) { | ||||
|                                     var dataset = data.datasets[tooltipItem.datasetIndex]; | ||||
|                                     var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) { | ||||
|                                         return previousValue + currentValue; | ||||
|                                     }); | ||||
|                                     var currentValue = dataset.data[tooltipItem.index]; | ||||
|                                     var precentage = Math.floor(((currentValue / total) * 100) + 0.5); | ||||
|                                     return precentage + "% - " + data.labels[tooltipItem.index]; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|             </script> | ||||
|         </div> | ||||
|     </div> | ||||
| <?php } ?> | ||||
							
								
								
									
										261
									
								
								wp-content/plugins/wp-statistics/includes/log/authors.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										261
									
								
								wp-content/plugins/wp-statistics/includes/log/authors.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,261 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
|  | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Author Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php | ||||
| 	//Set Default Time Picker Option | ||||
| 	list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| 	if ( array_key_exists( 'author', $_GET ) ) { | ||||
| 		$author = intval( $_GET['author'] ); | ||||
| 	} else { | ||||
| 		if ( array_key_exists( 'preauthor', $_GET ) ) { | ||||
| 			$author = intval( $_GET['preauthor'] ); | ||||
| 		} else { | ||||
| 			$author = 0; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$html = __( 'Select Author', 'wp-statistics' ) . ': '; | ||||
| 	$html .= '<select name="author" id="author">'; | ||||
|  | ||||
| 	$authors_list = get_users( 'who=authors' ); | ||||
|  | ||||
| 	foreach ( $authors_list as $author_obj ) { | ||||
|  | ||||
| 		if ( $author_obj !== false ) { | ||||
| 			if ( $author_obj->ID === $author ) { | ||||
| 				$selected = ' SELECTED'; | ||||
| 			} else { | ||||
| 				$selected = ''; | ||||
| 			} | ||||
|  | ||||
| 			$html .= '<option value="' . $author_obj->ID . "\"{$selected}>" . ( $author_obj->display_name != "" ? $author_obj->display_name : $author_obj->user_login ) . '</option>'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$html .= '</select>'; | ||||
|  | ||||
| 	$html .= ' <input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">'; | ||||
| 	$html .= '<br>'; | ||||
|  | ||||
| 	list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 		$daysToDisplay, | ||||
| 		$rangestart, | ||||
| 		$rangeend | ||||
| 	); | ||||
|  | ||||
| 	wp_statistics_date_range_selector( | ||||
| 		WP_Statistics::$page['authors'], | ||||
| 		$daysToDisplay, | ||||
| 		null, | ||||
| 		null, | ||||
| 		'&preauthor=' . $author, | ||||
| 		$html | ||||
| 	); | ||||
|  | ||||
| 	$args = array( | ||||
| 		'author' => $author, | ||||
| 	); | ||||
|  | ||||
| 	$posts = get_posts( $args ); | ||||
|  | ||||
| 	$visit_total   = 0; | ||||
| 	$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 ); | ||||
| 	$posts_stats   = array(); | ||||
| 	$visits        = array(); | ||||
|  | ||||
| 	// Setup the array, otherwise PHP may throw an error. | ||||
| 	foreach ( $posts as $post ) { | ||||
| 		$posts_stats[ $post->ID ] = 0; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
|  | ||||
| 		$stat = 0; | ||||
| 		foreach ( $posts as $post ) { | ||||
| 			$temp_stat                = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID ); | ||||
| 			$posts_stats[ $post->ID ] += $temp_stat; | ||||
| 			$stat                     = $temp_stat; | ||||
| 		} | ||||
|  | ||||
| 		$visits[]    = $stat; | ||||
| 		$visit_total += $stat; | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Author Statistics Chart', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="hit-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
| 							<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Visits', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $visits ); ?>], | ||||
|                                             backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||
|                                             borderColor: 'rgba(54, 162, 235, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Author Statistics Summary', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="summary-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th></th> | ||||
|                                 <th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Number of posts by author:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Chart Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'All Time Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php | ||||
|  | ||||
| 										$stat = 0; | ||||
| 										foreach ( $posts as $post ) { | ||||
| 											$stat += wp_statistics_pages( 'total', null, $post->ID ); | ||||
| 										} | ||||
|  | ||||
| 										echo number_format_i18n( $stat ); ?></span></th> | ||||
|                             </tr> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Author Posts Sorted by Hits', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="post-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Post Title', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
| 							<?php | ||||
| 							arsort( $posts_stats ); | ||||
|  | ||||
| 							$posts_by_id = array(); | ||||
|  | ||||
| 							foreach ( $posts as $post ) { | ||||
| 								$posts_by_id[ $post->ID ] = $post; | ||||
| 							} | ||||
|  | ||||
| 							foreach ( $posts_stats as $post_id => $post_stat ) { | ||||
| 								$post_obj = $posts_by_id[ $post_id ]; | ||||
|  | ||||
| 								?> | ||||
|                                 <tr> | ||||
|                                     <th> | ||||
|                                         <a href="<?php echo get_permalink( | ||||
| 											$post_obj | ||||
| 										); ?>"><?php echo esc_html( $post_obj->post_title ); ?></a> | ||||
|                                     </th> | ||||
|                                     <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span> | ||||
|                                     </th> | ||||
|                                 </tr> | ||||
| 								<?php | ||||
| 							} | ||||
| 							?> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
							
								
								
									
										248
									
								
								wp-content/plugins/wp-statistics/includes/log/categories.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										248
									
								
								wp-content/plugins/wp-statistics/includes/log/categories.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,248 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Category Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php | ||||
| 	//Set Default Time Picker Option | ||||
| 	list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| 	if ( array_key_exists( 'cat', $_GET ) ) { | ||||
| 		$category = intval( $_GET['cat'] ); | ||||
| 	} else { | ||||
| 		if ( array_key_exists( 'precat', $_GET ) ) { | ||||
| 			$category = intval( $_GET['precat'] ); | ||||
| 		} else { | ||||
| 			$category = 0; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$html = __( 'Select Category', 'wp-statistics' ) . ': '; | ||||
|  | ||||
| 	$args = array( | ||||
| 		'selected' => $category, | ||||
| 		'echo'     => 0, | ||||
| 	); | ||||
|  | ||||
| 	$html .= wp_dropdown_categories( $args ); | ||||
| 	$html .= '<input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">'; | ||||
| 	$html .= '<br>'; | ||||
|  | ||||
| 	list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 		$daysToDisplay, | ||||
| 		$rangestart, | ||||
| 		$rangeend | ||||
| 	); | ||||
|  | ||||
| 	wp_statistics_date_range_selector( | ||||
| 		WP_Statistics::$page['categories'], | ||||
| 		$daysToDisplay, | ||||
| 		null, | ||||
| 		null, | ||||
| 		'&precat=' . $category, | ||||
| 		$html | ||||
| 	); | ||||
|  | ||||
| 	$args = array( | ||||
| 		'category' => $category, | ||||
| 	); | ||||
|  | ||||
| 	$posts = get_posts( $args ); | ||||
|  | ||||
| 	$visit_total   = 0; | ||||
| 	$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 ); | ||||
| 	$posts_stats   = array(); | ||||
| 	$visits        = array(); | ||||
|  | ||||
| 	// Setup the array, otherwise PHP may throw an error. | ||||
| 	foreach ( $posts as $post ) { | ||||
| 		$posts_stats[ $post->ID ] = 0; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
|  | ||||
| 		$stat = 0; | ||||
| 		foreach ( $posts as $post ) { | ||||
| 			$temp_stat                = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID ); | ||||
| 			$posts_stats[ $post->ID ] += $temp_stat; | ||||
| 			$stat                     = $temp_stat; | ||||
| 		} | ||||
|  | ||||
| 		$visits[]    = $stat; | ||||
| 		$visit_total += $stat; | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Category Statistics Chart', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="hit-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
| 							<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Visits', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $visits ); ?>], | ||||
|                                             backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||
|                                             borderColor: 'rgba(54, 162, 235, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Category Statistics Summary', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="summary-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th></th> | ||||
|                                 <th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Number of posts in category:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Chart Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'All Time Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php | ||||
|  | ||||
| 										$stat = 0; | ||||
| 										foreach ( $posts as $post ) { | ||||
| 											$stat += wp_statistics_pages( 'total', null, $post->ID ); | ||||
| 										} | ||||
|  | ||||
| 										echo number_format_i18n( $stat ); ?></span></th> | ||||
|                             </tr> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Category Posts Sorted by Hits', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="post-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Post Title', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
| 							<?php | ||||
| 							arsort( $posts_stats ); | ||||
|  | ||||
| 							$posts_by_id = array(); | ||||
|  | ||||
| 							foreach ( $posts as $post ) { | ||||
| 								$posts_by_id[ $post->ID ] = $post; | ||||
| 							} | ||||
|  | ||||
| 							foreach ( $posts_stats as $post_id => $post_stat ) { | ||||
| 								$post_obj = $posts_by_id[ $post_id ]; | ||||
|  | ||||
| 								?> | ||||
|                                 <tr> | ||||
|                                     <th> | ||||
|                                         <a href="<?php echo get_permalink( | ||||
| 											$post_obj | ||||
| 										); ?>"><?php echo esc_html( $post_obj->post_title ); ?></a> | ||||
|                                     </th> | ||||
|                                     <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span> | ||||
|                                     </th> | ||||
|                                 </tr> | ||||
| 								<?php | ||||
| 							} | ||||
| 							?> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
							
								
								
									
										269
									
								
								wp-content/plugins/wp-statistics/includes/log/exclusions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										269
									
								
								wp-content/plugins/wp-statistics/includes/log/exclusions.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,269 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| if ( $WP_Statistics->get_option( 'record_exclusions' ) != 1 ) { | ||||
| 	echo "<div class='updated settings-error'><p><strong>" . | ||||
| 	     __( | ||||
| 		     'Attention: Exclusion are not currently set to be recorded, the results below may not reflect current statistics!', | ||||
| 		     'wp-statistics' | ||||
| 	     ) . | ||||
| 	     "</strong></p></div>"; | ||||
| } | ||||
|  | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
| $total_stats = $WP_Statistics->get_option( 'chart_totals' ); | ||||
|  | ||||
| $excluded_reasons          = array( | ||||
| 	'Robot', | ||||
| 	'Browscap', | ||||
| 	'IP Match', | ||||
| 	'Self Referral', | ||||
| 	'Login Page', | ||||
| 	'User Role', | ||||
| 	'GeoIP', | ||||
| 	'Hostname', | ||||
| 	'Robot Threshold', | ||||
| 	'Honey Pot', | ||||
| 	'Feeds', | ||||
| 	'Excluded URL', | ||||
| 	'404 Pages', | ||||
| 	'Referrer Spam', | ||||
| 	'AJAX Request', | ||||
| 	'CronJob', | ||||
| ); | ||||
| $excluded_reason_tags      = array( | ||||
| 	'Robot'           => 'robot', | ||||
| 	'Browscap'        => 'browscap', | ||||
| 	'IP Match'        => 'ipmatch', | ||||
| 	'Self Referral'   => 'selfreferral', | ||||
| 	'Login Page'      => 'loginpage', | ||||
| 	'User Role'       => 'userrole', | ||||
| 	'Total'           => 'total', | ||||
| 	'GeoIP'           => 'geoip', | ||||
| 	'Hostname'        => 'hostname', | ||||
| 	'Robot Threshold' => 'robot_threshold', | ||||
| 	'Honey Pot'       => 'honeypot', | ||||
| 	'Feeds'           => 'feed', | ||||
| 	'Excluded URL'    => 'excluded_url', | ||||
| 	'404 Pages'       => 'excluded_404s', | ||||
| 	'Referrer Spam'   => 'referrer_spam', | ||||
| 	'AJAX Request'    => 'ajax', | ||||
| 	'CronJob'         => 'cronjob', | ||||
| ); | ||||
| $excluded_reason_db        = array( | ||||
| 	'Robot'           => 'robot', | ||||
| 	'Browscap'        => 'browscap', | ||||
| 	'IP Match'        => 'ip match', | ||||
| 	'Self Referral'   => 'self referral', | ||||
| 	'Login Page'      => 'login page', | ||||
| 	'User Role'       => 'user role', | ||||
| 	'Total'           => 'total', | ||||
| 	'GeoIP'           => 'geoip', | ||||
| 	'Hostname'        => 'hostname', | ||||
| 	'Robot Threshold' => 'robot_threshold', | ||||
| 	'Honey Pot'       => 'honeypot', | ||||
| 	'Feeds'           => 'feed', | ||||
| 	'Excluded URL'    => 'excluded url', | ||||
| 	'404 Pages'       => '404', | ||||
| 	'Referrer Spam'   => 'referrer_spam', | ||||
| 	'AJAX Request'    => 'ajax', | ||||
| 	'CronJob'         => 'cronjob', | ||||
| ); | ||||
| $excluded_reason_translate = array( | ||||
| 	'Robot'           => json_encode( __( 'Robot', 'wp-statistics' ) ), | ||||
| 	'Browscap'        => json_encode( __( 'Browscap', 'wp-statistics' ) ), | ||||
| 	'IP Match'        => json_encode( __( 'IP Match', 'wp-statistics' ) ), | ||||
| 	'Self Referral'   => json_encode( __( 'Self Referral', 'wp-statistics' ) ), | ||||
| 	'Login Page'      => json_encode( __( 'Login Page', 'wp-statistics' ) ), | ||||
| 	'User Role'       => json_encode( __( 'User Role', 'wp-statistics' ) ), | ||||
| 	'Total'           => json_encode( __( 'Total', 'wp-statistics' ) ), | ||||
| 	'GeoIP'           => json_encode( __( 'GeoIP', 'wp-statistics' ) ), | ||||
| 	'Hostname'        => json_encode( __( 'Hostname', 'wp-statistics' ) ), | ||||
| 	'Robot Threshold' => json_encode( __( 'Robot Threshold', 'wp-statistics' ) ), | ||||
| 	'Honey Pot'       => json_encode( __( 'Honey Pot', 'wp-statistics' ) ), | ||||
| 	'Feeds'           => json_encode( __( 'Feeds', 'wp-statistics' ) ), | ||||
| 	'Excluded URL'    => json_encode( __( 'Excluded URL', 'wp-statistics' ) ), | ||||
| 	'404 Pages'       => json_encode( __( '404 Pages', 'wp-statistics' ) ), | ||||
| 	'Referrer Spam'   => json_encode( __( 'Referrer Spam', 'wp-statistics' ) ), | ||||
| 	'AJAX Request'    => json_encode( __( 'AJAX Request', 'wp-statistics' ) ), | ||||
| 	'CronJob'         => json_encode( __( 'CronJob', 'wp-statistics' ) ), | ||||
| ); | ||||
| $excluded_results          = array( 'Total' => array() ); | ||||
| $excluded_total            = 0; | ||||
|  | ||||
| foreach ( $excluded_reasons as $reason ) { | ||||
| 	// The reasons array above is used both for display and internal purposes.  Internally the values are all lower case but the array | ||||
| 	// is created with mixed case so it looks nice to the user.  Therefore we have to convert it to lower case here. | ||||
| 	$thisreason = $excluded_reason_db[ $reason ]; | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
|  | ||||
| 		// We're looping through the days backwards, so let's fine out what date we want to look at. | ||||
| 		$thisdate = $WP_Statistics->real_current_date( 'Y-m-d', '-' . $i, $rangeend_utime ); | ||||
|  | ||||
| 		// Create the SQL query string to get the data. | ||||
| 		$query = $wpdb->prepare( | ||||
| 			"SELECT count FROM {$wpdb->prefix}statistics_exclusions WHERE reason = %s AND date = %s", | ||||
| 			$thisreason, | ||||
| 			$thisdate | ||||
| 		); | ||||
|  | ||||
| 		// Execute the query. | ||||
| 		$excluded_results[ $reason ][ $i ] = $wpdb->get_var( $query ); | ||||
|  | ||||
| 		// If we're returned an error or a FALSE value, then let's make sure it's set to a numerical 0. | ||||
| 		if ( $excluded_results[ $reason ][ $i ] < 1 ) { | ||||
| 			$excluded_results[ $reason ][ $i ] = 0; | ||||
| 		} | ||||
|  | ||||
| 		// Make sure to initialize the results so we don't get warnings when WP_DEBUG is enabled. | ||||
| 		if ( ! array_key_exists( $i, $excluded_results['Total'] ) ) { | ||||
| 			$excluded_results['Total'][ $i ] = 0; | ||||
| 		} | ||||
|  | ||||
| 		// We're totalling things up here for use later. | ||||
| 		$excluded_results['Total'][ $i ] += $excluded_results[ $reason ][ $i ]; | ||||
| 		$excluded_total                  += $excluded_results[ $reason ][ $i ]; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| $excuded_all_time = $wpdb->get_var( "SELECT SUM(count) FROM {$wpdb->prefix}statistics_exclusions" ); | ||||
|  | ||||
| // If the chart totals is enabled, cheat a little and just add another reason category to the list so it gets generated later. | ||||
| if ( $total_stats == 1 ) { | ||||
| 	$excluded_reasons[] = 'Total'; | ||||
| } | ||||
|  | ||||
| for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 	$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
| } | ||||
|  | ||||
| $stats = array(); | ||||
| foreach ( $excluded_reasons as $reason ) { | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$stats[ $reason ][] = $excluded_results[ $reason ][ $i ]; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Exclusions Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php wp_statistics_date_range_selector( WP_Statistics::$page['exclusions'], $daysToDisplay ); ?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Exclusions Statistical Chart', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <div class="inside"> | ||||
|                             <canvas id="hit-stats" height="80"></canvas> | ||||
|                             <script type='text/javascript' src='<?php echo WP_Statistics::$reg['plugin-url']; ?>assets/js/Chart.bundle.min.js'></script> | ||||
|                             <script> | ||||
|                                 var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
|                                 <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                                 var ChartJs = new Chart(ctx, { | ||||
|                                     type: 'line', | ||||
|                                     data: { | ||||
|                                         labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                         datasets: [ | ||||
| 											<?php foreach ($stats as $key => $value) : $i ++; ?> | ||||
|                                             { | ||||
|                                                 label: '<?php echo $key; ?>', | ||||
|                                                 data: [<?php echo implode( ',', $value ); ?>], | ||||
|                                                 backgroundColor: <?php echo wp_statistics_generate_rgba_color( $i, '0.2' ); ?>, | ||||
|                                                 borderColor: <?php echo wp_statistics_generate_rgba_color( $i, '1' ); ?>, | ||||
|                                                 borderWidth: 1, | ||||
|                                                 fill: true, | ||||
|                                             }, | ||||
| 											<?php endforeach; ?> | ||||
|                                         ] | ||||
|                                     }, | ||||
|                                     options: { | ||||
|                                         responsive: true, | ||||
|                                         legend: { | ||||
|                                             position: 'bottom', | ||||
|                                         }, | ||||
|                                         title: { | ||||
|                                             display: true, | ||||
|                                             text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                         }, | ||||
|                                         tooltips: { | ||||
|                                             mode: 'index', | ||||
|                                             intersect: false, | ||||
|                                         }, | ||||
|                                         scales: { | ||||
|                                             yAxes: [{ | ||||
|                                                 ticks: { | ||||
|                                                     beginAtZero: true | ||||
|                                                 } | ||||
|                                             }] | ||||
|                                         } | ||||
|                                     } | ||||
|                                 }); | ||||
|                             </script> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Hits Statistics Summary', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="summary-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th></th> | ||||
|                                 <th class="th-center"><?php _e( 'Exclusions', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Chart Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $excluded_total ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'All Time Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"> | ||||
|                                     <span><?php echo number_format_i18n( $excuded_all_time ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										166
									
								
								wp-content/plugins/wp-statistics/includes/log/hit-statistics.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								wp-content/plugins/wp-statistics/includes/log/hit-statistics.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,166 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Hit Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php | ||||
| 	//Set Default Time Picker Option | ||||
| 	list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| 	list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 		$daysToDisplay, | ||||
| 		$rangestart, | ||||
| 		$rangeend | ||||
| 	); | ||||
|  | ||||
| 	wp_statistics_date_range_selector( WP_Statistics::$page['hits'], $daysToDisplay ); | ||||
|  | ||||
| 	$visit_total   = 0; | ||||
| 	$visitor_total = 0; | ||||
| 	$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 ); | ||||
| 	$visitors      = array(); | ||||
| 	$visits        = array(); | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$stat        = wp_statistics_visit( '-' . (int) ( $i + $daysInThePast ), true ); | ||||
| 		$visit_total += $stat; | ||||
| 		$visits[]    = $stat; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$stat          = wp_statistics_visitor( '-' . (int) ( $i + $daysInThePast ), true ); | ||||
| 		$visitor_total += $stat; | ||||
| 		$visitors[]    = $stat; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Hits Statistics Chart', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="hit-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
|                             <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
| 										<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?> | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Visitors', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $visitors ); ?>], | ||||
|                                             backgroundColor: 'rgba(255, 99, 132, 0.2)', | ||||
|                                             borderColor: 'rgba(255, 99, 132, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
| 										<?php } ?> | ||||
| 										<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?> | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Visits', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $visits ); ?>], | ||||
|                                             backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||
|                                             borderColor: 'rgba(54, 162, 235, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
| 										<?php } ?> | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Hits Statistics Summary', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="summary-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th></th> | ||||
|                                 <th class="th-center"><?php _e( 'Visits', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><?php _e( 'Visitors', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Chart Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span> | ||||
|                                 </th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $visitor_total ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'All Time Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"> | ||||
|                                     <span><?php echo number_format_i18n( wp_statistics_visit( 'total' ) ); ?></span> | ||||
|                                 </th> | ||||
|                                 <th class="th-center"> | ||||
| 									<span><?php echo number_format_i18n( | ||||
| 											wp_statistics_visitor( 'total', null, true ) | ||||
| 										); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
							
								
								
									
										223
									
								
								wp-content/plugins/wp-statistics/includes/log/last-search.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										223
									
								
								wp-content/plugins/wp-statistics/includes/log/last-search.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,223 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| $search_engines = wp_statistics_searchengine_list(); | ||||
|  | ||||
| $search_result['All'] = wp_statistics_searchword( 'all', 'total' ); | ||||
|  | ||||
| foreach ( $search_engines as $key => $se ) { | ||||
| 	$search_result[ $key ] = wp_statistics_searchword( $key, 'total' ); | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'referred', $_GET ) ) { | ||||
| 	if ( $_GET['referred'] != '' ) { | ||||
| 		$referred = $_GET['referred']; | ||||
| 	} else { | ||||
| 		$referred = 'All'; | ||||
| 	} | ||||
| } else { | ||||
| 	$referred = 'All'; | ||||
| } | ||||
|  | ||||
| $total = $search_result[ $referred ]; | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Latest Search Words', 'wp-statistics' ) ); ?> | ||||
|     <br/> | ||||
|     <ul class="subsubsub"> | ||||
| 		<?php | ||||
| 		$search_result_count = count( $search_result ); | ||||
| 		$i                   = 0; | ||||
| 		$separator           = ' | '; | ||||
|  | ||||
| 		foreach ( $search_result as $key => $value ) { | ||||
| 			$i ++; | ||||
|  | ||||
| 			if ( $i == $search_result_count ) { | ||||
| 				$separator = ''; | ||||
| 			} | ||||
|  | ||||
| 			if ( $key == 'All' ) { | ||||
| 				$tag       = ''; | ||||
| 				$name      = 'All'; | ||||
| 				$translate = __( 'All', 'wp-statistics' ); | ||||
| 			} else { | ||||
| 				$tag       = $search_engines[ $key ]['tag']; | ||||
| 				$name      = $search_engines[ $key ]['name']; | ||||
| 				$translate = $search_engines[ $key ]['translated']; | ||||
| 			} | ||||
|  | ||||
| 			//Check current class | ||||
| 			$current = ""; | ||||
| 			if ( ( ! isset( $_GET['referred'] ) and $name == 'All' ) || ( isset( $_GET['referred'] ) and $tag == trim( $_GET['referred'] ) ) ) { | ||||
| 				$current = 'class="current" '; | ||||
| 			} | ||||
|  | ||||
| 			echo "<li><a {$current} href='" . ( $name == 'All' ? WP_Statistics_Admin_Pages::admin_url( 'words' ) : WP_Statistics_Admin_Pages::admin_url( 'words', array( 'referred' => $tag ) ) ) . "'>" . $translate . " <span class='count'>(" . number_format_i18n( $value ) . ")</span></a></li>{$separator}"; | ||||
| 		} | ||||
| 		?> | ||||
|     </ul> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Latest Search Word Statistics', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <div class='log-latest'> | ||||
| 							<?php | ||||
| 							if ( $total > 0 ) { | ||||
| 								// Instantiate pagination object with appropriate arguments | ||||
| 								$items_per_page = 10; | ||||
| 								$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 								$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
| 								$start          = $offset; | ||||
| 								$end            = $offset + $items_per_page; | ||||
|  | ||||
| 								// Retrieve MySQL data | ||||
| 								if ( $referred && $referred != '' ) { | ||||
| 									$search_query = wp_statistics_searchword_query( $referred ); | ||||
| 								} else { | ||||
| 									$search_query = wp_statistics_searchword_query( 'all' ); | ||||
| 								} | ||||
|  | ||||
| 								// Determine if we're using the old or new method of storing search engine info and build the appropriate table name. | ||||
| 								$tablename = $wpdb->prefix . 'statistics_'; | ||||
|  | ||||
| 								if ( $WP_Statistics->get_option( 'search_converted' ) ) { | ||||
| 									$tabletwo  = $tablename . 'visitor'; | ||||
| 									$tablename .= 'search'; | ||||
| 									$result    = $wpdb->get_results( | ||||
| 										"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT {$start}, {$end}" | ||||
| 									); | ||||
| 								} else { | ||||
| 									$tablename .= 'visitor'; | ||||
| 									$result    = $wpdb->get_results( | ||||
| 										"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT {$start}, {$end}" | ||||
| 									); | ||||
| 								} | ||||
|  | ||||
| 								$ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| 								$dash_icon = wp_statistics_icons( 'dashicons-location-alt', 'map' ); | ||||
|  | ||||
| 								echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"><tr>"; | ||||
| 								echo "<td>" . __( 'Word', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 									echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 								} | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 								} | ||||
| 								echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "</tr>"; | ||||
|  | ||||
| 								// Load city name | ||||
| 								$geoip_reader = false; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 								} | ||||
|  | ||||
| 								foreach ( $result as $items ) { | ||||
|  | ||||
| 									if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) { | ||||
| 										continue; | ||||
| 									} | ||||
|  | ||||
| 									if ( $WP_Statistics->get_option( 'search_converted' ) ) { | ||||
| 										$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine( $items->engine ); | ||||
| 										$words              = $items->words; | ||||
| 									} else { | ||||
| 										$this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred ); | ||||
| 										$words              = $WP_Statistics->Search_Engine_QueryString( $items->referred ); | ||||
| 									} | ||||
|  | ||||
| 									echo "<tr>"; | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo $words; | ||||
| 									echo "</td>"; | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false | ||||
| 									) { | ||||
| 										$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 									} else { | ||||
| 										$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 									} | ||||
| 									echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 									echo "</td>"; | ||||
| 									$city = ''; | ||||
| 									if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 										if ( $geoip_reader != false ) { | ||||
| 											try { | ||||
| 												$reader = $geoip_reader->city( $items->ip ); | ||||
| 												$city   = $reader->city->name; | ||||
| 											} catch ( Exception $e ) { | ||||
| 												$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 											} | ||||
|  | ||||
| 											if ( ! $city ) { | ||||
| 												$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 											} | ||||
| 										} | ||||
| 									} | ||||
|  | ||||
| 									if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 										echo "</td>"; | ||||
| 									} | ||||
|  | ||||
| 									if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										echo $city; | ||||
| 										echo "</td>"; | ||||
| 									} | ||||
|  | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo date( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 									echo "</td>"; | ||||
|  | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 										$ip_string = __( '#hash#', 'wp-statistics' ); | ||||
| 									} else { | ||||
| 										$ip_string = "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>{$items->ip}</a>"; | ||||
| 									} | ||||
| 									echo $ip_string; | ||||
| 									echo "</td>"; | ||||
|  | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo $WP_Statistics->get_referrer_link( $items->referred ); | ||||
| 									echo "</td>"; | ||||
|  | ||||
| 									echo "</tr>"; | ||||
| 								} | ||||
|  | ||||
| 								echo "</table>"; | ||||
| 							} | ||||
| 							?> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 				<?php | ||||
| 				if ( $total > 0 ) { | ||||
| 					wp_statistics_paginate_links( array( | ||||
| 						'item_per_page' => $items_per_page, | ||||
| 						'total'         => $total, | ||||
| 						'current'       => $page, | ||||
| 					) ); | ||||
| 				} ?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
							
								
								
									
										208
									
								
								wp-content/plugins/wp-statistics/includes/log/last-visitor.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										208
									
								
								wp-content/plugins/wp-statistics/includes/log/last-visitor.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,208 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| $ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| $_var  = 'agent'; | ||||
| $_get  = '%'; | ||||
| $title = 'All'; | ||||
|  | ||||
| if ( array_key_exists( 'agent', $_GET ) ) { | ||||
| 	$_var  = 'agent'; | ||||
| 	$_get  = '%' . $_GET['agent'] . '%'; | ||||
| 	$title = htmlentities( $_GET['agent'], ENT_QUOTES ); | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'ip', $_GET ) ) { | ||||
| 	$_var  = 'ip'; | ||||
| 	$_get  = '%' . $_GET['ip'] . '%'; | ||||
| 	$title = htmlentities( $_GET['ip'], ENT_QUOTES ); | ||||
| } | ||||
|  | ||||
| $_get          = esc_attr( $_get ); | ||||
| $total_visitor = $wpdb->get_var( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor`" ); | ||||
|  | ||||
| if ( $_get != '%' ) { | ||||
| 	$total = $wpdb->get_var( | ||||
| 		$wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get ) | ||||
| 	); | ||||
| } else { | ||||
| 	$total = $total_visitor; | ||||
| } | ||||
|  | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Recent Visitors', 'wp-statistics' ) ); ?> | ||||
|     <br/> | ||||
|     <ul class="subsubsub"> | ||||
|         <li class="all"><a <?php if ( $_get == '%' ) { | ||||
| 				echo 'class="current"'; | ||||
| 			} ?>href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'visitors' ); ?>"><?php _e( 'All', 'wp-statistics' ); ?> | ||||
|                 <span class="count">(<?php echo number_format_i18n( $total_visitor ); ?>)</span></a></li> | ||||
| 		<?php | ||||
| 		if ( isset( $_var ) ) { | ||||
| 			$spacer = " | "; | ||||
|  | ||||
| 			if ( $_var == 'agent' ) { | ||||
| 				$Browsers      = wp_statistics_ua_list(); | ||||
| 				$browser_names = wp_statistics_get_browser_list(); | ||||
| 				$i             = 0; | ||||
| 				$Total         = count( $Browsers ); | ||||
| 				echo $spacer; | ||||
| 				foreach ( $Browsers as $Browser ) { | ||||
| 					if ( $Browser == null ) { | ||||
| 						continue; | ||||
| 					} | ||||
|  | ||||
| 					$i ++; | ||||
| 					if ( $title == $Browser ) { | ||||
| 						$current = 'class="current" '; | ||||
| 					} else { | ||||
| 						$current = ""; | ||||
| 					} | ||||
| 					if ( $i == $Total ) { | ||||
| 						$spacer = ""; | ||||
| 					} | ||||
|  | ||||
| 					//Get Browser name | ||||
| 					$browser_name = wp_statistics_get_browser_list( strtolower( $Browser ) ); | ||||
| 					echo "<li><a " . $current . "href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'agent' => $Browser ) ) . "'> " . $browser_name . " <span class='count'>(" . number_format_i18n( wp_statistics_useragent( $Browser ) ) . ")</span></a></li>"; | ||||
| 					echo $spacer; | ||||
| 				} | ||||
| 			} else { | ||||
| 				if ( $_get != '%' ) { | ||||
| 					$current = 'class="current" '; | ||||
| 				} else { | ||||
| 					$current = ""; | ||||
| 				} | ||||
| 				echo $spacer . "<li><a {$current} href='?page=" . WP_Statistics::$page['visitors'] . "&{$_var}={$_get}'>{$title} <span class='count'>({$total})</span></a></li>"; | ||||
| 			} | ||||
| 		} | ||||
| 		?> | ||||
|     </ul> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Recent Visitor Statistics', 'wp-statistics' ); | ||||
| 					if ( $_get != '%' ) { | ||||
| 						$paneltitle = $paneltitle . ' [' . __( 'Filtered by', 'wp-statistics' ) . ': ' . $title . ']'; | ||||
| 					} ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						// Retrieve MySQL data | ||||
| 						if ( $_get != '%' ) { | ||||
| 							$sql = $wpdb->prepare( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `{$_var}` LIKE %s", $_get ); | ||||
| 						} else { | ||||
| 							$sql = "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor`"; | ||||
| 						} | ||||
|  | ||||
| 						// Instantiate pagination object with appropriate arguments | ||||
| 						$total          = $wpdb->get_var( $sql ); | ||||
| 						$items_per_page = 15; | ||||
| 						$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 						$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
|  | ||||
| 						//Get Query Result | ||||
| 						$query  = str_replace( "SELECT count(*) FROM", "SELECT * FROM", $sql ) . "  ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$offset}, {$items_per_page}"; | ||||
| 						$result = $wpdb->get_results( $query ); | ||||
|  | ||||
| 						echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"><tr>"; | ||||
| 						echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 						if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 							echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 						} | ||||
| 						if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 							echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 						} | ||||
| 						echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 						echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 						echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 						echo "</tr>"; | ||||
|  | ||||
| 						// Load city name | ||||
| 						$geoip_reader = false; | ||||
| 						if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 							$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 						} | ||||
|  | ||||
| 						foreach ( $result as $items ) { | ||||
| 							echo "<tr>"; | ||||
| 							echo "<td style=\"text-align: left\">"; | ||||
| 							if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 								$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 							} else { | ||||
| 								$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 							} | ||||
| 							echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 							echo "</td>"; | ||||
| 							$city = ''; | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								if ( $geoip_reader != false ) { | ||||
| 									try { | ||||
| 										$reader = $geoip_reader->city( $items->ip ); | ||||
| 										$city   = $reader->city->name; | ||||
| 									} catch ( Exception $e ) { | ||||
| 										$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 									} | ||||
|  | ||||
| 									if ( ! $city ) { | ||||
| 										$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 									} | ||||
| 								} | ||||
| 							} | ||||
|  | ||||
| 							if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 								echo "</td>"; | ||||
| 							} | ||||
|  | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo $city; | ||||
| 								echo "</td>"; | ||||
| 							} | ||||
|  | ||||
| 							echo "<td style=\"text-align: left\">"; | ||||
| 							echo date_i18n( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 							echo "</td>"; | ||||
|  | ||||
| 							echo "<td style=\"text-align: left\">"; | ||||
| 							if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 								$ip_string = __( '#hash#', 'wp-statistics' ); | ||||
| 							} else { | ||||
| 								$ip_string = "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>{$items->ip}</a>"; | ||||
| 							} | ||||
| 							echo $ip_string; | ||||
| 							echo "</td>"; | ||||
|  | ||||
| 							echo "<td style=\"text-align: left\">"; | ||||
| 							echo $WP_Statistics->get_referrer_link( $items->referred ); | ||||
| 							echo "</td>"; | ||||
|  | ||||
| 							echo "</tr>"; | ||||
| 						} | ||||
| 						echo "</table>"; | ||||
| 						?> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 				<?php | ||||
| 				//Show Pagination | ||||
| 				wp_statistics_paginate_links( array( | ||||
| 					'item_per_page' => $items_per_page, | ||||
| 					'total'         => $total, | ||||
| 					'current'       => $page, | ||||
| 				) ); | ||||
| 				?> | ||||
|             </div> | ||||
|         </div> | ||||
							
								
								
									
										140
									
								
								wp-content/plugins/wp-statistics/includes/log/log.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								wp-content/plugins/wp-statistics/includes/log/log.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| <?php | ||||
| $nag_html = ''; | ||||
|  | ||||
| if ( ! $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 	$nag_html .= '<div class="notice notice-warning"><p>' . sprintf( __( 'GeoIP collection is not enabled. Please go to <a href="%s">setting page</a> to enable GeoIP for getting more information and location (country) from the visitor.', 'wp-statistics' ), WP_Statistics_Admin_Pages::admin_url( 'settings', array( 'tab' => 'externals-settings' ) ) ) . '</p></div>'; | ||||
| } | ||||
|  | ||||
| if ( ! $WP_Statistics->get_option( 'disable_donation_nag', false ) ) { | ||||
| 	$nag_html .= '<div class="notice notice-success is-dismissible wps-donate-notice"><p>' . __( 'Have you thought about donating to WP Statistics?', 'wp-statistics' ) . ' <a href="http://wp-statistics.com/donate/" target="_blank">' . __( 'Donate Now!', 'wp-statistics' ) . '</a></p></div>'; | ||||
| } | ||||
|  | ||||
| // WP Statistics 10.0 had a bug which could corrupt  the metabox display if the user re-ordered the widgets.  Check to see if the meta data is corrupt and if so delete it. | ||||
| $widget_order = get_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page', true ); | ||||
|  | ||||
| if ( is_array( $widget_order ) && count( $widget_order ) > 2 ) { | ||||
| 	delete_user_meta( $WP_Statistics->user_id, 'meta-box-order_toplevel_page_wps_overview_page' ); | ||||
| } | ||||
|  | ||||
| // Add the about box here as metaboxes added on the actual page load cannot be closed. | ||||
| add_meta_box( 'wps_about_postbox', sprintf( __( 'WP Statistics - Version %s', 'wp-statistics' ), WP_Statistics::$reg['version'] ), 'wp_statistics_generate_overview_postbox_contents', $WP_Statistics->menu_slugs['overview'], 'side', null, array( 'widget' => 'about' ) ); | ||||
|  | ||||
| function wp_statistics_generate_overview_postbox_contents( $post, $args ) { | ||||
| 	$widget       = $args['args']['widget']; | ||||
| 	$container_id = str_replace( '.', '_', $widget . '_postbox' ); | ||||
|  | ||||
| 	echo '<div id="' . $container_id . '">' . WP_Statistics_Admin_Pages::loading_meta_box() . '</div>'; | ||||
| 	wp_statistics_generate_widget_load_javascript( $widget, $container_id ); | ||||
| } | ||||
|  | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php echo $nag_html; ?> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title(); ?> | ||||
| 	<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> | ||||
| 	<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> | ||||
|  | ||||
|     <div class="metabox-holder" id="overview-widgets"> | ||||
|         <div class="postbox-container" id="wps-postbox-container-1"> | ||||
| 			<?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'side', '' ); ?> | ||||
|         </div> | ||||
|  | ||||
|         <div class="postbox-container" id="wps-postbox-container-2"> | ||||
| 			<?php do_meta_boxes( $WP_Statistics->menu_slugs['overview'], 'normal', '' ); ?> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| <?php | ||||
|  | ||||
| //Prepare List Of Page Url | ||||
| $page_urls   = array(); | ||||
| $widget_list = array( 'browsers', 'countries', 'hits', 'pages', 'referring', 'search', 'words', 'top-visitors', 'recent' ); | ||||
| $all_widget  = WP_Statistics_Dashboard::widget_list(); | ||||
| foreach ( $widget_list as $widget ) { | ||||
| 	if ( array_key_exists( $widget, $all_widget ) ) { | ||||
| 		$page_urls[ 'wps_' . str_replace( "-", "_", $widget ) . '_more_button' ] = WP_Statistics_Admin_Pages::admin_url( $all_widget[ $widget ]['page_url'] ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //Add Extra Pages For Overview Page | ||||
| foreach ( array( 'exclusions' => 'exclusions', 'users_online' => 'online' ) as $p_key => $p_link ) { | ||||
| 	$page_urls[ 'wps_' . $p_key . '_more_button' ] = WP_Statistics_Admin_Pages::admin_url( $p_link ); | ||||
| } | ||||
| ?> | ||||
| <script type="text/javascript"> | ||||
|     var wp_statistics_destinations = <?php echo json_encode( $page_urls ); ?>; | ||||
|     var wp_statistics_loading_image = '<?php echo WP_Statistics_Admin_Pages::loading_meta_box(); ?>' | ||||
|  | ||||
|     jQuery(document).ready(function () { | ||||
|  | ||||
|         // Add the "more" and "refresh" buttons. | ||||
|         jQuery('.postbox').each(function () { | ||||
|             var temp = jQuery(this); | ||||
|             var temp_id = temp.attr('id'); | ||||
|             var temp_html = temp.html(); | ||||
|             if (temp_id == 'wps_summary_postbox' || temp_id == 'wps_map_postbox' || temp_id == 'wps_about_postbox') { | ||||
|                 if (temp_id != 'wps_about_postbox') { | ||||
|                     new_text = '<?php echo WP_Statistics_Admin_Pages::meta_box_button( 'refresh' );?>'; | ||||
|                     new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button')); | ||||
|  | ||||
|                     temp_html = temp_html.replace('</button>', new_text); | ||||
|                 } | ||||
|             } else { | ||||
|                 new_text = '<?php echo WP_Statistics_Admin_Pages::meta_box_button();?>'; | ||||
|                 new_text = new_text.replace('{{refreshid}}', temp_id.replace('_postbox', '_refresh_button')); | ||||
|                 new_text = new_text.replace('{{moreid}}', temp_id.replace('_postbox', '_more_button')); | ||||
|  | ||||
|                 temp_html = temp_html.replace('</button>', new_text); | ||||
|             } | ||||
|  | ||||
|             temp.html(temp_html); | ||||
|         }); | ||||
|  | ||||
|         // close postboxes that should be closed | ||||
|         jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); | ||||
|  | ||||
|         // postboxes setup | ||||
|         postboxes.add_postbox_toggles('<?php echo $WP_Statistics->menu_slugs['overview']; ?>'); | ||||
|  | ||||
|         jQuery('.wps-refresh').unbind('click').on('click', wp_statistics_refresh_widget); | ||||
|         jQuery('.wps-more').unbind('click').on('click', wp_statistics_goto_more); | ||||
|         jQuery('.hide-postbox-tog').on('click', wp_statistics_refresh_on_toggle_widget); | ||||
|         jQuery('.wps-donate-notice').on('click', '.notice-dismiss', function () { | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_close_notice', | ||||
|                 'notice': 'donate', | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'get', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         // Added New Ads | ||||
| 		<?php | ||||
| 		$overview_ads = get_option( 'wp_statistics_overview_page_ads', false ); | ||||
| 		if($overview_ads != false and is_array( $overview_ads ) and $overview_ads['ads']['ID'] != $overview_ads['view'] and $overview_ads['ads']['status'] == "yes") { | ||||
| 		?> | ||||
|         jQuery(`<div id="wps_overview_ads_postbox" class="postbox"><div class="inside"><div class="close-overview-ads"><span class="dashicons dashicons-dismiss"></span></div><a href="<?php echo( isset( $overview_ads['ads']['link'] ) ? $overview_ads['ads']['link'] : '' ); ?>" title="<?php echo( isset( $overview_ads['ads']['title'] ) ? $overview_ads['ads']['title'] : '' ); ?>" <?php echo( $overview_ads['ads']['_target'] == "yes" ? ' target="_blank"' : '' ); ?>><img style="display: block;" src="<?php echo( isset( $overview_ads['ads']['image'] ) ? $overview_ads['ads']['image'] : '' ); ?>" alt="<?php echo( isset( $overview_ads['ads']['title'] ) ? $overview_ads['ads']['title'] : '' ); ?>"></a></div></div>`).insertAfter("#wps-postbox-container-2 #normal-sortables div.postbox:first"); | ||||
|         jQuery(document).on('click', '.close-overview-ads', function () { | ||||
|             jQuery("#wps_overview_ads_postbox").fadeOut("normal"); | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'get', | ||||
|                 data: { | ||||
|                     'action': 'wp_statistics_close_overview_ads', | ||||
|                     'ads_id': '<?php echo $overview_ads['ads']['ID']; ?>', | ||||
|                     'wps_nonce': '<?php echo wp_create_nonce( 'overview_ads_nonce' ); ?>' | ||||
|                 }, | ||||
|                 datatype: 'json' | ||||
|             }); | ||||
|         }); | ||||
| 		<?php | ||||
| 		} | ||||
| 		?> | ||||
|  | ||||
|     }); | ||||
| </script> | ||||
							
								
								
									
										169
									
								
								wp-content/plugins/wp-statistics/includes/log/online.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								wp-content/plugins/wp-statistics/includes/log/online.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,169 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Online Users', 'wp-statistics' ) ); ?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Online Users', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						//Get List ISO country | ||||
| 						$ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| 						//Get Total User Online | ||||
| 						$sql   = "SELECT COUNT(*) FROM {$wpdb->prefix}statistics_useronline"; | ||||
| 						$total = $wpdb->get_var( $sql ); | ||||
|  | ||||
| 						if ( $total > 0 ) { | ||||
|  | ||||
| 							// Load city name | ||||
| 							$geoip_reader = false; | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 							} | ||||
|  | ||||
| 							//Show Table | ||||
| 							echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"online-users\"><tr>"; | ||||
| 							echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 							if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 								echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 							} | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 							} | ||||
| 							echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td>" . __( 'Online For', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td>" . __( 'Page', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td></td>"; | ||||
| 							echo "</tr>"; | ||||
|  | ||||
| 							// Instantiate pagination object with appropriate arguments | ||||
| 							$items_per_page = 10; | ||||
| 							$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 							$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
| 							$start          = $offset; | ||||
| 							$end            = $offset + $items_per_page; | ||||
|  | ||||
| 							//Get Query Result | ||||
| 							$query  = str_replace( "SELECT COUNT(*) FROM", "SELECT * FROM", $sql ) . "  ORDER BY `{$wpdb->prefix}statistics_useronline`.`ID` DESC LIMIT {$offset}, {$items_per_page}"; | ||||
| 							$result = $wpdb->get_results( $query ); | ||||
|  | ||||
| 							foreach ( $result as $items ) { | ||||
|  | ||||
| 								//Sanitize Online Table | ||||
| 								if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 									$ip_string  = __( '#hash#', 'wp-statistics' ); | ||||
| 									$map_string = ""; | ||||
| 								} else { | ||||
| 									$ip_string  = "{$items->ip}"; | ||||
| 									$map_string = "<a class='wps-text-muted' href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>" . wp_statistics_icons( 'dashicons-visibility', 'visibility' ) . "</a><a class='show-map wps-text-muted' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp-statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>"; | ||||
| 								} | ||||
|  | ||||
| 								echo "<tr>"; | ||||
|  | ||||
| 								//Show Browser | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 									$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 								} else { | ||||
| 									$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 								} | ||||
| 								echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								//Show Country | ||||
| 								if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 									echo "</td>"; | ||||
| 								} | ||||
|  | ||||
| 								//Show City | ||||
| 								$city = ''; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									if ( $geoip_reader != false ) { | ||||
| 										try { | ||||
| 											$reader = $geoip_reader->city( $items->ip ); | ||||
| 											$city   = $reader->city->name; | ||||
| 										} catch ( Exception $e ) { | ||||
| 											$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 										} | ||||
| 										if ( ! $city ) { | ||||
| 											$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 										} | ||||
| 									} | ||||
| 								} | ||||
|  | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo $city; | ||||
| 									echo "</td>"; | ||||
| 								} | ||||
|  | ||||
| 								//Show IP | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo $ip_string; | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								//Show Online For | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								$timediff = ( $items->timestamp - $items->created ); | ||||
| 								if ( $timediff > 3600 ) { | ||||
| 									$onlinefor = date( "H:i:s", ( $items->timestamp - $items->created ) ); | ||||
| 								} else if ( $timediff > 60 ) { | ||||
| 									$onlinefor = "00:" . date( "i:s", ( $items->timestamp - $items->created ) ); | ||||
| 								} else { | ||||
| 									$onlinefor = "00:00:" . date( "s", ( $items->timestamp - $items->created ) ); | ||||
| 								} | ||||
| 								echo "<span>" . $onlinefor . "</span>"; | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								//Show Page | ||||
| 								$page_info = wp_statistics_get_page_info( $items->page_id, $items->type ); | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo ( $page_info['link'] != '' ? '<a href="' . $page_info['link'] . '" target="_blank" class="wps-text-danger">' : '' ) . mb_substr( $page_info['title'], 0, 200, "utf-8" ) . ( $page_info['link'] != '' ? '</a>' : '' ); | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								//Show Referrer | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo $WP_Statistics->get_referrer_link( $items->referred ); | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								//Show Link View IP | ||||
| 								echo "<td style=\"text-align: center\">"; | ||||
| 								echo $map_string; | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								echo '</tr>'; | ||||
| 							} | ||||
|  | ||||
| 							echo "</table>"; | ||||
| 						} else { | ||||
| 							echo "<div class='wps-center'>" . __( 'Currently there are no online users in the site.', 'wp-statistics' ) . "</div>"; | ||||
| 						} | ||||
| 						?> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 				<?php | ||||
| 				if ( $total > 0 ) { | ||||
| 					wp_statistics_paginate_links( array( | ||||
| 						'item_per_page' => $items_per_page, | ||||
| 						'total'         => $total, | ||||
| 						'current'       => $page, | ||||
| 					) ); | ||||
| 				} ?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| @@ -0,0 +1,95 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| if ( array_key_exists( 'page-uri', $_GET ) ) { | ||||
| 	$pageuri = $_GET['page-uri']; | ||||
| } else { | ||||
| 	$pageuri = null; | ||||
| } | ||||
| if ( array_key_exists( 'page-id', $_GET ) ) { | ||||
| 	$pageid = (int) $_GET['page-id']; | ||||
| } else if ( array_key_exists( 'prepage', $_GET ) ) { | ||||
| 	$pageid = (int) $_GET['prepage']; | ||||
| } else { | ||||
| 	$pageid = null; | ||||
| } | ||||
|  | ||||
| if ( $pageuri && ! $pageid ) { | ||||
| 	$pageid = wp_statistics_uri_to_id( $pageuri ); | ||||
| } | ||||
|  | ||||
| $post = get_post( $pageid ); | ||||
| if ( is_object( $post ) ) { | ||||
| 	$title = esc_html( $post->post_title ); | ||||
| } else { | ||||
| 	$title = ""; | ||||
| } | ||||
|  | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
|  | ||||
| //Check Page | ||||
| if ( array_key_exists( 'page-id', $_GET ) ) { | ||||
| 	$page = intval( $_GET['page-id'] ); | ||||
| } else { | ||||
| 	if ( array_key_exists( 'prepage', $_GET ) ) { | ||||
| 		$page = intval( $_GET['prepage'] ); | ||||
| 	} else { | ||||
| 		$page = 0; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //Check Page Type | ||||
| $arg       = array(); | ||||
| $post_type = get_post_type( $page ); | ||||
| if ( $page > 0 and $post_type != "page" ) { | ||||
| 	$arg = array( "post_type" => get_post_type( $page ), "posts_per_page" => 50, "order" => "DESC" ); | ||||
| } | ||||
|  | ||||
| //Add arg to This Url | ||||
| $url_fields = '&prepage=' . $pageid; | ||||
|  | ||||
| //Show Select Box Ui | ||||
| $html = __( 'Select Page', 'wp-statistics' ) . ': '; | ||||
| $html .= '<select name="page-id">'; | ||||
| foreach ( wp_statistics_get_post_list( $arg ) as $post_id => $post_title ) { | ||||
| 	$html .= '<option value="' . $post_id . '"' . selected( $post_id, $page, false ) . '>' . $post_title . '</option>'; | ||||
| } | ||||
| $html .= '</select>'; | ||||
| $html .= ' <input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">'; | ||||
| $html .= '<br>'; | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( sprintf( __( 'Page Trend for Post ID %s', 'wp-statistics' ), $pageid ) . ' - ' . $title ); ?> | ||||
| 	<?php wp_statistics_date_range_selector( WP_Statistics::$page['pages'], $daysToDisplay, null, null, $url_fields, $html ); ?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Page Trend', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						include( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/page.php' ); | ||||
| 						wp_statistics_generate_page_postbox_content( | ||||
| 							$pageuri, | ||||
| 							$pageid, | ||||
| 							$daysToDisplay, | ||||
| 							null, | ||||
| 							$rangestart, | ||||
| 							$rangeend | ||||
| 						); ?> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| @@ -0,0 +1,127 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| $search_engines = wp_statistics_searchengine_list(); | ||||
|  | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
| $daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 ); | ||||
|  | ||||
| $total_stats = $WP_Statistics->get_option( 'chart_totals' ); | ||||
| $date        = array(); | ||||
| $stats       = array(); | ||||
| $total_daily = array(); | ||||
|  | ||||
| foreach ( $search_engines as $se ) { | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		if ( ! array_key_exists( $i, $total_daily ) ) { | ||||
| 			$total_daily[ $i ] = 0; | ||||
| 		} | ||||
|  | ||||
| 		$stat                   = wp_statistics_searchengine( $se['tag'], '-' . ( $i + $daysInThePast ) ); | ||||
| 		$stats[ $se['name'] ][] = $stat; | ||||
| 		$total_daily[ $i ]      += $stat; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 	$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
| } | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Search Engine Referral Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php wp_statistics_date_range_selector( WP_Statistics::$page['searches'], $daysToDisplay ); ?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Search Engine Referral Statistics', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="search-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var colors = []; | ||||
|                             colors['baidu'] = ['rgba(35, 25, 220, 0.2)', 'rgba(35, 25, 220, 1)']; | ||||
|                             colors['bing'] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)']; | ||||
|                             colors['duckduckgo'] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)']; | ||||
|                             colors['google'] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)']; | ||||
|                             colors['yahoo'] = ['rgba(64, 0, 144, 0.2)', 'rgba(64, 0, 144, 1)']; | ||||
|                             colors['yandex'] = ['rgba(255, 219, 77, 0.2)', 'rgba(255, 219, 77, 1)']; | ||||
|                             colors['ask'] = ['rgba(205, 0, 0, 0.2)', 'rgba(205, 0, 0, 1)']; | ||||
|                             colors['clearch'] = ['rgba(13, 0, 76, 0.2)', 'rgba(13, 0, 76, 1)']; | ||||
|                             colors['qwant'] = ['rgba(53, 60, 82, 0.2)', 'rgba(53, 60, 82, 1)']; | ||||
|  | ||||
|                             var ctx = document.getElementById("search-stats").getContext('2d'); | ||||
|                             <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
| 										<?php foreach ( $search_engines as $se ): ?> | ||||
|                                         { | ||||
|                                             label: '<?php echo $se['name']; ?>', | ||||
|                                             data: [<?php echo implode( ',', $stats[ $se['name'] ] ); ?>], | ||||
|                                             backgroundColor: colors['<?php echo $se['tag']; ?>'][0], | ||||
|                                             borderColor: colors['<?php echo $se['tag']; ?>'][1], | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
| 										<?php endforeach; ?> | ||||
| 										<?php if ( $total_stats == 1 ) : ?> | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Total', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $total_daily ); ?>], | ||||
|                                             backgroundColor: 'rgba(180, 180, 180, 0.2)', | ||||
|                                             borderColor: 'rgba(180, 180, 180, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: false, | ||||
|                                         }, | ||||
| 										<?php endif;?> | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo sprintf( __( 'Search engine referrals in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										264
									
								
								wp-content/plugins/wp-statistics/includes/log/tags.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										264
									
								
								wp-content/plugins/wp-statistics/includes/log/tags.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,264 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Tag Statistics', 'wp-statistics' ) ); ?> | ||||
| 	<?php | ||||
| 	//Set Default Time Picker Option | ||||
| 	list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
|  | ||||
| 	if ( array_key_exists( 'tag', $_GET ) ) { | ||||
| 		$tag = $_GET['tag']; | ||||
| 	} else { | ||||
| 		if ( array_key_exists( 'pretag', $_GET ) ) { | ||||
| 			$tag = $_GET['pretag']; | ||||
| 		} else { | ||||
| 			$tag = ''; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$html = __( 'Select Tag', 'wp-statistics' ) . ': '; | ||||
|  | ||||
| 	$tags = get_tags(); | ||||
|  | ||||
| 	$html .= '<select name="tag" id="tag">'; | ||||
|  | ||||
| 	foreach ( $tags as $tag_obj ) { | ||||
| 		// If a tag hasn't been selected yet, use the first one in the tag list. | ||||
| 		if ( '' === $tag ) { | ||||
| 			$tag = $tag_obj->slug; | ||||
| 		} | ||||
|  | ||||
| 		// Check to see if this tag is the one that is currently selected. | ||||
| 		if ( $tag_obj->slug === $tag ) { | ||||
| 			$selected = ' SELECTED'; | ||||
| 		} else { | ||||
| 			$selected = ''; | ||||
| 		} | ||||
|  | ||||
| 		$html .= "<option value=\"{$tag_obj->slug}\"{$selected}>{$tag_obj->name}</option>"; | ||||
| 	} | ||||
|  | ||||
| 	$html .= '</select>'; | ||||
| 	$html .= ' <input type="submit" value="' . __( 'Select', 'wp-statistics' ) . '" class="button-primary">'; | ||||
| 	$html .= '<br>'; | ||||
|  | ||||
| 	// Get TimeStamp | ||||
| 	list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 		$daysToDisplay, | ||||
| 		$rangestart, | ||||
| 		$rangeend | ||||
| 	); | ||||
|  | ||||
| 	wp_statistics_date_range_selector( WP_Statistics::$page['tags'], $daysToDisplay, null, null, '&pretag=' . $tag, $html ); | ||||
|  | ||||
| 	$args = array( | ||||
| 		'tax_query' => array( | ||||
| 			array( | ||||
| 				'taxonomy' => 'post_tag', | ||||
| 				'field'    => 'slug', | ||||
| 				'terms'    => sanitize_title( $tag ), | ||||
| 			), | ||||
| 		), | ||||
| 	); | ||||
|  | ||||
| 	$posts = get_posts( $args ); | ||||
|  | ||||
| 	$visit_total   = 0; | ||||
| 	$daysInThePast = (int) ( ( time() - $rangeend_utime ) / 86400 ); | ||||
| 	$posts_stats   = array(); | ||||
| 	$visits        = array(); | ||||
|  | ||||
| 	// Setup the array, otherwise PHP may throw an error. | ||||
| 	foreach ( $posts as $post ) { | ||||
| 		$posts_stats[ $post->ID ] = 0; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
|  | ||||
| 		$stat = 0; | ||||
| 		foreach ( $posts as $post ) { | ||||
| 			$temp_stat                = wp_statistics_pages( '-' . (int) ( $i + $daysInThePast ), null, $post->ID ); | ||||
| 			$posts_stats[ $post->ID ] += $temp_stat; | ||||
| 			$stat                     = $temp_stat; | ||||
| 		} | ||||
|  | ||||
| 		$visits[]    = $stat; | ||||
| 		$visit_total += $stat; | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Tag Statistics Chart', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="hit-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
| 							<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
|                                         { | ||||
|                                             label: '<?php _e( 'Visits', 'wp-statistics' ); ?>', | ||||
|                                             data: [<?php echo implode( ',', $visits ); ?>], | ||||
|                                             backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||
|                                             borderColor: 'rgba(54, 162, 235, 1)', | ||||
|                                             borderWidth: 1, | ||||
|                                             fill: true, | ||||
|                                         }, | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $daysToDisplay ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Tag Statistics Summary', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="summary-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th></th> | ||||
|                                 <th class="th-center"><?php _e( 'Count', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Number of posts in tag:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( count( $posts ) ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Chart Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php echo number_format_i18n( $visit_total ); ?></span> | ||||
|                                 </th> | ||||
|                             </tr> | ||||
|  | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'All Time Visits Total:', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><span><?php | ||||
|  | ||||
| 										$stat = 0; | ||||
| 										foreach ( $posts as $post ) { | ||||
| 											$stat += wp_statistics_pages( 'total', null, $post->ID ); | ||||
| 										} | ||||
|  | ||||
| 										echo number_format_i18n( $stat ); ?></span></th> | ||||
|                             </tr> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <div class="postbox-container" style="width: 100%; float: left; margin-right:20px"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Tag Posts Sorted by Hits', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <table width="auto" class="widefat table-stats" id="post-stats"> | ||||
|                             <tbody> | ||||
|                             <tr> | ||||
|                                 <th><?php _e( 'Post Title', 'wp-statistics' ); ?></th> | ||||
|                                 <th class="th-center"><?php _e( 'Hits', 'wp-statistics' ); ?></th> | ||||
|                             </tr> | ||||
|  | ||||
| 							<?php | ||||
| 							arsort( $posts_stats ); | ||||
|  | ||||
| 							$posts_by_id = array(); | ||||
|  | ||||
| 							foreach ( $posts as $post ) { | ||||
| 								$posts_by_id[ $post->ID ] = $post; | ||||
| 							} | ||||
|  | ||||
| 							foreach ( $posts_stats as $post_id => $post_stat ) { | ||||
| 								$post_obj = $posts_by_id[ $post_id ]; | ||||
|  | ||||
| 								?> | ||||
|                                 <tr> | ||||
|                                     <th> | ||||
|                                         <a href="<?php echo get_permalink( | ||||
| 											$post_obj | ||||
| 										); ?>"><?php echo esc_html( $post_obj->post_title ); ?></a> | ||||
|                                     </th> | ||||
|                                     <th class="th-center"><span><?php echo number_format_i18n( $post_stat ); ?></span> | ||||
|                                     </th> | ||||
|                                 </tr> | ||||
| 								<?php | ||||
| 							} | ||||
| 							?> | ||||
|                             </tbody> | ||||
|                         </table> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
							
								
								
									
										221
									
								
								wp-content/plugins/wp-statistics/includes/log/top-countries.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										221
									
								
								wp-content/plugins/wp-statistics/includes/log/top-countries.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,221 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
|  | ||||
| //Load ISO | ||||
| $ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| //Get Custom Country | ||||
| $country_name  = ''; | ||||
| $total_visitor = 0; | ||||
| if ( isset( $_REQUEST['country'] ) ) { | ||||
| 	if ( array_key_exists( $_REQUEST['country'], $ISOCountryCode ) ) { | ||||
| 		$country_name = $ISOCountryCode[ $_REQUEST['country'] ]; | ||||
| 		$total        = $wpdb->get_var( "SELECT COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` WHERE `location` = '" . $_REQUEST['country'] . "'" ); | ||||
| 	} else { | ||||
| 		echo '<script>window.location.href = "' . WP_Statistics_Admin_Pages::admin_url( 'countries' ) . '";</script>'; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php | ||||
| 	//Show Time Range only in all list | ||||
| 	if ( ! isset( $_REQUEST['country'] ) ) { | ||||
| 		WP_Statistics_Admin_Pages::show_page_title( __( 'Top Countries', 'wp-statistics' ) ); | ||||
| 		wp_statistics_date_range_selector( WP_Statistics::$page['countries'], $daysToDisplay ); | ||||
| 	} else { | ||||
| 		WP_Statistics_Admin_Pages::show_page_title( $country_name . ' ' . __( 'Visitors', 'wp-statistics' ) ); | ||||
| 		?> | ||||
|         <br/> | ||||
|         <ul class="subsubsub"> | ||||
|             <li class="all"> | ||||
|                 <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'countries' ); ?>"><?php _e( 'All', 'wp-statistics' ); ?></a> | ||||
|             </li> | ||||
|             | | ||||
|             <li> | ||||
|                 <a class="current" href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'countries', array( 'country' => $_REQUEST['country'] ) ) ?>"> | ||||
| 					<?php echo $country_name; ?> | ||||
|                     <span class="count">(<?php echo number_format_i18n( $total ); ?>)</span></a> | ||||
|             </li> | ||||
|         </ul> | ||||
| 		<?php | ||||
| 	} | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php | ||||
| 					if ( ! isset( $_REQUEST['country'] ) ) { | ||||
| 						$paneltitle = __( 'Top Countries', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						$paneltitle = $country_name; | ||||
| 					} | ||||
| 					?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						if ( ! isset( $_REQUEST['country'] ) ) { | ||||
| 							?> | ||||
|  | ||||
|                             <table class="widefat table-stats" id="last-referrer" style="width: 100%;"> | ||||
|                                 <tr> | ||||
|                                     <td width="10%"><?php _e( 'Rank', 'wp-statistics' ); ?></td> | ||||
|                                     <td width="30%" style="text-align: center;"><?php _e( 'Flag', 'wp-statistics' ); ?></td> | ||||
|                                     <td width="30%" style="text-align: center;"><?php _e( 'Country', 'wp-statistics' ); ?></td> | ||||
|                                     <td width="30%" style="text-align: center;"><?php _e( 'Visitor Count', 'wp-statistics' ); ?></td> | ||||
|                                 </tr> | ||||
|  | ||||
| 								<?php | ||||
| 								$rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime ); | ||||
| 								$rangeenddate   = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime ); | ||||
|  | ||||
| 								$result = $wpdb->get_results( | ||||
| 									sprintf( "SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` BETWEEN '%s' AND '%s' GROUP BY `location` ORDER BY `count` DESC", | ||||
| 										$rangestartdate, | ||||
| 										$rangeenddate | ||||
| 									) | ||||
| 								); | ||||
| 								$i      = 0; | ||||
|  | ||||
| 								foreach ( $result as $item ) { | ||||
| 									$i ++; | ||||
| 									$item->location = strtoupper( $item->location ); | ||||
|  | ||||
| 									echo "<tr>"; | ||||
| 									echo "<td>$i</td>"; | ||||
| 									echo "<td style=\"text-align: center;\"><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item->location . '.png' ) . "' title='{$ISOCountryCode[$item->location]}'/></td>"; | ||||
| 									echo "<td style='text-align: left; padding-" . ( is_rtl() === true ? 'right' : 'left' ) . ": 12.8%;'>{$ISOCountryCode[$item->location]}</td>"; | ||||
| 									echo "<td style=\"text-align: center;\"><a href='" . WP_Statistics_Admin_Pages::admin_url( 'countries', array( 'country' => $item->location ) ) . "'>" . number_format_i18n( $item->count ) . "</a></td>"; | ||||
| 									echo "</tr>"; | ||||
| 								} | ||||
| 								?> | ||||
|                             </table> | ||||
| 						<?php } else { | ||||
| 							/* | ||||
| 							 * Show Custom Country | ||||
| 							 */ | ||||
|  | ||||
| 							// Retrieve MySQL data | ||||
| 							$sql = "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE `location` = '" . $_REQUEST['country'] . "'"; | ||||
|  | ||||
| 							// Instantiate pagination object with appropriate arguments | ||||
| 							$total          = $wpdb->get_var( $sql ); | ||||
| 							$items_per_page = 15; | ||||
| 							$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 							$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
|  | ||||
| 							//Get Query Result | ||||
| 							$query  = str_replace( "SELECT count(*) FROM", "SELECT * FROM", $sql ) . "  ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC LIMIT {$offset}, {$items_per_page}"; | ||||
| 							$result = $wpdb->get_results( $query ); | ||||
|  | ||||
| 							echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"><tr>"; | ||||
| 							echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 							if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 								echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 							} | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 							} | ||||
| 							echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "</tr>"; | ||||
|  | ||||
| 							// Load city name | ||||
| 							$geoip_reader = false; | ||||
| 							if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 								$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 							} | ||||
|  | ||||
| 							foreach ( $result as $items ) { | ||||
| 								echo "<tr>"; | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 									$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 								} else { | ||||
| 									$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 								} | ||||
| 								echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 								echo "</td>"; | ||||
| 								$city = ''; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									if ( $geoip_reader != false ) { | ||||
| 										try { | ||||
| 											$reader = $geoip_reader->city( $items->ip ); | ||||
| 											$city   = $reader->city->name; | ||||
| 										} catch ( Exception $e ) { | ||||
| 											$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 										} | ||||
|  | ||||
| 										if ( ! $city ) { | ||||
| 											$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 										} | ||||
| 									} | ||||
| 								} | ||||
|  | ||||
| 								if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 									echo "</td>"; | ||||
| 								} | ||||
|  | ||||
| 								if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 									echo "<td style=\"text-align: left\">"; | ||||
| 									echo $city; | ||||
| 									echo "</td>"; | ||||
| 								} | ||||
|  | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo date_i18n( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 									$ip_string = __( '#hash#', 'wp-statistics' ); | ||||
| 								} else { | ||||
| 									$ip_string = "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>{$items->ip}</a>"; | ||||
| 								} | ||||
| 								echo $ip_string; | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								echo "<td style=\"text-align: left\">"; | ||||
| 								echo $WP_Statistics->get_referrer_link( $items->referred ); | ||||
| 								echo "</td>"; | ||||
|  | ||||
| 								echo "</tr>"; | ||||
| 							} | ||||
| 							echo "</table>"; | ||||
| 						} ?> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
| 		<?php | ||||
| 		if ( isset( $_REQUEST['country'] ) ) { | ||||
| 			//Show Pagination | ||||
| 			wp_statistics_paginate_links( array( | ||||
| 				'item_per_page' => $items_per_page, | ||||
| 				'total'         => $total, | ||||
| 				'current'       => $page, | ||||
| 			) ); | ||||
| 		} | ||||
| 		?> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										177
									
								
								wp-content/plugins/wp-statistics/includes/log/top-pages.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								wp-content/plugins/wp-statistics/includes/log/top-pages.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,177 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
| $daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 ); | ||||
|  | ||||
| list( $total, $uris ) = wp_statistics_get_top_pages( | ||||
| 	$WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangestart_utime ), | ||||
| 	$WP_Statistics->Real_Current_Date( 'Y-m-d', '-0', $rangeend_utime ) | ||||
| ); | ||||
| $count = 0; | ||||
|  | ||||
| $stats = array(); | ||||
| foreach ( $uris as $uri ) { | ||||
| 	$count ++; | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$stats[ $uri[0] ][] = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $uri[0] ); | ||||
| 	} | ||||
|  | ||||
| 	if ( $count > 4 ) { | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 	$date[] = "'" . $WP_Statistics->Real_Current_Date( 'M j', '-' . $i, $rangeend_utime ) . "'"; | ||||
| } | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Top Pages', 'wp-statistics' ) ); ?> | ||||
| 	<?php wp_statistics_date_range_selector( WP_Statistics::$page['pages'], $daysToDisplay ); ?> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Top 5 Pages Trends', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|                         <canvas id="hit-stats" height="80"></canvas> | ||||
|                         <script> | ||||
|                             var colors = []; | ||||
|                             colors[0] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)']; | ||||
|                             colors[1] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)']; | ||||
|                             colors[2] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)']; | ||||
|                             colors[3] = ['rgba(255, 99, 132, 0.2)', 'rgba(255, 99, 132, 1)']; | ||||
|                             colors[4] = ['rgba(54, 162, 235, 0.2)', 'rgba(54, 162, 235, 1)']; | ||||
|  | ||||
|                             var ctx = document.getElementById("hit-stats").getContext('2d'); | ||||
| 							<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|                             var ChartJs = new Chart(ctx, { | ||||
|                                 type: 'line', | ||||
|                                 data: { | ||||
|                                     labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                                     datasets: [ | ||||
| 										<?php foreach ($stats as $key => $value) : $i ++; ?> | ||||
|                                         { | ||||
|                                             label: '<?php echo $key; ?>', | ||||
|                                             data: [<?php echo implode( ',', $value ); ?>], | ||||
|                                             backgroundColor: colors[<?php echo $i; ?>][0], | ||||
|                                             borderColor: colors[<?php echo $i; ?>][1], | ||||
|                                             fill: true, | ||||
|                                             borderWidth: 1, | ||||
|                                         }, | ||||
| 										<?php endforeach; ?> | ||||
|                                     ] | ||||
|                                 }, | ||||
|                                 options: { | ||||
|                                     responsive: true, | ||||
|                                     legend: { | ||||
|                                         position: 'bottom', | ||||
|                                     }, | ||||
|                                     title: { | ||||
|                                         display: true, | ||||
|                                         text: '<?php echo htmlentities( __( 'Top 5 Page Trending Stats', 'wp-statistics' ), ENT_QUOTES ); ?>' | ||||
|                                     }, | ||||
|                                     tooltips: { | ||||
|                                         mode: 'index', | ||||
|                                         intersect: false, | ||||
|                                     }, | ||||
|                                     scales: { | ||||
|                                         yAxes: [{ | ||||
|                                             ticks: { | ||||
|                                                 beginAtZero: true | ||||
|                                             } | ||||
|                                         }] | ||||
|                                     } | ||||
|                                 } | ||||
|                             }); | ||||
|                         </script> | ||||
|                     </div> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Top Pages', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						if ( $total > 0 ) { | ||||
| 							// Instantiate pagination object with appropriate arguments | ||||
| 							$items_per_page = 10; | ||||
| 							$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 							$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
| 							$start          = $offset; | ||||
| 							$end            = $offset + $items_per_page; | ||||
| 							$site_url       = site_url(); | ||||
| 							$count          = 0; | ||||
|  | ||||
| 							echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"><tr>"; | ||||
| 							echo "<td width='10%'>" . __( 'ID', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td width='40%'>" . __( 'Title', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td width='40%'>" . __( 'Link', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "<td width='10%'>" . __( 'Visits', 'wp-statistics' ) . "</td>"; | ||||
| 							echo "</tr>"; | ||||
|  | ||||
| 							foreach ( $uris as $uri ) { | ||||
| 								$count ++; | ||||
| 								if ( $count >= $start ) { | ||||
|  | ||||
| 									//Check Pages Id exist | ||||
| 									if ( $uri[2] > 0 ) { | ||||
| 										$arg = array( 'page-id' => $uri[2] ); | ||||
| 									} else { | ||||
| 										$arg = array( 'page-uri' => $uri[0] ); | ||||
| 									} | ||||
|  | ||||
| 									echo "<tr>"; | ||||
| 									echo "<td style=\"text-align: left\">" . $count . "</td>"; | ||||
| 									echo "<td style=\"text-align: left\">" . $uri[3] . "</td>"; | ||||
| 									echo "<td style=\"text-align: left\"><a dir='ltr' href='" . $uri[4] . "' target='_blank'>" . htmlentities( urldecode( $uri[0] ), ENT_QUOTES ) . "</a></td>"; | ||||
| 									echo "<td style=\"text-align: left\"><a href='" . WP_Statistics_Admin_Pages::admin_url( 'pages', $arg ) . "'>" . number_format_i18n( $uri[1] ) . "</a></td>"; | ||||
| 								} | ||||
|  | ||||
| 								if ( $count == $start + 10 ) { | ||||
| 									break; | ||||
| 								} | ||||
|  | ||||
| 							} | ||||
|  | ||||
| 							echo "</table>"; | ||||
| 						} | ||||
| 						?> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 				<?php if ( $total > 0 ) { | ||||
| 					wp_statistics_paginate_links( array( | ||||
| 						'item_per_page' => $items_per_page, | ||||
| 						'total'         => $total, | ||||
| 						'current'       => $page, | ||||
| 					) ); | ||||
| 				} ?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										291
									
								
								wp-content/plugins/wp-statistics/includes/log/top-referring.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										291
									
								
								wp-content/plugins/wp-statistics/includes/log/top-referring.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,291 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| $date_args = ''; | ||||
| //Set Default Time Picker Option | ||||
| list( $daysToDisplay, $rangestart, $rangeend ) = wp_statistics_prepare_range_time_picker(); | ||||
| if ( isset( $_GET['hitdays'] ) and $_GET['hitdays'] > 0 ) { | ||||
| 	$date_args .= '&hitdays=' . $daysToDisplay; | ||||
| } | ||||
| if ( isset( $_GET['rangeend'] ) and isset( $_GET['rangestart'] ) and strtotime( $_GET['rangestart'] ) != false and strtotime( $_GET['rangeend'] ) != false ) { | ||||
| 	$date_args .= '&rangestart=' . $rangestart . '&rangeend=' . $rangeend; | ||||
| } | ||||
|  | ||||
| list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 	$daysToDisplay, | ||||
| 	$rangestart, | ||||
| 	$rangeend | ||||
| ); | ||||
|  | ||||
| $rangestartdate = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangestart_utime ); | ||||
| $rangeenddate   = $WP_Statistics->real_current_date( 'Y-m-d', '-0', $rangeend_utime ); | ||||
|  | ||||
| if ( array_key_exists( 'referr', $_GET ) ) { | ||||
| 	$referr       = $title = $_GET['referr']; | ||||
| 	$referr_field = '&referr=' . $referr; | ||||
| } else { | ||||
| 	$referr       = ''; | ||||
| 	$referr_field = null; | ||||
| } | ||||
|  | ||||
| $get_urls = array(); | ||||
| $total    = 0; | ||||
|  | ||||
| if ( $referr ) { | ||||
|  | ||||
| 	//Get domain Name | ||||
| 	$search_url = wp_statistics_get_domain_name( trim( $_GET['referr'] ) ); | ||||
| 	$result     = $wpdb->get_results( | ||||
| 		$wpdb->prepare( | ||||
| 			"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `referred` REGEXP \"^(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}\" AND referred <> '' AND LENGTH(referred) >=12 AND (`referred` LIKE  %s OR `referred` LIKE %s OR `referred` LIKE %s OR `referred` LIKE %s) AND `last_counter` BETWEEN %s AND %s ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC", | ||||
| 			'https://www.' . $wpdb->esc_like( $search_url ) . '%', 'https://' . $wpdb->esc_like( $search_url ) . '%', 'http://www.' . $wpdb->esc_like( $search_url ) . '%', 'http://' . $wpdb->esc_like( $search_url ) . '%', | ||||
| 			$rangestartdate, | ||||
| 			$rangeenddate | ||||
| 		) | ||||
| 	); | ||||
|  | ||||
| 	$total = count( $result ); | ||||
| } else { | ||||
|  | ||||
| 	//Get Wordpress Domain | ||||
| 	$where       = ''; | ||||
| 	$domain_name = rtrim( preg_replace( '/^https?:\/\//', '', get_site_url() ), " / " ); | ||||
| 	foreach ( array( "http", "https", "ftp" ) as $protocol ) { | ||||
| 		foreach ( array( '', 'www.' ) as $w3 ) { | ||||
| 			$where = " AND `referred` NOT LIKE '{$protocol}://{$w3}{$domain_name}%' "; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	//Get List referred | ||||
| 	$result = $wpdb->get_results( | ||||
| 		$wpdb->prepare( | ||||
| 			"SELECT SUBSTRING_INDEX(REPLACE( REPLACE( referred, 'http://', '') , 'https://' , '') , '/', 1 ) as `domain`, count(referred) as `number` FROM {$wpdb->prefix}statistics_visitor WHERE `referred` REGEXP \"^(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}\" AND referred <> '' AND LENGTH(referred) >=12 AND `last_counter` BETWEEN %s AND %s {$where} GROUP BY domain ORDER BY `number` DESC", | ||||
| 			$rangestartdate, | ||||
| 			$rangeenddate | ||||
| 		) | ||||
| 	); | ||||
|  | ||||
| 	//Number Total Row | ||||
| 	$total = count( $result ); | ||||
| } | ||||
|  | ||||
| //Load country Code | ||||
| $ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Top Referring Sites', 'wp-statistics' ) ); ?> | ||||
|     <div><?php wp_statistics_date_range_selector( WP_Statistics::$page['referrers'], $daysToDisplay, null, null, $referr_field ); ?></div> | ||||
|     <br class="clear"/> | ||||
|  | ||||
|     <ul class="subsubsub"> | ||||
| 		<?php if ( $referr ) { ?> | ||||
|             <li class="all"><a <?php if ( ! $referr ) { | ||||
| 					echo 'class="current"'; | ||||
| 				} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e( | ||||
| 						'All', | ||||
| 						'wp-statistics' | ||||
| 					); ?></a> | ||||
|             </li>| | ||||
|             <li> | ||||
|                 <a class="current" href="?page=<?php echo WP_Statistics::$page['referrers']; ?>&referr=<?php echo $WP_Statistics->html_sanitize_referrer( $referr ) . $date_args; ?>"> <?php echo htmlentities( $title, ENT_QUOTES ); ?> | ||||
|                     <span class="count">(<?php echo number_format_i18n( $total ); ?>)</span></a></li> | ||||
| 		<?php } else { ?> | ||||
|             <li class="all"><a <?php if ( ! $referr ) { | ||||
| 					echo 'class="current"'; | ||||
| 				} ?>href="?page=<?php echo WP_Statistics::$page['referrers'] . $date_args; ?>"><?php _e( | ||||
| 						'All', | ||||
| 						'wp-statistics' | ||||
| 					); ?> | ||||
|                     <span class="count">(<?php echo number_format_i18n( $total ); ?>)</span></a></li> | ||||
| 		<?php } ?> | ||||
|     </ul> | ||||
|     <div class="postbox-container" id="last-log"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php if ( $referr ) { | ||||
| 						$paneltitle = sprintf( | ||||
| 							__( 'Referring site: %s', 'wp-statistics' ), | ||||
| 							$WP_Statistics->html_sanitize_referrer( $referr ) | ||||
| 						); | ||||
| 					} else { | ||||
| 						$paneltitle = __( 'Top Referring Sites', 'wp-statistics' ); | ||||
| 					}; ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
|                         <span class="screen-reader-text"><?php printf( __( 'Toggle panel: %s', 'wp-statistics' ), $paneltitle ); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
| 						<?php | ||||
| 						echo "<div class='log-latest'>"; | ||||
|  | ||||
| 						if ( $total > 0 ) { | ||||
| 							// Initiate pagination object with appropriate arguments | ||||
| 							$items_per_page = 10; | ||||
| 							$page           = isset( $_GET['pagination-page'] ) ? abs( (int) $_GET['pagination-page'] ) : 1; | ||||
| 							$offset         = ( $page * $items_per_page ) - $items_per_page; | ||||
| 							$start          = $offset; | ||||
| 							$end            = $offset + $items_per_page; | ||||
|  | ||||
| 							if ( $referr ) { | ||||
|  | ||||
| 								//Show Table | ||||
| 								echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"top-referring\"><tr>"; | ||||
| 								echo "<td>" . __( 'Link', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 									echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 								} | ||||
| 								echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td></td>"; | ||||
| 								echo "</tr>"; | ||||
|  | ||||
| 								$i = 1; | ||||
| 								foreach ( $result as $items ) { | ||||
| 									if ( $i > $start and $i <= $end ) { | ||||
|  | ||||
| 										//Sanitize IP | ||||
| 										if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 											$ip_string  = __( '#hash#', 'wp-statistics' ); | ||||
| 											$map_string = ""; | ||||
| 										} else { | ||||
| 											$ip_string  = "{$items->ip}"; | ||||
| 											$map_string = "<a class='wps-text-muted' href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>" . wp_statistics_icons( 'dashicons-visibility', 'visibility' ) . "</a><a class='show-map wps-text-muted' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __( 'Map', 'wp-statistics' ) . "'>" . wp_statistics_icons( 'dashicons-location-alt', 'map' ) . "</a>"; | ||||
| 										} | ||||
|  | ||||
| 										echo "<tr>"; | ||||
|  | ||||
| 										//show Referrer Link | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										echo '<a href="' . $items->referred . '" target="_blank" title="' . $items->referred . '">' . preg_replace( "(^https?://)", "", trim( $items->referred ) ) . '</a>'; | ||||
| 										echo "</td>"; | ||||
|  | ||||
| 										//Show IP | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										echo $ip_string; | ||||
| 										echo "</td>"; | ||||
|  | ||||
| 										//Show Browser | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 											$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 										} else { | ||||
| 											$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 										} | ||||
| 										echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 										echo "</td>"; | ||||
|  | ||||
| 										//Show Country | ||||
| 										if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 											echo "<td style=\"text-align: left\">"; | ||||
| 											echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 											echo "</td>"; | ||||
| 										} | ||||
|  | ||||
| 										//Show Date | ||||
| 										echo "<td style=\"text-align: left\">"; | ||||
| 										echo date_i18n( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 										echo "</td>"; | ||||
|  | ||||
| 										//Show Link View IP | ||||
| 										echo "<td style=\"text-align: center\">"; | ||||
| 										echo $map_string; | ||||
| 										echo "</td>"; | ||||
|  | ||||
| 										echo '</tr>'; | ||||
|  | ||||
| 									} | ||||
| 									$i ++; | ||||
| 								} | ||||
|  | ||||
| 								echo '</table>'; | ||||
| 							} else { | ||||
|  | ||||
| 								//Show Table | ||||
| 								echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"top-referring\"><tr>"; | ||||
| 								echo "<td>" . __( 'Rating', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Site Url', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Site Title', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td>" . __( 'Server IP', 'wp-statistics' ) . "</td>"; | ||||
| 								if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 									echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 								} | ||||
| 								echo "<td>" . __( 'References', 'wp-statistics' ) . "</td>"; | ||||
| 								echo "<td></td>"; | ||||
| 								echo "</tr>"; | ||||
|  | ||||
|  | ||||
| 								//Get Refer Site Detail | ||||
| 								$refer_opt     = get_option( 'wp_statistics_referrals_detail' ); | ||||
| 								$referrer_list = ( empty( $refer_opt ) ? array() : $refer_opt ); | ||||
|  | ||||
| 								//Default unknown Column Value | ||||
| 								$unknown = '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( "Unknown", 'wp-statistics' ) . '</span>'; | ||||
|  | ||||
| 								$i = 1; | ||||
| 								foreach ( $result as $items ) { | ||||
| 									if ( $i > $start and $i <= $end ) { | ||||
|  | ||||
| 										//Prepare Data | ||||
| 										$domain = $items->domain; | ||||
| 										$number = wp_statistics_get_number_referer_from_domain( $items->domain, array( $rangestartdate, $rangeenddate ) ); | ||||
|  | ||||
| 										//Get Site Link | ||||
| 										$referrer_html = $WP_Statistics->html_sanitize_referrer( $domain ); | ||||
|  | ||||
| 										//Get Site information if Not Exist | ||||
| 										if ( ! array_key_exists( $domain, $referrer_list ) ) { | ||||
| 											$get_site_inf             = wp_statistics_get_domain_server( $domain ); | ||||
| 											$get_site_title           = wp_statistics_get_site_title( $domain ); | ||||
| 											$referrer_list[ $domain ] = array( | ||||
| 												'ip'      => $get_site_inf['ip'], | ||||
| 												'country' => $get_site_inf['country'], | ||||
| 												'title'   => ( $get_site_title === false ? '' : $get_site_title ), | ||||
| 											); | ||||
| 										} | ||||
|  | ||||
| 										echo "<tr>"; | ||||
| 										echo "<td>" . number_format_i18n( $i ) . "</td>"; | ||||
| 										echo "<td>" . wp_statistics_show_site_icon( $domain ) . " " . $WP_Statistics->get_referrer_link( $domain, $referrer_list[ $domain ]['title'] ) . "</td>"; | ||||
| 										echo "<td>" . ( trim( $referrer_list[ $domain ]['title'] ) == "" ? $unknown : $referrer_list[ $domain ]['title'] ) . "</td>"; | ||||
| 										echo "<td>" . ( trim( $referrer_list[ $domain ]['ip'] ) == "" ? $unknown : $referrer_list[ $domain ]['ip'] ) . "</td>"; | ||||
| 										if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 											echo "<td>" . ( trim( $referrer_list[ $domain ]['country'] ) == "" ? $unknown : "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $referrer_list[ $domain ]['country'] . '.png' ) . "' title='{$ISOCountryCode[$referrer_list[ $domain ]['country']]}' class='log-tools'/>" ) . "</td>"; | ||||
| 										} | ||||
| 										echo "<td><a class='wps-text-success' href='?page=" . WP_Statistics::$page['referrers'] . "&referr=" . $referrer_html . $date_args . "'>" . number_format_i18n( $number ) . "</a></td>"; | ||||
| 										echo "</tr>"; | ||||
| 									} | ||||
| 									$i ++; | ||||
| 								} | ||||
|  | ||||
| 								echo "</table>"; | ||||
|  | ||||
| 								//Save Referrer List Update | ||||
| 								update_option( 'wp_statistics_referrals_detail', $referrer_list, 'no' ); | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 						echo '</div>'; | ||||
| 						?> | ||||
|                     </div> | ||||
|                 </div> | ||||
| 				<?php | ||||
| 				if ( $total > 0 ) { | ||||
| 					wp_statistics_paginate_links( array( | ||||
| 						'item_per_page' => $items_per_page, | ||||
| 						'total'         => $total, | ||||
| 						'current'       => $page, | ||||
| 					) ); | ||||
| 				} | ||||
| 				?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| @@ -0,0 +1,75 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         postboxes.add_postbox_toggles(pagenow); | ||||
|     }); | ||||
| </script> | ||||
| <?php | ||||
| $ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
| include( WP_Statistics::$reg['plugin-dir'] . 'includes/log/widgets/top.visitors.php' ); | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Top 100 Visitors Today', 'wp-statistics' ) ); ?> | ||||
| 	<?php | ||||
| 	wp_enqueue_script( 'jquery-ui-datepicker' ); | ||||
| 	wp_register_style( 'jquery-ui-smoothness-css', WP_Statistics::$reg['plugin-url'] . 'assets/css/jquery-ui-smoothness.min.css' ); | ||||
| 	wp_enqueue_style( 'jquery-ui-smoothness-css' ); | ||||
|  | ||||
| 	$current = 0; | ||||
| 	$statsdate  = $WP_Statistics->Current_Date( get_option( "date_format" ), '-' . $current ); | ||||
| 	$rang_start = $WP_Statistics->Current_Date( "Y-m-d" ); | ||||
| 	if ( isset( $_GET['statsdate'] ) and strtotime( $_GET['statsdate'] ) != false ) { | ||||
| 		$statsdate  = date( get_option( "date_format" ), strtotime( $_GET['statsdate'] ) ); | ||||
| 		$rang_start = date( "Y-m-d", strtotime( $_GET['statsdate'] ) ); | ||||
| 	} | ||||
|  | ||||
| 	echo '<br><form method="get">' . "\r\n"; | ||||
| 	echo ' ' . __( 'Date', 'wp-statistics' ) . ': '; | ||||
|  | ||||
| 	echo '<input type="hidden" name="page" value="' . WP_Statistics::$page['top-visitors'] . '">' . "\r\n"; | ||||
| 	echo '<input type="text" size="18" name="statsdate" id="statsdate" value="' . htmlentities( $statsdate, ENT_QUOTES ) . '" autocomplete="off" placeholder="' . __( wp_statistics_dateformat_php_to_jqueryui( get_option( "date_format" ) ), 'wp-statistics' ) . '"> <input type="submit" value="' . __( 'Go', 'wp-statistics' ) . '" class="button-primary">' . "\r\n"; | ||||
| 	echo '<input type="hidden" name="statsdate" id="stats-date" value="' . $rang_start . '">'; | ||||
| 	echo '</form>' . "\r\n"; | ||||
|  | ||||
| 	echo '<script src="' . WP_Statistics::$reg['plugin-url'] . 'assets/js/moment.min.js?ver=2.24.0"></script>'; | ||||
| 	echo '<script> | ||||
|         jQuery(function() {  | ||||
|         jQuery( "#statsdate" ).datepicker({dateFormat: \'' . wp_statistics_dateformat_php_to_jqueryui( get_option( "date_format" ) ) . '\',  | ||||
|         onSelect: function(selectedDate) { | ||||
|             if (selectedDate.length > 0) { | ||||
|                 jQuery("#stats-date").val(moment(selectedDate, \'' . wp_statistics_convert_php_to_moment_js( get_option( "date_format" ) ) . '\').format(\'YYYY-MM-DD\')); | ||||
|             } | ||||
|         } | ||||
|         }); | ||||
|         }); | ||||
|         </script>' . "\r\n"; | ||||
|  | ||||
| 	?> | ||||
|     <div class="postbox-container" id="last-log" style="width: 100%;"> | ||||
|         <div class="metabox-holder"> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div class="postbox"> | ||||
| 					<?php $paneltitle = __( 'Top Visitors', 'wp-statistics' ); ?> | ||||
|                     <button class="handlediv" type="button" aria-expanded="true"> | ||||
| 						<span class="screen-reader-text"><?php printf( | ||||
| 								__( 'Toggle panel: %s', 'wp-statistics' ), | ||||
| 								$paneltitle | ||||
| 							); ?></span> | ||||
|                         <span class="toggle-indicator" aria-hidden="true"></span> | ||||
|                     </button> | ||||
|                     <h2 class="hndle"><span><?php echo $paneltitle; ?></h2> | ||||
|  | ||||
|                     <div class="inside"> | ||||
|  | ||||
| 						<?php wp_statistics_generate_top_visitors_postbox_content( | ||||
| 							$ISOCountryCode, | ||||
| 							$statsdate, | ||||
| 							100, | ||||
| 							false | ||||
| 						); ?> | ||||
|  | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| @@ -0,0 +1,30 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_about_postbox_content() { | ||||
| 	global $WP_Statistics; | ||||
| 	?> | ||||
|     <div style="text-align: center;"> | ||||
|         <a href="https://wp-statistics.com" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/logo-250.png' ); ?>"></a> | ||||
|     </div> | ||||
|  | ||||
|     <div id="about-links" style="text-align: center;"> | ||||
|         <p> | ||||
|             <a href="https://wp-statistics.com" target="_blank"><?php _e( 'Website', 'wp-statistics' ); ?></a></p> | <p> | ||||
|             <a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank"><?php _e( 'Rate & Review', 'wp-statistics' ); ?></a> | ||||
|         </p> | ||||
| 		<?php | ||||
| 		if ( current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ) ) ) { | ||||
| 			?> | ||||
|             | <p> | ||||
|                 <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'settings', array( 'tab' => 'about' ) ); ?>"><?php _e( 'More Info', 'wp-statistics' ); ?></a> | ||||
|             </p>| <p> | ||||
|                 <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'wps_welcome' ); ?>"><?php _e( 'What’s New', 'wp-statistics' ); ?>?</a></p> | ||||
| 			<?php | ||||
| 		} | ||||
| 		?> | ||||
|         <div class="wps-postbox-veronalabs"> | ||||
|             <a href="https://veronalabs.com" target="_blank" title="<?php _e( 'Power by VeronaLabs', 'wp-statistics' ); ?>"><img src="https://veronalabs.com/wp-content/themes/veronalabs.com/assets/images/logo.svg"/></a> | ||||
|         </div> | ||||
|     </div> | ||||
| 	<?php | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,86 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_browsers_postbox_content() { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
| 	$id                   = 'browser-stats-' . rand( 111, 999 ); | ||||
| 	$Browsers             = wp_statistics_ua_list(); | ||||
| 	$BrowserVisits        = array(); | ||||
| 	$total                = 0; | ||||
| 	$count                = 0; | ||||
| 	$topten               = 0; | ||||
| 	$topten_browser_name  = array(); | ||||
| 	$topten_browser_value = array(); | ||||
|  | ||||
| 	foreach ( $Browsers as $Browser ) { | ||||
| 		//Get List Of count Visitor By Agent | ||||
| 		$BrowserVisits[ $Browser ] = wp_statistics_useragent( $Browser ); | ||||
| 		//Sum This agent | ||||
| 		$total += $BrowserVisits[ $Browser ]; | ||||
| 	} | ||||
|  | ||||
| 	//Add Unknown Agent to total | ||||
| 	$total += $other_agent_count = $wpdb->get_var( 'SELECT COUNT(*) FROM `' . $wpdb->prefix . 'statistics_visitor` WHERE `agent` NOT IN (\'' . implode( "','", $Browsers ) . '\')' ); | ||||
|  | ||||
| 	//Sort Browser List By Visitor ASC | ||||
| 	arsort( $BrowserVisits ); | ||||
|  | ||||
| 	foreach ( $BrowserVisits as $key => $value ) { | ||||
| 		$topten += $value; | ||||
| 		$count ++; | ||||
| 		if ( $count > 9 ) { | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		//Get Browser name | ||||
| 		$browser_name = wp_statistics_get_browser_list( strtolower( $key ) ); | ||||
|  | ||||
| 		$topten_browser_name[]  = "'" . $browser_name . "'"; | ||||
| 		$topten_browser_value[] = $value; | ||||
| 		$topten_browser_color[] = wp_statistics_generate_rgba_color( $count, '0.4' ); | ||||
| 	} | ||||
|  | ||||
| 	if ( $topten_browser_name and $topten_browser_value and $other_agent_count > 0 ) { | ||||
| 		$topten_browser_name[]  = "'" . __( 'Other', 'wp-statistics' ) . "'"; | ||||
| 		$topten_browser_value[] = ( $total - $topten ); | ||||
| 		$topten_browser_color[] = wp_statistics_generate_rgba_color( 10, '0.4' ); | ||||
| 	} | ||||
| 	?> | ||||
|     <canvas id="<?php echo $id; ?>" height="220"></canvas> | ||||
|     <script> | ||||
|         var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d'); | ||||
|         <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|         var ChartJs = new Chart(ctx, { | ||||
|             type: 'pie', | ||||
|             data: { | ||||
|                 labels: [<?php echo implode( ', ', $topten_browser_name ); ?>], | ||||
|                 datasets: [{ | ||||
|                     label: '<?php _e( 'Browsers', 'wp-statistics' ); ?>', | ||||
|                     data: [<?php echo implode( ', ', $topten_browser_value ); ?>], | ||||
|                     backgroundColor: [<?php echo implode( ', ', $topten_browser_color ); ?>], | ||||
|                 }] | ||||
|             }, | ||||
|             options: { | ||||
|                 responsive: true, | ||||
|                 legend: { | ||||
|                     position: 'bottom', | ||||
|                 }, | ||||
|                 animation: { | ||||
|                     duration: 0, | ||||
|                 }, | ||||
|                 tooltips: { | ||||
|                     callbacks: { | ||||
|                         label: function (tooltipItem, data) { | ||||
|                             var dataset = data.datasets[tooltipItem.datasetIndex]; | ||||
|                             var total = dataset.data.reduce(function (previousValue, currentValue, currentIndex, array) { | ||||
|                                 return previousValue + currentValue; | ||||
|                             }); | ||||
|                             var currentValue = dataset.data[tooltipItem.index]; | ||||
|                             var precentage = Math.floor(((currentValue / total) * 100) + 0.5); | ||||
|                             return precentage + "% - " + data.labels[tooltipItem.index]; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,29 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_countries_postbox_content() { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
| 	$ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
| 	?> | ||||
|     <table width="100%" class="widefat table-stats" id="last-referrer"> | ||||
|         <tr> | ||||
|             <td width="10%" style='text-align: left'><?php _e( 'Rank', 'wp-statistics' ); ?></td> | ||||
|             <td width="10%" style='text-align: left'><?php _e( 'Flag', 'wp-statistics' ); ?></td> | ||||
|             <td width="40%" style='text-align: left'><?php _e( 'Country', 'wp-statistics' ); ?></td> | ||||
|             <td width="40%" style='text-align: left'><?php _e( 'Visitor Count', 'wp-statistics' ); ?></td> | ||||
|         </tr> | ||||
| 		<?php | ||||
| 		$result = $wpdb->get_results( "SELECT `location`, COUNT(`location`) AS `count` FROM `{$wpdb->prefix}statistics_visitor` GROUP BY `location` ORDER BY `count` DESC LIMIT 10" ); | ||||
| 		$i      = 0; | ||||
| 		foreach ( $result as $item ) { | ||||
| 			$i ++; | ||||
| 			$item->location = strtoupper( $item->location ); | ||||
| 			echo "<tr>"; | ||||
| 			echo "<td style='text-align: left;'>$i</td>"; | ||||
| 			echo "<td style='text-align: left;'><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item->location . '.png' ) . "' title='{$ISOCountryCode[$item->location]}'/></td>"; | ||||
| 			echo "<td style='text-align: left;'>{$ISOCountryCode[$item->location]}</td>"; | ||||
| 			echo "<td style='text-align: left;'><a href='" . WP_Statistics_Admin_Pages::admin_url( 'countries', array( 'country' => $item->location ) ) . "'>" . number_format_i18n( $item->count ) . "</a></td>"; | ||||
| 			echo "</tr>"; | ||||
| 		} | ||||
| 		?> | ||||
|     </table> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,78 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_hits_postbox_content( $size = '300', $days = 20 ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
| 	$id       = 'visits-stats-' . rand( 111, 999 ); | ||||
| 	$visitors = array(); | ||||
| 	$visits   = array(); | ||||
|  | ||||
| 	for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'"; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 		$visitors[] = wp_statistics_visitor( '-' . $i, true ); | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 		$visits[] = wp_statistics_visit( '-' . $i, true ); | ||||
| 	} | ||||
| 	?> | ||||
|     <canvas id="<?php echo $id; ?>" height="<?php echo $size; ?>"></canvas> | ||||
|     <script> | ||||
|         var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d'); | ||||
| 		<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|         var ChartJs = new Chart(ctx, { | ||||
|             type: 'line', | ||||
|             data: { | ||||
|                 labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                 datasets: [ | ||||
| 					<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?> | ||||
|                     { | ||||
|                         label: '<?php _e( 'Visitors', 'wp-statistics' ); ?>', | ||||
|                         data: [<?php echo implode( ',', $visitors ); ?>], | ||||
|                         backgroundColor: 'rgba(255, 99, 132, 0.2)', | ||||
|                         borderColor: 'rgba(255, 99, 132, 1)', | ||||
|                         borderWidth: 1, | ||||
|                         fill: true, | ||||
|                     }, | ||||
| 					<?php } ?> | ||||
| 					<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?> | ||||
|                     { | ||||
|                         label: '<?php _e( 'Visits', 'wp-statistics' ); ?>', | ||||
|                         data: [<?php echo implode( ',', $visits ); ?>], | ||||
|                         backgroundColor: 'rgba(54, 162, 235, 0.2)', | ||||
|                         borderColor: 'rgba(54, 162, 235, 1)', | ||||
|                         borderWidth: 1, | ||||
|                         fill: true, | ||||
|                     }, | ||||
| 					<?php } ?> | ||||
|                 ] | ||||
|             }, | ||||
|             options: { | ||||
|                 responsive: true, | ||||
|                 legend: { | ||||
|                     position: 'bottom', | ||||
|                 }, | ||||
|                 animation: { | ||||
|                     duration: 0, | ||||
|                 }, | ||||
|                 title: { | ||||
|                     display: true, | ||||
|                     text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $days ); ?>' | ||||
|                 }, | ||||
|                 tooltips: { | ||||
|                     mode: 'index', | ||||
|                     intersect: false, | ||||
|                 }, | ||||
|                 scales: { | ||||
|                     yAxes: [{ | ||||
|                         ticks: { | ||||
|                             beginAtZero: true | ||||
|                         } | ||||
|                     }] | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,124 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_map_postbox_content( $ISOCountryCode ) { | ||||
|  | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	if ( $WP_Statistics->get_option( 'geoip' ) && ! $WP_Statistics->get_option( 'disable_map' ) ) { ?> | ||||
|         <div id="map_canvas"></div> | ||||
|  | ||||
| 		<?php $result = $wpdb->get_row( | ||||
| 			"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" | ||||
| 		); ?> | ||||
|         <script type="text/javascript"> | ||||
|             var country_pin = Array(); | ||||
|             var country_color = Array(); | ||||
|  | ||||
|             jQuery(document).ready(function () { | ||||
|  | ||||
| 				<?php | ||||
| 				$result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$WP_Statistics->Current_Date('Y-m-d')}'" ); | ||||
| 				$final_result = array(); | ||||
| 				$final_result['000'] = array(); | ||||
|  | ||||
| 				//Load City Geoip | ||||
| 				$geoip_reader = false; | ||||
| 				if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 					$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 				} | ||||
|  | ||||
| 				if ( $result ) { | ||||
| 					foreach ( $result as $new_r ) { | ||||
| 						$new_r->location = strtolower( $new_r->location ); | ||||
|  | ||||
| 						$final_result[ $new_r->location ][] = array | ||||
| 						( | ||||
| 							'location' => $new_r->location, | ||||
| 							'agent'    => $new_r->agent, | ||||
| 							'ip'       => $new_r->ip, | ||||
| 						); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				$final_total = count( $result ) - count( $final_result['000'] ); | ||||
|  | ||||
| 				unset( $final_result['000'] ); | ||||
|  | ||||
| 				$startColor = array( 200, 238, 255 ); | ||||
| 				$endColor = array( 0, 100, 145 ); | ||||
|  | ||||
| 				foreach($final_result as $items) { | ||||
|  | ||||
| 				foreach ( $items as $markets ) { | ||||
|  | ||||
| 					if ( $markets['location'] == '000' ) { | ||||
| 						continue; | ||||
| 					} | ||||
|  | ||||
| 					$flag = "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . strtoupper( $markets['location'] ) . '.png' ) . "' title='{$ISOCountryCode[strtoupper($markets['location'])]}' class='log-tools'/> {$ISOCountryCode[strtoupper($markets['location'])]}"; | ||||
|  | ||||
| 					if ( array_search( strtolower( $markets['agent'] ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 						$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $markets['agent'] . ".png' class='log-tools' title='{$markets['agent']}'/>"; | ||||
| 					} else { | ||||
| 						$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/unknown.png' ) . "' class='log-tools' title='{$markets['agent']}'/>"; | ||||
| 					} | ||||
|  | ||||
| 					if ( substr( $markets['ip'], 0, 6 ) == '#hash#' ) { | ||||
| 						$markets['ip'] = __( '#hash#', 'wp-statistics' ); | ||||
| 					} | ||||
|  | ||||
| 					$city = ''; | ||||
| 					if ( $geoip_reader != false ) { | ||||
| 						try { | ||||
| 							$reader = $geoip_reader->city( $markets['ip'] ); | ||||
| 							$city   = $reader->city->name; | ||||
| 						} catch ( Exception $e ) { | ||||
| 							$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 						} | ||||
| 					} | ||||
| 					if ( $city != "" ) { | ||||
| 						$city = ' - ' . $city; | ||||
| 					} | ||||
|  | ||||
| 					$get_ipp[ $markets['location'] ][] = "<p>{$agent} {$markets['ip']} {$city}</p>"; | ||||
| 				} | ||||
|  | ||||
| 				$market_total = count( $get_ipp[ $markets['location'] ] ); | ||||
| 				$last_five = ""; | ||||
|  | ||||
| 				// Only show the last five visitors, more just makes the map a mess. | ||||
| 				for ( $i = $market_total; $i > $market_total - 6; $i -- ) { | ||||
| 					if ( array_key_exists( $i, $get_ipp[ $markets['location'] ] ) ) { | ||||
| 						$last_five .= $get_ipp[ $markets['location'] ][ $i ]; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				$summary = ' [' . $market_total . ']'; | ||||
|  | ||||
| 				$color = sprintf( "#%02X%02X%02X", round( $startColor[0] + ( $endColor[0] - $startColor[0] ) * $market_total / $final_total ), round( $startColor[1] + ( $endColor[1] - $startColor[1] ) * $market_total / $final_total ), round( $startColor[2] + ( $endColor[2] - $startColor[2] ) * $market_total / $final_total ) ); | ||||
| 				?> | ||||
|                 country_pin['<?php echo $markets['location'];?>'] = "<div class='map-html-marker'><?php echo $flag . $summary . '<hr />' . $last_five; ?></div>"; | ||||
|                 country_color['<?php echo $markets['location'];?>'] = "<?php echo $color;?>"; | ||||
| 				<?php | ||||
| 				} | ||||
| 				?> | ||||
|                 var data_total = <?php echo $final_total;?>; | ||||
|  | ||||
|                 jQuery('#map_canvas').vectorMap({ | ||||
|                     map: 'world_en', | ||||
|                     colors: country_color, | ||||
|                     onLabelShow: function (element, label, code) { | ||||
|                         if (country_pin[code] !== undefined) { | ||||
|                             label.html(country_pin[code]); | ||||
|                         } | ||||
|                         else { | ||||
|                             label.html(label.html() + ' [0]<hr />'); | ||||
|                         } | ||||
|                     }, | ||||
|                 }); | ||||
|  | ||||
|  | ||||
|             }); | ||||
|         </script> | ||||
| 		<?php | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										104
									
								
								wp-content/plugins/wp-statistics/includes/log/widgets/page.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								wp-content/plugins/wp-statistics/includes/log/widgets/page.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,104 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @param        $pageuri | ||||
|  * @param        $pageid | ||||
|  * @param int $days | ||||
|  * @param null $chart_title | ||||
|  * @param string $rangestart | ||||
|  * @param string $rangeend | ||||
|  */ | ||||
| function wp_statistics_generate_page_postbox_content( | ||||
| 	$pageuri, | ||||
| 	$pageid, | ||||
| 	$days = 20, | ||||
| 	$chart_title = null, | ||||
| 	$rangestart = '', | ||||
| 	$rangeend = '' | ||||
| ) { | ||||
| 	GLOBAL $WP_Statistics; | ||||
|  | ||||
| 	if ( ! $WP_Statistics->get_option( 'pages' ) ) { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if ( $chart_title == null ) { | ||||
| 		$chart_title = __( 'Page Trending Stats', 'wp-statistics' ); | ||||
| 	} | ||||
|  | ||||
| 	if ( $pageuri && ! $pageid ) { | ||||
| 		$pageid = wp_statistics_uri_to_id( $pageuri ); | ||||
| 	} | ||||
|  | ||||
| 	$post = get_post( $pageid ); | ||||
| 	if ( is_object( $post ) ) { | ||||
| 		$title = esc_html( $post->post_title ); | ||||
| 	} else { | ||||
| 		$title = ""; | ||||
| 	} | ||||
|  | ||||
| 	$urlfields = "&page-id={$pageid}"; | ||||
| 	if ( $pageuri ) { | ||||
| 		$urlfields .= "&page-uri={$pageuri}"; | ||||
| 	} | ||||
|  | ||||
| 	list( $daysToDisplay, $rangestart_utime, $rangeend_utime ) = wp_statistics_date_range_calculator( | ||||
| 		$days, | ||||
| 		$rangestart, | ||||
| 		$rangeend | ||||
| 	); | ||||
| 	$daysInThePast = round( ( time() - $rangeend_utime ) / 86400, 0 ); | ||||
|  | ||||
| 	for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'"; | ||||
| 	} | ||||
|  | ||||
| 	for ( $i = $daysToDisplay; $i >= 0; $i -- ) { | ||||
| 		$stats[] = wp_statistics_pages( '-' . ( $i + $daysInThePast ), $pageuri, $pageid ); | ||||
| 	} | ||||
| 	?> | ||||
|     <canvas id="visits-stats" height="80"></canvas> | ||||
|     <script> | ||||
|         var ctx = document.getElementById("visits-stats").getContext('2d'); | ||||
|         <?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|         var ChartJs = new Chart(ctx, { | ||||
|             type: 'line', | ||||
|             data: { | ||||
|                 labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                 datasets: [ | ||||
| 					<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?> | ||||
|                     { | ||||
|                         label: '<?php echo $title; ?>', | ||||
|                         data: [<?php echo implode( ',', $stats ); ?>], | ||||
|                         backgroundColor: 'rgba(255, 99, 132, 0.2)', | ||||
|                         borderColor: 'rgba(255, 99, 132, 1)', | ||||
|                         borderWidth: 1, | ||||
|                         fill: true, | ||||
|                     }, | ||||
| 					<?php } ?> | ||||
|                 ] | ||||
|             }, | ||||
|             options: { | ||||
|                 responsive: true, | ||||
|                 legend: { | ||||
|                     position: 'bottom', | ||||
|                 }, | ||||
|                 title: { | ||||
|                     display: true, | ||||
|                     text: '<?php _e( 'Number of Hits', 'wp-statistics' ); ?>' | ||||
|                 }, | ||||
|                 tooltips: { | ||||
|                     mode: 'index', | ||||
|                     intersect: false, | ||||
|                 }, | ||||
|                 scales: { | ||||
|                     yAxes: [{ | ||||
|                         ticks: { | ||||
|                             beginAtZero: true | ||||
|                         } | ||||
|                     }] | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,49 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_pages_postbox_content() { | ||||
| 	global $wpdb; | ||||
|  | ||||
| 	$result   = $wpdb->get_results( "SELECT `pages`.`uri`,`pages`.`id`,`pages`.`type`, SUM(`pages`.`count`) + IFNULL(`historical`.`value`, 0) AS `count_sum` FROM `{$wpdb->prefix}statistics_pages` `pages` LEFT JOIN `{$wpdb->prefix}statistics_historical` `historical` ON `pages`.`uri`=`historical`.`uri` AND `historical`.`category`='uri' GROUP BY `uri` ORDER BY `count_sum` DESC LIMIT 10" ); | ||||
| 	$site_url = site_url(); | ||||
| 	$counter  = 0; | ||||
| 	echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"><tr>"; | ||||
| 	echo "<td width='10%'>" . __( 'ID', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "<td width='40%'>" . __( 'Title', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "<td width='40%'>" . __( 'Link', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "<td width='10%'>" . __( 'Visits', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "</tr>"; | ||||
|  | ||||
| 	foreach ( $result as $item ) { | ||||
| 		$counter += 1; | ||||
|  | ||||
| 		// Lookup the post title. | ||||
| 		$page_info = wp_statistics_get_page_info( $item->id, $item->type ); | ||||
| 		$title     = mb_substr( $page_info['title'], 0, 200, "utf-8" ); | ||||
| 		$page_link = $page_info['link']; | ||||
|  | ||||
| 		/** | ||||
| 		 * Check Get title by url | ||||
| 		 * @since v12.5.7 | ||||
| 		 */ | ||||
| 		if ( $page_link == '' ) { | ||||
| 			$page_link = htmlentities( $site_url . $item->uri, ENT_QUOTES ); | ||||
| 			$id        = wp_statistics_uri_to_id( $item->uri ); | ||||
| 			$post      = get_post( $id ); | ||||
| 			if ( is_object( $post ) ) { | ||||
| 				$title = esc_html( $post->post_title ); | ||||
| 			} else { | ||||
| 				if ( $item->uri == '/' ) { | ||||
| 					$title = get_bloginfo(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		echo "<tr>"; | ||||
| 		echo "<td style=\"text-align: left\">" . $counter . "</td>"; | ||||
| 		echo "<td style=\"text-align: left\">" . $title . "</td>"; | ||||
| 		echo '<td style="text-align: left"><a href="' . $page_link . '" target="_blank">' . htmlentities( urldecode( $item->uri ), ENT_QUOTES ) . '</a></td>'; | ||||
| 		echo '<td style="text-align: left"><a href="' . WP_Statistics_Admin_Pages::admin_url( 'pages', array( 'page-uri' => htmlentities( $item->uri, ENT_QUOTES ) ) ) . '">' . number_format_i18n( $item->count_sum ) . '</a></td>'; | ||||
| 		echo '</tr>'; | ||||
|  | ||||
| 	} | ||||
| 	echo '</table>'; | ||||
| } | ||||
| @@ -0,0 +1,235 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_quickstats_postbox_content( $search_engines, $search = false, $time = false ) { | ||||
|  | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	$show_visitors = $WP_Statistics->get_option( 'visitor' ); | ||||
| 	?> | ||||
|     <table width="100%" class="widefat table-stats" id="summary-stats"> | ||||
|         <tbody> | ||||
| 		<?php if ( $WP_Statistics->get_option( 'useronline' ) ) { ?> | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Online Users:', 'wp-statistics' ); ?></th> | ||||
|                 <th colspan="2" id="th-colspan"> | ||||
|                     <span><a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'online' ); ?>"><?php echo wp_statistics_useronline(); ?></a></span> | ||||
|                 </th> | ||||
|             </tr> | ||||
| 		<?php } | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th width="60%"></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						_e( 'Visitors', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						_e( 'Visits', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Today:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'today' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Yesterday:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'yesterday' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 7 Days (Week):', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 7 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 7 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'week' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 30 Days (Month):', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 30 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 30 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'month' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 365 Days (Year):', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'year' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Total:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'total' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
| 			<?php | ||||
| 		} | ||||
|  | ||||
| 		if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) { | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'visitors' ) || | ||||
| 			     $WP_Statistics->get_option( 'visits' ) || | ||||
| 			     $WP_Statistics->get_option( 'useronline' ) | ||||
| 			) { | ||||
| 				?> | ||||
|                 <tr> | ||||
|                     <th colspan="3"><br> | ||||
|                         <hr> | ||||
|                     </th> | ||||
|                 </tr> | ||||
| 			<?php } ?> | ||||
|             <tr> | ||||
|                 <th colspan="3" style="text-align: center;"><?php _e( | ||||
| 						'Search Engine Referrals', | ||||
| 						'wp-statistics' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th width="60%"></th> | ||||
|                 <th class="th-center"><?php _e( 'Today', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php _e( 'Yesterday', 'wp-statistics' ); ?></th> | ||||
|             </tr> | ||||
|  | ||||
| 			<?php | ||||
| 			$se_today_total     = 0; | ||||
| 			$se_yesterday_total = 0; | ||||
| 			foreach ( $search_engines as $se ) { | ||||
| 				?> | ||||
|                 <tr> | ||||
|                     <th> | ||||
|                         <img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e( | ||||
| 							$se['name'], | ||||
| 							'wp-statistics' | ||||
| 						); ?> | ||||
|                         : | ||||
|                     </th> | ||||
|                     <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' ); | ||||
| 							$se_today_total                    += $se_temp; | ||||
| 							echo number_format_i18n( $se_temp ); ?></span></th> | ||||
|                     <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' ); | ||||
| 							$se_yesterday_total                += $se_temp; | ||||
| 							echo number_format_i18n( $se_temp ); ?></span></th> | ||||
|                 </tr> | ||||
|  | ||||
| 				<?php | ||||
| 			} | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Daily Total:', 'wp-statistics' ); ?></th> | ||||
|                 <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span> | ||||
|                 </td> | ||||
|                 <td id="th-colspan" class="th-center"> | ||||
|                     <span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Total:', 'wp-statistics' ); ?></th> | ||||
|                 <th colspan="2" id="th-colspan"> | ||||
|                     <span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} | ||||
|  | ||||
| 		if ( $time == true ) { | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th colspan="3"><br> | ||||
|                     <hr> | ||||
|                 </th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp-statistics' ); ?> | ||||
|                     <span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e( | ||||
| 								'(Adjustment)', | ||||
| 								'wp-statistics' | ||||
| 							); ?></a></span> | ||||
|                 </th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3"><?php echo sprintf( | ||||
| 						__( 'Date: %s', 'wp-statistics' ), | ||||
| 						'<code dir="ltr">' . | ||||
| 						$WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) . | ||||
| 						'</code>' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3"><?php echo sprintf( | ||||
| 						__( 'Time: %s', 'wp-statistics' ), | ||||
| 						'<code dir="ltr">' . | ||||
| 						$WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) . | ||||
| 						'</code>' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
| 		<?php } ?> | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
|     <br> | ||||
|     <hr width="80%"/><br> | ||||
| 	<?php | ||||
|  | ||||
| 	// Include the hits chart widget, we're going to display the last 10 days only as the WordPress columns are kind of small to do much else. | ||||
| 	include( WP_Statistics::$reg['plugin-dir'] . "includes/log/widgets/hits.php" ); | ||||
|  | ||||
| 	wp_statistics_generate_hits_postbox_content( "220px", 10 ); | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,86 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_recent_postbox_content( $ISOCountryCode, $count = 10 ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	$result = $wpdb->get_results( | ||||
| 		"SELECT * FROM `{$wpdb->prefix}statistics_visitor` ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC  LIMIT 0, {$count}" | ||||
| 	); | ||||
|  | ||||
| 	echo "<div class=\"wp-statistics-table\">"; | ||||
| 	echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"> | ||||
| 		  <tr>"; | ||||
| 	echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 	if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 		echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 	} | ||||
| 	if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 		echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 	} | ||||
| 	echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 	echo "</tr>"; | ||||
|  | ||||
| 	// Load city name | ||||
| 	$geoip_reader = false; | ||||
| 	if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 		$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $result as $items ) { | ||||
| 		echo "<tr>"; | ||||
| 		echo "<td style=\"text-align: left\">"; | ||||
| 		if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 			$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 		} else { | ||||
| 			$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 		} | ||||
| 		echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 		echo "</td>"; | ||||
| 		$city = ''; | ||||
| 		if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 			if ( $geoip_reader != false ) { | ||||
| 				try { | ||||
| 					$reader = $geoip_reader->city( $items->ip ); | ||||
| 					$city   = $reader->city->name; | ||||
| 				} catch ( Exception $e ) { | ||||
| 					$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 				} | ||||
|  | ||||
| 				if ( ! $city ) { | ||||
| 					$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 			echo "<td style=\"text-align: left\">"; | ||||
| 			echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 			echo "</td>"; | ||||
| 		} | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 			echo "<td style=\"text-align: left\">"; | ||||
| 			echo $city; | ||||
| 			echo "</td>"; | ||||
| 		} | ||||
|  | ||||
| 		echo "<td style=\"text-align: left\">"; | ||||
| 		echo date_i18n( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 		echo "</td>"; | ||||
|  | ||||
| 		echo "<td style=\"text-align: left\">"; | ||||
| 		if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 			$ip_string = __( '#hash#', 'wp-statistics' ); | ||||
| 		} else { | ||||
| 			$ip_string = "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>{$items->ip}</a>"; | ||||
| 		} | ||||
| 		echo $ip_string; | ||||
| 		echo "</td>"; | ||||
| 		echo "<td style=\"text-align: left\">" . $WP_Statistics->get_referrer_link( $items->referred ) . "</td>"; | ||||
| 		echo "</tr>"; | ||||
| 	} | ||||
|  | ||||
| 	echo "</table>"; | ||||
| 	echo "</div>"; | ||||
| } | ||||
| @@ -0,0 +1,73 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_referring_postbox_content( $count = 10 ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	//Get Top Referring | ||||
| 	if ( false === ( $get_urls = get_transient( 'wps_top_referring' ) ) ) { | ||||
|  | ||||
| 		//Get Wordpress Domain | ||||
| 		$where       = ''; | ||||
| 		$domain_name = rtrim( preg_replace( '/^https?:\/\//', '', get_site_url() ), " / " ); | ||||
| 		foreach ( array( "http", "https", "ftp" ) as $protocol ) { | ||||
| 			foreach ( array( '', 'www.' ) as $w3 ) { | ||||
| 				$where = " AND `referred` NOT LIKE '{$protocol}://{$w3}{$domain_name}%' "; | ||||
| 			} | ||||
| 		} | ||||
| 		$result = $wpdb->get_results( "SELECT SUBSTRING_INDEX(REPLACE( REPLACE( referred, 'http://', '') , 'https://' , '') , '/', 1 ) as `domain`, count(referred) as `number` FROM {$wpdb->prefix}statistics_visitor WHERE `referred` REGEXP \"^(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}\" AND referred <> '' AND LENGTH(referred) >=12 {$where} GROUP BY domain ORDER BY `number` DESC LIMIT $count" ); | ||||
| 		foreach ( $result as $items ) { | ||||
| 			$get_urls[ $items->domain ] = wp_statistics_get_number_referer_from_domain( $items->domain ); | ||||
| 		} | ||||
|  | ||||
| 		// Put the results in a transient. Expire after 12 hours. | ||||
| 		set_transient( 'wps_top_referring', $get_urls, 12 * HOUR_IN_SECONDS ); | ||||
| 	} | ||||
| 	?> | ||||
|     <table width="100%" class="widefat table-stats" id="top-referrer"> | ||||
|         <tr> | ||||
|             <td width="50%"><?php _e( 'Address', 'wp-statistics' ); ?></td> | ||||
|             <td width="40%"><?php _e( 'Server IP', 'wp-statistics' ); ?></td> | ||||
|             <td width="10%"><?php _e( 'References', 'wp-statistics' ); ?></td> | ||||
|         </tr> | ||||
| 		<?php | ||||
|  | ||||
| 		//Load country Code | ||||
| 		$ISOCountryCode = $WP_Statistics->get_country_codes(); | ||||
|  | ||||
| 		//Get Refer Site Detail | ||||
| 		$refer_opt     = get_option( 'wp_statistics_referrals_detail' ); | ||||
| 		$referrer_list = ( empty( $refer_opt ) ? array() : $refer_opt ); | ||||
|  | ||||
| 		if ( ! $get_urls ) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		foreach ( $get_urls as $domain => $number ) { | ||||
|  | ||||
| 			//Get Site Link | ||||
| 			$referrer_html = $WP_Statistics->html_sanitize_referrer( $domain ); | ||||
|  | ||||
| 			//Get Site information if Not Exist | ||||
| 			if ( ! array_key_exists( $domain, $referrer_list ) ) { | ||||
| 				$get_site_inf             = wp_statistics_get_domain_server( $domain ); | ||||
| 				$get_site_title           = wp_statistics_get_site_title( $domain ); | ||||
| 				$referrer_list[ $domain ] = array( | ||||
| 					'ip'      => $get_site_inf['ip'], | ||||
| 					'country' => $get_site_inf['country'], | ||||
| 					'title'   => ( $get_site_title === false ? '' : $get_site_title ), | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			echo "<tr>"; | ||||
| 			echo "<td>" . wp_statistics_show_site_icon( $domain ) . " " . $WP_Statistics->get_referrer_link( $domain, $referrer_list[ $domain ]['title'], true ) . "</td>"; | ||||
| 			echo "<td><span class='wps-cursor-default' " . ( $referrer_list[ $domain ]['country'] != "" ? 'title="' . $ISOCountryCode[ $referrer_list[ $domain ]['country'] ] . '"' : '' ) . ">" . ( $referrer_list[ $domain ]['ip'] != "" ? $referrer_list[ $domain ]['ip'] : '-' ) . "</span></td>"; | ||||
| 			echo "<td><a href='" . WP_Statistics_Admin_Pages::admin_url( 'referrers', array( 'referr' => $referrer_html ) ) . "'>" . number_format_i18n( $number ) . "</a></td>"; | ||||
| 			echo "</tr>"; | ||||
| 		} | ||||
|  | ||||
| 		//Save Referrer List Update | ||||
| 		update_option( 'wp_statistics_referrals_detail', $referrer_list, 'no' ); | ||||
|  | ||||
| 		?> | ||||
|     </table> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,96 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_search_postbox_content( $search_engines, $size = "300", $days = 20 ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
| 	$id          = 'search-stats-' . rand( 111, 999 ); | ||||
| 	$total_stats = $WP_Statistics->get_option( 'chart_totals' ); | ||||
| 	$date        = array(); | ||||
| 	$stats       = array(); | ||||
| 	$total_daily = array(); | ||||
|  | ||||
| 	for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 		$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'"; | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $search_engines as $se ) { | ||||
| 		for ( $i = $days; $i >= 0; $i -- ) { | ||||
| 			if ( ! array_key_exists( $i, $total_daily ) ) { | ||||
| 				$total_daily[ $i ] = 0; | ||||
| 			} | ||||
|  | ||||
| 			$stat                   = wp_statistics_searchengine( $se['tag'], '-' . $i ); | ||||
| 			$stats[ $se['name'] ][] = $stat; | ||||
| 			$total_daily[ $i ]      += $stat; | ||||
| 		} | ||||
| 	} | ||||
| 	?> | ||||
|     <canvas id="<?php echo $id; ?>" height="<?php echo $size; ?>"></canvas> | ||||
|     <script> | ||||
|         var colors = []; | ||||
|         colors['baidu'] = ['rgba(35, 25, 220, 0.2)', 'rgba(35, 25, 220, 1)']; | ||||
|         colors['bing'] = ['rgba(12, 132, 132, 0.2)', 'rgba(12, 132, 132, 1)']; | ||||
|         colors['duckduckgo'] = ['rgba(222, 88, 51, 0.2)', 'rgba(222, 88, 51, 1)']; | ||||
|         colors['google'] = ['rgba(23, 107, 239, 0.2)', 'rgba(23, 107, 239, 1)']; | ||||
|         colors['yahoo'] = ['rgba(64, 0, 144, 0.2)', 'rgba(64, 0, 144, 1)']; | ||||
|         colors['yandex'] = ['rgba(255, 219, 77, 0.2)', 'rgba(255, 219, 77, 1)']; | ||||
|         colors['ask'] = ['rgba(205, 0, 0, 0.2)', 'rgba(205, 0, 0, 1)']; | ||||
|         colors['clearch'] = ['rgba(13, 0, 76, 0.2)', 'rgba(13, 0, 76, 1)']; | ||||
|         colors['qwant'] = ['rgba(53, 60, 82, 0.2)', 'rgba(53, 60, 82, 1)']; | ||||
|  | ||||
|         var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d'); | ||||
| 		<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?> | ||||
|         var ChartJs = new Chart(ctx, { | ||||
|             type: 'line', | ||||
|             data: { | ||||
|                 labels: [<?php echo implode( ', ', $date ); ?>], | ||||
|                 datasets: [ | ||||
| 					<?php foreach ( $search_engines as $se ): ?> | ||||
|                     { | ||||
|                         label: '<?php echo $se['name']; ?>', | ||||
|                         data: [<?php echo implode( ',', $stats[ $se['name'] ] ); ?>], | ||||
|                         backgroundColor: colors['<?php echo $se['tag']; ?>'][0], | ||||
|                         borderColor: colors['<?php echo $se['tag']; ?>'][1], | ||||
|                         borderWidth: 1, | ||||
|                         fill: true, | ||||
|                     }, | ||||
| 					<?php endforeach; ?> | ||||
| 					<?php if ( $total_stats == 1 ) : ?> | ||||
|                     { | ||||
|                         label: '<?php _e( 'Total', 'wp-statistics' ); ?>', | ||||
|                         data: [<?php echo implode( ',', $total_daily ); ?>], | ||||
|                         backgroundColor: 'rgba(180, 180, 180, 0.2)', | ||||
|                         borderColor: 'rgba(180, 180, 180, 1)', | ||||
|                         borderWidth: 1, | ||||
|                         fill: false, | ||||
|                     }, | ||||
| 					<?php endif;?> | ||||
|                 ] | ||||
|             }, | ||||
|             options: { | ||||
|                 responsive: true, | ||||
|                 legend: { | ||||
|                     position: 'bottom', | ||||
|                 }, | ||||
|                 animation: { | ||||
|                     duration: 0, | ||||
|                 }, | ||||
|                 title: { | ||||
|                     display: true, | ||||
|                     text: '<?php echo sprintf( __( 'Search engine referrals in the last %s days', 'wp-statistics' ), $days ); ?>' | ||||
|                 }, | ||||
|                 tooltips: { | ||||
|                     mode: 'index', | ||||
|                     intersect: false, | ||||
|                 }, | ||||
|                 scales: { | ||||
|                     yAxes: [{ | ||||
|                         ticks: { | ||||
|                             beginAtZero: true | ||||
|                         } | ||||
|                     }] | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     </script> | ||||
| 	<?php | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,222 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_summary_postbox_content( $search_engines, $search = true, $time = true ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
| 	$show_visitors = $WP_Statistics->get_option( 'visitor' ); | ||||
| 	?> | ||||
|     <table width="100%" class="widefat table-stats" id="summary-stats"> | ||||
|         <tbody> | ||||
| 		<?php if ( $WP_Statistics->get_option( 'useronline' ) ) { ?> | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Online Users:', 'wp-statistics' ); ?></th> | ||||
|                 <th colspan="2" id="th-colspan"> | ||||
|                     <span><a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'online' ); ?>"><?php echo wp_statistics_useronline(); ?></a></span> | ||||
|                 </th> | ||||
|             </tr> | ||||
| 		<?php } | ||||
|  | ||||
| 		if ( $WP_Statistics->get_option( 'visitors' ) || $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th width="60%"></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						_e( 'Visitors', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						_e( 'Visits', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Today:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'today', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'today' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Yesterday:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'yesterday', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 1 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'yesterday' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 7 Days:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 7 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'week', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 7 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'week' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 30 Days:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 30 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'month', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 30 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'month' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Last 365 Days:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'year', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'year' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Total:', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visitors' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visitor( 'total', null, true ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|                 <th class="th-center"><?php if ( $WP_Statistics->get_option( 'visits' ) ) { | ||||
| 						echo '<a href="' . WP_Statistics_Admin_Pages::admin_url( 'hits', array( 'hitdays' => 365 ) ) . '"><span>' . number_format_i18n( wp_statistics_visit( 'total' ) ) . '</span></a>'; | ||||
| 					} else { | ||||
| 						echo ''; | ||||
| 					} ?></th> | ||||
|             </tr> | ||||
|  | ||||
| 			<?php | ||||
| 		} | ||||
|  | ||||
| 		if ( $search == true && $WP_Statistics->get_option( 'visitors' ) ) { | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'visitors' ) || | ||||
| 			     $WP_Statistics->get_option( 'visits' ) || | ||||
| 			     $WP_Statistics->get_option( 'useronline' ) | ||||
| 			) { | ||||
| 				?> | ||||
|                 <tr> | ||||
|                     <th colspan="3"><br> | ||||
|                         <hr> | ||||
|                     </th> | ||||
|                 </tr> | ||||
| 			<?php } ?> | ||||
|             <tr> | ||||
|                 <th colspan="3" style="text-align: center;"><?php _e( | ||||
| 						'Search Engine Referrals', | ||||
| 						'wp-statistics' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th width="60%"></th> | ||||
|                 <th class="th-center"><?php _e( 'Today', 'wp-statistics' ); ?></th> | ||||
|                 <th class="th-center"><?php _e( 'Yesterday', 'wp-statistics' ); ?></th> | ||||
|             </tr> | ||||
|  | ||||
| 			<?php | ||||
| 			$se_today_total     = 0; | ||||
| 			$se_yesterday_total = 0; | ||||
| 			foreach ( $search_engines as $se ) { | ||||
| 				?> | ||||
|                 <tr> | ||||
|                     <th> | ||||
|                         <img src='<?php echo plugins_url( 'wp-statistics/assets/images/' . $se['image'] ); ?>'> <?php _e( | ||||
| 							$se['name'], | ||||
| 							'wp-statistics' | ||||
| 						); ?> | ||||
|                         : | ||||
|                     </th> | ||||
|                     <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'today' ); | ||||
| 							$se_today_total                    += $se_temp; | ||||
| 							echo number_format_i18n( $se_temp ); ?></span></th> | ||||
|                     <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine( $se['tag'], 'yesterday' ); | ||||
| 							$se_yesterday_total                += $se_temp; | ||||
| 							echo number_format_i18n( $se_temp ); ?></span></th> | ||||
|                 </tr> | ||||
|  | ||||
| 				<?php | ||||
| 			} | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Daily Total:', 'wp-statistics' ); ?></th> | ||||
|                 <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n( $se_today_total ); ?></span> | ||||
|                 </td> | ||||
|                 <td id="th-colspan" class="th-center"> | ||||
|                     <span><?php echo number_format_i18n( $se_yesterday_total ); ?></span></td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th><?php _e( 'Total:', 'wp-statistics' ); ?></th> | ||||
|                 <th colspan="2" id="th-colspan"> | ||||
|                     <span><?php echo number_format_i18n( wp_statistics_searchengine( 'all' ) ); ?></span></th> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} | ||||
|  | ||||
| 		if ( $time == true ) { | ||||
| 			?> | ||||
|             <tr> | ||||
|                 <th colspan="3"><br> | ||||
|                     <hr> | ||||
|                 </th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3" style="text-align: center;"><?php _e( 'Current Time and Date', 'wp-statistics' ); ?> | ||||
|                     <span id="time_zone"><a href="<?php echo admin_url( 'options-general.php' ); ?>"><?php _e( '(Adjustment)', 'wp-statistics' ); ?></a></span> | ||||
|                 </th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3"><?php echo sprintf( | ||||
| 						__( 'Date: %s', 'wp-statistics' ), | ||||
| 						'<code dir="ltr">' . | ||||
| 						$WP_Statistics->Current_Date_i18n( get_option( 'date_format' ) ) . | ||||
| 						'</code>' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr> | ||||
|                 <th colspan="3"><?php echo sprintf( | ||||
| 						__( 'Time: %s', 'wp-statistics' ), | ||||
| 						'<code dir="ltr">' . | ||||
| 						$WP_Statistics->Current_Date_i18n( get_option( 'time_format' ) ) . | ||||
| 						'</code>' | ||||
| 					); ?></th> | ||||
|             </tr> | ||||
| 		<?php } ?> | ||||
|         </tbody> | ||||
|     </table> | ||||
| 	<?php | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,91 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_top_visitors_postbox_content( | ||||
| 	$ISOCountryCode, | ||||
| 	$day = 'today', | ||||
| 	$count = 10, | ||||
| 	$compact = false | ||||
| ) { | ||||
|  | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	if ( $day == 'today' ) { | ||||
| 		$sql_time = $WP_Statistics->Current_Date( 'Y-m-d' ); | ||||
| 	} else { | ||||
| 		$sql_time = date( 'Y-m-d', strtotime( $day ) ); | ||||
| 	} | ||||
|  | ||||
| 	//Load City Geoip | ||||
| 	$geoip_reader = false; | ||||
| 	if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 		$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 	} | ||||
|  | ||||
| 	?> | ||||
|     <div class="wp-statistics-table"> | ||||
|     <table width="100%" class="widefat table-stats" id="last-referrer"> | ||||
|         <tr> | ||||
|             <td><?php _e( 'Rank', 'wp-statistics' ); ?></td> | ||||
|             <td><?php _e( 'Hits', 'wp-statistics' ); ?></td> | ||||
|             <td><?php _e( 'Flag', 'wp-statistics' ); ?></td> | ||||
|             <td><?php _e( 'Country', 'wp-statistics' ); ?></td> | ||||
| 			<?php if ( $geoip_reader != false ) { | ||||
| 				echo '<td>' . __( 'City', 'wp-statistics' ) . '</td>'; | ||||
| 			} ?> | ||||
|             <td><?php _e( 'IP', 'wp-statistics' ); ?></td> | ||||
| 			<?php if ( $compact == false ) { ?> | ||||
|                 <td><?php _e( 'Agent', 'wp-statistics' ); ?></td> | ||||
|                 <td><?php _e( 'Platform', 'wp-statistics' ); ?></td> | ||||
|                 <td><?php _e( 'Version', 'wp-statistics' ); ?></td> | ||||
| 			<?php } ?> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		$result = $wpdb->get_results( | ||||
| 			"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE last_counter = '{$sql_time}' ORDER BY hits DESC" | ||||
| 		); | ||||
|  | ||||
| 		$i = 0; | ||||
|  | ||||
| 		foreach ( $result as $visitor ) { | ||||
| 			$i ++; | ||||
|  | ||||
| 			$item = strtoupper( $visitor->location ); | ||||
|  | ||||
| 			if ( $geoip_reader != false ) { | ||||
| 				try { | ||||
| 					$reader = $geoip_reader->city( $visitor->ip ); | ||||
| 					$city   = $reader->city->name; | ||||
| 				} catch ( Exception $e ) { | ||||
| 					$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 				} | ||||
| 				if ( ! $city ) { | ||||
| 					$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			echo "<tr>"; | ||||
| 			echo "<td>$i</td>"; | ||||
| 			echo "<td>" . (int) $visitor->hits . "</td>"; | ||||
| 			echo "<td><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item . '.png' ) . "' title='{$ISOCountryCode[$item]}'/></td>"; | ||||
| 			echo "<td>{$ISOCountryCode[$item]}</td>"; | ||||
| 			if ( $geoip_reader != false ) { | ||||
| 				echo "<td>{$city}</td>"; | ||||
| 			} | ||||
| 			echo "<td>{$visitor->ip}</td>"; | ||||
|  | ||||
| 			if ( $compact == false ) { | ||||
| 				echo "<td>{$visitor->agent}</td>"; | ||||
| 				echo "<td>{$visitor->platform}</td>"; | ||||
| 				echo "<td>{$visitor->version}</td>"; | ||||
| 			} | ||||
| 			echo "</tr>"; | ||||
|  | ||||
| 			if ( $i == $count ) { | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		?> | ||||
|     </table> | ||||
|     </div> | ||||
| 	<?php | ||||
| } | ||||
| @@ -0,0 +1,41 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_users_online_postbox_content( $ISOCountryCode ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	$result = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}statistics_useronline` ORDER BY `ID` DESC LIMIT 10" ); | ||||
| 	$i      = 0; | ||||
| 	if ( count( $result ) > 0 ) { | ||||
|  | ||||
| 		?> | ||||
|         <table width="100%" class="widefat table-stats" id="current_page"> | ||||
|         <tr> | ||||
|             <td width="10%" style='text-align: left'><?php _e( 'Country', 'wp-statistics' ); ?></td> | ||||
|             <td width="10%" style='text-align: left'><?php _e( 'IP', 'wp-statistics' ); ?></td> | ||||
|             <td width="40%" style='text-align: left'><?php _e( 'Page', 'wp-statistics' ); ?></td> | ||||
|             <td width="40%" style='text-align: left'><?php _e( 'Referrer', 'wp-statistics' ); ?></td> | ||||
|         </tr> | ||||
| 		<?php | ||||
| 		foreach ( $result as $item ) { | ||||
| 			$i ++; | ||||
|  | ||||
| 			//Get current Location info | ||||
| 			$item->location = strtoupper( $item->location ); | ||||
|  | ||||
| 			//Get current Page info | ||||
| 			$page_info = wp_statistics_get_page_info( $item->page_id, $item->type ); | ||||
|  | ||||
| 			echo "<tr>"; | ||||
| 			echo "<td style='text-align: left'><img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $item->location . '.png' ) . "' title='{$ISOCountryCode[$item->location]}'/></td>"; | ||||
| 			echo "<td style='text-align: left !important'>{$item->ip}</td>"; | ||||
| 			echo "<td style='text-align: left !important'>" . ( $page_info['link'] != '' ? '<a href="' . $page_info['link'] . '" target="_blank">' : '' ) . mb_substr( $page_info['title'], 0, 200, "utf-8" ) . ( $page_info['link'] != '' ? '</a>' : '' ) . "</td>"; | ||||
| 			echo "<td style='text-align: left !important'>" . $WP_Statistics->get_referrer_link( $item->referred ) . "</td>"; | ||||
| 			echo "</tr>"; | ||||
| 		} | ||||
|  | ||||
| 		echo '</table>'; | ||||
|  | ||||
| 	} else { | ||||
| 		_e( "no online users yet.", 'wp-statistics' ); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										119
									
								
								wp-content/plugins/wp-statistics/includes/log/widgets/words.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								wp-content/plugins/wp-statistics/includes/log/widgets/words.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,119 @@ | ||||
| <?php | ||||
| function wp_statistics_generate_words_postbox_content( $ISOCountryCode, $count = 10 ) { | ||||
| 	global $wpdb, $WP_Statistics; | ||||
|  | ||||
| 	// Retrieve MySQL data for the search words. | ||||
| 	$search_query = wp_statistics_searchword_query( 'all' ); | ||||
|  | ||||
| 	// Determine if we're using the old or new method of storing search engine info and build the appropriate table name. | ||||
| 	$tablename = $wpdb->prefix . 'statistics_'; | ||||
|  | ||||
| 	if ( $WP_Statistics->get_option( 'search_converted' ) ) { | ||||
| 		$tabletwo  = $tablename . 'visitor'; | ||||
| 		$tablename .= 'search'; | ||||
| 		$result    = $wpdb->get_results( | ||||
| 			"SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT 0, {$count}" | ||||
| 		); | ||||
| 	} else { | ||||
| 		$tablename .= 'visitor'; | ||||
| 		$result    = $wpdb->get_results( | ||||
| 			"SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT 0, {$count}" | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	if ( sizeof( $result ) > 0 ) { | ||||
| 		echo "<div class=\"wp-statistics-table\">"; | ||||
| 		echo "<table width=\"100%\" class=\"widefat table-stats\" id=\"last-referrer\"> | ||||
| 		  <tr>"; | ||||
| 		echo "<td>" . __( 'Word', 'wp-statistics' ) . "</td>"; | ||||
| 		echo "<td>" . __( 'Browser', 'wp-statistics' ) . "</td>"; | ||||
| 		if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 			echo "<td>" . __( 'Country', 'wp-statistics' ) . "</td>"; | ||||
| 		} | ||||
| 		if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 			echo "<td>" . __( 'City', 'wp-statistics' ) . "</td>"; | ||||
| 		} | ||||
| 		echo "<td>" . __( 'Date', 'wp-statistics' ) . "</td>"; | ||||
| 		echo "<td>" . __( 'IP', 'wp-statistics' ) . "</td>"; | ||||
| 		echo "<td>" . __( 'Referrer', 'wp-statistics' ) . "</td>"; | ||||
| 		echo "</tr>"; | ||||
|  | ||||
| 		// Load city name | ||||
| 		$geoip_reader = false; | ||||
| 		if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 			$geoip_reader = $WP_Statistics::geoip_loader( 'city' ); | ||||
| 		} | ||||
|  | ||||
| 		foreach ( $result as $items ) { | ||||
|  | ||||
| 			if ( ! $WP_Statistics->Search_Engine_QueryString( $items->referred ) ) { | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'search_converted' ) ) { | ||||
| 				$this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine( $items->engine ); | ||||
| 				$words              = $items->words; | ||||
| 			} else { | ||||
| 				$this_search_engine = $WP_Statistics->Search_Engine_Info( $items->referred ); | ||||
| 				$words              = $WP_Statistics->Search_Engine_QueryString( $items->referred ); | ||||
| 			} | ||||
|  | ||||
| 			echo "<tr>"; | ||||
| 			echo "<td style=\"text-align: left\"><span title='{$words}' class='wps-cursor-default wps-text-wrap'>".$words."</span></td>"; | ||||
| 			echo "<td style=\"text-align: left\">"; | ||||
| 			if ( array_search( strtolower( $items->agent ), wp_statistics_get_browser_list( 'key' ) ) !== false ) { | ||||
| 				$agent = "<img src='" . plugins_url( 'wp-statistics/assets/images/' ) . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>"; | ||||
| 			} else { | ||||
| 				$agent = wp_statistics_icons( 'dashicons-editor-help', 'unknown' ); | ||||
| 			} | ||||
| 			echo "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'overview', array( 'type' => 'last-all-visitor', 'agent' => $items->agent ) ) . "'>{$agent}</a>"; | ||||
| 			echo "</td>"; | ||||
| 			$city = ''; | ||||
| 			if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 				if ( $geoip_reader != false ) { | ||||
| 					try { | ||||
| 						$reader = $geoip_reader->city( $items->ip ); | ||||
| 						$city   = $reader->city->name; | ||||
| 					} catch ( Exception $e ) { | ||||
| 						$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 					} | ||||
|  | ||||
| 					if ( ! $city ) { | ||||
| 						$city = __( 'Unknown', 'wp-statistics' ); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'geoip' ) ) { | ||||
| 				echo "<td style=\"text-align: left\">"; | ||||
| 				echo "<img src='" . plugins_url( 'wp-statistics/assets/images/flags/' . $items->location . '.png' ) . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>"; | ||||
| 				echo "</td>"; | ||||
| 			} | ||||
|  | ||||
| 			if ( $WP_Statistics->get_option( 'geoip_city' ) ) { | ||||
| 				echo "<td style=\"text-align: left\">"; | ||||
| 				echo $city; | ||||
| 				echo "</td>"; | ||||
| 			} | ||||
|  | ||||
| 			echo "<td style=\"text-align: left\">"; | ||||
| 			echo date_i18n( get_option( 'date_format' ), strtotime( $items->last_counter ) ); | ||||
| 			echo "</td>"; | ||||
|  | ||||
| 			echo "<td style=\"text-align: left\">"; | ||||
| 			if ( substr( $items->ip, 0, 6 ) == '#hash#' ) { | ||||
| 				$ip_string = __( '#hash#', 'wp-statistics' ); | ||||
| 			} else { | ||||
| 				$ip_string = "<a href='" . WP_Statistics_Admin_Pages::admin_url( 'visitors', array( 'type' => 'last-all-visitor', 'ip' => $items->ip ) ) . "'>{$items->ip}</a>"; | ||||
| 			} | ||||
| 			echo $ip_string; | ||||
| 			echo "</td>"; | ||||
| 			echo "<td style=\"text-align: left\">" . $WP_Statistics->get_referrer_link( $items->referred ) . "</td>";; | ||||
| 			echo "</tr>"; | ||||
| 		} | ||||
|  | ||||
| 		echo "</table>"; | ||||
| 		echo "</div>"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,123 @@ | ||||
| <div class="wrap wps-wrap"> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Database Setup', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="index-submit"><?php _e( 'Re-run Install:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="install-submit" class="button button-primary" type="button" value="<?php _e( 'Install Now!', 'wp-statistics' ); ?>" name="install-submit" onclick="location.href=document.URL+'&install=1&tab=database'"> | ||||
|                 <p class="description"><?php _e( 'If for some reason your installation of WP Statistics is missing the database tables or other core items, this will re-execute the install process.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Database Index', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="index-submit"><?php _e( 'Countries:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
| 				<?php | ||||
| 				GLOBAL $wpdb, $WP_Statistics; | ||||
| 				$wp_prefix = $wpdb->prefix; | ||||
|  | ||||
| 				$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' ); | ||||
|  | ||||
| 				// Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 				$result = $wpdb->query( | ||||
| 					"SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip_agent'" | ||||
| 				); | ||||
|  | ||||
| 				// Note, the result will be the number of fields contained in the index, so in our case 5. | ||||
| 				if ( $result != 5 ) { | ||||
| 					$dbupdates['date_ip_agent'] = true; | ||||
| 					?> | ||||
|                     <input id="index-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="index-submit" onclick="location.href=document.URL+'&index=1&tab=database'"> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ) . ' ' . __( 'To create the index on the older installs duplicate entries must be deleted first.', 'wp-statistics' ) . ' ' . __( 'Clicking "Update Now" will scan the vistitors table, delete duplicate entries and add the index.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} else { | ||||
| 					$dbupdates['date_ip_agent'] = false; | ||||
| 					?> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} | ||||
| 				?> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="index-submit"><?php _e( 'Visits Table:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
| 				<?php | ||||
| 				GLOBAL $wpdb; | ||||
| 				$wp_prefix = $wpdb->prefix; | ||||
|  | ||||
| 				// Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 				$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" ); | ||||
|  | ||||
| 				// Note, the result will be the number of fields contained in the index, so in our case 1. | ||||
| 				if ( $result != 1 ) { | ||||
| 					$dbupdates['unique_date'] = true; | ||||
| 					?> | ||||
|                     <input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="visit-submit" onclick="location.href=document.URL+'&visits=1&tab=database'"> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ) . ' ' . __( 'To create the index on the older installs duplicate entries must be deleted first.', 'wp-statistics' ) . ' ' . __( 'Clicking "Update Now" will scan the vistits table, delete duplicate entries and add the index.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visits table.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} else { | ||||
| 					$dbupdates['unique_date'] = false; | ||||
| 					?> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} | ||||
|  | ||||
| 				$WP_Statistics->update_option( 'pending_db_updates', $dbupdates ); | ||||
| 				?> | ||||
|             </td> | ||||
|  | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Search Table', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="index-submit"><?php _e( 'Convert:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
| 				<?php | ||||
| 				// Note, the result will be the number of fields contained in the index, so in our case 1. | ||||
| 				if ( $WP_Statistics->get_option( 'search_converted' ) != 1 ) { | ||||
| 					?> | ||||
|                     <input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Convert Now!', 'wp-statistics' ); ?>" name="search-submit" onclick="location.href=document.URL+'&search=1&tab=database'"> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets.', 'wp-statistics' ) . ' ' . __( 'A new table has been created to hold this information in a more scalable fashion, however the old data must first be converted to the new format before it can be used.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} else { | ||||
| 					?> | ||||
|                     <p class="description"><?php echo __( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets.', 'wp-statistics' ) . ' ' . __( 'A new table has been created to hold this information in a more scalable fashion.', 'wp-statistics' ); ?></p> | ||||
|                     <p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p> | ||||
| 					<?php | ||||
| 				} | ||||
| 				?> | ||||
|             </td> | ||||
|  | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
| </div> | ||||
| @@ -0,0 +1,63 @@ | ||||
| <div class="wrap wps-wrap"> | ||||
|  | ||||
|     <form method="post"> | ||||
|         <input type="hidden" name="wps_export" value="true"> | ||||
| 		<?php wp_nonce_field( 'wp_statistics_export_nonce', 'wps_export_file' ); ?> | ||||
|         <table class="form-table"> | ||||
|             <tbody> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row" colspan="2"><h3><?php _e( 'Export', 'wp-statistics' ); ?></h3></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="table-to-export"><?php _e( 'Export from:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <select dir="ltr" id="table-to-export" name="table-to-export" required> | ||||
|                         <option value=""><?php _e( 'Please select', 'wp-statistics' ); ?></option> | ||||
| 						<?php | ||||
| 						foreach ( wp_statistics_db_table( 'all', array( 'historical', 'visitor_relationships' ) ) as $tbl_key => $tbl_name ) { | ||||
| 							echo '<option value="' . $tbl_key . '">' . $tbl_name . '</option>'; | ||||
| 						} | ||||
| 						?> | ||||
|                     </select> | ||||
|  | ||||
|                     <p class="description"><?php _e( 'Select the table for the output file.', 'wp-statistics' ); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="export-file-type"><?php _e( 'Export To:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <select dir="ltr" id="export-file-type" name="export-file-type" required> | ||||
|                         <option value=""><?php _e( 'Please select', 'wp-statistics' ); ?></option> | ||||
|                         <option value="xml">XML</option> | ||||
|                         <option value="csv">CSV</option> | ||||
|                         <option value="tsv">TSV</option> | ||||
|                     </select> | ||||
|  | ||||
|                     <p class="description"><?php _e( 'Select the output file type.', 'wp-statistics' ); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="export-headers"><?php _e( 'Include Header Row:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="export-headers" type="checkbox" value="1" name="export-headers"> | ||||
|                     <p class="description"><?php _e( 'Include a header row as the first line of the exported file.', 'wp-statistics' ); ?></p> | ||||
| 					<?php submit_button( __( 'Start Now!', 'wp-statistics' ), 'primary', 'export-file-submit' ); ?> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             </tbody> | ||||
|         </table> | ||||
|     </form> | ||||
| </div> | ||||
| @@ -0,0 +1,78 @@ | ||||
| <?php | ||||
| // Get the historical number of visitors to the site | ||||
| $historical_visitors = $WP_Statistics->Get_Historical_Data( 'visitors' ); | ||||
|  | ||||
| // Get the historical number of visits to the site | ||||
| $historical_visits = $WP_Statistics->Get_Historical_Data( 'visits' ); | ||||
|  | ||||
| ?> | ||||
| <div class="wrap wps-wrap"> | ||||
|     <form id="wps_historical_form" method="post"> | ||||
| 		<?php wp_nonce_field( 'historical_form', 'wp-statistics-nonce' ); ?> | ||||
|         <table class="form-table"> | ||||
|             <tbody> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row" colspan="2"><h3><?php _e( 'Historical Values', 'wp-statistics' ); ?></h3></th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top" id="wps_historical_purge" style="display: none"> | ||||
|                 <th scope="row" colspan=2> | ||||
| 					<?php _e( | ||||
| 						'Note: As you have just purged the database you must reload this page for these numbers to be correct.', | ||||
| 						'wp-statistics' | ||||
| 					); ?> | ||||
|                 </th> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
| 					<?php _e( 'Visitors', 'wp-statistics' ); ?>: | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input type="text" size="10" value="<?php echo $historical_visitors; ?>" | ||||
|                            id="wps_historical_visitors" name="wps_historical_visitors"> | ||||
|  | ||||
|                     <p class="description"><?php echo sprintf( | ||||
| 							__( | ||||
| 								'Number of historical number of visitors to the site (current value is %s).', | ||||
| 								'wp-statistics' | ||||
| 							), | ||||
| 							number_format_i18n( $historical_visitors ) | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
| 					<?php _e( 'Visits', 'wp-statistics' ); ?>: | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input type="text" size="10" value="<?php echo $historical_visits; ?>" id="wps_historical_visits" | ||||
|                            name="wps_historical_visits"> | ||||
|  | ||||
|                     <p class="description"><?php echo sprintf( | ||||
| 							__( | ||||
| 								'Number of historical number of visits to the site (current value is %s).', | ||||
| 								'wp-statistics' | ||||
| 							), | ||||
| 							number_format_i18n( $historical_visits ) | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <td colspan=2> | ||||
|                     <input id="historical-submit" class="button button-primary" type="submit" | ||||
|                            value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="historical-submit"/> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             </tbody> | ||||
|  | ||||
|         </table> | ||||
|  | ||||
|     </form> | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,341 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         jQuery("#purge-data-submit").click(function () { | ||||
|  | ||||
|             var action = jQuery('#purge-data').val(); | ||||
|  | ||||
|             if (action == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#purge-data-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#purge-data-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_purge_data', | ||||
|                 'purge-days': action, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#purge-data-status").html(""); | ||||
|                     jQuery("#purge-data-result").html(result); | ||||
|                     jQuery("#purge-data-submit").removeAttr("disabled"); | ||||
|                     jQuery("#wps_historical_purge").show(); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         jQuery("#purge-visitor-hits-submit").click(function () { | ||||
|  | ||||
|             var action = jQuery('#purge-visitor-hits').val(); | ||||
|  | ||||
|             if (action == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#purge-visitor-hits-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#purge-visitor-hits-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_purge_visitor_hits', | ||||
|                 'purge-hits': action, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#purge-visitor-hits-status").html(""); | ||||
|                     jQuery("#purge-visitor-hits-result").html(result); | ||||
|                     jQuery("#purge-visitor-hits-submit").removeAttr("disabled"); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         jQuery("#empty-table-submit").click(function () { | ||||
|  | ||||
|             var action = jQuery('#empty-table').val(); | ||||
|  | ||||
|             if (action == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#empty-table-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#empty-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_empty_table', | ||||
|                 'table-name': action, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#empty-status").html(""); | ||||
|                     jQuery("#empty-result").html(result); | ||||
|                     jQuery("#empty-table-submit").removeAttr("disabled"); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         jQuery("#delete-agents-submit").click(function () { | ||||
|  | ||||
|             var action = jQuery('#delete-agent').val(); | ||||
|  | ||||
|             if (action == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#delete-agents-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#delete-agents-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_delete_agents', | ||||
|                 'agent-name': action, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#delete-agents-status").html(""); | ||||
|                     jQuery("#delete-agents-result").html(result); | ||||
|                     jQuery("#delete-agents-submit").removeAttr("disabled"); | ||||
|                     aid = data['agent-name'].replace(/[^a-zA-Z]/g, ""); | ||||
|                     jQuery("#agent-" + aid + "-id").remove(); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         jQuery("#delete-platforms-submit").click(function () { | ||||
|  | ||||
|             var action = jQuery('#delete-platform').val(); | ||||
|  | ||||
|             if (action == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#delete-platforms-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#delete-platforms-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_delete_platforms', | ||||
|                 'platform-name': action, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#delete-platforms-status").html(""); | ||||
|                     jQuery("#delete-platforms-result").html(result); | ||||
|                     jQuery("#delete-platforms-submit").removeAttr("disabled"); | ||||
|                     pid = data['platform-name'].replace(/[^a-zA-Z]/g, ""); | ||||
|                     jQuery("#platform-" + pid + "-id").remove(); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         jQuery("#delete-ip-submit").click(function () { | ||||
|  | ||||
|             var value = jQuery('#delete-ip').val(); | ||||
|  | ||||
|             if (value == 0) | ||||
|                 return false; | ||||
|  | ||||
|             var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (!agree) | ||||
|                 return false; | ||||
|  | ||||
|             jQuery("#delete-ip-submit").attr("disabled", "disabled"); | ||||
|             jQuery("#delete-ip-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>"); | ||||
|  | ||||
|             var data = { | ||||
|                 'action': 'wp_statistics_delete_ip', | ||||
|                 'ip-address': value, | ||||
|             }; | ||||
|  | ||||
|             jQuery.ajax({ | ||||
|                 url: ajaxurl, | ||||
|                 type: 'post', | ||||
|                 data: data, | ||||
|                 datatype: 'json', | ||||
|             }) | ||||
|                 .always(function (result) { | ||||
|                     jQuery("#delete-ip-status").html(""); | ||||
|                     jQuery("#delete-ip-result").html(result); | ||||
|                     jQuery("#delete-ip-submit").removeAttr("disabled"); | ||||
|                     jQuery("#delete-ip").value(''); | ||||
|                 }); | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
|  | ||||
| <div class="wrap wps-wrap"> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Data', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="empty-table"><?php _e( 'Empty Table:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <select dir="ltr" id="empty-table" name="empty-table"> | ||||
|                     <option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option> | ||||
| 					<?php | ||||
| 					foreach ( wp_statistics_db_table( 'all', 'historical' ) as $tbl_key => $tbl_name ) { | ||||
| 						echo '<option value="' . $tbl_key . '">' . $tbl_name . '</option>'; | ||||
| 					} | ||||
| 					?> | ||||
|                     <option value="all"><?php echo __( 'All', 'wp-statistics' ); ?></option> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'All data table will be lost.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="empty-table-submit" class="button button-primary" type="submit" value="<?php _e( 'Clear now!', 'wp-statistics' ); ?>" name="empty-table-submit" Onclick="return false;"/> | ||||
|                 <span id="empty-status"></span> | ||||
|                 <div id="empty-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr> | ||||
|             <th scope="row"> | ||||
|                 <label for="purge-data"><?php _e( 'Purge records older than:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="purge-data" name="wps_purge_data" value="365"/> | ||||
|                 <label for="purge-data"><?php _e( 'Days', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( 'Delete user statistics data older than the selected number of days.', 'wp-statistics' ) . ' ' . __( 'Minimum value is 30 days.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="purge-data-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-data-submit" Onclick="return false;"/> | ||||
|                 <span id="purge-data-status"></span> | ||||
|                 <div id="purge-data-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr> | ||||
|             <th scope="row"> | ||||
|                 <label for="purge-visitor-hits"><?php _e( 'Purge visitors with more than:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="purge-visitor-hits" name="wps_purge_visitor_hits" value="10"/> | ||||
|                 <label for="purge-visitor-hits"><?php _e( 'Hits', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( 'Delete user statistics data where the user has more than the defined number of hits in a day.', 'wp-statistics' ) . ' ' . __( 'This can be useful to clear up old data when your site has been hit by a bot.', 'wp-statistics' ) . ' ' . __( 'This will remove the visitor and their hits to the site, however it will not remove individual page hits as that data is not recorded on a per use basis.', 'wp-statistics' ) . ' ' . __( 'Minimum value is 10 hits.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="purge-visitor-hits-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-visitor-hits-submit" Onclick="return false;"/> | ||||
|                 <span id="purge-visitor-hits-status"></span> | ||||
|                 <div id="purge-visitor-hits-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Delete User Agent Types', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="delete-agent"><?php _e( 'Delete Agents:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <select dir="ltr" id="delete-agent" name="delete-agent"> | ||||
|                     <option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option> | ||||
| 					<?php | ||||
| 					$agents = wp_statistics_ua_list(); | ||||
|  | ||||
| 					foreach ( $agents as $agent ) { | ||||
| 						$aid = preg_replace( "/[^a-zA-Z]/", "", $agent ); | ||||
| 						echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>"; | ||||
| 					} | ||||
| 					?> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'All visitor data will be lost for this agent type.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="delete-agents-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-agents-submit" Onclick="return false;"> | ||||
|                 <span id="delete-agents-status"></span> | ||||
|                 <div id="delete-agents-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="delete-platform"><?php _e( 'Delete Platforms:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <select dir="ltr" id="delete-platform" name="delete-platform"> | ||||
|                     <option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option> | ||||
| 					<?php | ||||
| 					$platforms = wp_statistics_platform_list(); | ||||
|  | ||||
| 					foreach ( $platforms as $platform ) { | ||||
| 						$pid = preg_replace( "/[^a-zA-Z]/", "", $platform ); | ||||
| 						echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>"; | ||||
| 					} | ||||
| 					?> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'All visitor data will be lost for this platform type.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="delete-platforms-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-platforms-submit" Onclick="return false;"> | ||||
|                 <span id="delete-platforms-status"></span> | ||||
|                 <div id="delete-platforms-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="delete-ip"><?php _e( 'Delete IP:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input dir="ltr" id="delete-ip" type="text" name="delete-ip"/> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'All visitor data will be lost for this IP.', 'wp-statistics' ); ?></p> | ||||
|                 <input id="delete-ip-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-ip-submit" Onclick="return false;"> | ||||
|                 <span id="delete-ip-status"></span> | ||||
|                 <div id="delete-ip-result"></div> | ||||
|             </td> | ||||
|         </tr> | ||||
|         </tbody> | ||||
|     </table> | ||||
| </div> | ||||
| @@ -0,0 +1,294 @@ | ||||
| <div class="wrap wps-wrap"> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Resources', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo number_format_i18n( memory_get_usage() ); ?></strong> <?php _e( 'Bytes', 'wp-statistics' ); ?> | ||||
|                 <p class="description"><?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'PHP Memory Limit', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo ini_get( 'memory_limit' ); ?></strong> | ||||
|                 <p class="description"><?php _e( 'The memory limit a script is allowed to consume, set in php.ini.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		foreach ( $result as $table_name => $number_row ) { | ||||
| 			?> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
| 					<?php echo sprintf( __( 'Number of rows in the %s table', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); ?> | ||||
|                     : | ||||
|                 </th> | ||||
|                 <td> | ||||
|                     <strong><?php echo number_format_i18n( $number_row ); ?></strong> <?php echo _n( 'Row', 'Rows', number_format_i18n( $number_row ), 'wp-statistics' ); ?> | ||||
|                     <p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} | ||||
| 		?> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Version Info', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'WP Statistics Version', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo WP_Statistics::$reg['version']; ?></strong> | ||||
|                 <p class="description"><?php _e( 'The WP Statistics version you are running.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'PHP Version', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo phpversion(); ?></strong> | ||||
|                 <p class="description"><?php _e( 'The PHP version you are running.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'PHP Safe Mode', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( ini_get( 'safe_mode' ) ) { | ||||
| 						_e( 'Yes', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						_e( 'No', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'PHP IPv6 Enabled', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( defined( 'AF_INET6' ) ) { | ||||
| 						_e( 'Yes', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						_e( 'No', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Is PHP compiled with IPv6 support. You may see warning messages in your PHP log if it is not and you receive HTTP headers with IPv6 addresses in them.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'jQuery Version', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong> | ||||
|                     <script type="text/javascript">document.write(jQuery().jquery);</script> | ||||
|                 </strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'The jQuery version you are running.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'cURL Version', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( function_exists( 'curl_version' ) ) { | ||||
| 						$curl_ver = curl_version(); | ||||
| 						echo $curl_ver['version']; | ||||
| 					} else { | ||||
| 						_e( 'cURL not installed', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Zlib gzopen()', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( function_exists( 'gzopen' ) ) { | ||||
| 						_e( 'Installed', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						_e( 'Not installed', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'If the gzopen() function is installed. The gzopen() function is required for the GeoIP database to be downloaded successfully.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'GMP PHP extension', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( extension_loaded( 'gmp' ) ) { | ||||
| 						_e( 'Installed', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						_e( 'Not installed', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'BCMath PHP extension', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php if ( extension_loaded( 'bcmath' ) ) { | ||||
| 						_e( 'Installed', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						_e( 'Not installed', 'wp-statistics' ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'File Info', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'GeoIP Database', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php $upload_dir = wp_upload_dir(); | ||||
| 					$GeoIP_filename       = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb'; | ||||
| 					$GeoIP_filedate       = @filemtime( $GeoIP_filename ); | ||||
|  | ||||
| 					if ( $GeoIP_filedate === false ) { | ||||
| 						_e( 'Database file does not exist.', 'wp-statistics' ); | ||||
| 					} else { | ||||
| 						echo size_format( @filesize( $GeoIP_filename ), 2 ) . __( ', created on ', 'wp-statistics' ) . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $GeoIP_filedate ); | ||||
| 					} ?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'The file size and date of the GeoIP database.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Client Info', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Client IP', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo $WP_Statistics->get_IP(); ?></strong> | ||||
|                 <p class="description"><?php _e( 'The client IP address.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'User Agent', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong> | ||||
|                 <p class="description"><?php _e( 'The client user agent string.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Browser', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php $agent = $WP_Statistics->get_UserAgent(); | ||||
| 					echo $agent['browser']; | ||||
| 					?></strong> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'The detected client browser.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Version', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo $agent['version']; ?></strong> | ||||
|                 <p class="description"><?php _e( 'The detected client browser version.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
| 				<?php _e( 'Platform', 'wp-statistics' ); ?>: | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <strong><?php echo $agent['platform']; ?></strong> | ||||
|                 <p class="description"><?php _e( 'The detected client platform.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Server Info', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		$list = array( 'SERVER_SOFTWARE', 'HTTP_HOST', 'REMOTE_ADDR', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'HTTP_X_REAL_IP', ); | ||||
| 		foreach ( $list as $server ) { | ||||
| 			if ( isset( $_SERVER[ $server ] ) ) { | ||||
| 				echo '<tr valign="top"> | ||||
|                      <th scope="row"> | ||||
|                     ' . $server . ' | ||||
|                     </th> | ||||
|                     <td> | ||||
|                         <strong>' . $_SERVER[ $server ] . '</strong> | ||||
|                     </td> | ||||
|                 </tr>'; | ||||
| 			} | ||||
| 		} | ||||
| 		?> | ||||
|         </tbody> | ||||
|     </table> | ||||
| </div> | ||||
| @@ -0,0 +1,58 @@ | ||||
| <script type="text/javascript"> | ||||
|     jQuery(document).ready(function () { | ||||
|         jQuery("#hash-ips-submit").click(function () { | ||||
|             var agree = confirm('<?php _e( 'This will replace all IP addresses in the database with hash values and cannot be undo, are you sure?', 'wp-statistics' ); ?>'); | ||||
|  | ||||
|             if (agree) | ||||
|                 location.href = document.URL + '&tab=updates&hash-ips=1'; | ||||
|  | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| <div class="wrap wps-wrap"> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'GeoIP Options', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="populate-submit"><?php _e( 'Countries:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="populate-submit" class="button button-primary" type="button" | ||||
|                        value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="populate-submit" | ||||
|                        onclick="location.href=document.URL+'&tab=updates&populate=1'"> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Updates any unknown location data in the database, this may take a while', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="populate-submit"><?php _e( 'Hash IP Addresses:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="hash-ips-submit" class="button button-primary" type="button" | ||||
|                        value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="hash-ips-submit"> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Replace IP addresses in the database with hash values, you will not be able to recover the IP addresses in the future to populate location information afterwards and this may take a while', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
| </div> | ||||
| @@ -0,0 +1,270 @@ | ||||
| <?php | ||||
| global $wpdb, $WP_Statistics; | ||||
| $wp_prefix = $wpdb->prefix; | ||||
|  | ||||
| if ( ! is_super_admin() ) { | ||||
| 	wp_die( __( 'Access denied!', 'wp-statistics' ) ); | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'populate', $_GET ) ) { | ||||
| 	if ( intval( $_GET['populate'] ) == 1 ) { | ||||
| 		echo WP_Statistics_Updates::populate_geoip_info(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'hash-ips', $_GET ) ) { | ||||
| 	if ( intval( $_GET['hash-ips'] ) == 1 ) { | ||||
| 		// Generate a random salt | ||||
| 		$characters   = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||||
| 		$randomString = ''; | ||||
| 		for ( $i = 0; $i < 50; $i ++ ) { | ||||
| 			$randomString .= $characters[ rand( 0, strlen( $characters ) - 1 ) ]; | ||||
| 		} | ||||
|  | ||||
| 		// Get the rows from the Visitors table. | ||||
| 		$result = $wpdb->get_results( "SELECT DISTINCT ip FROM {$wp_prefix}statistics_visitor" ); | ||||
|  | ||||
| 		foreach ( $result as $row ) { | ||||
| 			if ( substr( $row->ip, 0, 6 ) != '#hash#' ) { | ||||
| 				$wpdb->update( | ||||
| 					$wp_prefix . "statistics_visitor", | ||||
| 					array( | ||||
| 						'ip' => '#hash#' . sha1( $row->ip . $randomString ), | ||||
| 					), | ||||
| 					array( | ||||
| 						'ip' => $row->ip, | ||||
| 					) | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		echo "<div class='updated settings-error'><p><strong>" . __( 'IP Addresses replaced with hash values.', 'wp-statistics' ) . "</strong></p></div>"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'install', $_GET ) ) { | ||||
| 	if ( intval( $_GET['install'] ) == 1 ) { | ||||
| 		$WPS_Installed = "1.0"; | ||||
| 		new WP_Statistics_Install( $WP_Statistics ); | ||||
| 		echo "<div class='updated settings-error'><p><strong>" . __( 'Install routine complete.', 'wp-statistics' ) . "</strong></p></div>"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'index', $_GET ) ) { | ||||
| 	if ( intval( $_GET['index'] ) == 1 ) { | ||||
| 		// Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 		$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'" ); | ||||
|  | ||||
| 		if ( $result != 5 ) { | ||||
| 			// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error. | ||||
| 			$result = $wpdb->get_results( | ||||
| 				"SELECT ID, last_counter, ip FROM {$wp_prefix}statistics_visitor ORDER BY last_counter, ip" | ||||
| 			); | ||||
|  | ||||
| 			// Setup the inital values. | ||||
| 			$lastrow    = array( 'last_counter' => '', 'ip' => '' ); | ||||
| 			$deleterows = array(); | ||||
|  | ||||
| 			// Ok, now iterate over the results. | ||||
| 			foreach ( $result as $row ) { | ||||
| 				// if the last_counter (the date) and IP is the same as the last row, add the row to be deleted. | ||||
| 				if ( $row->last_counter == $lastrow['last_counter'] && $row->ip == $lastrow['ip'] ) { | ||||
| 					$deleterows[] .= $row->ID; | ||||
| 				} | ||||
|  | ||||
| 				// Update the last row data. | ||||
| 				$lastrow['last_counter'] = $row->last_counter; | ||||
| 				$lastrow['ip']           = $row->ip; | ||||
| 			} | ||||
|  | ||||
| 			// Now do the actual deletions. | ||||
| 			foreach ( $deleterows as $row ) { | ||||
| 				$wpdb->delete( $wp_prefix . 'statistics_visitor', array( 'ID' => $row ) ); | ||||
| 			} | ||||
|  | ||||
| 			// The table should be ready to be updated now with the new index, so let's do it. | ||||
| 			$result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visitor' . " ADD UNIQUE `date_ip_agent` ( `last_counter`, `ip`, `agent` (75), `platform` (75), `version` (75) )" ); | ||||
|  | ||||
| 			// We might have an old index left over from 7.1-7.3 so lets make sure to delete it. | ||||
| 			$wpdb->query( "DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor" ); | ||||
|  | ||||
| 			// Record in the options that we've done this update. | ||||
| 			$dbupdates                  = $WP_Statistics->get_option( 'pending_db_updates' ); | ||||
| 			$dbupdates['date_ip_agent'] = false; | ||||
| 			$WP_Statistics->update_option( 'pending_db_updates', $dbupdates ); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'visits', $_GET ) ) { | ||||
| 	if ( intval( $_GET['visits'] ) == 1 ) { | ||||
| 		// Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them | ||||
| 		$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" ); | ||||
|  | ||||
| 		// Note, the result will be the number of fields contained in the index, so in our case 1. | ||||
| 		if ( $result != 1 ) { | ||||
| 			// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error. | ||||
| 			$result = $wpdb->get_results( | ||||
| 				"SELECT ID, last_counter, visit FROM {$wp_prefix}statistics_visit ORDER BY last_counter, visit DESC" | ||||
| 			); | ||||
|  | ||||
| 			// Setup the initial values. | ||||
| 			$lastrow    = array( 'last_counter' => '', 'visit' => 0, 'id' => 0 ); | ||||
| 			$deleterows = array(); | ||||
|  | ||||
| 			// Ok, now iterate over the results. | ||||
| 			foreach ( $result as $row ) { | ||||
| 				// if the last_counter (the date) and IP is the same as the last row, add the row to be deleted. | ||||
| 				if ( $row->last_counter == $lastrow['last_counter'] ) { | ||||
| 					$deleterows[] .= $row->ID; | ||||
| 				} | ||||
|  | ||||
| 				// Update the lastrow data. | ||||
| 				$lastrow['last_counter'] = $row->last_counter; | ||||
| 				$lastrow['id']           = $row->ID; | ||||
| 				$lastrow['visit']        = $row->visit; | ||||
| 			} | ||||
|  | ||||
| 			// Now do the acutal deletions. | ||||
| 			foreach ( $deleterows as $row ) { | ||||
| 				$wpdb->delete( $wp_prefix . 'statistics_visit', array( 'ID' => $row ) ); | ||||
| 			} | ||||
|  | ||||
| 			// The table should be ready to be updated now with the new index, so let's do it. | ||||
| 			$result = $wpdb->get_results( | ||||
| 				"ALTER TABLE " . $wp_prefix . 'statistics_visit' . " ADD UNIQUE `unique_date` ( `last_counter` )" | ||||
| 			); | ||||
|  | ||||
| 			// Record in the options that we've done this update. | ||||
| 			$dbupdates                = $WP_Statistics->get_option( 'pending_db_updates' ); | ||||
| 			$dbupdates['unique_date'] = false; | ||||
| 			$WP_Statistics->update_option( 'pending_db_updates', $dbupdates ); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'historical-submit', $_POST ) ) { | ||||
| 	if ( array_key_exists( 'wps_historical_visitors', $_POST ) ) { | ||||
| 		$result = $wpdb->update( | ||||
| 			$wp_prefix . "statistics_historical", | ||||
| 			array( 'value' => $_POST['wps_historical_visitors'] ), | ||||
| 			array( 'category' => 'visitors' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( $result == 0 ) { | ||||
| 			$result = $wpdb->insert( | ||||
| 				$wp_prefix . "statistics_historical", | ||||
| 				array( | ||||
| 					'value'    => $_POST['wps_historical_visitors'], | ||||
| 					'category' => 'visitors', | ||||
| 					'page_id'  => - 1, | ||||
| 					'uri'      => '-1', | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if ( array_key_exists( 'wps_historical_visits', $_POST ) ) { | ||||
| 		$result = $wpdb->update( | ||||
| 			$wp_prefix . "statistics_historical", | ||||
| 			array( 'value' => $_POST['wps_historical_visits'] ), | ||||
| 			array( 'category' => 'visits' ) | ||||
| 		); | ||||
|  | ||||
| 		if ( $result == 0 ) { | ||||
| 			$result = $wpdb->insert( | ||||
| 				$wp_prefix . "statistics_historical", | ||||
| 				array( | ||||
| 					'value'    => $_POST['wps_historical_visits'], | ||||
| 					'category' => 'visits', | ||||
| 					'page_id'  => - 2, | ||||
| 					'uri'      => '-2', | ||||
| 				) | ||||
| 			); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| if ( array_key_exists( 'search', $_GET ) ) { | ||||
|  | ||||
| 	// Make sure we get all the search engines, even the ones the disabled ones. | ||||
| 	$se_list   = wp_statistics_searchengine_list(); | ||||
| 	$total     = 0; | ||||
| 	$limitsize = 10000; | ||||
|  | ||||
| 	foreach ( $se_list as $key => $se ) { | ||||
| 		$sql      = wp_statistics_searchengine_query( $key ); | ||||
| 		$rowcount = $wpdb->get_var( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}" ); | ||||
| 		$offset   = 0; | ||||
|  | ||||
| 		while ( $rowcount > 0 ) { | ||||
| 			$result = $wpdb->get_results( | ||||
| 				"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}" | ||||
| 			); | ||||
| 			foreach ( $result as $row ) { | ||||
| 				$parts                = parse_url( $row->referred ); | ||||
| 				$data['last_counter'] = $row->last_counter; | ||||
| 				$data['engine']       = $key; | ||||
| 				$data['host']         = $parts['host']; | ||||
| 				$data['words']        = $WP_Statistics->Search_Engine_QueryString( $row->referred ); | ||||
| 				$data['visitor']      = $row->ID; | ||||
|  | ||||
| 				if ( $data['words'] == 'No search query found!' ) { | ||||
| 					$data['words'] = ''; | ||||
| 				} | ||||
|  | ||||
| 				$wpdb->insert( $wpdb->prefix . 'statistics_search', $data ); | ||||
| 				$total ++; | ||||
| 			} | ||||
|  | ||||
| 			$rowcount -= $limitsize; | ||||
| 			$offset   += $limitsize; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$WP_Statistics->update_option( 'search_converted', 1 ); | ||||
| 	echo "<div class='updated settings-error'><p><strong>" . sprintf( __( 'Search table conversion complete, %d rows added.', 'wp-statistics' ), $total ) . "</strong></p></div>"; | ||||
| } | ||||
| ?> | ||||
| <div class="wrap wps-wrap wp-statistics-settings"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Optimization', 'wp-statistics' ) ); ?> | ||||
|  | ||||
|     <div id="poststuff"> | ||||
|         <div id="post-body" class="metabox-holder columns-2"> | ||||
|             <div class="wp-list-table widefat widefat"> | ||||
|                 <div class="wp-statistics-container"> | ||||
|                     <ul class="tabs"> | ||||
|                         <li class="tab-link current" data-tab="resources"><?php _e( 'Resources/Information', 'wp-statistics' ); ?></li> | ||||
|                         <li class="tab-link" data-tab="export"><?php _e( 'Export', 'wp-statistics' ); ?></li> | ||||
|                         <li class="tab-link" data-tab="purging"><?php _e( 'Purging', 'wp-statistics' ); ?></li> | ||||
|                         <li class="tab-link" data-tab="database"><?php _e( 'Database', 'wp-statistics' ); ?></li> | ||||
|                         <li class="tab-link" data-tab="updates"><?php _e( 'Updates', 'wp-statistics' ); ?></li> | ||||
|                         <li class="tab-link" data-tab="historical"><?php _e( 'Historical', 'wp-statistics' ); ?></li> | ||||
|                     </ul> | ||||
|  | ||||
|                     <div id="resources" class="tab-content current"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-resources.php' ); ?> | ||||
|                     </div> | ||||
|                     <div id="export" class="tab-content"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-export.php' ); ?> | ||||
|                     </div> | ||||
|                     <div id="purging" class="tab-content"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-purging.php' ); ?> | ||||
|                     </div> | ||||
|                     <div id="database" class="tab-content"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-database.php' ); ?> | ||||
|                     </div> | ||||
|                     <div id="updates" class="tab-content"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-updates.php' ); ?> | ||||
|                     </div> | ||||
|                     <div id="historical" class="tab-content"> | ||||
| 						<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-historical.php' ); ?> | ||||
|                     </div> | ||||
|                 </div><!-- container --> | ||||
|             </div> | ||||
|  | ||||
| 			<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										181
									
								
								wp-content/plugins/wp-statistics/includes/robotslist.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										181
									
								
								wp-content/plugins/wp-statistics/includes/robotslist.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,181 @@ | ||||
| <?php | ||||
| global $wps_robotarray, $wps_robotslist; | ||||
|  | ||||
| $wps_robotarray = array( | ||||
| 	'007ac9', | ||||
| 	'5bot', | ||||
| 	'A6-Indexer', | ||||
| 	'AbachoBOT', | ||||
| 	'accoona', | ||||
| 	'AcoiRobot', | ||||
| 	'AddThis.com', | ||||
| 	'ADmantX', | ||||
| 	'AdsBot-Google', | ||||
| 	'advbot', | ||||
| 	'AhrefsBot', | ||||
| 	'aiHitBot', | ||||
| 	'alexa', | ||||
| 	'alphabot', | ||||
| 	'AltaVista', | ||||
| 	'AntivirusPro', | ||||
| 	'anyevent', | ||||
| 	'appie', | ||||
| 	'Applebot', | ||||
| 	'archive.org_bot', | ||||
| 	'Ask Jeeves', | ||||
| 	'ASPSeek', | ||||
| 	'Baiduspider', | ||||
| 	'Benjojo', | ||||
| 	'BeetleBot', | ||||
| 	'bingbot', | ||||
| 	'Blekkobot', | ||||
| 	'blexbot', | ||||
| 	'BOT for JCE', | ||||
| 	'bubing', | ||||
| 	'Butterfly', | ||||
| 	'cbot', | ||||
| 	'clamantivirus', | ||||
| 	'cliqzbot', | ||||
| 	'clumboot', | ||||
| 	'coccoc', | ||||
| 	'crawler', | ||||
| 	'CrocCrawler', | ||||
| 	'crowsnest.tv', | ||||
| 	'dbot', | ||||
| 	'dl2bot', | ||||
| 	'dotbot', | ||||
| 	'downloadbot', | ||||
| 	'duckduckgo', | ||||
| 	'Dumbot', | ||||
| 	'EasouSpider', | ||||
| 	'eStyle', | ||||
| 	'EveryoneSocialBot', | ||||
| 	'Exabot', | ||||
| 	'ezooms', | ||||
| 	'facebook.com', | ||||
| 	'facebookexternalhit', | ||||
| 	'FAST', | ||||
| 	'Feedfetcher-Google', | ||||
| 	'feedzirra', | ||||
| 	'findxbot', | ||||
| 	'Firfly', | ||||
| 	'FriendFeedBot', | ||||
| 	'froogle', | ||||
| 	'GeonaBot', | ||||
| 	'Gigabot', | ||||
| 	'girafabot', | ||||
| 	'gimme60bot', | ||||
| 	'glbot', | ||||
| 	'Googlebot', | ||||
| 	'GroupHigh', | ||||
| 	'ia_archiver', | ||||
| 	'IDBot', | ||||
| 	'InfoSeek', | ||||
| 	'inktomi', | ||||
| 	'IstellaBot', | ||||
| 	'jetmon', | ||||
| 	'Kraken', | ||||
| 	'Leikibot', | ||||
| 	'linkapediabot', | ||||
| 	'linkdexbot', | ||||
| 	'LinkpadBot', | ||||
| 	'LoadTimeBot', | ||||
| 	'looksmart', | ||||
| 	'ltx71', | ||||
| 	'Lycos', | ||||
| 	'Mail.RU_Bot', | ||||
| 	'Me.dium', | ||||
| 	'meanpathbot', | ||||
| 	'mediabot', | ||||
| 	'medialbot', | ||||
| 	'Mediapartners-Google', | ||||
| 	'MJ12bot', | ||||
| 	'msnbot', | ||||
| 	'MojeekBot', | ||||
| 	'monobot', | ||||
| 	'moreover', | ||||
| 	'MRBOT', | ||||
| 	'NationalDirectory', | ||||
| 	'NerdyBot', | ||||
| 	'NetcraftSurveyAgent', | ||||
| 	'niki-bot', | ||||
| 	'nutch', | ||||
| 	'Openbot', | ||||
| 	'OrangeBot', | ||||
| 	'owler', | ||||
| 	'p4Bot', | ||||
| 	'PaperLiBot', | ||||
| 	'pageanalyzer', | ||||
| 	'PagesInventory', | ||||
| 	'Pimonster', | ||||
| 	'porkbun', | ||||
| 	'pr-cy', | ||||
| 	'proximic', | ||||
| 	'pwbot', | ||||
| 	'r4bot', | ||||
| 	'rabaz', | ||||
| 	'Rambler', | ||||
| 	'Rankivabot', | ||||
| 	'revip', | ||||
| 	'riddler', | ||||
| 	'rogerbot', | ||||
| 	'Scooter', | ||||
| 	'Scrubby', | ||||
| 	'scrapy.org', | ||||
| 	'SearchmetricsBot', | ||||
| 	'sees.co', | ||||
| 	'SemanticBot', | ||||
| 	'SemrushBot', | ||||
| 	'SeznamBot', | ||||
| 	'sfFeedReader', | ||||
| 	'shareaholic-bot', | ||||
| 	'sistrix', | ||||
| 	'SiteExplorer', | ||||
| 	'Slurp', | ||||
| 	'Socialradarbot', | ||||
| 	'SocialSearch', | ||||
| 	'Sogou web spider', | ||||
| 	'Spade', | ||||
| 	'spbot', | ||||
| 	'SpiderLing', | ||||
| 	'SputnikBot', | ||||
| 	'Superfeedr', | ||||
| 	'SurveyBot', | ||||
| 	'TechnoratiSnoop', | ||||
| 	'TECNOSEEK', | ||||
| 	'Teoma', | ||||
| 	'trendictionbot', | ||||
| 	'TweetmemeBot', | ||||
| 	'Twiceler', | ||||
| 	'Twitterbot', | ||||
| 	'Twitturls', | ||||
| 	'u2bot', | ||||
| 	'uMBot-LN', | ||||
| 	'uni5download', | ||||
| 	'unrulymedia', | ||||
| 	'UptimeRobot', | ||||
| 	'URL_Spider_SQL', | ||||
| 	'Vagabondo', | ||||
| 	'vBSEO', | ||||
| 	'WASALive-Bot', | ||||
| 	'WebAlta Crawler', | ||||
| 	'WebBug', | ||||
| 	'WebFindBot', | ||||
| 	'WebMasterAid', | ||||
| 	'WeSEE', | ||||
| 	'Wotbox', | ||||
| 	'wsowner', | ||||
| 	'wsr-agent', | ||||
| 	'www.galaxy.com', | ||||
| 	'x100bot', | ||||
| 	'XoviBot', | ||||
| 	'xzybot', | ||||
| 	'yandex', | ||||
| 	'Yahoo', | ||||
| 	'Yammybot', | ||||
| 	'YoudaoBot', | ||||
| 	'ZyBorg', | ||||
| 	'ZemlyaCrawl', | ||||
| ); | ||||
|  | ||||
| $wps_robotslist = implode("\n", $wps_robotarray); | ||||
| @@ -0,0 +1,163 @@ | ||||
| <table class="form-table"> | ||||
|     <tbody> | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" align="center"> | ||||
|             <img src="<?php echo plugins_url( 'wp-statistics/assets/images/logo-250.png' ); ?>"></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" align="center"> | ||||
|             <h2><?php echo sprintf( __( 'WP Statistics V%s', 'wp-statistics' ), WP_Statistics::$reg['version'] ); ?></h2> | ||||
|         </td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" align="center"> | ||||
| 			<?php echo sprintf( | ||||
| 				__( 'This product includes GeoLite2 data created by %s.', 'wp-statistics' ), | ||||
| 				'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>' | ||||
| 			); ?> | ||||
|         </td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" align="center"> | ||||
|             <hr/> | ||||
|         </td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><h2><?php _e( 'Donate', 'wp-statistics' ); ?></h2></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><?php echo sprintf( | ||||
| 				__( | ||||
| 					'Feel like showing us how much you enjoy WP Statistics? Drop by our %sdonation%s page and show us some love!', | ||||
| 					'wp-statistics' | ||||
| 				), | ||||
| 				'<a href="http://wp-statistics.com/donate" target="_blank">', | ||||
| 				'</a>' | ||||
| 			); ?></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><h2><?php _e( 'Visit Us Online', 'wp-statistics' ); ?></h2></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><?php echo sprintf( | ||||
| 				__( | ||||
| 					'Come visit our great new %swebsite%s and keep up to date on the latest news about WP Statistics.', | ||||
| 					'wp-statistics' | ||||
| 				), | ||||
| 				'<a href="http://wp-statistics.com" target="_blank">', | ||||
| 				'</a>' | ||||
| 			); ?></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><h2><?php _e( 'Rate and Review at WordPress.org', 'wp-statistics' ); ?></h2></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><?php printf( | ||||
| 				__( | ||||
| 					'Thanks for installing WP Statistics, we encourage you to submit a %srating and review%s over at WordPress.org. Your feedback is greatly appreciated!', | ||||
| 					'wp-statistics' | ||||
| 				), | ||||
| 				'<a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank">', | ||||
| 				'</a>' | ||||
| 			); ?> | ||||
|         </td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><h2><?php _e( 'Translations', 'wp-statistics' ); ?></h2></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><?php echo sprintf( | ||||
| 				__( | ||||
| 					'WP Statistics supports internationalization. Please visit %sWP Statistics translations page%s to help translation.', | ||||
| 					'wp-statistics' | ||||
| 				), | ||||
| 				'<a href="https://wp-statistics.com/translations/" target="_blank">', | ||||
| 				'</a>' | ||||
| 			); ?></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"><h2><?php _e( 'Support', 'wp-statistics' ); ?></h2></td> | ||||
|     </tr> | ||||
|  | ||||
|     <tr valign="top"> | ||||
|         <td scope="row" colspan="2"> | ||||
|             <p><?php _e( | ||||
| 					"We're sorry you're having problem with WP Statistics and we're happy to help out. Here are a few things to do before contacting us:", | ||||
| 					'wp-statistics' | ||||
| 				); ?></p> | ||||
|  | ||||
|             <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;"> | ||||
|                 <li><?php echo sprintf( | ||||
| 						__( 'Have you read the %sFAQs%s?', 'wp-statistics' ), | ||||
| 						'<a title="' . | ||||
| 						__( 'FAQs', 'wp-statistics' ) . | ||||
| 						'" href="http://wp-statistics.com/category/faq/" target="_blank">', | ||||
| 						'</a>' | ||||
| 					); ?></li> | ||||
|                 <li><?php echo sprintf( | ||||
| 						__( 'Have you read the %sdocumentation%s?', 'wp-statistics' ), | ||||
| 						'<a title="' . | ||||
| 						__( 'Documentation', 'wp-statistics' ) . | ||||
| 						'" href="http://wp-statistics.com/category/documentation/">', | ||||
| 						'</a>' | ||||
| 					); ?></li> | ||||
|                 <li><?php echo sprintf( | ||||
| 						__( 'Have you search the %ssupport forum%s for a similar issue?', 'wp-statistics' ), | ||||
| 						'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">', | ||||
| 						'</a>' | ||||
| 					); ?></li> | ||||
|                 <li><?php _e( | ||||
| 						'Have you search the Internet for any error messages you are receiving?', | ||||
| 						'wp-statistics' | ||||
| 					); ?></li> | ||||
|                 <li><?php _e( 'Make sure you have access to your PHP error logs.', 'wp-statistics' ); ?></li> | ||||
|             </ul> | ||||
|  | ||||
|             <p><?php _e( 'And a few things to double-check:', 'wp-statistics' ); ?></p> | ||||
|  | ||||
|             <ul style="list-style-type: disc; list-style-position: inside; padding-left: 25px;"> | ||||
|                 <li><?php _e( 'How\'s your memory_limit in php.ini?', 'wp-statistics' ); ?></li> | ||||
|                 <li><?php _e( | ||||
| 						'Have you tried disabling any other plugins you may have installed?', | ||||
| 						'wp-statistics' | ||||
| 					); ?></li> | ||||
|                 <li><?php _e( 'Have you tried using the default WordPress theme?', 'wp-statistics' ); ?></li> | ||||
|                 <li><?php _e( 'Have you double checked the plugin settings?', 'wp-statistics' ); ?></li> | ||||
|                 <li><?php _e( 'Do you have all the required PHP extensions installed?', 'wp-statistics' ); ?></li> | ||||
|                 <li><?php echo __( | ||||
| 					               'Are you getting a blank or incomplete page displayed in your browser?', | ||||
| 					               'wp-statistics' | ||||
| 				               ) . | ||||
| 				               ' ' . | ||||
| 				               __( | ||||
| 					               'Did you view the source for the page and check for any fatal errors?', | ||||
| 					               'wp-statistics' | ||||
| 				               ); ?></li> | ||||
|                 <li><?php _e( 'Have you checked your PHP and web server error logs?', 'wp-statistics' ); ?></li> | ||||
|             </ul> | ||||
|  | ||||
|             <p><?php _e( 'Still not having any luck?', 'wp-statistics' ); ?><?php echo sprintf( | ||||
| 					__( | ||||
| 						'Then please open a new thread on the %sWordPress.org support forum%s and we\'ll respond as soon as possible.', | ||||
| 						'wp-statistics' | ||||
| 					), | ||||
| 					'<a href="http://wordpress.org/support/plugin/wp-statistics" target="_blank">', | ||||
| 					'</a>' | ||||
| 				); ?></p> | ||||
|         </td> | ||||
|     </tr> | ||||
|  | ||||
|     </tbody> | ||||
| </table> | ||||
| @@ -0,0 +1,94 @@ | ||||
| <?php | ||||
|  | ||||
| //Get List Roles Wordpress | ||||
| global $wp_roles; | ||||
| $role_list = $wp_roles->get_names(); | ||||
|  | ||||
| //Save Option Access | ||||
| if ( $wps_nonce_valid ) { | ||||
| 	$wps_option_list = array_merge( $wps_option_list, array( 'wps_read_capability', 'wps_manage_capability' ) ); | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
|  | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Access Levels', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
| 		<?php | ||||
|  | ||||
|         //Get List Of Capability | ||||
| 		foreach ( $wp_roles->roles as $role ) { | ||||
| 			$cap_list = $role['capabilities']; | ||||
| 			foreach ( $cap_list as $key => $cap ) { | ||||
|  | ||||
| 			    //remove level_ from List | ||||
| 				if ( substr( $key, 0, 6 ) != 'level_' ) { | ||||
| 					$all_caps[ $key ] = 1; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		ksort( $all_caps ); | ||||
| 		$read_cap    = $WP_Statistics->get_option( 'read_capability', 'manage_options' ); | ||||
| 		$option_list = ''; | ||||
| 		foreach ( $all_caps as $key => $cap ) { | ||||
| 			if ( $key == $read_cap ) { | ||||
| 				$selected = " SELECTED"; | ||||
| 			} else { | ||||
| 				$selected = ""; | ||||
| 			} | ||||
| 			$option_list .= "<option value='{$key}'{$selected}>{$key}</option>"; | ||||
| 		} | ||||
| 		?> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_read_capability"><?php _e( 'Required user level to view WP Statistics:', 'wp-statistics' ) ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <select dir="ltr" id="wps_read_capability" name="wps_read_capability"><?php echo $option_list; ?></select> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		$manage_cap = $WP_Statistics->get_option( 'manage_capability', 'manage_options' ); | ||||
| 		foreach ( $all_caps as $key => $cap ) { | ||||
| 			if ( $key == $manage_cap ) { | ||||
| 				$selected = " SELECTED"; | ||||
| 			} else { | ||||
| 				$selected = ""; | ||||
| 			} | ||||
| 			$option_list .= "<option value='{$key}'{$selected}>{$key}</option>"; | ||||
| 		} | ||||
| 		?> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_manage_capability"><?php _e( 'Required user level to manage WP Statistics:', 'wp-statistics' ) ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <select dir="ltr" id="wps_manage_capability" name="wps_manage_capability"><?php echo $option_list; ?></select> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
|                 <p class="description"><?php echo sprintf( __( 'See the %sWordPress Roles and Capabilities page%s for details on capability levels.', 'wp-statistics' ), '<a target=_blank href="http://codex.wordpress.org/Roles_and_Capabilities">', '</a>' ); ?></p> | ||||
|                 <p class="description"><?php echo __( 'Hint: manage_network = Super Admin Network, manage_options = Administrator, edit_others_posts = Editor, publish_posts = Author, edit_posts = Contributor, read = Everyone.', 'wp-statistics' ); ?></p> | ||||
|                 <p class="description"><?php echo __( 'Each of the above cascades the rights upwards in the default WordPress configuration. So for example selecting publish_posts grants the right to Authors, Editors, Admins and Super Admins.', 'wp-statistics' ); ?></p> | ||||
|                 <p class="description"><?php echo sprintf( __( 'If you need a more robust solution to delegate access you might want to look at %s in the WordPress plugin directory.', 'wp-statistics' ), '<a href="http://wordpress.org/plugins/capability-manager-enhanced/" target=_blank>Capability Manager Enhanced</a>' ); ?></p> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,466 @@ | ||||
| <?php | ||||
| global $wp_roles; | ||||
|  | ||||
| $role_list = $wp_roles->get_names(); | ||||
|  | ||||
| if ( $wps_nonce_valid ) { | ||||
|  | ||||
| 	foreach ( $role_list as $role ) { | ||||
| 		$role_post = 'wps_exclude_' . str_replace( " ", "_", strtolower( $role ) ); | ||||
|  | ||||
| 		if ( array_key_exists( $role_post, $_POST ) ) { | ||||
| 			$value = $_POST[ $role_post ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
|  | ||||
| 		$new_option = str_replace( "wps_", "", $role_post ); | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	if ( array_key_exists( 'wps_create_honeypot', $_POST ) ) { | ||||
| 		$my_post = array( | ||||
| 			'post_type'    => 'page', | ||||
| 			'post_title'   => __( 'WP Statistics Honey Pot Page', 'wp-statistics' ) . | ||||
| 			                  ' [' . | ||||
| 			                  $WP_Statistics->Current_Date() . | ||||
| 			                  ']', | ||||
| 			'post_content' => __( 'This is the Honey Pot for WP Statistics to use, do not delete.', 'wp-statistics' ), | ||||
| 			'post_status'  => 'publish', | ||||
| 			'post_author'  => 1, | ||||
| 		); | ||||
|  | ||||
| 		$_POST['wps_honeypot_postid'] = wp_insert_post( $my_post ); | ||||
| 	} | ||||
|  | ||||
| 	$wps_option_list = array_merge( | ||||
| 		$wps_option_list, | ||||
| 		array( | ||||
| 			'wps_record_exclusions', | ||||
| 			'wps_robotlist', | ||||
| 			'wps_exclude_ip', | ||||
| 			'wps_exclude_loginpage', | ||||
| 			'wps_exclude_adminpage', | ||||
| 			'wps_force_robot_update', | ||||
| 			'wps_excluded_countries', | ||||
| 			'wps_included_countries', | ||||
| 			'wps_excluded_hosts', | ||||
| 			'wps_robot_threshold', | ||||
| 			'wps_use_honeypot', | ||||
| 			'wps_honeypot_postid', | ||||
| 			'wps_exclude_feeds', | ||||
| 			'wps_excluded_urls', | ||||
| 			'wps_exclude_404s', | ||||
| 			'wps_corrupt_browser_info', | ||||
| 			'wps_exclude_ajax', | ||||
| 		) | ||||
| 	); | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
|  | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Exclusions', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><label for="wps-exclusions"><?php _e( 'Record exclusions:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <input id="wps-exclusions" type="checkbox" value="1" | ||||
|                        name="wps_record_exclusions" <?php echo $WP_Statistics->get_option( 'record_exclusions' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps-exclusions"><?php _e( | ||||
| 						'Enable', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'This will record all the excluded hits in a separate table with the reasons why it was excluded but no other information.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'This will generate a lot of data but is useful if you want to see the total number of hits your site gets, not just actual user visits.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Exclude User Roles', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
| 		<?php | ||||
| 		$role_option_list = ''; | ||||
|  | ||||
| 		foreach ( $role_list as $role ) { | ||||
| 			$store_name       = 'exclude_' . str_replace( " ", "_", strtolower( $role ) ); | ||||
| 			$option_name      = 'wps_' . $store_name; | ||||
| 			$role_option_list .= $option_name . ','; | ||||
|  | ||||
| 			$translated_role_name = translate_user_role( $role ); | ||||
| 			?> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"><label for="<?php echo $option_name; ?>"><?php echo $translated_role_name; ?>:</label> | ||||
|                 </th> | ||||
|                 <td> | ||||
|                     <input id="<?php echo $option_name; ?>" type="checkbox" value="1" | ||||
|                            name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true | ||||
| 						? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e( | ||||
| 							'Exclude', | ||||
| 							'wp-statistics' | ||||
| 						); ?></label> | ||||
|  | ||||
|                     <p class="description"><?php echo sprintf( | ||||
| 							__( 'Exclude %s role from data collection.', 'wp-statistics' ), | ||||
| 							$translated_role_name | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
| 		<?php } ?> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'IP/Robot Exclusions', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Robot list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php | ||||
| 					$robotlist = $WP_Statistics->get_option( 'robotlist' ); | ||||
|  | ||||
| 					if ( ! isset( $wps_robotarray ) ) { | ||||
| 						include( WP_Statistics::$reg['plugin-dir'] . 'includes/robotslist.php' ); | ||||
| 					} | ||||
|  | ||||
| 					if ( $robotlist == '' ) { | ||||
| 						$robotlist = implode( "\n", $wps_robotarray ); | ||||
| 						update_option( 'wps_robotlist', $robotlist ); | ||||
| 					} | ||||
|  | ||||
| 					echo htmlentities( $robotlist, ENT_QUOTES ); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of words (one per line) to match against to detect robots. Entries must be at least 4 characters long or they will be ignored.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|                 <a onclick="var wps_robotlist = getElementById('wps_robotlist'); wps_robotlist.value = '<?php echo implode( | ||||
| 					'\n', | ||||
| 					$wps_robotarray | ||||
| 				); ?>';" class="button"><?php _e( 'Reset to Default', 'wp-statistics' ); ?></a> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="force_robot_update"><?php _e( 'Force robot list update after upgrades:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <input id="force_robot_update" type="checkbox" value="1" | ||||
|                        name="wps_force_robot_update" <?php echo $WP_Statistics->get_option( 'force_robot_update' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="force_robot_update"><?php _e( | ||||
| 						'Enable', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo sprintf( | ||||
| 						__( | ||||
| 							'Force the robot list to be reset to the default after an update to WP Statistics takes place. Note if this option is enabled any custom robots you have added to the list will be lost.', | ||||
| 							'wp-statistics' | ||||
| 						), | ||||
| 						$role | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><label for="wps_robot_threshold"><?php _e( 'Robot visit threshold:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <input id="wps_robot_threshold" type="text" size="5" name="wps_robot_threshold" | ||||
|                        value="<?php echo $WP_Statistics->get_option( 'robot_threshold' ); ?>"> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'Treat visitors with more than this number of visits per day as robots. 0 = disabled.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded IP address list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code" | ||||
|                           dir="ltr"><?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'exclude_ip' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of IP addresses and subnet masks (one per line) to exclude from statistics collection.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'For IPv4 addresses, both 192.168.0.0/24 and 192.168.0.0/255.255.255.0 formats are accepted. To specify an IP address only, use a subnet value of 32 or 255.255.255.255.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'For IPv6 addresses use the fc00::/7 format.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|                 <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n10.0.0.0/8' ); }" | ||||
|                    class="button"><?php _e( 'Add 10.0.0.0', 'wp-statistics' ); ?></a> | ||||
|                 <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n172.16.0.0/12' ); }" | ||||
|                    class="button"><?php _e( 'Add 172.16.0.0', 'wp-statistics' ); ?></a> | ||||
|                 <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n192.168.0.0/16' ); }" | ||||
|                    class="button"><?php _e( 'Add 192.168.0.0', 'wp-statistics' ); ?></a> | ||||
|                 <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\nfc00::/7' ); }" | ||||
|                    class="button"><?php _e( 'Add fc00::/7', 'wp-statistics' ); ?></a> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Use Honey Pot:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="use_honeypot" type="checkbox" value="1" | ||||
|                        name="wps_use_honeypot" <?php echo $WP_Statistics->get_option( 'use_honeypot' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps_use_honeypot"><?php _e( | ||||
| 						'Enable', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'Use a Honey Pot page to identify robots.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><label for="honeypot_postid"><?php _e( 'Honey Pot post ID', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <input id="honeypot_postid" type="text" | ||||
|                        value="<?php echo htmlentities( $WP_Statistics->get_option( 'honeypot_postid' ), ENT_QUOTES ); ?>" | ||||
|                        size="5" name="wps_honeypot_postid"> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'The post ID to use for the Honey Pot page.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|                 <input id="wps_create_honeypot" type="checkbox" value="1" name="wps_create_honeypot"><label | ||||
|                         for="wps_create_honeypot"><?php _e( 'Create a new Honey Pot page', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="corrupt_browser_info"><?php _e( 'Treat corrupt browser info as a bot:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|             <td> | ||||
|                 <input id="corrupt_browser_info" type="checkbox" value="1" | ||||
|                        name="wps_corrupt_browser_info" <?php echo $WP_Statistics->get_option( 'corrupt_browser_info' ) == | ||||
| 				                                                  true ? "checked='checked'" : ''; ?>><label | ||||
|                         for="wps_corrupt_browser_info"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'GeoIP Exclusions', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded countries list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code" | ||||
|                           dir="ltr"><?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'excluded_countries' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of country codes (one per line, two letters each) to exclude from statistics collection.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Use "000" (three zeros) to exclude unknown countries.', | ||||
| 						'wp-statistics' | ||||
| 					).' '.sprintf(__( '(%1$sISO 3166 Country Codes%2$s)', 'wp-statistics' ), '<a href="' . esc_url( 'https://dev.maxmind.com/geoip/legacy/codes/iso3166/' ) . '" target="_blank">','</a>' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Included countries list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code" | ||||
|                           dir="ltr"><?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'included_countries' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of country codes (one per line, two letters each) to include in statistics collection, if this list is not empty, only visitors from the included countries will be recorded', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Use "000" (three zeros) to exclude unknown countries.', | ||||
| 						'wp-statistics' | ||||
| 					).' '.sprintf(__( '(%1$sISO 3166 Country Codes%2$s)', 'wp-statistics' ), '<a href="' . esc_url( 'https://dev.maxmind.com/geoip/legacy/codes/iso3166/' ) . '" target="_blank">','</a>' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Host Exclusions', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded hosts list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code" | ||||
|                           dir="ltr"><?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'excluded_hosts' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|                 <br> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'Note: this option will NOT perform a reverse DNS lookup on each page load but instead cache the IP address for the provided hostnames for one hour. If you are excluding dynamically assigned hosts you may find some degree of overlap when the host changes it\'s IP address and when the cache is updated resulting in some hits recorded.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Site URL Exclusions', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded login page:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="wps-exclude-loginpage" type="checkbox" value="1" | ||||
|                        name="wps_exclude_loginpage" <?php echo $WP_Statistics->get_option( 'exclude_loginpage' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps-exclude-loginpage"><?php _e( | ||||
| 						'Exclude', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Exclude the login page for registering as a hit.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded Admin page:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="wps-exclude-adminpage" type="checkbox" value="1" | ||||
|                        name="wps_exclude_adminpage" <?php echo $WP_Statistics->get_option( 'exclude_adminpage' ) == true | ||||
|                     ? "checked='checked'" : ''; ?>><label for="wps-exclude-adminpage"><?php _e( | ||||
|                         'Exclude', | ||||
|                         'wp-statistics' | ||||
|                     ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
|                         'Exclude any call to the WordPress Admin pages.', | ||||
|                         'wp-statistics' | ||||
|                     ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded RSS feeds:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="wps-exclude-feeds" type="checkbox" value="1" | ||||
|                        name="wps_exclude_feeds" <?php echo $WP_Statistics->get_option( 'exclude_feeds' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps-exclude-feeds"><?php _e( | ||||
| 						'Exclude', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Exclude the RSS feeds for registering as a hit.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded 404 pages:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="wps-exclude-404s" type="checkbox" value="1" | ||||
|                        name="wps_exclude_404s" <?php echo $WP_Statistics->get_option( 'exclude_404s' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps-exclude-404s"><?php _e( | ||||
| 						'Exclude', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Exclude any URL that returns a "404 - Not Found" message.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded AJAX calls:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
|                 <input id="wps-exclude-ajax" type="checkbox" value="1" | ||||
|                        name="wps_exclude_ajax" <?php echo $WP_Statistics->get_option( 'exclude_ajax' ) == true | ||||
| 					? "checked='checked'" : ''; ?>><label for="wps-exclude-ajax"><?php _e( | ||||
| 						'Exclude', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Exclude any call to the WordPress AJAX system.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"><?php _e( 'Excluded URLs list:', 'wp-statistics' ); ?></th> | ||||
|             <td> | ||||
| 				<textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code" | ||||
|                           dir="ltr"><?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'excluded_urls' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?></textarea> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|                 <br> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'Note: this option will NOT handle URL parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,315 @@ | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
|  | ||||
| 	$wps_option_list = array( | ||||
| 		'wps_geoip', | ||||
| 		'wps_update_geoip', | ||||
| 		'wps_schedule_geoip', | ||||
| 		'wps_geoip_city', | ||||
| 		'wps_auto_pop', | ||||
| 		'wps_private_country_code', | ||||
| 		'wps_referrerspam', | ||||
| 		'wps_schedule_referrerspam' | ||||
| 	); | ||||
|  | ||||
| 	// For country codes we always use upper case, otherwise default to 000 which is 'unknown'. | ||||
| 	if ( array_key_exists( 'wps_private_country_code', $_POST ) ) { | ||||
| 		$_POST['wps_private_country_code'] = trim( strtoupper( $_POST['wps_private_country_code'] ) ); | ||||
| 	} else { | ||||
| 		$_POST['wps_private_country_code'] = '000'; | ||||
| 	} | ||||
|  | ||||
| 	if ( $_POST['wps_private_country_code'] == '' ) { | ||||
| 		$_POST['wps_private_country_code'] = '000'; | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'GeoIP settings', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
| 				<?php echo sprintf( | ||||
| 					__( 'IP location services are provided by data created by %s.', 'wp-statistics' ), | ||||
| 					'<a href="http://www.maxmind.com" target=_blank>MaxMind</a>' | ||||
| 				); ?> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		if ( wp_statistics_geoip_supported() ) { | ||||
| 			?> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="geoip-enable"><?php _e( 'GeoIP collection:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="geoip-enable" type="checkbox" name="wps_geoip" <?php echo( $WP_Statistics->get_option( 'geoip' ) === 'on' ? "checked='checked'" : '' ); ?>> | ||||
|                     <label for="geoip-enable"> | ||||
| 						<?php _e( 'Enable', 'wp-statistics' ); ?> | ||||
|                         <form action="" method="post" style="display: inline;"> | ||||
|                             <input type="hidden" name="geoip_name" value="country"> | ||||
| 							<?php submit_button( __( "Update Database", 'wp-statistics' ), "secondary", "update_geoip", false ); ?> | ||||
|                         </form> | ||||
|                     </label> | ||||
|  | ||||
|                     <p class="description"><?php _e( | ||||
| 							'For getting more information and location (country) from visitor, enable this feature.', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="geoip-city"><?php _e( 'GeoIP City:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="geoip-city" type="checkbox" name="wps_geoip_city" <?php echo( $WP_Statistics->get_option( 'geoip_city' ) == 'on' ? "checked='checked'" : '' ); ?>> | ||||
|                     <label for="geoip-city"> | ||||
| 						<?php _e( 'Enable', 'wp-statistics' ); ?> | ||||
|                         <form action="" method="post" style="display: inline;"> | ||||
|                             <input type="hidden" name="geoip_name" value="city"> | ||||
| 							<?php submit_button( __( "Update Database", 'wp-statistics' ), "secondary", "update_geoip", false ); ?> | ||||
|                         </form> | ||||
|                     </label> | ||||
|  | ||||
|                     <p class="description"><?php _e( | ||||
| 							'See Visitor\'s City Name', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="geoip-schedule"><?php _e( 'Schedule monthly update of GeoIP DB:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="geoip-schedule" type="checkbox" name="wps_schedule_geoip" <?php echo $WP_Statistics->get_option( 'schedule_geoip' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                     <label for="geoip-schedule"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
| 					<?php | ||||
| 					if ( $WP_Statistics->get_option( 'schedule_geoip' ) ) { | ||||
| 						echo '<p class="description">' . __( 'Next update will be', 'wp-statistics' ) . ': <code>'; | ||||
| 						$last_update = $WP_Statistics->get_option( 'last_geoip_dl' ); | ||||
| 						$this_month  = strtotime( __( 'First Tuesday of this month', 'wp-statistics' ) ); | ||||
|  | ||||
| 						if ( $last_update > $this_month ) { | ||||
| 							$next_update = strtotime( __( 'First Tuesday of next month', 'wp-statistics' ) ) + | ||||
| 							               ( 86400 * 2 ); | ||||
| 						} else { | ||||
| 							$next_update = $this_month + ( 86400 * 2 ); | ||||
| 						} | ||||
|  | ||||
| 						$next_schedule = wp_next_scheduled( 'wp_statistics_geoip_hook' ); | ||||
|  | ||||
| 						if ( $next_schedule ) { | ||||
| 							echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) . | ||||
| 							     ' @ ' . | ||||
| 							     $WP_Statistics->Local_Date( get_option( 'time_format' ), $next_schedule ); | ||||
| 						} else { | ||||
| 							echo $WP_Statistics->Local_Date( get_option( 'date_format' ), $next_update ) . | ||||
| 							     ' @ ' . | ||||
| 							     $WP_Statistics->Local_Date( get_option( 'time_format' ), time() ); | ||||
| 						} | ||||
|  | ||||
| 						echo '</code></p>'; | ||||
| 					} | ||||
| 					?> | ||||
|                     <p class="description"><?php _e( | ||||
| 							'Download of the GeoIP database will be scheduled for 2 days after the first Tuesday of the month.', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|  | ||||
|                     <p class="description"><?php _e( | ||||
| 							'This option will also download the database if the local filesize is less than 1k (which usually means the stub that comes with the plugin is still in place).', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="geoip-schedule"><?php _e( | ||||
| 							'Populate missing GeoIP after update of GeoIP DB:', | ||||
| 							'wp-statistics' | ||||
| 						); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="geoip-auto-pop" type="checkbox" name="wps_auto_pop" <?php echo $WP_Statistics->get_option( 'auto_pop' ) == true | ||||
| 						? "checked='checked'" : ''; ?>> | ||||
|                     <label for="geoip-auto-pop"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                     <p class="description"><?php _e( | ||||
| 							'Update any missing GeoIP data after downloading a new database.', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="geoip-schedule"><?php _e( 'Country code for private IP addresses:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input type="text" size="3" id="geoip-private-country-code" name="wps_private_country_code" value="<?php echo htmlentities( | ||||
| 						$WP_Statistics->get_option( 'private_country_code', '000' ), | ||||
| 						ENT_QUOTES | ||||
| 					); ?>"> | ||||
|  | ||||
|                     <p class="description"><?php echo __( | ||||
| 						                                  'The international standard two letter country code (ie. US = United States, CA = Canada, etc.) for private (non-routable) IP addresses (ie. 10.0.0.1, 192.158.1.1, 127.0.0.1, etc.).', | ||||
| 						                                  'wp-statistics' | ||||
| 					                                  ) . ' ' . __( | ||||
| 						                                  'Use "000" (three zeros) to use "Unknown" as the country code.', | ||||
| 						                                  'wp-statistics' | ||||
| 					                                  ); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} else { | ||||
| 			?> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row" colspan="2"> | ||||
| 					<?php | ||||
| 					echo __( 'GeoIP collection is disabled due to the following reasons:', 'wp-statistics' ) . '<br><br>'; | ||||
|  | ||||
| 					if ( ! function_exists( 'curl_init' ) ) { | ||||
| 						echo '<br>    * '; | ||||
| 						_e( | ||||
| 							'GeoIP collection requires the cURL PHP extension and it is not loaded on your version of PHP!', | ||||
| 							'wp-statistics' | ||||
| 						); | ||||
| 						echo '<br>'; | ||||
| 					} | ||||
|  | ||||
| 					if ( ! function_exists( 'bcadd' ) ) { | ||||
| 						echo '<br>    * '; | ||||
| 						_e( | ||||
| 							'GeoIP collection requires the BC Math PHP extension and it is not loaded on your version of PHP!', | ||||
| 							'wp-statistics' | ||||
| 						); | ||||
| 						echo '<br>'; | ||||
| 					} | ||||
|  | ||||
| 					if ( ini_get( 'safe_mode' ) ) { | ||||
| 						echo '<br>    * '; | ||||
| 						_e( | ||||
| 							'PHP safe mode detected! GeoIP collection is not supported with PHP\'s safe mode enabled!', | ||||
| 							'wp-statistics' | ||||
| 						); | ||||
| 						echo '<br>'; | ||||
| 					} | ||||
| 					?> | ||||
|                 </th> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} ?> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
|                 <h3><?php _e( 'Matomo Referrer Spam Blacklist settings', 'wp-statistics' ); ?></h3> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
| 				<?php echo sprintf( | ||||
| 					__( 'Referrer spam blacklist is provided by Matomo, available from %s.', 'wp-statistics' ), | ||||
| 					'<a href="https://github.com/matomo-org/referrer-spam-blacklist" target=_blank>https://github.com/matomo-org/referrer-spam-blacklist</a>' | ||||
| 				); ?> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="referrerspam-enable"><?php _e( 'Matomo Referrer Spam Blacklist usage:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="referrerspam-enable" type="checkbox" name="wps_referrerspam" <?php echo $WP_Statistics->get_option( 'referrerspam' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="referrerspam-enable"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'The Matomo Referrer Spam Blacklist database will be downloaded and used to detect referrer spam.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top" class="referrerspam_field"<?php if ( ! $WP_Statistics->get_option( 'referrerspam' ) ) { echo ' style="display:none;"';  }  ?>> | ||||
|             <th scope="row"> | ||||
|                 <label for="geoip-update"><?php _e( 'Update Matomo Referrer Spam Blacklist Info:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <a href = "<?php echo WP_Statistics_Admin_Pages::admin_url( 'settings', array( 'tab' => 'externals-settings', 'update-referrerspam' => 'yes' ) ) ?>" class="button"><?php _e( 'Update', 'wp-staitsitcs' ); ?></a> | ||||
|                 <p class="description"><?php _e( 'Click button to download the update.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top" class="referrerspam_field"<?php if ( ! $WP_Statistics->get_option( 'referrerspam' ) ) { echo ' style="display:none;"';  }  ?>> | ||||
|             <th scope="row"> | ||||
|                 <label for="referrerspam-schedule"><?php _e( 'Schedule weekly update of Matomo Referrer Spam Blacklist DB:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="referrerspam-schedule" type="checkbox" name="wps_schedule_referrerspam" <?php echo $WP_Statistics->get_option( | ||||
| 					'schedule_referrerspam' | ||||
| 				) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="referrerspam-schedule"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
| 				<?php | ||||
| 				if ( $WP_Statistics->get_option( 'schedule_referrerspam' ) ) { | ||||
| 					echo '<p class="description">' . __( 'Next update will be', 'wp-statistics' ) . ': <code>'; | ||||
| 					$last_update = $WP_Statistics->get_option( 'schedule_referrerspam' ); | ||||
| 					if ( $last_update == 0 ) { | ||||
| 						$last_update = time(); | ||||
| 					} | ||||
| 					$next_update = $last_update + ( 86400 * 7 ); | ||||
|  | ||||
| 					$next_schedule = wp_next_scheduled( 'wp_statistics_referrerspam_hook' ); | ||||
|  | ||||
| 					if ( $next_schedule ) { | ||||
| 						echo date( get_option( 'date_format' ), $next_schedule ) . | ||||
| 						     ' @ ' . | ||||
| 						     date( get_option( 'time_format' ), $next_schedule ); | ||||
| 					} else { | ||||
| 						echo date( get_option( 'date_format' ), $next_update ) . | ||||
| 						     ' @ ' . | ||||
| 						     date( get_option( 'time_format' ), time() ); | ||||
| 					} | ||||
|  | ||||
| 					echo '</code></p>'; | ||||
| 				} | ||||
| 				?> | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Download of the Matomo Referrer Spam Blacklist database will be scheduled for once a week.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,450 @@ | ||||
| <?php | ||||
| $selist                       = wp_statistics_searchengine_list( true ); | ||||
| $permalink                    = get_option( 'permalink_structure' ); | ||||
| $disable_strip_uri_parameters = false; | ||||
|  | ||||
| if ( $permalink == '' || strpos( $permalink, '?' ) !== false ) { | ||||
| 	$disable_strip_uri_parameters = true; | ||||
| } | ||||
|  | ||||
| if ( $wps_nonce_valid ) { | ||||
| 	foreach ( $selist as $se ) { | ||||
| 		$se_post = 'wps_disable_se_' . $se['tag']; | ||||
|  | ||||
| 		if ( array_key_exists( $se_post, $_POST ) ) { | ||||
| 			$value = $_POST[ $se_post ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$new_option = str_replace( "wps_", "", $se_post ); | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
|  | ||||
| 	$wps_option_list = array( | ||||
| 		'wps_useronline', | ||||
| 		'wps_visits', | ||||
| 		'wps_visitors', | ||||
| 		'wps_visitors_log', | ||||
| 		'wps_pages', | ||||
| 		'wps_track_all_pages', | ||||
| 		'wps_use_cache_plugin', | ||||
| 		'wps_disable_column', | ||||
| 		'wps_hit_post_metabox', | ||||
| 		'wps_show_hits', | ||||
| 		'wps_display_hits_position', | ||||
| 		'wps_check_online', | ||||
| 		'wps_menu_bar', | ||||
| 		'wps_coefficient', | ||||
| 		'wps_chart_totals', | ||||
| 		'wps_hide_notices', | ||||
| 		'wps_all_online', | ||||
| 		'wps_strip_uri_parameters', | ||||
| 		'wps_addsearchwords', | ||||
| 	); | ||||
|  | ||||
| 	// We need to check the permalink format for the strip_uri_parameters option, if the permalink is the default or contains uri parameters, we can't strip them. | ||||
| 	if ( $disable_strip_uri_parameters ) { | ||||
| 		$_POST['wps_strip_uri_parameters'] = ''; | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
|     <script type="text/javascript"> | ||||
|         function ToggleShowHitsOptions() { | ||||
|             jQuery('[id^="wps_show_hits_option"]').fadeToggle(); | ||||
|         } | ||||
|     </script> | ||||
|  | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Online Users', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="useronline"><?php _e( 'Online User:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="useronline" type="checkbox" value="1" name="wps_useronline" <?php echo $WP_Statistics->get_option( 'useronline' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="useronline"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="check_online"><?php _e( 'Check for online users every:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="check_online" name="wps_check_online" value="<?php echo htmlentities( $WP_Statistics->get_option( 'check_online' ), ENT_QUOTES ); ?>"/> | ||||
| 				<?php _e( 'Seconds', 'wp-statistics' ); ?> | ||||
|                 <p class="description"><?php echo sprintf( | ||||
| 						__( 'Time for the check accurate online user in the site. Now: %s Seconds', 'wp-statistics' ), | ||||
| 						$WP_Statistics->get_option( 'check_online' ) | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="allonline"><?php _e( 'Record all user:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="allonline" type="checkbox" value="1" name="wps_all_online" <?php echo $WP_Statistics->get_option( 'all_online' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="allonline"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Ignores the exclusion settings and records all users that are online (including self referrals and robots). Should only be used for troubleshooting.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Visits', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="visits"><?php _e( 'Visits:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="visits" type="checkbox" value="1" name="wps_visits" <?php echo $WP_Statistics->get_option( 'visits' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="visits"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Visitors', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top" id="visitors_tr"> | ||||
|             <th scope="row"> | ||||
|                 <label for="visitors"><?php _e( 'Visitors:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="visitors" type="checkbox" value="1" name="wps_visitors" <?php echo $WP_Statistics->get_option( 'visitors' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="visitors"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top" id="visitors_log_tr" <?php echo( $WP_Statistics->get_option( 'visitors' ) == false ? 'style="display:none;"' : '' ) ?>> | ||||
|             <th scope="row"> | ||||
|                 <label for="visitors_log"><?php _e( 'Visitors logs:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="visitors_log" type="checkbox" value="1" name="wps_visitors_log" <?php echo $WP_Statistics->get_option( 'visitors_log' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="visitors_log"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'If enabled, you will receive a report of each user\'s visit to the pages', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="coefficient"><?php _e( 'Coefficient per visitor:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="coefficient" name="wps_coefficient" value="<?php echo htmlentities( $WP_Statistics->get_option( 'coefficient' ), ENT_QUOTES ); ?>"/> | ||||
|  | ||||
|                 <p class="description"><?php echo sprintf( | ||||
| 						__( 'For each visit to account for several hits. Currently %s.', 'wp-statistics' ), | ||||
| 						$WP_Statistics->get_option( 'coefficient' ) | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Pages and Posts', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="pages"><?php _e( 'Pages:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="pages" type="checkbox" value="1" name="wps_pages" <?php echo $WP_Statistics->get_option( 'pages' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="pages"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="all_pages"><?php _e( 'Track all pages:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="all_pages" type="checkbox" value="1" name="wps_track_all_pages" <?php echo $WP_Statistics->get_option( 'track_all_pages' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="all_pages"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|                 <p class="description"><?php echo sprintf( __( 'Track All Wordpress Page Contains Category, Post Tags, Author, Custom Taxonomy and ...', 'wp-statistics' ), admin_url( 'options-permalink.php' ) ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		if ( ! $disable_strip_uri_parameters ) { | ||||
| 			?> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="strip_uri_parameters"><?php _e( 'Strip parameters from URI:', 'wp-statistics' ); ?></label> | ||||
|                 </th> | ||||
|  | ||||
|                 <td> | ||||
|                     <input id="strip_uri_parameters" type="checkbox" value="1" name="wps_strip_uri_parameters" <?php echo $WP_Statistics->get_option( 'strip_uri_parameters' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                     <label for="strip_uri_parameters"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                     <p class="description"><?php _e( 'This will remove anything after the ? in a URL.', 'wp-statistics' ); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} | ||||
| 		?> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="disable_column"><?php _e( 'Hits column', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="disable_column" type="checkbox" value="1" name="wps_disable_column" <?php echo $WP_Statistics->get_option( 'disable_column' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="disable_column"><?php _e( 'Disable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="hit_post_metabox"><?php _e( 'Hit metabox chart:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="hit_post_metabox" type="checkbox" value="1" name="wps_hit_post_metabox" <?php echo $WP_Statistics->get_option( 'hit_post_metabox' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="hit_post_metabox"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Show hits meta box chart in the edit of all post types page.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="show_hits"><?php _e( 'Hits in single page:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="show_hits" type="checkbox" value="1" name="wps_show_hits" <?php echo $WP_Statistics->get_option( 'show_hits' ) == true | ||||
| 					? "checked='checked'" : ''; ?> onClick='ToggleShowHitsOptions();'> | ||||
|                 <label for="show_hits"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable show hits in content', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php if ( $WP_Statistics->get_option( 'show_hits' ) ) { | ||||
| 			$hidden = ""; | ||||
| 		} else { | ||||
| 			$hidden = " style='display: none;'"; | ||||
| 		} ?> | ||||
|         <tr valign="top"<?php echo $hidden; ?> id='wps_show_hits_option'> | ||||
|             <td scope="row" style="vertical-align: top;"> | ||||
|                 <label for="display_hits_position"><?php _e( 'Display position:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <select name="wps_display_hits_position" id="display_hits_position"> | ||||
|                     <option value="0" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), '0' ); ?>><?php _e( | ||||
| 							'Please select', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|                     <option value="before_content" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), 'before_content' ); ?>><?php _e( | ||||
| 							'Before Content', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|  | ||||
|                     <option value="after_content" <?php selected( $WP_Statistics->get_option( 'display_hits_position' ), 'after_content' ); ?>><?php _e( | ||||
| 							'After Content', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Choose the position to show Hits.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Cache Plugin', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="all_pages"><?php _e( 'Use Cache Plugin:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="use_cache_plugin" type="checkbox" value="1" name="wps_use_cache_plugin" <?php echo $WP_Statistics->get_option( 'use_cache_plugin' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="use_cache_plugin"><?php _e( 'Yes', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'If you use WordPress Cache Plugins, enable this option.', 'wp-statistics' ); ?></p> | ||||
|                 <p class="description"><?php echo sprintf( __( 'To register WP-Statistics REST API endpoint  ( %s ) , go to the <a href="%s">Permalink page</a> and update the permalink with press Save Changes.', 'wp-statistics' ), WP_Statistics_Rest::route, admin_url( 'options-permalink.php' ) ); ?></p> | ||||
|                 <p class="description"><?php echo __( 'Don\'t forget to clear your enabled plugin cache.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Miscellaneous', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="menu-bar"><?php _e( 'Show stats in menu bar:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <select name="wps_menu_bar" id="menu-bar"> | ||||
|                     <option value="0" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '0' ); ?>><?php _e( | ||||
| 							'No', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|                     <option value="1" <?php selected( $WP_Statistics->get_option( 'menu_bar' ), '1' ); ?>><?php _e( | ||||
| 							'Yes', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Show stats in admin menu bar', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="hide_notices"><?php _e( 'Hide admin notices about non active features:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="hide_notices" type="checkbox" value="1" name="wps_hide_notices" <?php echo $WP_Statistics->get_option( 'hide_notices' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="hide_notices"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'By default WP Statistics displays an alert if any of the core features are disabled on every admin page, this option will disable these notices.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Search Engines', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="addsearchwords"><?php _e( 'Add page title to empty search words:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="addsearchwords" type="checkbox" value="1" name="wps_addsearchwords" <?php echo $WP_Statistics->get_option( 'addsearchwords' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="addsearchwords"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'If a search engine is identified as the referrer but it does not include the search query this option will substitute the page title in quotes preceded by "~:" as the search query to help identify what the user may have been searching for.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Disabling all search engines is not allowed, doing so will result in all search engines being active.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </th> | ||||
|         </tr> | ||||
| 		<?php | ||||
| 		$se_option_list = ''; | ||||
|  | ||||
| 		foreach ( $selist as $se ) { | ||||
| 			$option_name    = 'wps_disable_se_' . $se['tag']; | ||||
| 			$store_name     = 'disable_se_' . $se['tag']; | ||||
| 			$se_option_list .= $option_name . ','; | ||||
| 			?> | ||||
|  | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row"> | ||||
|                     <label for="<?php echo $option_name; ?>"><?php _e( $se['name'], 'wp-statistics' ); ?>:</label> | ||||
|                 </th> | ||||
|                 <td> | ||||
|                     <input id="<?php echo $option_name; ?>" type="checkbox" value="1" name="<?php echo $option_name; ?>" <?php echo $WP_Statistics->get_option( $store_name ) == true | ||||
| 						? "checked='checked'" : ''; ?>><label for="<?php echo $option_name; ?>"><?php _e( | ||||
| 							'Disable', | ||||
| 							'wp-statistics' | ||||
| 						); ?></label> | ||||
|  | ||||
|                     <p class="description"><?php echo sprintf( | ||||
| 							__( 'Disable %s from data collection and reporting.', 'wp-statistics' ), | ||||
| 							$se['name'] | ||||
| 						); ?></p> | ||||
|                 </td> | ||||
|             </tr> | ||||
| 		<?php } ?> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Charts', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="chart-totals"><?php _e( 'Include totals:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="chart-totals" type="checkbox" value="1" name="wps_chart_totals" <?php echo $WP_Statistics->get_option( 'chart_totals' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="chart-totals"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Add a total line to charts with multiple values, like the search engine referrals', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,139 @@ | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
|  | ||||
| 	$wps_option_list = array( | ||||
| 		'wps_schedule_dbmaint', | ||||
| 		'wps_schedule_dbmaint_days', | ||||
| 		'wps_schedule_dbmaint_visitor', | ||||
| 		'wps_schedule_dbmaint_visitor_hits', | ||||
| 	); | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <script type="text/javascript"> | ||||
|         function DBMaintWarning() { | ||||
|             var checkbox = jQuery('#wps_schedule_dbmaint'); | ||||
|  | ||||
|             if (checkbox.attr('checked') == 'checked') { | ||||
|                 if (!confirm('<?php _e( 'This will permanently delete data from the database each day, are you sure you want to enable this option?', 'wp-statistics' ); ?>')) | ||||
|                     checkbox.attr('checked', false); | ||||
|             } | ||||
|  | ||||
|  | ||||
|         } | ||||
|     </script> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Purge Old Data Daily', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_schedule_dbmaint"><?php _e( 'Enabled:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="wps_schedule_dbmaint" type="checkbox" | ||||
|                        name="wps_schedule_dbmaint" <?php echo $WP_Statistics->get_option( 'schedule_dbmaint' ) == true | ||||
| 					? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'> | ||||
|                 <label for="wps_schedule_dbmaint"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'A WP Cron job will be run daily to purge any data older than a set number of days.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_schedule_dbmaint_days"><?php _e( 'Purge data older than:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="wps_schedule_dbmaint_days" | ||||
|                        name="wps_schedule_dbmaint_days" value="<?php echo htmlentities( | ||||
| 					$WP_Statistics->get_option( 'schedule_dbmaint_days', "365" ), | ||||
| 					ENT_QUOTES | ||||
| 				); ?>"/> | ||||
| 				<?php _e( 'Days', 'wp-statistics' ); ?> | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'The number of days to keep statistics for.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Minimum value is 30 days.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Invalid values will disable the daily maintenance.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Purge High Hit Count Visitors Daily', 'wp-statistics' ); ?></h3> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_schedule_dbmaint_visitor"><?php _e( 'Enabled:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="wps_schedule_dbmaint_visitor" type="checkbox" | ||||
|                        name="wps_schedule_dbmaint_visitor" <?php echo $WP_Statistics->get_option( | ||||
| 					'schedule_dbmaint_visitor' | ||||
| 				) == true ? "checked='checked'" : ''; ?> onclick='DBMaintWarning();'> | ||||
|                 <label for="wps_schedule_dbmaint_visitor"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'A WP Cron job will be run daily to purge any users statistics data where the user has more than the defined number of hits in a day (aka they are probably a bot).', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="wps_schedule_dbmaint_visitor_hits"><?php _e( | ||||
| 						'Purge visitors with more than:', | ||||
| 						'wp-statistics' | ||||
| 					); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input type="text" class="small-text code" id="wps_schedule_dbmaint_visitor_hits" | ||||
|                        name="wps_schedule_dbmaint_visitor_hits" value="<?php echo htmlentities( | ||||
| 					$WP_Statistics->get_option( 'schedule_dbmaint_visitor_hits', '50' ), | ||||
| 					ENT_QUOTES | ||||
| 				); ?>"/> | ||||
| 				<?php _e( 'Hits', 'wp-statistics' ); ?> | ||||
|                 <p class="description"><?php echo __( | ||||
| 						'The number of hits required to delete the visitor.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Minimum value is 10 hits.', | ||||
| 						'wp-statistics' | ||||
| 					) . ' ' . __( | ||||
| 						'Invalid values will disable the daily maintenance.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,293 @@ | ||||
| <?php | ||||
| $selist = wp_statistics_searchengine_list( true ); | ||||
|  | ||||
| if ( $wps_nonce_valid ) { | ||||
|  | ||||
| 	// We need to handle a change in the report schedule manually, so check to see it has been set. | ||||
| 	if ( array_key_exists( 'wps_time_report', $_POST ) ) { | ||||
| 		// If the report has been changed, we need to update the schedule. | ||||
| 		if ( $WP_Statistics->get_option( 'time_report' ) != $_POST['wps_time_report'] ) { | ||||
| 			// Remove the old schedule if it exists. | ||||
| 			if ( wp_next_scheduled( 'report_hook' ) ) { | ||||
| 				wp_unschedule_event( wp_next_scheduled( 'report_hook' ), 'report_hook' ); | ||||
| 			} | ||||
|  | ||||
| 			// Setup the new schedule, we could just let this fall through and let the code in schedule.php deal with it | ||||
| 			// but that would require an extra page load to start the schedule so do it here instead. | ||||
| 			wp_schedule_event( time(), $_POST['wps_time_report'], 'report_hook' ); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$wps_option_list = array( | ||||
| 		"wps_stats_report", | ||||
| 		"wps_time_report", | ||||
| 		"wps_send_report", | ||||
| 		"wps_content_report", | ||||
| 		"wps_email_list", | ||||
| 		"wps_geoip_report", | ||||
| 		"wps_prune_report", | ||||
| 		"wps_upgrade_report", | ||||
| 		"wps_admin_notices", | ||||
| 	); | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
|  | ||||
| 		// WordPress escapes form data no matter what the setting of magic quotes is in PHP (http://www.theblog.ca/wordpress-addslashes-magic-quotes). | ||||
| 		$value = stripslashes( $value ); | ||||
|  | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <script type="text/javascript"> | ||||
|         function ToggleStatOptions() { | ||||
|             jQuery('[id^="wps_stats_report_option"]').fadeToggle(); | ||||
|         } | ||||
|     </script> | ||||
|  | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Common Report Options', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row" style="vertical-align: top;"> | ||||
|                 <label for="email-report"><?php _e( 'E-mail addresses:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <input dir="ltr" type="text" id="email_list" name="wps_email_list" size="30" value="<?php if ( $WP_Statistics->get_option( 'email_list' ) == '' ) { | ||||
| 					$WP_Statistics->store_option( 'email_list', get_bloginfo( 'admin_email' ) ); | ||||
| 				} | ||||
| 				echo htmlentities( $WP_Statistics->get_option( 'email_list' ), ENT_QUOTES ); ?>"/> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'A comma separated list of e-mail addresses to send reports to.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Update Reports', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row"> | ||||
|                 <label for="geoip-report"><?php _e( 'GeoIP:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="geoip-report" type="checkbox" value="1" name="wps_geoip_report" <?php echo $WP_Statistics->get_option( 'geoip_report' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="geoip-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Send a report whenever the GeoIP database is updated.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row"> | ||||
|                 <label for="prune-report"><?php _e( 'Pruning:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="prune-report" type="checkbox" value="1" name="wps_prune_report" <?php echo $WP_Statistics->get_option( 'prune_report' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="prune-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Send a report whenever the pruning of database is run.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row"> | ||||
|                 <label for="upgrade-report"><?php _e( 'Upgrade:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="upgrade-report" type="checkbox" value="1" name="wps_upgrade_report" <?php echo $WP_Statistics->get_option( 'upgrade_report' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="upgrade-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Send a report whenever the plugin is upgraded.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Statistical reporting', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="stats-report"><?php _e( 'Statistical reporting:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="stats-report" type="checkbox" value="1" name="wps_stats_report" <?php echo $WP_Statistics->get_option( 'stats_report' ) == true | ||||
| 					? "checked='checked'" : ''; ?> onClick='ToggleStatOptions();'> | ||||
|                 <label for="stats-report"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Enable or disable this feature', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php if ( $WP_Statistics->get_option( 'stats_report' ) ) { | ||||
| 			$hidden = ""; | ||||
| 		} else { | ||||
| 			$hidden = " style='display: none;'"; | ||||
| 		} ?> | ||||
|         <tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'> | ||||
|             <td scope="row" style="vertical-align: top;"> | ||||
|                 <label for="time-report"><?php _e( 'Schedule:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <select name="wps_time_report" id="time-report"> | ||||
|                     <option value="0" <?php selected( $WP_Statistics->get_option( 'time_report' ), '0' ); ?>><?php _e( | ||||
| 							'Please select', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
| 					<?php | ||||
| 					function wp_statistics_schedule_sort( $a, $b ) { | ||||
| 						if ( $a['interval'] == $b['interval'] ) { | ||||
| 							return 0; | ||||
| 						} | ||||
|  | ||||
| 						return ( $a['interval'] < $b['interval'] ) ? - 1 : 1; | ||||
| 					} | ||||
|  | ||||
| 					//Get List Of Schedules Wordpress | ||||
| 					$schedules = wp_get_schedules(); | ||||
| 					uasort( $schedules, 'wp_statistics_schedule_sort' ); | ||||
| 					$schedules_item = array(); | ||||
|  | ||||
| 					foreach ( $schedules as $key => $value ) { | ||||
| 						if ( ! in_array( $value, $schedules_item ) ) { | ||||
| 							echo '<option value="' . $key . '" ' . selected( $WP_Statistics->get_option( 'time_report' ), $key ) . '>' . $value['display'] . '</option>'; | ||||
| 							$schedules_item[] = $value; | ||||
| 						} | ||||
| 					} | ||||
| 					?> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Select how often to receive statistical report.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'> | ||||
|             <td scope="row" style="vertical-align: top;"> | ||||
|                 <label for="send-report"><?php _e( 'Send reports via:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <select name="wps_send_report" id="send-report"> | ||||
|                     <option value="0" <?php selected( $WP_Statistics->get_option( 'send_report' ), '0' ); ?>><?php _e( | ||||
| 							'Please select', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
|                     <option value="mail" <?php selected( $WP_Statistics->get_option( 'send_report' ), 'mail' ); ?>><?php _e( | ||||
| 							'Email', | ||||
| 							'wp-statistics' | ||||
| 						); ?></option> | ||||
| 					<?php if ( is_plugin_active( 'wp-sms/wp-sms.php' ) || is_plugin_active( 'wp-sms-pro/wp-sms.php' ) ) { ?> | ||||
|                         <option value="sms" <?php selected( | ||||
| 							$WP_Statistics->get_option( 'send_report' ), | ||||
| 							'sms' | ||||
| 						); ?>><?php _e( 'SMS', 'wp-statistics' ); ?></option> | ||||
| 					<?php } ?> | ||||
|                 </select> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Select delivery method for statistical report.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|  | ||||
| 				<?php if ( ! is_plugin_active( 'wp-sms/wp-sms.php' ) ) { ?> | ||||
|                     <p class="description note"><?php echo sprintf( | ||||
| 							__( 'Note: To send SMS text messages please install the %s plugin.', 'wp-statistics' ), | ||||
| 							'<a href="http://wordpress.org/extend/plugins/wp-sms/" target="_blank">' . | ||||
| 							__( 'WordPress SMS', 'wp-statistics' ) . | ||||
| 							'</a>' | ||||
| 						); ?></p> | ||||
| 				<?php } ?> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"<?php echo $hidden; ?> id='wps_stats_report_option'> | ||||
|             <td scope="row" style="vertical-align: top;"> | ||||
|                 <label for="content-report"><?php _e( 'Message body:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
| 				<?php wp_editor( | ||||
| 					$WP_Statistics->get_option( 'content_report' ), | ||||
| 					'content-report', | ||||
| 					array( | ||||
| 						'media_buttons' => false, | ||||
| 						'textarea_name' => 'wps_content_report', | ||||
| 						'textarea_rows' => 5, | ||||
| 					) | ||||
| 				); ?> | ||||
|                 <p class="description"><?php _e( 'Enter the contents of the report.', 'wp-statistics' ); ?></p> | ||||
|  | ||||
|                 <p class="description data"> | ||||
| 					<?php _e( | ||||
| 						'Any shortcode supported by your installation of WordPress, include all shortcodes for WP Statistics (see the documentation for a list of codes available) are supported in the body of the message. Here are some examples:', | ||||
| 						'wp-statistics' | ||||
| 					); ?> | ||||
|                     <br><br>     <?php _e( 'Online User', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=usersonline]</code><br> | ||||
|                         <?php _e( 'Today\'s Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visitors time=today]</code><br> | ||||
|                         <?php _e( 'Today\'s Visits', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visits time=today]</code><br> | ||||
|                         <?php _e( 'Yesterday\'s Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visitors time=yesterday]</code><br> | ||||
|                         <?php _e( 'Yesterday\'s Visits', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visits time=yesterday]</code><br> | ||||
|                         <?php _e( 'Total Visitors', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visitors time=total]</code><br> | ||||
|                         <?php _e( 'Total Visits', 'wp-statistics' ); ?>: <code>[wpstatistics | ||||
|                         stat=visits time=total]</code><br> | ||||
|                 </p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Admin Notices', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row"> | ||||
|                 <label for="admin-notices"><?php _e( 'All Notices:', 'wp-statistics' ); ?></label> | ||||
|             </td> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="admin-notices" type="checkbox" value="1" name="wps_admin_notices" <?php echo $WP_Statistics->get_option( 'admin_notices' ) == true ? "checked='checked'" : ''; ?>> | ||||
|                 <label for="admin-notices"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Show all notices and suggestion from WP-Statistics in the admin.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); ?> | ||||
| @@ -0,0 +1,106 @@ | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
| 	$wps_option_list = array( 'wps_disable_map', 'wps_disable_dashboard', 'wps_disable_editor' ); | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		$new_option = str_replace( 'wps_', '', $option ); | ||||
|  | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
|  | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Only display the global options if the user is an administrator. | ||||
| if ( $wps_admin ) { | ||||
| 	?> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Dashboard', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row" colspan="2"><?php _e( | ||||
| 					'The following items are global to all users.', | ||||
| 					'wp-statistics' | ||||
| 				); ?></td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="disable-map"><?php _e( 'Disable dashboard widgets:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="disable-dashboard" type="checkbox" value="1" | ||||
|                        name="wps_disable_dashboard" <?php echo $WP_Statistics->get_option( 'disable_dashboard' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="disable-dashboard"><?php _e( 'Disable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Disable the dashboard widgets.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Page/Post Editor', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row" colspan="2"><?php _e( | ||||
| 					'The following items are global to all users.', | ||||
| 					'wp-statistics' | ||||
| 				); ?></td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="disable-map"><?php _e( 'Disable post/page editor widget:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="disable-editor" type="checkbox" value="1" | ||||
|                        name="wps_disable_editor" <?php echo $WP_Statistics->get_option( 'disable_editor' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="disable-editor"><?php _e( 'Disable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Disable the page/post editor widget.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Map', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row" colspan="2"><?php _e( | ||||
| 					'The following items are global to all users.', | ||||
| 					'wp-statistics' | ||||
| 				); ?></td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="disable-map"><?php _e( 'Disable map:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="disable-map" type="checkbox" value="1" | ||||
|                        name="wps_disable_map" <?php echo $WP_Statistics->get_option( 'disable_map' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="disable-map"><?php _e( 'Disable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Disable the map display', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
| 	<?php | ||||
| } | ||||
|  | ||||
| submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,89 @@ | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
| 	$wps_option_list = array( | ||||
| 		'wps_anonymize_ips', | ||||
| 		'wps_hash_ips', | ||||
| 		'wps_store_ua', | ||||
| 		'wps_all_online', | ||||
| 	); | ||||
|  | ||||
| 	// If the IP hash's are enabled, disable storing the complete user agent. | ||||
| 	if ( array_key_exists( 'wps_hash_ips', $_POST ) ) { | ||||
| 		$_POST['wps_store_ua'] = ''; | ||||
| 	} | ||||
|  | ||||
| 	foreach ( $wps_option_list as $option ) { | ||||
| 		if ( array_key_exists( $option, $_POST ) ) { | ||||
| 			$value = $_POST[ $option ]; | ||||
| 		} else { | ||||
| 			$value = ''; | ||||
| 		} | ||||
| 		$new_option = str_replace( "wps_", "", $option ); | ||||
| 		$WP_Statistics->store_option( $new_option, $value ); | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'Privacy and Data Protection', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <td scope="row" colspan="2"><?php echo sprintf( __( 'If you want to delete visitor data, please <a href="%s">click here</a>.', 'wp-statistics' ), WP_Statistics_Admin_Pages::admin_url( 'optimization', array( 'tab' => 'purging' ) ) ); ?></td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="anonymize_ips"><?php _e( 'Anonymize IP Addresses:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="anonymize_ips" type="checkbox" value="1" name="wps_anonymize_ips" <?php echo $WP_Statistics->get_option( 'anonymize_ips' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="anonymize_ips"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( 'This option anonymizes the user IP address for GDPR compliance. For example, 888.888.888.888 > 888.888.888.000.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="hash_ips"><?php _e( 'Hash IP Addresses:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="hash_ips" type="checkbox" value="1" name="wps_hash_ips" <?php echo $WP_Statistics->get_option( 'hash_ips' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="hash_ips"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php echo __( | ||||
| 					                                  'This feature will not store IP addresses in the database but instead used a unique hash.', | ||||
| 					                                  'wp-statistics' | ||||
| 				                                  ) . ' ' . __( | ||||
| 					                                  'The "Store entire user agent string" setting will be disabled if this is selected.', | ||||
| 					                                  'wp-statistics' | ||||
| 				                                  ) . ' ' . __( | ||||
| 					                                  'You will not be able to recover the IP addresses in the future to recover location information if this is enabled.', | ||||
| 					                                  'wp-statistics' | ||||
| 				                                  ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="store_ua"><?php _e( 'Store entire user agent string:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="store_ua" type="checkbox" value="1" name="wps_store_ua" <?php echo $WP_Statistics->get_option( 'store_ua' ) == true | ||||
| 					? "checked='checked'" : ''; ?>> | ||||
|                 <label for="store_ua"><?php _e( 'Enable', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( 'Only enabled for debugging. (If the IP hash\'s are enabled, This option disabling automatically.)', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,129 @@ | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
|  | ||||
| 	if ( array_key_exists( 'wps_remove_plugin', $_POST ) ) { | ||||
| 		if ( is_super_admin() ) { | ||||
| 			update_option( 'wp_statistics_removal', 'true' ); | ||||
|  | ||||
| 			// We need to reload the page after we reset the options but it's too late to do it through a HTTP redirect so do a  | ||||
| 			// JavaScript redirect instead. | ||||
| 			echo '<script type="text/javascript">window.location.href="' . admin_url() . 'plugins.php";</script>'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if ( array_key_exists( 'wps_reset_plugin', $_POST ) ) { | ||||
| 		if ( is_super_admin() ) { | ||||
| 			GLOBAL $wpdb, $WP_Statistics; | ||||
|  | ||||
| 			$default_options   = $WP_Statistics->Default_Options(); | ||||
| 			$excluded_defaults = array( 'force_robot_update', 'robot_list' ); | ||||
|  | ||||
| 			// Handle multi site implementations | ||||
| 			if ( is_multisite() ) { | ||||
| 				// Loop through each of the sites. | ||||
| 				$sites = $WP_Statistics->get_wp_sites_list(); | ||||
| 				foreach ( $sites as $blog_id ) { | ||||
|  | ||||
| 					switch_to_blog( $blog_id ); | ||||
|  | ||||
| 					// Delete the wp_statistics option. | ||||
| 					update_option( 'wp_statistics', array() ); | ||||
| 					// Delete the user options. | ||||
| 					$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" ); | ||||
|  | ||||
| 					$WP_Statistics->load_options(); | ||||
|  | ||||
| 					// Set some intelligent defaults. | ||||
| 					foreach ( $default_options as $key => $value ) { | ||||
| 						if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) { | ||||
| 							$WP_Statistics->store_option( $key, $value ); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					$WP_Statistics->save_options(); | ||||
| 				} | ||||
|  | ||||
| 				restore_current_blog(); | ||||
| 			} else { | ||||
| 				// Delete the wp_statistics option. | ||||
| 				update_option( 'wp_statistics', array() ); | ||||
| 				// Delete the user options. | ||||
| 				$wpdb->query( "DELETE FROM {$wpdb->prefix}usermeta WHERE meta_key LIKE 'wp_statistics%'" ); | ||||
|  | ||||
| 				$WP_Statistics->load_options(); | ||||
|  | ||||
| 				// Set some intelligent defaults. | ||||
| 				foreach ( $default_options as $key => $value ) { | ||||
| 					if ( ! in_array( $key, $excluded_defaults ) && false === $WP_Statistics->get_option( $key ) ) { | ||||
| 						$WP_Statistics->store_option( $key, $value ); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				$WP_Statistics->save_options(); | ||||
| 			} | ||||
|  | ||||
| 			// We need to reload the page after we reset the options but it's too late to do it through a HTTP redirect so do a  | ||||
| 			// JavaScript redirect instead. | ||||
| 			echo '<script type="text/javascript">window.location.href="' . WP_Statistics_Admin_Pages::admin_url( 'settings' ) . '";</script>'; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"><h3><?php _e( 'WP Statisitcs Removal', 'wp-statistics' ); ?></h3></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
| 				<?php _e( | ||||
| 					'Uninstalling WP Statistics will not remove the data and settings, you can use this option to remove the WP Statistics data from your install before uninstalling the plugin.', | ||||
| 					'wp-statistics' | ||||
| 				); ?> | ||||
|                 <br> | ||||
|                 <br> | ||||
| 				<?php _e( | ||||
| 					'Once you submit this form the settings will be deleted during the page load, however WP Statistics will still show up in your Admin menu until another page load is executed.', | ||||
| 					'wp-statistics' | ||||
| 				); ?> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="reset-plugin"><?php _e( 'Reset options:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="reset-plugin" type="checkbox" name="wps_reset_plugin"> | ||||
|                 <label for="reset-plugin"><?php _e( 'Reset', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Reset the plugin options to the defaults. This will remove all user and global settings but will keep all other data. This action cannot be undone. Note: For multisite installs this will reset all sites to the defaults.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row"> | ||||
|                 <label for="remove-plugin"><?php _e( 'Remove data and settings:', 'wp-statistics' ); ?></label> | ||||
|             </th> | ||||
|  | ||||
|             <td> | ||||
|                 <input id="remove-plugin" type="checkbox" name="wps_remove_plugin"> | ||||
|                 <label for="remove-plugin"><?php _e( 'Remove', 'wp-statistics' ); ?></label> | ||||
|  | ||||
|                 <p class="description"><?php _e( | ||||
| 						'Remove data and settings, this action cannot be undone.', | ||||
| 						'wp-statistics' | ||||
| 					); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); ?> | ||||
| @@ -0,0 +1,168 @@ | ||||
| <?php | ||||
|  | ||||
| // Save Option | ||||
| if ( $wps_nonce_valid and $wps_admin ) { | ||||
|  | ||||
| 	$value = 'REMOTE_ADDR'; | ||||
| 	if ( isset( $_POST['ip_method'] ) and ! empty( $_POST['ip_method'] ) ) { | ||||
|  | ||||
| 		// Check Custom Header | ||||
| 		if ( $_POST['ip_method'] == "CUSTOM_HEADER" ) { | ||||
| 			if ( trim( $_POST['user_custom_header_ip_method'] ) != "" ) { | ||||
| 				$value = $_POST['user_custom_header_ip_method']; | ||||
| 			} | ||||
| 		} else { | ||||
| 			$value = $_POST['ip_method']; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$WP_Statistics->update_option( 'ip_method', $value ); | ||||
| } | ||||
|  | ||||
| // Get IP Method | ||||
| $ip_method = WP_Statistics::getIPMethod(); | ||||
|  | ||||
| // Add TickBox | ||||
| add_thickbox(); | ||||
|  | ||||
| ?> | ||||
|     <!-- Show Help $_SERVER --> | ||||
|     <style> | ||||
|         #TB_window { | ||||
|             direction: ltr; | ||||
|         } | ||||
|     </style> | ||||
|     <div id="list-of-php-server" style="display:none;"> | ||||
|         <table style="direction: ltr;"> | ||||
|             <tr> | ||||
|                 <td width="330" style="color: #3238fb; border-bottom: 1px solid #bcbeff;padding-top:10px;padding-bottom:10px;"> | ||||
|                     <b><?php _e( '$_SERVER', 'wp-statistics' ); ?></b></td> | ||||
|                 <td style="color: #3238fb; border-bottom: 1px solid #bcbeff;padding-top:10px;padding-bottom:10px;"> <?php _e( 'Value', 'wp-statistics' ); ?></td> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 			foreach ( $_SERVER as $key => $value ) { | ||||
| 				?> | ||||
|                 <tr> | ||||
|                     <td width="330" style="padding-top:10px;padding-bottom:10px;"> | ||||
|                         <b><?php echo $key; ?></b></td> | ||||
|                     <td style="padding-top:10px;padding-bottom:10px;"> <?php echo ( $value == "" ? "-" : substr( str_replace( array( "\n", "\r" ), '', trim( $value ) ), 0, 200 ) ) . ( strlen( $value ) > 200 ? '..' : '' ); ?></td> | ||||
|                 </tr> | ||||
| 				<?php | ||||
| 			} | ||||
| 			?> | ||||
|         </table> | ||||
|     </div> | ||||
|     <table class="form-table"> | ||||
|         <tbody> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2" style="padding-bottom: 10px; font-weight: normal;line-height: 25px;"> | ||||
| 				<?php _e( 'Your real IP detected with ipify.org service:', 'wp-statistics' ); ?> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2"> | ||||
|                 <code id="user_real_ip" style="padding: 15px;font-size: 30px;font-weight: 200; letter-spacing: 2px;font-family: 'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;"> | ||||
|                     <script type="application/javascript"> | ||||
|                         jQuery(document).ready(function () { | ||||
|                             jQuery.ajax({ | ||||
|                                 url: "https://api.ipify.org?format=json", | ||||
|                                 dataType: 'json', | ||||
|                                 error: function (jqXHR) { | ||||
|                                     if (jqXHR.status == 0) { | ||||
|                                         jQuery("code#user_real_ip").html("<?php _e( 'Please check your internet connection and try again.', 'wp-statistics' ); ?>"); | ||||
|                                     } | ||||
|                                 }, | ||||
|                                 success: function (json) { | ||||
|                                     jQuery("code#user_real_ip").html(json['ip']); | ||||
|                                 } | ||||
|                             }); | ||||
|                         }); | ||||
|                     </script> | ||||
|                 </code></th> | ||||
|         </tr> | ||||
|  | ||||
|         <tr> | ||||
|             <td colspan="3"> | ||||
|                 <p><?php _e( 'The items below return the IP address that is different on each server. Is the best way that you choose.', 'wp-statistics' ); ?></p> | ||||
|             </td> | ||||
|         </tr> | ||||
|  | ||||
| 		<?php | ||||
| 		foreach ( WP_Statistics::list_of_server_ip_variable() as $method ) { | ||||
| 			?> | ||||
|             <tr valign="top"> | ||||
|                 <th scope="row" colspan="2" style="padding-top: 8px;padding-bottom: 8px;"> | ||||
|                     <table> | ||||
|                         <tr> | ||||
|                             <td style="width: 10px; padding: 0px;"> | ||||
|                                 <input type="radio" name="ip_method" style="vertical-align: -3px;" value="<?php echo $method; ?>"<?php if ( $ip_method == $method ) { | ||||
| 									echo " checked=\"checked\""; | ||||
| 								} ?>> | ||||
|                             </td> | ||||
|                             <td style="width: 250px;"> <?php printf( __( 'Use %1$s', 'wp-statistics' ), $method ); ?></td> | ||||
|                             <td><code><?php | ||||
| 									if ( isset( $_SERVER[ $method ] ) and ! empty( $_SERVER[ $method ] ) ) { | ||||
| 										echo $_SERVER[ $method ]; | ||||
| 									} else { | ||||
| 										_e( 'No available data.', 'wp-statistics' ); | ||||
| 									} ?> | ||||
|                                 </code> | ||||
| 								<?php | ||||
| 								if ( isset( $_SERVER[ $method ] ) and ! empty( $_SERVER[ $method ] ) and $WP_Statistics->check_sanitize_ip( $_SERVER[ $method ] ) === false ) { | ||||
| 									echo '   <a href="https://wp-statistics.com/sanitize-user-ip/" style="color: #d04f4f;" target="_blank" title="' . __( 'Your value required to sanitize user IP', 'wp-statistics' ) . '"><span class="dashicons dashicons-warning"></span></a>'; | ||||
| 								} | ||||
| 								?> | ||||
|                             </td> | ||||
|                         </tr> | ||||
|                     </table> | ||||
|                 </th> | ||||
|             </tr> | ||||
| 			<?php | ||||
| 		} | ||||
| 		?> | ||||
|  | ||||
|         <!-- Custom Header --> | ||||
|         <tr valign="top"> | ||||
|             <th scope="row" colspan="2" style="padding-top: 0px;padding-bottom: 0px;"> | ||||
|                 <table> | ||||
|                     <tr> | ||||
|                         <td style="width: 10px; padding: 0px;"> | ||||
|                             <input type="radio" name="ip_method" style="vertical-align: -3px;" value="CUSTOM_HEADER" <?php if ( ! in_array( $ip_method, WP_Statistics::list_of_server_ip_variable() ) ) { | ||||
| 								echo " checked=\"checked\""; | ||||
| 							} ?>> | ||||
|                         </td> | ||||
|                         <td style="width: 250px;"> <?php echo __( 'Use Custom Header', 'wp-statistics' ); ?></td> | ||||
|                         <td style="padding-left: 0px;"> | ||||
|                             <input type="text" name="user_custom_header_ip_method" autocomplete="off" style="padding: 5px; width: 250px;height: 35px;" value="<?php if ( ! in_array( $ip_method, WP_Statistics::list_of_server_ip_variable() ) ) { | ||||
| 								echo $ip_method; | ||||
| 							} ?>"> | ||||
|  | ||||
|                             <p class="description"> | ||||
| 								<?php if ( ! in_array( $ip_method, WP_Statistics::list_of_server_ip_variable() ) ) { | ||||
| 									echo '<code>'; | ||||
| 									if ( isset( $_SERVER[ $ip_method ] ) and ! empty( $_SERVER[ $ip_method ] ) ) { | ||||
| 										echo $_SERVER[ $ip_method ]; | ||||
| 									} else { | ||||
| 										_e( 'No available data.', 'wp-statistics' ); | ||||
| 									} | ||||
| 								} | ||||
| 								echo '</code>'; | ||||
| 								if ( ! in_array( $ip_method, WP_Statistics::list_of_server_ip_variable() ) and isset( $_SERVER[ $ip_method ] ) and ! empty( $_SERVER[ $ip_method ] ) and $WP_Statistics->check_sanitize_ip( $_SERVER[ $ip_method ] ) === false ) { | ||||
| 									echo '   <a href="https://wp-statistics.com/sanitize-user-ip/" style="color: #d04f4f;" target="_blank" title="' . __( 'Your value required to sanitize user IP', 'wp-statistics' ) . '"><span class="dashicons dashicons-warning"></span></a>'; | ||||
| 								} | ||||
| 								?></p> | ||||
|                             <p class="description"><?php _e( 'If your server use the custom key in <code>$_SERVER</code> for getting IP. e.g. <code>HTTP_CF_CONNECTING_IP</code> in CloudFlare.', 'wp-statistics' ); ?></p> | ||||
|                             <p class="description"> | ||||
|                                 <a href="#TB_inline?&width=850&height=600&inlineId=list-of-php-server" class="thickbox"><?php _e( 'Show all <code>$_SERVER</code> in your server.', 'wp-statistics' ); ?></a> | ||||
|                             </p> | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                 </table> | ||||
|             </th> | ||||
|         </tr> | ||||
|  | ||||
|         </tbody> | ||||
|     </table> | ||||
|  | ||||
| <?php submit_button( __( 'Update', 'wp-statistics' ), 'primary', 'submit' ); | ||||
| @@ -0,0 +1,96 @@ | ||||
| <?php | ||||
|  | ||||
| //Check Form Security nonce | ||||
| $wps_nonce_valid = false; | ||||
| if ( array_key_exists( 'wp-statistics-nonce', $_POST ) ) { | ||||
| 	if ( wp_verify_nonce( $_POST['wp-statistics-nonce'], 'update-options' ) ) { | ||||
| 		$wps_nonce_valid = true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //Check User Access To Save Setting | ||||
| $wps_admin = false; | ||||
| if ( current_user_can( wp_statistics_validate_capability( $WP_Statistics->get_option( 'manage_capability', 'manage_options' ) ) ) ) { | ||||
| 	$wps_admin = true; | ||||
| } | ||||
|  | ||||
| if ( $wps_admin === false ) { | ||||
| 	$wps_admin = 0; | ||||
| } | ||||
|  | ||||
| ?> | ||||
|     <div class="wrap wps-wrap wp-statistics-settings"> | ||||
| 		<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Settings', 'wp-statistics' ) ); ?> | ||||
|  | ||||
|         <div id="poststuff"> | ||||
|             <div id="post-body" class="metabox-holder columns-2"> | ||||
|                 <div class="wp-list-table widefat widefat"> | ||||
|                     <form id="wp-statistics-settings-form" method="post"> | ||||
| 						<?php wp_nonce_field( 'update-options', 'wp-statistics-nonce' ); ?> | ||||
|                         <div class="wp-statistics-container"> | ||||
|                             <ul class="tabs"> | ||||
| 								<?php if ( $wps_admin ) { ?> | ||||
|                                     <li class="tab-link current" data-tab="general-settings"><?php _e( 'General', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="visitor-ip-settings"><?php _e( 'Visitor IP', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="privacy-settings"><?php _e( 'Privacy', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="notifications-settings"><?php _e( 'Notifications', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="overview-display-settings"><?php _e( 'Dashboard', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="access-settings"><?php _e( 'Access Levels', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="exclusions-settings"><?php _e( 'Exclusions', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="externals-settings"><?php _e( 'Externals', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="maintenance-settings"><?php _e( 'Maintenance', 'wp-statistics' ); ?></li> | ||||
|                                     <li class="tab-link" data-tab="removal-settings"><?php _e( 'Removal', 'wp-statistics' ); ?></li> | ||||
| 								<?php } ?> | ||||
|                                 <li class="tab-link" data-tab="about"><?php _e( 'About', 'wp-statistics' ); ?></li> | ||||
|                             </ul> | ||||
|  | ||||
| 							<?php if ( $wps_admin ) { ?> | ||||
|                                 <div id="general-settings" class="tab-content current"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-general.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="visitor-ip-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-visitor-ip.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="privacy-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-privacy.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="notifications-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-notifications.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="overview-display-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-overview-display.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="access-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-access-level.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="exclusions-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-exclusions.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="externals-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-externals.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="maintenance-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-maintenance.php' ); ?> | ||||
|                                 </div> | ||||
|                                 <div id="removal-settings" class="tab-content"> | ||||
| 									<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-removal.php' ); ?> | ||||
|                                 </div> | ||||
| 							<?php } ?> | ||||
|                             <div id="about" class="tab-content"> | ||||
| 								<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/settings/tabs/wps-about.php' ); ?> | ||||
|                             </div> | ||||
|                         </div><!-- container --> | ||||
|                     </form> | ||||
|                 </div> | ||||
| 				<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| <?php | ||||
| if ( $wps_nonce_valid ) { | ||||
| 	if ( $wps_admin ) { | ||||
| 		$WP_Statistics->save_options(); | ||||
| 	} | ||||
| 	$WP_Statistics->save_user_options(); | ||||
| } | ||||
| @@ -0,0 +1,65 @@ | ||||
| <div id="poststuff" class="wp-statistics-plugins"> | ||||
|     <div id="post-body" class="metabox-holder"> | ||||
|         <div class="wp-list-table widefat widefat plugin-install"> | ||||
|             <div id="the-list"> | ||||
|                 <?php foreach ( $plugins->items as $plugin ) : ?> | ||||
|                     <div class="plugin-card"> | ||||
|                         <?php if ( $plugin->is_feature and $plugin->featured_label ) : ?> | ||||
|                             <div class="cover-ribbon"> | ||||
|                                 <div class="cover-ribbon-inside"><?php echo $plugin->featured_label; ?></div> | ||||
|                             </div> | ||||
|                         <?php endif; ?> | ||||
|  | ||||
|                         <div class="plugin-card-top"> | ||||
|                             <div class="name column-name"> | ||||
|                                 <h3> | ||||
|                                     <a target="_blank" href="<?php echo $plugin->url; ?>" class="thickbox open-plugin-details-modal"> | ||||
|                                         <?php echo $plugin->name; ?> | ||||
|                                         <img src="<?php echo $plugin->icon; ?>" class="plugin-icon" alt=""> | ||||
|                                     </a> | ||||
|                                 </h3> | ||||
|                             </div> | ||||
|  | ||||
|                             <div class="desc column-description"> | ||||
|                                 <p><?php echo wp_trim_words( $plugin->description, 15 ); ?></p> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="plugin-card-bottom"> | ||||
|                             <div class="column-downloaded"> | ||||
|                                 <strong><?php _e( 'Version:', 'wp-statistics' ); ?></strong><?php echo ' ' . | ||||
|                                     $plugin->version; ?> | ||||
|                                 <p><strong><?php _e( 'Status:', 'wp-statistics' ); ?></strong> | ||||
|                                     <?php | ||||
|                                     if ( is_plugin_active( $plugin->slug . '/' . $plugin->slug . '.php' ) ) { | ||||
|                                         _e( 'Active', 'wp-statistics' ); | ||||
|                                     } else if ( file_exists( | ||||
|                                         WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php' | ||||
|                                     ) ) { | ||||
|                                         _e( 'Inactive', 'wp-statistics' ); | ||||
|                                     } else { | ||||
|                                         _e( 'Not installed', 'wp-statistics' ); | ||||
|                                     } | ||||
|                                     ?> | ||||
|                                 </p> | ||||
|                             </div> | ||||
|                             <div class="column-compatibility"> | ||||
|                                 <?php if ( is_plugin_active( $plugin->slug . '/' . $plugin->slug . '.php' ) ) { ?> | ||||
|                                     <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'plugins', array( 'action' => 'deactivate', 'plugin' => $plugin->slug ) ); ?>" class="button"><?php _e( 'Deactivate Add-On', 'wp-statistics' ); ?></a> | ||||
|                                 <?php } else { ?><?php if ( file_exists( | ||||
|                                     WP_PLUGIN_DIR . '/' . $plugin->slug . '/' . $plugin->slug . '.php' | ||||
|                                 ) ) { ?> | ||||
|                                     <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'plugins', array( 'action' => 'activate', 'plugin' => $plugin->slug ) ); ?>" class="button"><?php _e( 'Activate Add-On', 'wp-statistics' ); ?></a> | ||||
|                                 <?php } else { ?> | ||||
|                                     <div class="column-price"> | ||||
|                                         <strong>$<?php echo $plugin->price; ?></strong> | ||||
|                                     </div> | ||||
|                                     <a target="_blank" href="<?php echo $plugin->url; ?>" class="button-primary"><?php _e( 'Buy Add-On', 'wp-statistics' ); ?></a> | ||||
|                                 <?php } ?><?php } ?> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 <?php endforeach; ?> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
| @@ -0,0 +1,2 @@ | ||||
| <?php | ||||
| # Silence is golden. | ||||
| @@ -0,0 +1,6 @@ | ||||
| <div class="wrap wps-wrap"> | ||||
| 	<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Extensions for WP-Statistics', 'wp-statistics' ) ); ?> | ||||
|  | ||||
|     <p><p><?php _e( 'These extensions add functionality to your WP-Statistics.', 'wp-statistics' ); ?></p><br/></p> | ||||
|     <?php include( WP_Statistics::$reg['plugin-dir'] . "includes/templates/add-ons.php" ); ?> | ||||
| </div> | ||||
| @@ -0,0 +1,41 @@ | ||||
| <div id="postbox-container-1" class="postbox-container"> | ||||
|     <div class="meta-box-sortables"> | ||||
|         <div id="wps-plugins-support" class="postbox"> | ||||
|             <h2 class="hndle"><span><?php _e( 'Subscribe to Newsletter', 'wp-statistics' ); ?></span></h2> | ||||
|  | ||||
|             <div class="inside"> | ||||
|                 <form | ||||
|                         action="//veronalabs.us7.list-manage.com/subscribe/post?u=628dc1468c7c7db0ba42f0137&id=ea320ea877" | ||||
|                         method="post" name="mc-embedded-subscribe-form" target="_blank" novalidate> | ||||
|                     <p><?php _e( | ||||
| 							'Subscribe to our mailing list for get any news of the WP-Statistics', | ||||
| 							'wp-statistics' | ||||
| 						); ?></p> | ||||
|                     <input name="EMAIL" type="email" class="ltr" value="<?php bloginfo( 'admin_email' ); ?>"> | ||||
|                     <input type="hidden" name="b_628dc1468c7c7db0ba42f0137_ea320ea877" tabindex="-1" value=""> | ||||
|                     <input type="submit" value="<?php _e( 'Subscribe', 'wp-statistics' ); ?>" name="subscribe" | ||||
|                            class="button"> | ||||
|                 </form> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
| 	<?php | ||||
| 	$response      = wp_remote_get( 'https://wp-statistics.com/wp-json/plugin/postbox' ); | ||||
| 	$response_code = wp_remote_retrieve_response_code( $response ); | ||||
|  | ||||
| 	if ( ! is_wp_error( $response ) and $response_code == '200' ) : | ||||
| 		$result = json_decode( $response['body'] ); | ||||
| 		foreach ( $result->items as $item ) : ?> | ||||
|             <div class="meta-box-sortables"> | ||||
|                 <div id="wps-plugins-support" class="postbox"> | ||||
|                     <h2 class="hndle"><span><?php echo $item->title; ?></span></h2> | ||||
|  | ||||
|                     <div class="inside"><?php echo $item->content; ?></div> | ||||
|                 </div> | ||||
|             </div> | ||||
| 		<?php | ||||
| 		endforeach; | ||||
| 	endif; | ||||
| 	?> | ||||
| </div> | ||||
							
								
								
									
										187
									
								
								wp-content/plugins/wp-statistics/includes/templates/welcome.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								wp-content/plugins/wp-statistics/includes/templates/welcome.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,187 @@ | ||||
| <div class="wrap wps-wrap about-wrap full-width-layout"> | ||||
|     <div class="wp-statistics-welcome"> | ||||
|         <h1><?php printf( __( 'Welcome to WP-Statistics %s', 'wp-statistics' ), WP_Statistics::$reg['version'] ); ?></h1> | ||||
|  | ||||
|         <p class="about-text"> | ||||
| 			<?php printf( __( 'Thank you for updating to the latest version! We encourage you to submit a %srating and review%s over at WordPress.org. Your feedback is greatly appreciated!', 'wp-statistics' ), '<a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank">', '</a>' ); ?> | ||||
| 			<?php _e( 'Submit your rating:', 'wp-statistics' ); ?> | ||||
|             <a href="https://wordpress.org/support/plugin/wp-statistics/reviews/?rate=5#new-post" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/stars.png' ); ?>"/></a> | ||||
|         </p> | ||||
|  | ||||
|         <div class="wp-badge"><?php printf( __( 'Version %s', 'wp-statistics' ), WP_Statistics::$reg['version'] ); ?></div> | ||||
|  | ||||
|         <h2 class="nav-tab-wrapper wp-clearfix"> | ||||
|             <a href="<?php echo add_query_arg( array( 'page' => 'wps_welcome', 'tab' => 'whats-news' ), admin_url( 'admin.php' ) ); ?>" class="nav-tab <?php echo( ( ! isset( $_GET['tab'] ) || ( isset( $_GET['tab'] ) and $_GET['tab'] == "whats-news" ) ) ? "nav-tab-active" : "" ); ?>" data-tab="whats-news"><?php _e( 'New Product', 'wp-statistics' ); ?></a> | ||||
|             <a href="<?php echo add_query_arg( array( 'page' => 'wps_welcome', 'tab' => 'addons' ), admin_url( 'admin.php' ) ); ?>" class="nav-tab <?php echo( ( isset( $_GET['tab'] ) and $_GET['tab'] == "addons" ) ? "nav-tab-active" : "" ); ?>" data-tab="addons"><?php _e( 'Add-Ons', 'wp-statistics' ); ?></a> | ||||
|             <a href="<?php echo add_query_arg( array( 'page' => 'wps_welcome', 'tab' => 'credit' ), admin_url( 'admin.php' ) ); ?>" class="nav-tab <?php echo( ( isset( $_GET['tab'] ) and $_GET['tab'] == "credit" ) ? "nav-tab-active" : "" ); ?>" data-tab="credit"><?php _e( 'Credits', 'wp-statistics' ); ?></a> | ||||
|             <a href="<?php echo add_query_arg( array( 'page' => 'wps_welcome', 'tab' => 'changelog' ), admin_url( 'admin.php' ) ); ?>" class="nav-tab <?php echo( ( isset( $_GET['tab'] ) and $_GET['tab'] == "changelog" ) ? "nav-tab-active" : "" ); ?>" data-tab="changelog"><?php _e( 'Changelog', 'wp-statistics' ); ?></a> | ||||
|             <a href="https://wp-statistics.com/donate/" class="nav-tab donate" data-tab="link" target="_blank"><?php _e( 'Donate', 'wp-statistics' ); ?></a> | ||||
|         </h2> | ||||
|  | ||||
| 		<?php if ( ! isset( $_GET['tab'] ) || ( isset( $_GET['tab'] ) and $_GET['tab'] == "whats-news" ) ) { ?> | ||||
|             <div data-content="whats-news" class="tab-content current"> | ||||
|                 <section class="center-section"> | ||||
|                     <div class="left"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h2><?php _e( 'WP-Telegram Notifications', 'wp-statistics' ); ?></h2> | ||||
|                             <h4><?php echo sprintf( __( 'A new plugin from <a href="%s" target="_blank">VeronaLabs</a>.', 'wp-statistics' ), 'https://veronalabs.com' ); ?></h4> | ||||
|  | ||||
|                             <a href="https://wp-telegram.com/purchase/" target="_blank"> | ||||
|                                 <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/coupon-code.png' ); ?>"/> | ||||
|                             </a> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="normal-section"> | ||||
|                     <div class="left"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h2><?php _e( 'Connect with customers', 'wp-statistics' ); ?></h2> | ||||
|                             <p><?php _e( 'Your customers can easily send their message using the box placed on your website.', 'wp-statistics' ); ?></p> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <style> | ||||
|                         div#wp-telegram-chatbox img { | ||||
|                             width: 270px; | ||||
|                             display: inline-block; | ||||
|                         } | ||||
|                     </style> | ||||
|  | ||||
|                     <div class="right text-center" id="wp-telegram-chatbox"> | ||||
|                         <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/wp-telegram-chatbox.gif' ); ?>"/> | ||||
|                         <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/wp-telegram-iphone-2.png' ); ?>"/> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="normal-section"> | ||||
|                     <div class="right"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h2><?php _e( 'Send messages to your channels/Groups', 'wp-statistics' ); ?></h2> | ||||
|                             <p><?php _e( 'Simply send any message through the WordPress admin panel to your channels or groups on the telegram. No need to add a person as an admin to the channel/group to add send messages.', 'wp-statistics' ); ?></p> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="left text-center"> | ||||
|                         <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/wp-telegram-send.png' ); ?>"/> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="normal-section"> | ||||
|                     <div class="left"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h2><?php _e( 'Integrations & Notifications', 'wp-statistics' ); ?></h2> | ||||
|                             <p><?php _e( 'Integrate with famous plugins such as WooCommerce, CF7, GravityForms, Quforms and EDD.', 'wp-statistics' ); ?></p> | ||||
|                             <p><?php _e( 'For example: Receive the text of the messages sent in a form created with GravityForm on a particular channel or group. ', 'wp-statistics' ); ?></p> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="right text-center"> | ||||
|                         <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/wp-telegram-settings.png' ); ?>"/> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="normal-section"> | ||||
|                     <div class="right"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h2><?php _e( 'Supports multiple channels or groups', 'wp-statistics' ); ?></h2> | ||||
|                             <p><?php _e( 'You can add as many channels/groups as you want to the panel and arrange different tasks in different channels/groups.', 'wp-statistics' ); ?></p> | ||||
|                             <p><?php _e( 'For example, different groups for sales, marketing, support or technical team.', 'wp-statistics' ); ?></p> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="left text-center"> | ||||
|                         <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/wp-telegram-channels.png' ); ?>"/> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="center-section"> | ||||
|                     <div class="left"> | ||||
|                         <div class="content-padding"> | ||||
|                             <a href="https://wp-telegram.com/purchase/" target="_blank"> | ||||
|                                 <img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/what-is-new/coupon-code.png' ); ?>"/> | ||||
|                             </a> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </section> | ||||
|  | ||||
|                 <section class="center-section"> | ||||
|                     <div class="left"> | ||||
|                         <div class="content-padding"> | ||||
|                             <h3>Follow us on Social Media</h3> | ||||
|                         </div> | ||||
|  | ||||
|                         <a href="https://github.com/veronalabs" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-github.png' ); ?>"/></a> | ||||
|                         <a href="https://www.instagram.com/veronalabs/" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-instagram.png' ); ?>"/></a> | ||||
|                         <a href="https://www.linkedin.com/company/veronalabs/" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-linkedin.png' ); ?>"/></a> | ||||
|                         <a href="https://twitter.com/veronalabs" target="_blank"><img src="<?php echo plugins_url( 'wp-statistics/assets/images/welcome/icon-twitter.png' ); ?>"/></a> | ||||
|                     </div> | ||||
|                 </section> | ||||
|             </div> | ||||
| 		<?php } ?> | ||||
|  | ||||
| 		<?php if ( isset( $_GET['tab'] ) and $_GET['tab'] == "addons" ) { ?> | ||||
|             <div data-content="addons" class="tab-content current"> | ||||
|                 <section class="center-section"> | ||||
| 					<?php include( WP_Statistics::$reg['plugin-dir'] . "includes/templates/add-ons.php" ); ?> | ||||
|                 </section> | ||||
|             </div> | ||||
| 		<?php } ?> | ||||
|  | ||||
| 		<?php if ( isset( $_GET['tab'] ) and $_GET['tab'] == "credit" ) { ?> | ||||
|             <div data-content="credit" class="tab-content current"> | ||||
|                 <div class="about-wrap-content"> | ||||
|                     <p class="about-description"><?php echo sprintf( __( 'WP-Statistics is created by some people and is one of the <a href="%s" target="_blank">VeronaLabs.com</a> projects.', 'wp-statistics' ), 'https://veronalabs.com' ); ?></p> | ||||
|                     <h3 class="wp-people-group"><?php _e( 'Project Leaders', 'wp-statistics' ); ?></h3> | ||||
|                     <ul class="wp-people-group "> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/mostafas1990" class="web"><?php echo get_avatar( 'mst404@gmail.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Mostafa Soufi', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Original Author', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                     </ul> | ||||
|                     <h3 class="wp-people-group"><?php _e( 'Other Contributors', 'wp-statistics' ); ?></h3> | ||||
|                     <ul class="wp-people-group"> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/mehrshaddarzi" class="web"><?php echo get_avatar( 'mehrshad198@gmail.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Mehrshad Darzi', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Core Contributor', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/ghasemi71ir" class="web"><?php echo get_avatar( 'ghasemi71ir@gmail.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Mohammad Ghasemi', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Core Contributor', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/gregross" class="web"><?php echo get_avatar( 'greg@toolstack.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Greg Ross', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Core Contributor', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/dedidata" class="web"><?php echo get_avatar( 'dedidata.com@gmail.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Farhad Sakhaei', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Core Contributor', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                         <li class="wp-person"> | ||||
|                             <a href="https://profiles.wordpress.org/pedromendonca" class="web"><?php echo get_avatar( 'ped.gaspar@gmail.com', 62, '', '', array( 'class' => 'gravatar' ) ); ?><?php _e( 'Pedro Mendonça', 'wp-statistics' ); ?></a> | ||||
|                             <span class="title"><?php _e( 'Language Contributor', 'wp-statistics' ); ?></span> | ||||
|                         </li> | ||||
|                     </ul> | ||||
|  | ||||
|                     <p class="clear"><?php echo sprintf( __( 'WP-Statistics is being developed on GitHub, if you’re interested in contributing to the plugin, please look at the <a href="%s" target="_blank">GitHub page</a>.', 'wp-statistics' ), 'https://github.com/wp-statistics/wp-statistics' ); ?></p> | ||||
|                     <h3 class="wp-people-group"><?php _e( 'External Libraries', 'wp-statistics' ); ?></h3> | ||||
|                     <p class="wp-credits-list"> | ||||
|                         <a target="_blank" href="https://maxmind.com/">MaxMind</a>, | ||||
|                         <a target="_blank" href="https://www.chartjs.org/">Chart.js</a>, | ||||
|                         <a target="_blank" href="https://whichbrowser.net/">WhichBrowser</a>.</p> | ||||
|                 </div> | ||||
|             </div> | ||||
| 		<?php } ?> | ||||
|  | ||||
| 		<?php if ( isset( $_GET['tab'] ) and $_GET['tab'] == "changelog" ) { ?> | ||||
|             <div data-content="changelog" class="tab-content current"> | ||||
| 				<?php WP_Statistics_Welcome::show_change_log(); ?> | ||||
|             </div> | ||||
| 		<?php } ?> | ||||
|  | ||||
|         <hr style="clear: both;"> | ||||
|         <div class="wps-return-to-dashboard"> | ||||
|             <a href="<?php echo WP_Statistics_Admin_Pages::admin_url( 'overview' ); ?>"><?php _e( 'Go to Statistics → Overview', 'wp-statistics' ); ?></a> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										7
									
								
								wp-content/plugins/wp-statistics/includes/vendor/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								wp-content/plugins/wp-statistics/includes/vendor/autoload.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload.php @generated by Composer | ||||
|  | ||||
| require_once __DIR__ . '/composer/autoload_real.php'; | ||||
|  | ||||
| return ComposerAutoloaderInite38eff48d6e6d75cf438d3ef850d45a7::getLoader(); | ||||
							
								
								
									
										445
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ClassLoader.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										445
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ClassLoader.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,445 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * This file is part of Composer. | ||||
|  * | ||||
|  * (c) Nils Adermann <naderman@naderman.de> | ||||
|  *     Jordi Boggiano <j.boggiano@seld.be> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
|  | ||||
| namespace Composer\Autoload; | ||||
|  | ||||
| /** | ||||
|  * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | ||||
|  * | ||||
|  *     $loader = new \Composer\Autoload\ClassLoader(); | ||||
|  * | ||||
|  *     // register classes with namespaces | ||||
|  *     $loader->add('Symfony\Component', __DIR__.'/component'); | ||||
|  *     $loader->add('Symfony',           __DIR__.'/framework'); | ||||
|  * | ||||
|  *     // activate the autoloader | ||||
|  *     $loader->register(); | ||||
|  * | ||||
|  *     // to enable searching the include path (eg. for PEAR packages) | ||||
|  *     $loader->setUseIncludePath(true); | ||||
|  * | ||||
|  * In this example, if you try to use a class in the Symfony\Component | ||||
|  * namespace or one of its children (Symfony\Component\Console for instance), | ||||
|  * the autoloader will first look for the class under the component/ | ||||
|  * directory, and it will then fallback to the framework/ directory if not | ||||
|  * found before giving up. | ||||
|  * | ||||
|  * This class is loosely based on the Symfony UniversalClassLoader. | ||||
|  * | ||||
|  * @author Fabien Potencier <fabien@symfony.com> | ||||
|  * @author Jordi Boggiano <j.boggiano@seld.be> | ||||
|  * @see    http://www.php-fig.org/psr/psr-0/ | ||||
|  * @see    http://www.php-fig.org/psr/psr-4/ | ||||
|  */ | ||||
| class ClassLoader | ||||
| { | ||||
|     // PSR-4 | ||||
|     private $prefixLengthsPsr4 = array(); | ||||
|     private $prefixDirsPsr4 = array(); | ||||
|     private $fallbackDirsPsr4 = array(); | ||||
|  | ||||
|     // PSR-0 | ||||
|     private $prefixesPsr0 = array(); | ||||
|     private $fallbackDirsPsr0 = array(); | ||||
|  | ||||
|     private $useIncludePath = false; | ||||
|     private $classMap = array(); | ||||
|     private $classMapAuthoritative = false; | ||||
|     private $missingClasses = array(); | ||||
|     private $apcuPrefix; | ||||
|  | ||||
|     public function getPrefixes() | ||||
|     { | ||||
|         if (!empty($this->prefixesPsr0)) { | ||||
|             return call_user_func_array('array_merge', $this->prefixesPsr0); | ||||
|         } | ||||
|  | ||||
|         return array(); | ||||
|     } | ||||
|  | ||||
|     public function getPrefixesPsr4() | ||||
|     { | ||||
|         return $this->prefixDirsPsr4; | ||||
|     } | ||||
|  | ||||
|     public function getFallbackDirs() | ||||
|     { | ||||
|         return $this->fallbackDirsPsr0; | ||||
|     } | ||||
|  | ||||
|     public function getFallbackDirsPsr4() | ||||
|     { | ||||
|         return $this->fallbackDirsPsr4; | ||||
|     } | ||||
|  | ||||
|     public function getClassMap() | ||||
|     { | ||||
|         return $this->classMap; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $classMap Class to filename map | ||||
|      */ | ||||
|     public function addClassMap(array $classMap) | ||||
|     { | ||||
|         if ($this->classMap) { | ||||
|             $this->classMap = array_merge($this->classMap, $classMap); | ||||
|         } else { | ||||
|             $this->classMap = $classMap; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers a set of PSR-0 directories for a given prefix, either | ||||
|      * appending or prepending to the ones previously set for this prefix. | ||||
|      * | ||||
|      * @param string       $prefix  The prefix | ||||
|      * @param array|string $paths   The PSR-0 root directories | ||||
|      * @param bool         $prepend Whether to prepend the directories | ||||
|      */ | ||||
|     public function add($prefix, $paths, $prepend = false) | ||||
|     { | ||||
|         if (!$prefix) { | ||||
|             if ($prepend) { | ||||
|                 $this->fallbackDirsPsr0 = array_merge( | ||||
|                     (array) $paths, | ||||
|                     $this->fallbackDirsPsr0 | ||||
|                 ); | ||||
|             } else { | ||||
|                 $this->fallbackDirsPsr0 = array_merge( | ||||
|                     $this->fallbackDirsPsr0, | ||||
|                     (array) $paths | ||||
|                 ); | ||||
|             } | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         $first = $prefix[0]; | ||||
|         if (!isset($this->prefixesPsr0[$first][$prefix])) { | ||||
|             $this->prefixesPsr0[$first][$prefix] = (array) $paths; | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|         if ($prepend) { | ||||
|             $this->prefixesPsr0[$first][$prefix] = array_merge( | ||||
|                 (array) $paths, | ||||
|                 $this->prefixesPsr0[$first][$prefix] | ||||
|             ); | ||||
|         } else { | ||||
|             $this->prefixesPsr0[$first][$prefix] = array_merge( | ||||
|                 $this->prefixesPsr0[$first][$prefix], | ||||
|                 (array) $paths | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers a set of PSR-4 directories for a given namespace, either | ||||
|      * appending or prepending to the ones previously set for this namespace. | ||||
|      * | ||||
|      * @param string       $prefix  The prefix/namespace, with trailing '\\' | ||||
|      * @param array|string $paths   The PSR-4 base directories | ||||
|      * @param bool         $prepend Whether to prepend the directories | ||||
|      * | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     public function addPsr4($prefix, $paths, $prepend = false) | ||||
|     { | ||||
|         if (!$prefix) { | ||||
|             // Register directories for the root namespace. | ||||
|             if ($prepend) { | ||||
|                 $this->fallbackDirsPsr4 = array_merge( | ||||
|                     (array) $paths, | ||||
|                     $this->fallbackDirsPsr4 | ||||
|                 ); | ||||
|             } else { | ||||
|                 $this->fallbackDirsPsr4 = array_merge( | ||||
|                     $this->fallbackDirsPsr4, | ||||
|                     (array) $paths | ||||
|                 ); | ||||
|             } | ||||
|         } elseif (!isset($this->prefixDirsPsr4[$prefix])) { | ||||
|             // Register directories for a new namespace. | ||||
|             $length = strlen($prefix); | ||||
|             if ('\\' !== $prefix[$length - 1]) { | ||||
|                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | ||||
|             } | ||||
|             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | ||||
|             $this->prefixDirsPsr4[$prefix] = (array) $paths; | ||||
|         } elseif ($prepend) { | ||||
|             // Prepend directories for an already registered namespace. | ||||
|             $this->prefixDirsPsr4[$prefix] = array_merge( | ||||
|                 (array) $paths, | ||||
|                 $this->prefixDirsPsr4[$prefix] | ||||
|             ); | ||||
|         } else { | ||||
|             // Append directories for an already registered namespace. | ||||
|             $this->prefixDirsPsr4[$prefix] = array_merge( | ||||
|                 $this->prefixDirsPsr4[$prefix], | ||||
|                 (array) $paths | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers a set of PSR-0 directories for a given prefix, | ||||
|      * replacing any others previously set for this prefix. | ||||
|      * | ||||
|      * @param string       $prefix The prefix | ||||
|      * @param array|string $paths  The PSR-0 base directories | ||||
|      */ | ||||
|     public function set($prefix, $paths) | ||||
|     { | ||||
|         if (!$prefix) { | ||||
|             $this->fallbackDirsPsr0 = (array) $paths; | ||||
|         } else { | ||||
|             $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers a set of PSR-4 directories for a given namespace, | ||||
|      * replacing any others previously set for this namespace. | ||||
|      * | ||||
|      * @param string       $prefix The prefix/namespace, with trailing '\\' | ||||
|      * @param array|string $paths  The PSR-4 base directories | ||||
|      * | ||||
|      * @throws \InvalidArgumentException | ||||
|      */ | ||||
|     public function setPsr4($prefix, $paths) | ||||
|     { | ||||
|         if (!$prefix) { | ||||
|             $this->fallbackDirsPsr4 = (array) $paths; | ||||
|         } else { | ||||
|             $length = strlen($prefix); | ||||
|             if ('\\' !== $prefix[$length - 1]) { | ||||
|                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | ||||
|             } | ||||
|             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | ||||
|             $this->prefixDirsPsr4[$prefix] = (array) $paths; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Turns on searching the include path for class files. | ||||
|      * | ||||
|      * @param bool $useIncludePath | ||||
|      */ | ||||
|     public function setUseIncludePath($useIncludePath) | ||||
|     { | ||||
|         $this->useIncludePath = $useIncludePath; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Can be used to check if the autoloader uses the include path to check | ||||
|      * for classes. | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function getUseIncludePath() | ||||
|     { | ||||
|         return $this->useIncludePath; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Turns off searching the prefix and fallback directories for classes | ||||
|      * that have not been registered with the class map. | ||||
|      * | ||||
|      * @param bool $classMapAuthoritative | ||||
|      */ | ||||
|     public function setClassMapAuthoritative($classMapAuthoritative) | ||||
|     { | ||||
|         $this->classMapAuthoritative = $classMapAuthoritative; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Should class lookup fail if not found in the current class map? | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public function isClassMapAuthoritative() | ||||
|     { | ||||
|         return $this->classMapAuthoritative; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * APCu prefix to use to cache found/not-found classes, if the extension is enabled. | ||||
|      * | ||||
|      * @param string|null $apcuPrefix | ||||
|      */ | ||||
|     public function setApcuPrefix($apcuPrefix) | ||||
|     { | ||||
|         $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * The APCu prefix in use, or null if APCu caching is not enabled. | ||||
|      * | ||||
|      * @return string|null | ||||
|      */ | ||||
|     public function getApcuPrefix() | ||||
|     { | ||||
|         return $this->apcuPrefix; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers this instance as an autoloader. | ||||
|      * | ||||
|      * @param bool $prepend Whether to prepend the autoloader or not | ||||
|      */ | ||||
|     public function register($prepend = false) | ||||
|     { | ||||
|         spl_autoload_register(array($this, 'loadClass'), true, $prepend); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Unregisters this instance as an autoloader. | ||||
|      */ | ||||
|     public function unregister() | ||||
|     { | ||||
|         spl_autoload_unregister(array($this, 'loadClass')); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Loads the given class or interface. | ||||
|      * | ||||
|      * @param  string    $class The name of the class | ||||
|      * @return bool|null True if loaded, null otherwise | ||||
|      */ | ||||
|     public function loadClass($class) | ||||
|     { | ||||
|         if ($file = $this->findFile($class)) { | ||||
|             includeFile($file); | ||||
|  | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Finds the path to the file where the class is defined. | ||||
|      * | ||||
|      * @param string $class The name of the class | ||||
|      * | ||||
|      * @return string|false The path if found, false otherwise | ||||
|      */ | ||||
|     public function findFile($class) | ||||
|     { | ||||
|         // class map lookup | ||||
|         if (isset($this->classMap[$class])) { | ||||
|             return $this->classMap[$class]; | ||||
|         } | ||||
|         if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | ||||
|             return false; | ||||
|         } | ||||
|         if (null !== $this->apcuPrefix) { | ||||
|             $file = apcu_fetch($this->apcuPrefix.$class, $hit); | ||||
|             if ($hit) { | ||||
|                 return $file; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $file = $this->findFileWithExtension($class, '.php'); | ||||
|  | ||||
|         // Search for Hack files if we are running on HHVM | ||||
|         if (false === $file && defined('HHVM_VERSION')) { | ||||
|             $file = $this->findFileWithExtension($class, '.hh'); | ||||
|         } | ||||
|  | ||||
|         if (null !== $this->apcuPrefix) { | ||||
|             apcu_add($this->apcuPrefix.$class, $file); | ||||
|         } | ||||
|  | ||||
|         if (false === $file) { | ||||
|             // Remember that this class does not exist. | ||||
|             $this->missingClasses[$class] = true; | ||||
|         } | ||||
|  | ||||
|         return $file; | ||||
|     } | ||||
|  | ||||
|     private function findFileWithExtension($class, $ext) | ||||
|     { | ||||
|         // PSR-4 lookup | ||||
|         $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | ||||
|  | ||||
|         $first = $class[0]; | ||||
|         if (isset($this->prefixLengthsPsr4[$first])) { | ||||
|             $subPath = $class; | ||||
|             while (false !== $lastPos = strrpos($subPath, '\\')) { | ||||
|                 $subPath = substr($subPath, 0, $lastPos); | ||||
|                 $search = $subPath.'\\'; | ||||
|                 if (isset($this->prefixDirsPsr4[$search])) { | ||||
|                     $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | ||||
|                     foreach ($this->prefixDirsPsr4[$search] as $dir) { | ||||
|                         if (file_exists($file = $dir . $pathEnd)) { | ||||
|                             return $file; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // PSR-4 fallback dirs | ||||
|         foreach ($this->fallbackDirsPsr4 as $dir) { | ||||
|             if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | ||||
|                 return $file; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // PSR-0 lookup | ||||
|         if (false !== $pos = strrpos($class, '\\')) { | ||||
|             // namespaced class name | ||||
|             $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | ||||
|                 . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | ||||
|         } else { | ||||
|             // PEAR-like class name | ||||
|             $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | ||||
|         } | ||||
|  | ||||
|         if (isset($this->prefixesPsr0[$first])) { | ||||
|             foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { | ||||
|                 if (0 === strpos($class, $prefix)) { | ||||
|                     foreach ($dirs as $dir) { | ||||
|                         if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | ||||
|                             return $file; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // PSR-0 fallback dirs | ||||
|         foreach ($this->fallbackDirsPsr0 as $dir) { | ||||
|             if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | ||||
|                 return $file; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // PSR-0 include paths. | ||||
|         if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | ||||
|             return $file; | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Scope isolated include. | ||||
|  * | ||||
|  * Prevents access to $this/self from included files. | ||||
|  */ | ||||
| function includeFile($file) | ||||
| { | ||||
|     include $file; | ||||
| } | ||||
							
								
								
									
										21
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
|  | ||||
| Copyright (c) Nils Adermann, Jordi Boggiano | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is furnished | ||||
| to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
| THE SOFTWARE. | ||||
|  | ||||
							
								
								
									
										9
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_classmap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_classmap.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload_classmap.php @generated by Composer | ||||
|  | ||||
| $vendorDir = dirname(dirname(__FILE__)); | ||||
| $baseDir = dirname(dirname($vendorDir)); | ||||
|  | ||||
| return array( | ||||
| ); | ||||
							
								
								
									
										10
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_namespaces.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_namespaces.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload_namespaces.php @generated by Composer | ||||
|  | ||||
| $vendorDir = dirname(dirname(__FILE__)); | ||||
| $baseDir = dirname(dirname($vendorDir)); | ||||
|  | ||||
| return array( | ||||
|     'Parsedown' => array($vendorDir . '/erusev/parsedown'), | ||||
| ); | ||||
							
								
								
									
										18
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_psr4.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_psr4.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload_psr4.php @generated by Composer | ||||
|  | ||||
| $vendorDir = dirname(dirname(__FILE__)); | ||||
| $baseDir = dirname(dirname($vendorDir)); | ||||
|  | ||||
| return array( | ||||
|     'WhichBrowser\\' => array($vendorDir . '/whichbrowser/parser/src', $vendorDir . '/whichbrowser/parser/tests/src'), | ||||
|     'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), | ||||
|     'MaxMind\\WebService\\' => array($vendorDir . '/maxmind/web-service-common/src/WebService'), | ||||
|     'MaxMind\\Exception\\' => array($vendorDir . '/maxmind/web-service-common/src/Exception'), | ||||
|     'MaxMind\\Db\\' => array($vendorDir . '/maxmind-db/reader/src/MaxMind/Db'), | ||||
|     'Jaybizzle\\CrawlerDetect\\' => array($vendorDir . '/jaybizzle/crawler-detect/src'), | ||||
|     'IPTools\\' => array($vendorDir . '/s1lentium/iptools/src'), | ||||
|     'GeoIp2\\' => array($vendorDir . '/geoip2/geoip2/src'), | ||||
|     'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'), | ||||
| ); | ||||
							
								
								
									
										52
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_real.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_real.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload_real.php @generated by Composer | ||||
|  | ||||
| class ComposerAutoloaderInite38eff48d6e6d75cf438d3ef850d45a7 | ||||
| { | ||||
|     private static $loader; | ||||
|  | ||||
|     public static function loadClassLoader($class) | ||||
|     { | ||||
|         if ('Composer\Autoload\ClassLoader' === $class) { | ||||
|             require __DIR__ . '/ClassLoader.php'; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static function getLoader() | ||||
|     { | ||||
|         if (null !== self::$loader) { | ||||
|             return self::$loader; | ||||
|         } | ||||
|  | ||||
|         spl_autoload_register(array('ComposerAutoloaderInite38eff48d6e6d75cf438d3ef850d45a7', 'loadClassLoader'), true, true); | ||||
|         self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | ||||
|         spl_autoload_unregister(array('ComposerAutoloaderInite38eff48d6e6d75cf438d3ef850d45a7', 'loadClassLoader')); | ||||
|  | ||||
|         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); | ||||
|         if ($useStaticLoader) { | ||||
|             require_once __DIR__ . '/autoload_static.php'; | ||||
|  | ||||
|             call_user_func(\Composer\Autoload\ComposerStaticInite38eff48d6e6d75cf438d3ef850d45a7::getInitializer($loader)); | ||||
|         } else { | ||||
|             $map = require __DIR__ . '/autoload_namespaces.php'; | ||||
|             foreach ($map as $namespace => $path) { | ||||
|                 $loader->set($namespace, $path); | ||||
|             } | ||||
|  | ||||
|             $map = require __DIR__ . '/autoload_psr4.php'; | ||||
|             foreach ($map as $namespace => $path) { | ||||
|                 $loader->setPsr4($namespace, $path); | ||||
|             } | ||||
|  | ||||
|             $classMap = require __DIR__ . '/autoload_classmap.php'; | ||||
|             if ($classMap) { | ||||
|                 $loader->addClassMap($classMap); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $loader->register(true); | ||||
|  | ||||
|         return $loader; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										101
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_static.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/autoload_static.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| <?php | ||||
|  | ||||
| // autoload_static.php @generated by Composer | ||||
|  | ||||
| namespace Composer\Autoload; | ||||
|  | ||||
| class ComposerStaticInite38eff48d6e6d75cf438d3ef850d45a7 | ||||
| { | ||||
|     public static $prefixLengthsPsr4 = array ( | ||||
|         'W' =>  | ||||
|         array ( | ||||
|             'WhichBrowser\\' => 13, | ||||
|         ), | ||||
|         'P' =>  | ||||
|         array ( | ||||
|             'Psr\\Cache\\' => 10, | ||||
|         ), | ||||
|         'M' =>  | ||||
|         array ( | ||||
|             'MaxMind\\WebService\\' => 19, | ||||
|             'MaxMind\\Exception\\' => 18, | ||||
|             'MaxMind\\Db\\' => 11, | ||||
|         ), | ||||
|         'J' =>  | ||||
|         array ( | ||||
|             'Jaybizzle\\CrawlerDetect\\' => 24, | ||||
|         ), | ||||
|         'I' =>  | ||||
|         array ( | ||||
|             'IPTools\\' => 8, | ||||
|         ), | ||||
|         'G' =>  | ||||
|         array ( | ||||
|             'GeoIp2\\' => 7, | ||||
|         ), | ||||
|         'C' =>  | ||||
|         array ( | ||||
|             'Composer\\CaBundle\\' => 18, | ||||
|         ), | ||||
|     ); | ||||
|  | ||||
|     public static $prefixDirsPsr4 = array ( | ||||
|         'WhichBrowser\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/whichbrowser/parser/src', | ||||
|             1 => __DIR__ . '/..' . '/whichbrowser/parser/tests/src', | ||||
|         ), | ||||
|         'Psr\\Cache\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/psr/cache/src', | ||||
|         ), | ||||
|         'MaxMind\\WebService\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/maxmind/web-service-common/src/WebService', | ||||
|         ), | ||||
|         'MaxMind\\Exception\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/maxmind/web-service-common/src/Exception', | ||||
|         ), | ||||
|         'MaxMind\\Db\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', | ||||
|         ), | ||||
|         'Jaybizzle\\CrawlerDetect\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/jaybizzle/crawler-detect/src', | ||||
|         ), | ||||
|         'IPTools\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/s1lentium/iptools/src', | ||||
|         ), | ||||
|         'GeoIp2\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/geoip2/geoip2/src', | ||||
|         ), | ||||
|         'Composer\\CaBundle\\' =>  | ||||
|         array ( | ||||
|             0 => __DIR__ . '/..' . '/composer/ca-bundle/src', | ||||
|         ), | ||||
|     ); | ||||
|  | ||||
|     public static $prefixesPsr0 = array ( | ||||
|         'P' =>  | ||||
|         array ( | ||||
|             'Parsedown' =>  | ||||
|             array ( | ||||
|                 0 => __DIR__ . '/..' . '/erusev/parsedown', | ||||
|             ), | ||||
|         ), | ||||
|     ); | ||||
|  | ||||
|     public static function getInitializer(ClassLoader $loader) | ||||
|     { | ||||
|         return \Closure::bind(function () use ($loader) { | ||||
|             $loader->prefixLengthsPsr4 = ComposerStaticInite38eff48d6e6d75cf438d3ef850d45a7::$prefixLengthsPsr4; | ||||
|             $loader->prefixDirsPsr4 = ComposerStaticInite38eff48d6e6d75cf438d3ef850d45a7::$prefixDirsPsr4; | ||||
|             $loader->prefixesPsr0 = ComposerStaticInite38eff48d6e6d75cf438d3ef850d45a7::$prefixesPsr0; | ||||
|  | ||||
|         }, null, ClassLoader::class); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										19
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| Copyright (C) 2016 Composer | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||||
| this software and associated documentation files (the "Software"), to deal in | ||||
| the Software without restriction, including without limitation the rights to | ||||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||||
| of the Software, and to permit persons to whom the Software is furnished to do | ||||
| so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
							
								
								
									
										85
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/README.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/README.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| composer/ca-bundle | ||||
| ================== | ||||
|  | ||||
| Small utility library that lets you find a path to the system CA bundle, | ||||
| and includes a fallback to the Mozilla CA bundle. | ||||
|  | ||||
| Originally written as part of [composer/composer](https://github.com/composer/composer), | ||||
| now extracted and made available as a stand-alone library. | ||||
|  | ||||
|  | ||||
| Installation | ||||
| ------------ | ||||
|  | ||||
| Install the latest version with: | ||||
|  | ||||
| ```bash | ||||
| $ composer require composer/ca-bundle | ||||
| ``` | ||||
|  | ||||
|  | ||||
| Requirements | ||||
| ------------ | ||||
|  | ||||
| * PHP 5.3.2 is required but using the latest version of PHP is highly recommended. | ||||
|  | ||||
|  | ||||
| Basic usage | ||||
| ----------- | ||||
|  | ||||
| # `Composer\CaBundle\CaBundle` | ||||
|  | ||||
| - `CaBundle::getSystemCaRootBundlePath()`: Returns the system CA bundle path, or a path to the bundled one as fallback | ||||
| - `CaBundle::getBundledCaBundlePath()`: Returns the path to the bundled CA file | ||||
| - `CaBundle::validateCaFile($filename)`: Validates a CA file using opensl_x509_parse only if it is safe to use | ||||
| - `CaBundle::isOpensslParseSafe()`: Test if it is safe to use the PHP function openssl_x509_parse() | ||||
| - `CaBundle::reset()`: Resets the static caches | ||||
|  | ||||
|  | ||||
| ## To use with curl | ||||
|  | ||||
| ```php | ||||
| $curl = curl_init("https://example.org/"); | ||||
|  | ||||
| $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath(); | ||||
| if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) { | ||||
|     curl_setopt($curl, CURLOPT_CAPATH, $caPathOrFile); | ||||
| } else { | ||||
|     curl_setopt($curl, CURLOPT_CAINFO, $caPathOrFile); | ||||
| } | ||||
|  | ||||
| $result = curl_exec($curl); | ||||
| ``` | ||||
|  | ||||
| ## To use with php streams | ||||
|  | ||||
| ```php | ||||
| $opts = array( | ||||
|     'http' => array( | ||||
|         'method' => "GET" | ||||
|     ) | ||||
| ); | ||||
|  | ||||
| $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath(); | ||||
| if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) { | ||||
|     $opts['ssl']['capath'] = $caPathOrFile; | ||||
| } else { | ||||
|     $opts['ssl']['cafile'] = $caPathOrFile; | ||||
| } | ||||
|  | ||||
| $context = stream_context_create($opts); | ||||
| $result = file_get_contents('https://example.com', false, $context); | ||||
| ``` | ||||
|  | ||||
| ## To use with Guzzle | ||||
|  | ||||
| ```php | ||||
| $client = new \GuzzleHttp\Client([ | ||||
|     \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath() | ||||
| ]); | ||||
| ``` | ||||
|  | ||||
| License | ||||
| ------- | ||||
|  | ||||
| composer/ca-bundle is licensed under the MIT License, see the LICENSE file for details. | ||||
							
								
								
									
										54
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| { | ||||
|     "name": "composer/ca-bundle", | ||||
|     "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", | ||||
|     "type": "library", | ||||
|     "license": "MIT", | ||||
|     "keywords": [ | ||||
|         "cabundle", | ||||
|         "cacert", | ||||
|         "certificate", | ||||
|         "ssl", | ||||
|         "tls" | ||||
|     ], | ||||
|     "authors": [ | ||||
|         { | ||||
|             "name": "Jordi Boggiano", | ||||
|             "email": "j.boggiano@seld.be", | ||||
|             "homepage": "http://seld.be" | ||||
|         } | ||||
|     ], | ||||
|     "support": { | ||||
|         "irc": "irc://irc.freenode.org/composer", | ||||
|         "issues": "https://github.com/composer/ca-bundle/issues" | ||||
|     }, | ||||
|     "require": { | ||||
|         "ext-openssl": "*", | ||||
|         "ext-pcre": "*", | ||||
|         "php": "^5.3.2 || ^7.0" | ||||
|     }, | ||||
|     "require-dev": { | ||||
|         "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5", | ||||
|         "psr/log": "^1.0", | ||||
|         "symfony/process": "^2.5 || ^3.0 || ^4.0" | ||||
|     }, | ||||
|     "autoload": { | ||||
|         "psr-4": { | ||||
|             "Composer\\CaBundle\\": "src" | ||||
|         } | ||||
|     }, | ||||
|     "autoload-dev": { | ||||
|         "psr-4": { | ||||
|             "Composer\\CaBundle\\": "tests" | ||||
|         } | ||||
|     }, | ||||
|     "extra": { | ||||
|         "branch-alias": { | ||||
|             "dev-master": "1.x-dev" | ||||
|         } | ||||
|     }, | ||||
|     "config": { | ||||
|         "platform": { | ||||
|             "php": "5.3.9" | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										3401
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/res/cacert.pem
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3401
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/res/cacert.pem
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										308
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/src/CaBundle.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										308
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/ca-bundle/src/CaBundle.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,308 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * This file is part of composer/ca-bundle. | ||||
|  * | ||||
|  * (c) Composer <https://github.com/composer> | ||||
|  * | ||||
|  * For the full copyright and license information, please view | ||||
|  * the LICENSE file that was distributed with this source code. | ||||
|  */ | ||||
|  | ||||
| namespace Composer\CaBundle; | ||||
|  | ||||
| use Psr\Log\LoggerInterface; | ||||
| use Symfony\Component\Process\PhpProcess; | ||||
|  | ||||
| /** | ||||
|  * @author Chris Smith <chris@cs278.org> | ||||
|  * @author Jordi Boggiano <j.boggiano@seld.be> | ||||
|  */ | ||||
| class CaBundle | ||||
| { | ||||
|     private static $caPath; | ||||
|     private static $caFileValidity = array(); | ||||
|     private static $useOpensslParse; | ||||
|  | ||||
|     /** | ||||
|      * Returns the system CA bundle path, or a path to the bundled one | ||||
|      * | ||||
|      * This method was adapted from Sslurp. | ||||
|      * https://github.com/EvanDotPro/Sslurp | ||||
|      * | ||||
|      * (c) Evan Coury <me@evancoury.com> | ||||
|      * | ||||
|      * For the full copyright and license information, please see below: | ||||
|      * | ||||
|      * Copyright (c) 2013, Evan Coury | ||||
|      * All rights reserved. | ||||
|      * | ||||
|      * Redistribution and use in source and binary forms, with or without modification, | ||||
|      * are permitted provided that the following conditions are met: | ||||
|      * | ||||
|      *     * Redistributions of source code must retain the above copyright notice, | ||||
|      *       this list of conditions and the following disclaimer. | ||||
|      * | ||||
|      *     * Redistributions in binary form must reproduce the above copyright notice, | ||||
|      *       this list of conditions and the following disclaimer in the documentation | ||||
|      *       and/or other materials provided with the distribution. | ||||
|      * | ||||
|      * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||||
|      * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||
|      * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||
|      * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||||
|      * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||
|      * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||
|      * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||||
|      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
|      * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||||
|      * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|      * | ||||
|      * @param  LoggerInterface $logger optional logger for information about which CA files were loaded | ||||
|      * @return string          path to a CA bundle file or directory | ||||
|      */ | ||||
|     public static function getSystemCaRootBundlePath(LoggerInterface $logger = null) | ||||
|     { | ||||
|         if (self::$caPath !== null) { | ||||
|             return self::$caPath; | ||||
|         } | ||||
|  | ||||
|         // If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that. | ||||
|         // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. | ||||
|         $envCertFile = getenv('SSL_CERT_FILE'); | ||||
|         if ($envCertFile && is_readable($envCertFile) && static::validateCaFile($envCertFile, $logger)) { | ||||
|             return self::$caPath = $envCertFile; | ||||
|         } | ||||
|  | ||||
|         // If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that. | ||||
|         // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. | ||||
|         $envCertDir = getenv('SSL_CERT_DIR'); | ||||
|         if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) { | ||||
|             return self::$caPath = $envCertDir; | ||||
|         } | ||||
|  | ||||
|         $configured = ini_get('openssl.cafile'); | ||||
|         if ($configured && strlen($configured) > 0 && is_readable($configured) && static::validateCaFile($configured, $logger)) { | ||||
|             return self::$caPath = $configured; | ||||
|         } | ||||
|  | ||||
|         $configured = ini_get('openssl.capath'); | ||||
|         if ($configured && is_dir($configured) && is_readable($configured)) { | ||||
|             return self::$caPath = $configured; | ||||
|         } | ||||
|  | ||||
|         $caBundlePaths = array( | ||||
|             '/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package) | ||||
|             '/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package) | ||||
|             '/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package) | ||||
|             '/usr/local/share/certs/ca-root-nss.crt', // FreeBSD (ca_root_nss_package) | ||||
|             '/usr/ssl/certs/ca-bundle.crt', // Cygwin | ||||
|             '/opt/local/share/curl/curl-ca-bundle.crt', // OS X macports, curl-ca-bundle package | ||||
|             '/usr/local/share/curl/curl-ca-bundle.crt', // Default cURL CA bunde path (without --with-ca-bundle option) | ||||
|             '/usr/share/ssl/certs/ca-bundle.crt', // Really old RedHat? | ||||
|             '/etc/ssl/cert.pem', // OpenBSD | ||||
|             '/usr/local/etc/ssl/cert.pem', // FreeBSD 10.x | ||||
|             '/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package | ||||
|         ); | ||||
|  | ||||
|         foreach ($caBundlePaths as $caBundle) { | ||||
|             if (@is_readable($caBundle) && static::validateCaFile($caBundle, $logger)) { | ||||
|                 return self::$caPath = $caBundle; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         foreach ($caBundlePaths as $caBundle) { | ||||
|             $caBundle = dirname($caBundle); | ||||
|             if (@is_dir($caBundle) && glob($caBundle.'/*')) { | ||||
|                 return self::$caPath = $caBundle; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return self::$caPath = static::getBundledCaBundlePath(); // Bundled CA file, last resort | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the path to the bundled CA file | ||||
|      * | ||||
|      * In case you don't want to trust the user or the system, you can use this directly | ||||
|      * | ||||
|      * @return string path to a CA bundle file | ||||
|      */ | ||||
|     public static function getBundledCaBundlePath() | ||||
|     { | ||||
|         $caBundleFile = __DIR__.'/../res/cacert.pem'; | ||||
|  | ||||
|         // cURL does not understand 'phar://' paths | ||||
|         // see https://github.com/composer/ca-bundle/issues/10 | ||||
|         if (0 === strpos($caBundleFile, 'phar://')) { | ||||
|             file_put_contents( | ||||
|                 $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'), | ||||
|                 file_get_contents($caBundleFile) | ||||
|             ); | ||||
|  | ||||
|             register_shutdown_function(function() use ($tempCaBundleFile) { | ||||
|                 @unlink($tempCaBundleFile); | ||||
|             }); | ||||
|  | ||||
|             $caBundleFile = $tempCaBundleFile; | ||||
|         } | ||||
|  | ||||
|         return $caBundleFile; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Validates a CA file using opensl_x509_parse only if it is safe to use | ||||
|      * | ||||
|      * @param string          $filename | ||||
|      * @param LoggerInterface $logger   optional logger for information about which CA files were loaded | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public static function validateCaFile($filename, LoggerInterface $logger = null) | ||||
|     { | ||||
|         static $warned = false; | ||||
|  | ||||
|         if (isset(self::$caFileValidity[$filename])) { | ||||
|             return self::$caFileValidity[$filename]; | ||||
|         } | ||||
|  | ||||
|         $contents = file_get_contents($filename); | ||||
|  | ||||
|         // assume the CA is valid if php is vulnerable to | ||||
|         // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html | ||||
|         if (!static::isOpensslParseSafe()) { | ||||
|             if (!$warned && $logger) { | ||||
|                 $logger->warning(sprintf( | ||||
|                     'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.', | ||||
|                     PHP_VERSION | ||||
|                 )); | ||||
|                 $warned = true; | ||||
|             } | ||||
|  | ||||
|             $isValid = !empty($contents); | ||||
|         } else { | ||||
|             $isValid = (bool) openssl_x509_parse($contents); | ||||
|         } | ||||
|  | ||||
|         if ($logger) { | ||||
|             $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid')); | ||||
|         } | ||||
|  | ||||
|         return self::$caFileValidity[$filename] = $isValid; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Test if it is safe to use the PHP function openssl_x509_parse(). | ||||
|      * | ||||
|      * This checks if OpenSSL extensions is vulnerable to remote code execution | ||||
|      * via the exploit documented as CVE-2013-6420. | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     public static function isOpensslParseSafe() | ||||
|     { | ||||
|         if (null !== self::$useOpensslParse) { | ||||
|             return self::$useOpensslParse; | ||||
|         } | ||||
|  | ||||
|         if (PHP_VERSION_ID >= 50600) { | ||||
|             return self::$useOpensslParse = true; | ||||
|         } | ||||
|  | ||||
|         // Vulnerable: | ||||
|         // PHP 5.3.0 - PHP 5.3.27 | ||||
|         // PHP 5.4.0 - PHP 5.4.22 | ||||
|         // PHP 5.5.0 - PHP 5.5.6 | ||||
|         if ( | ||||
|                (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328) | ||||
|             || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423) | ||||
|             || (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50507) | ||||
|         ) { | ||||
|             // This version of PHP has the fix for CVE-2013-6420 applied. | ||||
|             return self::$useOpensslParse = true; | ||||
|         } | ||||
|  | ||||
|         if (defined('PHP_WINDOWS_VERSION_BUILD')) { | ||||
|             // Windows is probably insecure in this case. | ||||
|             return self::$useOpensslParse = false; | ||||
|         } | ||||
|  | ||||
|         $compareDistroVersionPrefix = function ($prefix, $fixedVersion) { | ||||
|             $regex = '{^'.preg_quote($prefix).'([0-9]+)$}'; | ||||
|  | ||||
|             if (preg_match($regex, PHP_VERSION, $m)) { | ||||
|                 return ((int) $m[1]) >= $fixedVersion; | ||||
|             } | ||||
|  | ||||
|             return false; | ||||
|         }; | ||||
|  | ||||
|         // Hard coded list of PHP distributions with the fix backported. | ||||
|         if ( | ||||
|             $compareDistroVersionPrefix('5.3.3-7+squeeze', 18) // Debian 6 (Squeeze) | ||||
|             || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7) // Debian 7 (Wheezy) | ||||
|             || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9) // Ubuntu 12.04 (Precise) | ||||
|         ) { | ||||
|             return self::$useOpensslParse = true; | ||||
|         } | ||||
|  | ||||
|         // Symfony Process component is missing so we assume it is unsafe at this point | ||||
|         if (!class_exists('Symfony\Component\Process\PhpProcess')) { | ||||
|             return self::$useOpensslParse = false; | ||||
|         } | ||||
|  | ||||
|         // This is where things get crazy, because distros backport security | ||||
|         // fixes the chances are on NIX systems the fix has been applied but | ||||
|         // it's not possible to verify that from the PHP version. | ||||
|         // | ||||
|         // To verify exec a new PHP process and run the issue testcase with | ||||
|         // known safe input that replicates the bug. | ||||
|  | ||||
|         // Based on testcase in https://github.com/php/php-src/commit/c1224573c773b6845e83505f717fbf820fc18415 | ||||
|         // changes in https://github.com/php/php-src/commit/76a7fd893b7d6101300cc656058704a73254d593 | ||||
|         $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K'; | ||||
|         $script = <<<'EOT' | ||||
|  | ||||
| error_reporting(-1); | ||||
| $info = openssl_x509_parse(base64_decode('%s')); | ||||
| var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']); | ||||
|  | ||||
| EOT; | ||||
|         $script = '<'."?php\n".sprintf($script, $cert); | ||||
|  | ||||
|         try { | ||||
|             $process = new PhpProcess($script); | ||||
|             $process->mustRun(); | ||||
|         } catch (\Exception $e) { | ||||
|             // In the case of any exceptions just accept it is not possible to | ||||
|             // determine the safety of openssl_x509_parse and bail out. | ||||
|             return self::$useOpensslParse = false; | ||||
|         } | ||||
|  | ||||
|         $output = preg_split('{\r?\n}', trim($process->getOutput())); | ||||
|         $errorOutput = trim($process->getErrorOutput()); | ||||
|  | ||||
|         if ( | ||||
|             count($output) === 3 | ||||
|             && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION) | ||||
|             && $output[1] === 'string(27) "stefan.esser@sektioneins.de"' | ||||
|             && $output[2] === 'int(-1)' | ||||
|             && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput) | ||||
|         ) { | ||||
|             // This PHP has the fix backported probably by a distro security team. | ||||
|             return self::$useOpensslParse = true; | ||||
|         } | ||||
|  | ||||
|         return self::$useOpensslParse = false; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Resets the static caches | ||||
|      */ | ||||
|     public static function reset() | ||||
|     { | ||||
|         self::$caFileValidity = array(); | ||||
|         self::$caPath = null; | ||||
|         self::$useOpensslParse = null; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										481
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/installed.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										481
									
								
								wp-content/plugins/wp-statistics/includes/vendor/composer/installed.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,481 @@ | ||||
| [ | ||||
|     { | ||||
|         "name": "composer/ca-bundle", | ||||
|         "version": "1.1.4", | ||||
|         "version_normalized": "1.1.4.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/composer/ca-bundle.git", | ||||
|             "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/composer/ca-bundle/zipball/558f321c52faeb4828c03e7dc0cfe39a09e09a2d", | ||||
|             "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "ext-openssl": "*", | ||||
|             "ext-pcre": "*", | ||||
|             "php": "^5.3.2 || ^7.0" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5", | ||||
|             "psr/log": "^1.0", | ||||
|             "symfony/process": "^2.5 || ^3.0 || ^4.0" | ||||
|         }, | ||||
|         "time": "2019-01-28T09:30:10+00:00", | ||||
|         "type": "library", | ||||
|         "extra": { | ||||
|             "branch-alias": { | ||||
|                 "dev-master": "1.x-dev" | ||||
|             } | ||||
|         }, | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "Composer\\CaBundle\\": "src" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Jordi Boggiano", | ||||
|                 "email": "j.boggiano@seld.be", | ||||
|                 "homepage": "http://seld.be" | ||||
|             } | ||||
|         ], | ||||
|         "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", | ||||
|         "keywords": [ | ||||
|             "cabundle", | ||||
|             "cacert", | ||||
|             "certificate", | ||||
|             "ssl", | ||||
|             "tls" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "erusev/parsedown", | ||||
|         "version": "1.7.3", | ||||
|         "version_normalized": "1.7.3.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/erusev/parsedown.git", | ||||
|             "reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/erusev/parsedown/zipball/6d893938171a817f4e9bc9e86f2da1e370b7bcd7", | ||||
|             "reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "ext-mbstring": "*", | ||||
|             "php": ">=5.3.0" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "phpunit/phpunit": "^4.8.35" | ||||
|         }, | ||||
|         "time": "2019-03-17T18:48:37+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-0": { | ||||
|                 "Parsedown": "" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Emanuil Rusev", | ||||
|                 "email": "hello@erusev.com", | ||||
|                 "homepage": "http://erusev.com" | ||||
|             } | ||||
|         ], | ||||
|         "description": "Parser for Markdown.", | ||||
|         "homepage": "http://parsedown.org", | ||||
|         "keywords": [ | ||||
|             "markdown", | ||||
|             "parser" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "geoip2/geoip2", | ||||
|         "version": "v2.9.0", | ||||
|         "version_normalized": "2.9.0.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/maxmind/GeoIP2-php.git", | ||||
|             "reference": "a807fbf65212eef5d8d2db1a1b31082b53633d77" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/maxmind/GeoIP2-php/zipball/a807fbf65212eef5d8d2db1a1b31082b53633d77", | ||||
|             "reference": "a807fbf65212eef5d8d2db1a1b31082b53633d77", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "maxmind-db/reader": "~1.0", | ||||
|             "maxmind/web-service-common": "~0.5", | ||||
|             "php": ">=5.4" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "friendsofphp/php-cs-fixer": "2.*", | ||||
|             "phpunit/phpunit": "4.*", | ||||
|             "squizlabs/php_codesniffer": "3.*" | ||||
|         }, | ||||
|         "time": "2018-04-10T15:32:59+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "GeoIp2\\": "src" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "Apache-2.0" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Gregory J. Oschwald", | ||||
|                 "email": "goschwald@maxmind.com", | ||||
|                 "homepage": "http://www.maxmind.com/" | ||||
|             } | ||||
|         ], | ||||
|         "description": "MaxMind GeoIP2 PHP API", | ||||
|         "homepage": "https://github.com/maxmind/GeoIP2-php", | ||||
|         "keywords": [ | ||||
|             "IP", | ||||
|             "geoip", | ||||
|             "geoip2", | ||||
|             "geolocation", | ||||
|             "maxmind" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "jaybizzle/crawler-detect", | ||||
|         "version": "v1.2.78", | ||||
|         "version_normalized": "1.2.78.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/JayBizzle/Crawler-Detect.git", | ||||
|             "reference": "0f91f34d375ddd5d7034b9eaf6b74acd0b2a0ed6" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/0f91f34d375ddd5d7034b9eaf6b74acd0b2a0ed6", | ||||
|             "reference": "0f91f34d375ddd5d7034b9eaf6b74acd0b2a0ed6", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "php": ">=5.3.0" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "phpunit/phpunit": "^4.8|^5.5|^6.5", | ||||
|             "satooshi/php-coveralls": "1.*" | ||||
|         }, | ||||
|         "time": "2019-01-15T21:21:27+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "Jaybizzle\\CrawlerDetect\\": "src/" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Mark Beech", | ||||
|                 "email": "m@rkbee.ch", | ||||
|                 "role": "Developer" | ||||
|             } | ||||
|         ], | ||||
|         "description": "CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent", | ||||
|         "homepage": "https://github.com/JayBizzle/Crawler-Detect/", | ||||
|         "keywords": [ | ||||
|             "crawler", | ||||
|             "crawler detect", | ||||
|             "crawler detector", | ||||
|             "crawlerdetect", | ||||
|             "php crawler detect" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "maxmind-db/reader", | ||||
|         "version": "v1.4.1", | ||||
|         "version_normalized": "1.4.1.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/maxmind/MaxMind-DB-Reader-php.git", | ||||
|             "reference": "eb83d0ee1c1f9b8a340206302136bc81ee02ae74" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/maxmind/MaxMind-DB-Reader-php/zipball/eb83d0ee1c1f9b8a340206302136bc81ee02ae74", | ||||
|             "reference": "eb83d0ee1c1f9b8a340206302136bc81ee02ae74", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "php": ">=5.4" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "friendsofphp/php-cs-fixer": "2.*", | ||||
|             "phpunit/phpunit": "4.* || 5.*", | ||||
|             "satooshi/php-coveralls": "1.0.*", | ||||
|             "squizlabs/php_codesniffer": "3.*" | ||||
|         }, | ||||
|         "suggest": { | ||||
|             "ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder", | ||||
|             "ext-gmp": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder", | ||||
|             "ext-maxminddb": "A C-based database decoder that provides significantly faster lookups" | ||||
|         }, | ||||
|         "time": "2019-01-04T19:55:56+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "MaxMind\\Db\\": "src/MaxMind/Db" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "Apache-2.0" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Gregory J. Oschwald", | ||||
|                 "email": "goschwald@maxmind.com", | ||||
|                 "homepage": "http://www.maxmind.com/" | ||||
|             } | ||||
|         ], | ||||
|         "description": "MaxMind DB Reader API", | ||||
|         "homepage": "https://github.com/maxmind/MaxMind-DB-Reader-php", | ||||
|         "keywords": [ | ||||
|             "database", | ||||
|             "geoip", | ||||
|             "geoip2", | ||||
|             "geolocation", | ||||
|             "maxmind" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "maxmind/web-service-common", | ||||
|         "version": "v0.5.0", | ||||
|         "version_normalized": "0.5.0.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/maxmind/web-service-common-php.git", | ||||
|             "reference": "61a9836fa3bb1743ab89752bae5005d71e78c73b" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/maxmind/web-service-common-php/zipball/61a9836fa3bb1743ab89752bae5005d71e78c73b", | ||||
|             "reference": "61a9836fa3bb1743ab89752bae5005d71e78c73b", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "composer/ca-bundle": "^1.0.3", | ||||
|             "ext-curl": "*", | ||||
|             "ext-json": "*", | ||||
|             "php": ">=5.4" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "friendsofphp/php-cs-fixer": "2.*", | ||||
|             "phpunit/phpunit": "4.*", | ||||
|             "squizlabs/php_codesniffer": "3.*" | ||||
|         }, | ||||
|         "time": "2018-02-12T22:31:54+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "MaxMind\\Exception\\": "src/Exception", | ||||
|                 "MaxMind\\WebService\\": "src/WebService" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "Apache-2.0" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Gregory Oschwald", | ||||
|                 "email": "goschwald@maxmind.com" | ||||
|             } | ||||
|         ], | ||||
|         "description": "Internal MaxMind Web Service API", | ||||
|         "homepage": "https://github.com/maxmind/web-service-common-php" | ||||
|     }, | ||||
|     { | ||||
|         "name": "psr/cache", | ||||
|         "version": "1.0.1", | ||||
|         "version_normalized": "1.0.1.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/php-fig/cache.git", | ||||
|             "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", | ||||
|             "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "php": ">=5.3.0" | ||||
|         }, | ||||
|         "time": "2016-08-06T20:24:11+00:00", | ||||
|         "type": "library", | ||||
|         "extra": { | ||||
|             "branch-alias": { | ||||
|                 "dev-master": "1.0.x-dev" | ||||
|             } | ||||
|         }, | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "Psr\\Cache\\": "src/" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "PHP-FIG", | ||||
|                 "homepage": "http://www.php-fig.org/" | ||||
|             } | ||||
|         ], | ||||
|         "description": "Common interface for caching libraries", | ||||
|         "keywords": [ | ||||
|             "cache", | ||||
|             "psr", | ||||
|             "psr-6" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "s1lentium/iptools", | ||||
|         "version": "v1.1.1", | ||||
|         "version_normalized": "1.1.1.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/S1lentium/IPTools.git", | ||||
|             "reference": "f6f8ab6132ca7443bd7cced1681f5066d725fd5f" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/S1lentium/IPTools/zipball/f6f8ab6132ca7443bd7cced1681f5066d725fd5f", | ||||
|             "reference": "f6f8ab6132ca7443bd7cced1681f5066d725fd5f", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "ext-bcmath": "*", | ||||
|             "php": ">=5.4.0" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "phpunit/phpunit": "~4.0", | ||||
|             "satooshi/php-coveralls": "~1.0" | ||||
|         }, | ||||
|         "time": "2018-09-19T06:15:53+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "IPTools\\": "src/" | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Safarov Alisher", | ||||
|                 "email": "alisher.safarov@outlook.com", | ||||
|                 "homepage": "https://github.com/S1lentium" | ||||
|             } | ||||
|         ], | ||||
|         "description": "PHP Library for manipulating network addresses (IPv4 and IPv6)", | ||||
|         "keywords": [ | ||||
|             "IP", | ||||
|             "IP-Tools", | ||||
|             "cidr", | ||||
|             "ipv4", | ||||
|             "ipv6", | ||||
|             "network", | ||||
|             "subnet" | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "name": "whichbrowser/parser", | ||||
|         "version": "v2.0.37", | ||||
|         "version_normalized": "2.0.37.0", | ||||
|         "source": { | ||||
|             "type": "git", | ||||
|             "url": "https://github.com/WhichBrowser/Parser-PHP.git", | ||||
|             "reference": "9c6ad8eadc23294b1c66d92876c11f13c5d4cf48" | ||||
|         }, | ||||
|         "dist": { | ||||
|             "type": "zip", | ||||
|             "url": "https://api.github.com/repos/WhichBrowser/Parser-PHP/zipball/9c6ad8eadc23294b1c66d92876c11f13c5d4cf48", | ||||
|             "reference": "9c6ad8eadc23294b1c66d92876c11f13c5d4cf48", | ||||
|             "shasum": "" | ||||
|         }, | ||||
|         "require": { | ||||
|             "php": ">=5.4.0", | ||||
|             "psr/cache": "^1.0" | ||||
|         }, | ||||
|         "require-dev": { | ||||
|             "icomefromthenet/reverse-regex": "0.0.6.3", | ||||
|             "phpunit/php-code-coverage": "^2.2|^3.0", | ||||
|             "phpunit/phpunit": "^4.0|^5.0", | ||||
|             "satooshi/php-coveralls": "^1.0", | ||||
|             "squizlabs/php_codesniffer": "2.5.*", | ||||
|             "symfony/yaml": ">=2.8" | ||||
|         }, | ||||
|         "suggest": { | ||||
|             "cache/array-adapter": "Allows testing of the caching functionality" | ||||
|         }, | ||||
|         "time": "2018-10-02T09:26:41+00:00", | ||||
|         "type": "library", | ||||
|         "installation-source": "dist", | ||||
|         "autoload": { | ||||
|             "psr-4": { | ||||
|                 "WhichBrowser\\": [ | ||||
|                     "src/", | ||||
|                     "tests/src/" | ||||
|                 ] | ||||
|             } | ||||
|         }, | ||||
|         "notification-url": "https://packagist.org/downloads/", | ||||
|         "license": [ | ||||
|             "MIT" | ||||
|         ], | ||||
|         "authors": [ | ||||
|             { | ||||
|                 "name": "Niels Leenheer", | ||||
|                 "email": "niels@leenheer.nl", | ||||
|                 "role": "Developer" | ||||
|             } | ||||
|         ], | ||||
|         "description": "Useragent sniffing library for PHP", | ||||
|         "homepage": "http://whichbrowser.net", | ||||
|         "keywords": [ | ||||
|             "browser", | ||||
|             "sniffing", | ||||
|             "ua", | ||||
|             "useragent" | ||||
|         ] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										20
									
								
								wp-content/plugins/wp-statistics/includes/vendor/erusev/parsedown/LICENSE.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								wp-content/plugins/wp-statistics/includes/vendor/erusev/parsedown/LICENSE.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| The MIT License (MIT) | ||||
|  | ||||
| Copyright (c) 2013-2018 Emanuil Rusev, erusev.com | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||||
| this software and associated documentation files (the "Software"), to deal in | ||||
| the Software without restriction, including without limitation the rights to | ||||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||||
| subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										1693
									
								
								wp-content/plugins/wp-statistics/includes/vendor/erusev/parsedown/Parsedown.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1693
									
								
								wp-content/plugins/wp-statistics/includes/vendor/erusev/parsedown/Parsedown.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user