Sync plugins from current page
Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
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>";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user