public_html/wp-content/plugins/wp-statistics/includes/functions/functions.php
// This function get the visit statistics for a given time frame.
This function get the visit statistics for a given time frame.
This function get the visit statistics for a given time frame .
function wp_statistics_visit( $time, $daily = null ) {
		global $wpdb, $WP_Statistics;
		if( $daily == true ) {
			$result = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}'" );
			if( $result) {
				return $result->visit;
			} else {
				return 0;
			}
		} else {
			switch( $time ) {
				case 'today':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
					break;
				case 'yesterday':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` = '{$WP_Statistics->Current_Date( 'Y-m-d', -1 )}'" );
					break;
				case 'week':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -7 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
					break;
				case 'month':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -30 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
					break;
				case 'year':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', -365 )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
					break;
				case 'total':
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit" );
					$result += $WP_Statistics->Get_Historical_Data( 'visits' );
					break;
				default:
					$result = $wpdb->get_var( "SELECT SUM(visit) FROM {$wpdb->prefix}statistics_visit WHERE `last_counter` BETWEEN '{$WP_Statistics->Current_Date( 'Y-m-d', $time )}' AND '{$WP_Statistics->Current_Date( 'Y-m-d' )}'" );
					break;
			}
		}
		if( $result == null ) { $result = 0; }
		return $result;
	}
function wp_statistics_visit ( $ time , $ daily = null ) { global $ wpdb , $ WP_Statistics ; if ( $ daily == true ) { $ result = $ wpdb -> get_row ( " SELECT * FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` = ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , $ time ) } ' " ) ; if ( $ result ) { return $ result -> visit ; } else { return 0 ; } } else { switch ( $ time ) { case 'today' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` = ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' ) } ' " ) ; break ; case 'yesterday' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` = ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , - 1 ) } ' " ) ; break ; case 'week' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` BETWEEN ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , - 7 ) } ' AND ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' ) } ' " ) ; break ; case 'month' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` BETWEEN ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , - 30 ) } ' AND ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' ) } ' " ) ; break ; case 'year' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` BETWEEN ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , - 365 ) } ' AND ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' ) } ' " ) ; break ; case 'total' : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit " ) ; $ result += $ WP_Statistics -> Get_Historical_Data ( 'visits' ) ; break ; default : $ result = $ wpdb -> get_var ( " SELECT SUM(visit) FROM  { $ wpdb -> prefix } statistics_visit WHERE `last_counter` BETWEEN ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' , $ time ) } ' AND ' { $ WP_Statistics -> Current_Date ( 'Y-m-d' ) } ' " ) ; break ; } } if ( $ result == null ) { $ result = 0 ; } return $ result ; }
This function get the visit statistics for a given time frame.
This function get the visit statistics for a given time frame .
// We need database and the global $WP_Statistics object access. // If we've been asked to do a daily count, it's a slightly different SQL query, so handle it separately. // Fetch the results from the database. // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case. // This function accepts several options for time parameter, each one has a unique SQL query string. // They're pretty self explanatory. // If we have a result, return it, otherwise force a 0 to be returned instead of the logical FALSE that would otherwise be the case.