| 1 |
<?php |
| 2 |
//"top-10-counter.js.php" Display number of page views |
| 3 |
Header("content-type: application/x-javascript"); |
| 4 |
|
| 5 |
if (!function_exists('add_action')) { |
| 6 |
$wp_root = '../../..'; |
| 7 |
if (file_exists($wp_root.'/wp-load.php')) { |
| 8 |
require_once($wp_root.'/wp-load.php'); |
| 9 |
} else { |
| 10 |
require_once($wp_root.'/wp-config.php'); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
// Display counter using Ajax |
| 15 |
function tptn_disp_count() { |
| 16 |
global $wpdb; |
| 17 |
|
| 18 |
$table_name = $wpdb->prefix . "top_ten"; |
| 19 |
$table_name_daily = $wpdb->prefix . "top_ten_daily"; |
| 20 |
$tptn_settings = tptn_read_options(); |
| 21 |
$count_disp_form = htmlspecialchars(stripslashes($tptn_settings[count_disp_form])); |
| 22 |
|
| 23 |
$id = intval($_GET['top_ten_id']); |
| 24 |
if($id > 0) { |
| 25 |
|
| 26 |
$resultscount = $wpdb->get_row("select postnumber, cntaccess from $table_name WHERE postnumber = $id"); |
| 27 |
$cntaccess = number_format((($resultscount) ? $resultscount->cntaccess : 0)); |
| 28 |
$count_disp_form = str_replace("%totalcount%", $cntaccess, $count_disp_form); |
| 29 |
|
| 30 |
// Now process daily count |
| 31 |
$resultscount = $wpdb->get_row("select postnumber, cntaccess from $table_name_daily WHERE postnumber = $id"); |
| 32 |
$cntaccess = number_format((($resultscount) ? $resultscount->cntaccess : 0)); |
| 33 |
$count_disp_form = str_replace("%dailycount%", $cntaccess, $count_disp_form); |
| 34 |
|
| 35 |
echo 'document.write("'.$count_disp_form.'")'; |
| 36 |
} |
| 37 |
} |
| 38 |
tptn_disp_count(); |
| 39 |
?> |
| 40 |
|