BVB Source Codes

Vehicle AdLogger v1.4.0 shu han edition Show update_stats.php Source code

Return Download Vehicle AdLogger v1.4.0 shu han edition: download update_stats.php Source code - Download Vehicle AdLogger v1.4.0 shu han edition Source code - Type:.php
  1. <?php
  2. /*#################################################################################
  3.         AdLogger
  4.         - An open-source tracking tool for preventing click fraud
  5.  
  6.         Copyright 2006 by Trevor Fitzgerald
  7.         http://www.adlogger.org
  8.  
  9.         This program is free software; you can redistribute it and/or
  10.         modify it under the terms of the GNU General Public License
  11.         as published by the Free Software Foundation; either version 2
  12.         of the License, or (at your option) any later version.
  13.  
  14.         This program is distributed in the hope that it will be useful,
  15.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.         GNU General Public License for more details.
  18.  
  19.         You should have received a copy of the GNU General Public License
  20.         along with this program; if not, write to the Free Software
  21.         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  22.  
  23.         If you find this script useful, please share it with others!
  24.  
  25.         Thank you!
  26. */#################################################################################
  27.  
  28. require ("../config_database.php");
  29. require ("../config_settings.php");
  30. require ("../config_admin.php");
  31. require ("./loginverify.php");
  32. require ("./functions.php");
  33.  
  34. /*
  35.  * Find out what the user is trying to update.
  36.  * If nothing was passed to the URL, produce an error
  37.  * because this page is not meant to be accessed directly.
  38.  */
  39. if (isset($_GET['update']) && !empty($_GET['update'])) {
  40.         $update = $_GET['update'];
  41. } else {
  42.         $start_time = micro_time(0);
  43.         bodyHeader('error', $version_num);
  44.         bodyNavigation('error'); ?>
  45.                 <h1>Error!</h1>
  46.                 <p>No update action has been specified. What are you trying to update?</p>
  47.                 </div>
  48.         <?php bodyFooter('error', $start_time); exit();
  49. }
  50.  
  51.  
  52. /*
  53.  * Optimize the ad_check logs table to purge all the old and unneccessary data.
  54.  * It will delete anything older than the clickmaxtime variable.
  55.  */
  56. $backlog_timeframe = $timestamp - $clickmaxtime;
  57. mysql_query("DELETE FROM " . $db_table_prefix . "adcheck_logs WHERE timestamp < '$backlog_timeframe'");
  58. mysql_query("OPTIMIZE TABLE " . $db_table_prefix . "adcheck_logs");
  59.  
  60.  
  61. /*
  62.  * If the user is trying to update the index stats,
  63.  * perform this code to do that.
  64.  */
  65. if ($update == 'index') {
  66.  
  67.         /*
  68.          * Go through each of the date ranges and count the
  69.          * number of clicks that exist for each of them.
  70.          */
  71.         // For today:
  72.                 $today_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp), date('Y', $timestamp));
  73.                 // All clicks:
  74.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$today_timestamp'");
  75.                         $row = mysql_fetch_array($result);
  76.                         $click_count_today = $row['COUNT(id)'];
  77.                 // Unique clicks:
  78.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$today_timestamp'");
  79.                         $row = mysql_fetch_array($result);
  80.                         $unique_visitors_click_today = $row['COUNT(DISTINCT visitor_ip)'];
  81.                 // Ad clicks:
  82.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_as' AND timestamp >= '$today_timestamp'");
  83.                         $row = mysql_fetch_array($result);
  84.                         $ad_clicks_today = $row['COUNT(id)'];
  85.                 // Link clicks:
  86.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_0ads_al%' AND timestamp >= '$today_timestamp'");
  87.                         $row = mysql_fetch_array($result);
  88.                         $link_clicks_today = $row['COUNT(id)'];
  89.  
  90.         // For yesterday:
  91.                 $yesterday_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp) - 1, date('Y', $timestamp));
  92.                 // All clicks:
  93.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$yesterday_timestamp' AND timestamp < $today_timestamp");
  94.                         $row = mysql_fetch_array($result);
  95.                         $click_count_yesterday = $row['COUNT(id)'];
  96.                 // Unique clicks:
  97.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$yesterday_timestamp' AND timestamp < $today_timestamp");
  98.                         $row = mysql_fetch_array($result);
  99.                         $unique_visitors_click_yesterday = $row['COUNT(DISTINCT visitor_ip)'];
  100.                 // Ad clicks:
  101.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_as' AND timestamp >= '$yesterday_timestamp' AND timestamp < '$today_timestamp'");
  102.                         $row = mysql_fetch_array($result);
  103.                         $ad_clicks_yest = $row['COUNT(id)'];
  104.                 // Link clicks:
  105.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_0ads_al%' AND timestamp >= '$yesterday_timestamp' AND timestamp < '$today_timestamp'");
  106.                         $row = mysql_fetch_array($result);
  107.                         $link_clicks_yest = $row['COUNT(id)'];
  108.  
  109.         // For this week:
  110.                 $weekago_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp) - 7, date('Y', $timestamp));
  111.                 // All clicks:
  112.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$weekago_timestamp'");
  113.                         $row = mysql_fetch_array($result);
  114.                         $click_count_week = $row['COUNT(id)'];
  115.                 // Unique clicks:
  116.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "logfiles WHERE timestamp >= '$weekago_timestamp'");
  117.                         $row = mysql_fetch_array($result);
  118.                         $unique_visitors_click_week = $row['COUNT(DISTINCT visitor_ip)'];
  119.                 // Ad clicks:
  120.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_as' AND timestamp >= '$weekago_timestamp'");
  121.                         $row = mysql_fetch_array($result);
  122.                         $ad_clicks_week = $row['COUNT(id)'];
  123.                 // Link clicks:
  124.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_0ads_al%' AND timestamp >= '$weekago_timestamp'");
  125.                         $row = mysql_fetch_array($result);
  126.                         $link_clicks_week = $row['COUNT(id)'];
  127.        
  128.         // Overall
  129.                 // All clicks:
  130.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles");
  131.                         $row = mysql_fetch_array($result);
  132.                         $click_count_overall = $row['COUNT(id)'];
  133.                 // Unique clicks:
  134.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "logfiles");
  135.                         $row = mysql_fetch_array($result);
  136.                         $unique_visitors_click = $row['COUNT(DISTINCT visitor_ip)'];
  137.                 // Ad clicks:
  138.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_as'");
  139.                         $row = mysql_fetch_array($result);
  140.                         $ad_clicks_overall = $row['COUNT(id)'];
  141.                 // Link clicks:
  142.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "logfiles WHERE format LIKE '%_0ads_al%'");
  143.                         $row = mysql_fetch_array($result);
  144.                         $link_clicks_overall = $row['COUNT(id)'];
  145.  
  146.         /*
  147.          * Finally, update the QuickStats table with all those values.
  148.          */
  149.         $sql = "
  150.                         UPDATE " . $db_table_prefix . "quickstats
  151.                                 SET `last_update_time` = " . $timestamp . ",
  152.                                         `index.today.total` = " . $click_count_today . ",
  153.                                         `index.today.unique` = " . $unique_visitors_click_today . ",
  154.                                         `index.today.ads` = " . $ad_clicks_today . ",
  155.                                         `index.today.links` = " . $link_clicks_today . ",
  156.                                         `index.yesterday.total` = " . $click_count_yesterday . ",
  157.                                         `index.yesterday.unique` = " . $unique_visitors_click_yesterday . ",
  158.                                         `index.yesterday.ads` = " . $ad_clicks_yest . ",
  159.                                         `index.yesterday.links` = " . $link_clicks_yest . ",
  160.                                         `index.week.total` = " . $click_count_week . ",
  161.                                         `index.week.unique` = " . $unique_visitors_click_week . ",
  162.                                         `index.week.ads` = " . $ad_clicks_week . ",
  163.                                         `index.week.links` = " . $link_clicks_week . ",
  164.                                         `index.overall.total` = " . $click_count_overall . ",
  165.                                         `index.overall.unique` = " . $unique_visitors_click . ",
  166.                                         `index.overall.ads` = " . $ad_clicks_overall . ",
  167.                                         `index.overall.links` = " . $link_clicks_overall . "
  168.                                 WHERE `id` = '1'
  169.                         ";
  170.         $result = mysql_query($sql);
  171.  
  172. /*
  173.  * If the person is trying to update the blocked stats,
  174.  * perform this code.
  175.  */
  176. } elseif ($update == 'blocks') {
  177.         /*
  178.          * First, delete any blocked entries that are older than one week.
  179.          */
  180.         $backlog_timeframe = $timestamp - 7*24*60*60;
  181.         mysql_query("DELETE FROM " . $db_table_prefix . "blocklogs WHERE timestamp < '$backlog_timeframe'");
  182.         mysql_query("OPTIMIZE TABLE " . $db_table_prefix . "blocklogs");
  183.  
  184.         /*
  185.          * Go through each of the date ranges and count the
  186.          * number of blocks that exist for each of them.
  187.          */
  188.         // For today:
  189.                 $today_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp), date('Y', $timestamp));
  190.                 // All blocks:
  191.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$today_timestamp'");
  192.                         $row = mysql_fetch_array($result);
  193.                         $block_count_today = $row['COUNT(id)'];
  194.                 // Unique blocks:
  195.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$today_timestamp'");
  196.                         $row = mysql_fetch_array($result);
  197.                         $block_visitors_today = $row['COUNT(DISTINCT visitor_ip)'];
  198.        
  199.         // For yesterday:
  200.                 $yesterday_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp) - 1, date('Y', $timestamp));
  201.                 // All blocks:
  202.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$yesterday_timestamp' AND timestamp < '$today_timestamp'");
  203.                         $row = mysql_fetch_array($result);
  204.                         $block_count_yesterday = $row['COUNT(id)'];
  205.                 // Unique blocks:
  206.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$yesterday_timestamp' AND timestamp < '$today_timestamp'");
  207.                         $row = mysql_fetch_array($result);
  208.                         $block_visitors_yesterday = $row['COUNT(DISTINCT visitor_ip)'];
  209.        
  210.         // For this week:
  211.                 $weekago_timestamp = mktime(0, 0, 0, date('n', $timestamp), date('d', $timestamp) - 7, date('Y', $timestamp));
  212.                 // All blocks:
  213.                 $result = mysql_query("SELECT COUNT(id) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$weekago_timestamp'");
  214.                         $row = mysql_fetch_array($result);
  215.                         $block_count_week = $row['COUNT(id)'];
  216.                 // Unique blocks:
  217.                 $result = mysql_query("SELECT COUNT(DISTINCT visitor_ip) FROM " . $db_table_prefix . "blocklogs WHERE timestamp >= '$weekago_timestamp'");
  218.                         $row = mysql_fetch_array($result);
  219.                         $block_visitors_week = $row['COUNT(DISTINCT visitor_ip)'];
  220.  
  221.         /*
  222.          * Finally, update the QuickStats table with all those values.
  223.          */
  224.         $sql = "
  225.                         UPDATE " . $db_table_prefix . "quickstats
  226.                                 SET `last_update_time` = " . $timestamp . ",
  227.                                         `block.today.total` = " . $block_count_today . ",
  228.                                         `block.today.unique` = " . $block_visitors_today . ",
  229.                                         `block.yesterday.total` = " . $block_count_yesterday . ",
  230.                                         `block.yesterday.unique` = " . $block_visitors_yesterday . ",
  231.                                         `block.week.total` = " . $block_count_week . ",
  232.                                         `block.week.unique` = " . $block_visitors_week . "
  233.                                 WHERE `id` = 2
  234.                         ";
  235.         $result = mysql_query($sql);
  236.  
  237. /*
  238.  * If the person is trying to update the database size variable,
  239.  * perform this code.
  240.  */
  241. } elseif ($update == 'db_size') {
  242.  
  243.         /*
  244.          * Declare an array that will query each table to find out the size of each.
  245.          */
  246.         $sql[0] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "adcheck_logs\"";
  247.         $sql[1] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "blocklogs\"";
  248.         $sql[2] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "channels\"";
  249.         $sql[3] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "logfiles\"";
  250.         $sql[4] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "quickstats\"";
  251.         $sql[5] = "SHOW TABLE STATUS LIKE \"" . $db_table_prefix . "users\"";
  252.  
  253.         $db_size = 0;
  254.  
  255.         // Go through and perform each of those queries
  256.         foreach($sql as $query) {
  257.                 $result = mysql_query($query);
  258.                         $row = mysql_fetch_array($result);
  259.                                 // Calculate the size of that table based on the data and index length.
  260.                                 $db_size += $row['Data_length'] + $row['Index_length'];
  261.         }
  262.  
  263.         // Finally, update the quickstats table with those values.
  264.         $sql = "UPDATE " . $db_table_prefix . "quickstats
  265.                                 SET `last_update_time` = " . $timestamp . ",
  266.                                         `db_size` = " . $db_size . "
  267.                                 WHERE `id` = 3
  268.                         ";
  269.         $result = mysql_query($sql);
  270.  
  271.         $_SESSION['changesuccess'] = "The database size has been successfully updated.";
  272.  
  273. } else {
  274.         /*
  275.          * If a differrent, invalid, update action was specified,
  276.          * produce an error.
  277.          */
  278.         $start_time = micro_time(0);
  279.         bodyHeader('error', $version_num);
  280.         bodyNavigation('error'); ?>
  281.                 <h1>Error!</h1>
  282.                 <p>An invalid update action has been specified.</p>
  283.                 </div>
  284.         <?php bodyFooter('error', $start_time); exit();
  285. }
  286.  
  287. /*
  288.  * If the referrer was passed via the URL, send the person
  289.  * back to where they came from.  Else just send them back
  290.  * to the index page.
  291.  */
  292. if (isset($_GET['ref']) && !empty($_GET['ref'])) {
  293.         $ref = $_GET['ref'];
  294. } else {
  295.         $ref = './';
  296. }
  297. header("Location: " . $ref);
  298. exit();
  299. ?>
