PluginProbe
WebberZone Top 10 — Popular Posts / 1.2
WebberZone Top 10 — Popular Posts v1.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-addcount.js.php

top-10-addcount.js.php in WebberZone Top 10 — Popular Posts 1.2, at top-10-addcount.js.php

50 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //"top-10-addcount.js.php" Add count to database
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 // Ajax Increment Counter
15 tptn_inc_count();
16 function tptn_inc_count() {
17 global $wpdb;
18 $table_name = $wpdb->prefix . "top_ten";
19 $top_ten_daily = $wpdb->prefix . "top_ten_daily";
20
21 $id = intval($_GET['top_ten_id']);
22 if($id > 0) {
23 $results = $wpdb->get_results("select postnumber, cntaccess from $table_name where postnumber = '$id'");
24 $test = 0;
25 if ($results) {
26 foreach ($results as $result) {
27 $wpdb->query("update $table_name set cntaccess = cntaccess + 1 where postnumber = $result->postnumber");
28 $test = 1;
29 }
30 }
31 if ($test == 0) {
32 $wpdb->query("insert into $table_name (postnumber, cntaccess) values('$id', '1')");
33 }
34 // Now update daily count
35 $results = $wpdb->get_results("select postnumber, cntaccess from $top_ten_daily where postnumber = '$id'");
36 $test = 0;
37 if ($results) {
38 foreach ($results as $result) {
39 $wpdb->query("update $top_ten_daily set cntaccess = cntaccess + 1 where postnumber = $result->postnumber");
40 $test = 1;
41 }
42 }
43 if ($test == 0) {
44 $wpdb->query("insert into $top_ten_daily (postnumber, cntaccess) values('$id', '1')");
45 }
46 }
47 }
48
49 ?>
50