Sync plugins from current page

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-09-11 19:08:46 +02:00
parent 85d41e4216
commit 8515ff9587
1847 changed files with 505469 additions and 0 deletions

View File

@@ -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( 'Whats 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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}
}

View 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
}

View File

@@ -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>';
}

View File

@@ -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 );
}

View File

@@ -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>";
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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' );
}
}

View 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>";
}
}