downloadupdate_stats.php Source code - Download Vehicle AdLogger v1.4.0 shu han edition Source code
Related Source Codes/Software:
Flash voting system v1.2 - Modify the localization program abroad 2016-09-05
HpAdsNew v2.09 pr1 CMSware localization version - Can use it to build DoubleClick that third-party a... 2016-09-05
The Advanced Poll v2.08 multilingual version - Can set up multiple support voting procedures, can... 2016-09-05
Search (PHP edition v1.0 voting system - Search (PHP edition V1.0 voting system functions a... 2016-09-05
PHP character images online voting system v1.0.1 - The tripod with two handles peak network voting sy... 2016-09-04
Openads v2.0.11 multilingual version - A banner AD using PHP development management and t... 2016-09-05
Angel Upload Manager v1.0 - Ablog author works. Many friends asked me to, I wi... 2016-09-05
Good mood multi-user v1.1 news system - Function description: 2016-09-05
V2.0 prodigal news system - 1, article categories: unlimited categories, and i... 2016-09-05
PHPNovelС˵ϵͳv4.0.6 - PHPNovel is a set of using PHP + mysql database op... 2016-09-05
mockery - Mockery is a simple yet flexible PHP mock object f... 2017-03-31
redisson - Redisson - distributed Java objects and services (... 2017-03-31
flow.js - A JavaScript library providing multiple simultaneo... 2017-03-31
Google-Maps-for-Rails - Enables easy Google map + overlays creation in Rub... 2017-03-31
DCIntrospect - Small library of visual debugging tools for iOS. 2017-03-31
Mining-the-Social-Web-2nd-Edition - The official online compendium for Mining the Soci... 2017-03-31
TensorFlow-Book - Accompanying source code for Machine Learning with... 2017-03-31
js-interview-review - The JS interview review. As I'm reviewing several ... 2017-03-31
script.js - Asyncronous JavaScript loader and dependency manag... 2017-03-31
dex-method-counts - Command-line tool to count per-package methods in ... 2017-03-31

 Back to top