PluginProbe
WebberZone Top 10 — Popular Posts / 1.5.2
WebberZone Top 10 — Popular Posts v1.5.2
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
top-10 / top-10-counter.js.php

top-10-counter.js.php in WebberZone Top 10 — Popular Posts 1.5.2, at top-10-counter.js.php

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $daily_range = $tptn_settings[daily_range]. ' DAY';
32 $current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL ".$daily_range."), INTERVAL 1 DAY) ");
33 $resultscount = $wpdb->get_row("SELECT postnumber, SUM(cntaccess) as sumCount FROM ".$table_name_daily." WHERE postnumber = ".$id." AND dp_date >= '".$current_date."' GROUP BY postnumber ");
34 $cntaccess = number_format((($resultscount) ? $resultscount->sumCount : 0));
35 $count_disp_form = str_replace("%dailycount%", $cntaccess, $count_disp_form);
36
37 echo 'document.write("'.$count_disp_form.'")';
38 }
39 }
40 tptn_disp_count();
41 ?>
42