| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wp-statistics/includes/log/widgets/ |
Upload File : |
<?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
}