- Timestamp:
- 02/12/08 14:08:39 (11 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
lib/action.php (modified) (1 diff)
-
lib/main.php (modified) (2 diffs)
-
wassup.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/action.php
r64 r73 42 42 $Tot->from_date = $from_date; 43 43 $Tot->to_date = $to_date; 44 $items_pie[] = $Tot->calc_tot(" items_by_type", $search, "spam");45 $items_pie[] = $Tot->calc_tot(" items_by_type", $search, "searchengine");46 $items_pie[] = $Tot->calc_tot(" items_by_type", $search, "referrer");47 $items_pie[] = $Tot->calc_tot(" items_by_type", $search, "direct");44 $items_pie[] = $Tot->calc_tot("count", $search, "AND spam>0", "DISTINCT"); 45 $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine!='' AND spam=0", "DISTINCT"); 46 $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND referrer NOT LIKE '%".$this->WpUrl."%' AND referrer!='' AND spam=0", "DISTINCT"); 47 $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND (referrer LIKE '%".$this->WpUrl."%' OR referrer='') AND spam=0", "DISTINCT"); 48 48 echo "<div align='center'><img src=http://chart.apis.google.com/chart?cht=p3&chco=0000ff&chs=600x300&chl=Spam|Search%20Engine|Referrer|Direct&chd=".chart_data($items_pie, null, null, null, 'pie')."></div>"; 49 49 // ACTION: DISPLAY RAW RECORDS -
trunk/lib/main.php
r72 r73 717 717 var $Limit; 718 718 var $Last; 719 var $Marked_ip;720 719 var $WpUrl; 721 720 722 721 // Function to show main query and count items 723 function calc_tot($Type, $Search="", $ pertype="") {722 function calc_tot($Type, $Search="", $specific_where_clause=null, $distinct_type=null) { 724 723 global $wpdb; 725 724 $this->ItemsType = $Type; … … 737 736 break; 738 737 // These are the queries to count the items hits/pages/spam 739 case " items":740 $itemstot = $wpdb->get_var("SELECT COUNT( DISTINCT wassup_id) AS itemstot FROM ".$this->tableName." WHERE wassup_id IS NOT NULLAND timestamp BETWEEN ".$this->from_date." AND ".$this->to_date." $ss ".$this->whereis);738 case "count": 739 $itemstot = $wpdb->get_var("SELECT COUNT(".$distinct_type." wassup_id) AS itemstot FROM ".$this->tableName." WHERE wassup_id IS NOT NULL ".$specific_where_clause." AND timestamp BETWEEN ".$this->from_date." AND ".$this->to_date." $ss ".$this->whereis); 741 740 return $itemstot; 742 break;743 case "pages":744 $pagestot = $wpdb->get_var("SELECT COUNT(wassup_id) AS pagestot FROM ".$this->tableName." WHERE wassup_id IS NOT NULL AND timestamp BETWEEN ".$this->from_date." AND ".$this->to_date." $ss ".$this->whereis);745 return $pagestot;746 break;747 case "spam":748 $spamtot = $wpdb->get_var("SELECT COUNT(wassup_id) AS spamtot FROM ".$this->tableName." WHERE wassup_id IS NOT NULL AND spam>0 AND timestamp BETWEEN ".$this->from_date." AND ".$this->to_date." $ss ".$this->whereis);749 return $spamtot;750 break;751 // Switch by specific count752 case "items_by_type":753 switch ($pertype) {754 case "spam":755 $items_type = "spam>0";756 break;757 case "marked":758 $items_type = "ip LIKE '%".$this->Marked_ip."%'";759 break;760 case "searchengine":761 $items_type = "searchengine!='' AND spam=0";762 break;763 case "referrer":764 $items_type = "searchengine='' AND referrer NOT LIKE '%".$this->WpUrl."%' AND referrer!='' AND spam=0";765 break;766 case "direct":767 $items_type = "searchengine='' AND (referrer LIKE '%".$this->WpUrl."%' OR referrer='') AND spam=0";768 break;769 }770 $itemstot_by_type = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) AS itemstot FROM ".$this->tableName." WHERE wassup_id IS NOT NULL AND $items_type AND timestamp BETWEEN ".$this->from_date." AND ".$this->to_date." $ss ".$this->whereis);771 return $itemstot_by_type;772 741 break; 773 742 } -
trunk/wassup.php
r71 r73 608 608 $Tot->WpUrl = $wpurl; 609 609 610 $itemstot = $Tot->calc_tot(" items", $search);611 $pagestot = $Tot->calc_tot(" pages", $search);612 $spamtot = $Tot->calc_tot(" spam", $search);610 $itemstot = $Tot->calc_tot("count", $search, null, "DISTINCT"); 611 $pagestot = $Tot->calc_tot("count", $search, null, null); 612 $spamtot = $Tot->calc_tot("count", $search, "AND spam>0"); 613 613 // Check if some records was marked 614 614 if ($wassup_settings['wmark'] == 1) { 615 $Tot->Marked_ip = $wassup_settings['wip']; 616 $markedtot = $Tot->calc_tot("items_by_type", $search, "marked"); 615 $markedtot = $Tot->calc_tot("count", $search, "AND ip LIKE '%".$wassup_settings['wip']."%'", "DISTINCT"); 617 616 } 618 617 … … 1100 1099 } 1101 1100 session_start(); //required to use/update $_SESSION 1101 1102 // Prevent Session Fixation attack (http://shiflett.org/articles/session-fixation) 1103 if (!isset($_SESSION['initiated'])) { 1104 session_regenerate_id(); 1105 $_SESSION['initiated'] = true; 1106 } 1107 1102 1108 //#confirm that session is started... 1103 1109 if (isset($_SESSION)) { … … 1280 1286 $insert = $wpdb->query( $wpdb->prepare("INSERT INTO $table_name (wassup_id, timestamp, ip, hostname, urlrequested, agent, referrer, search, searchpage, os, browser, language, screen_res, searchengine, spider, feed, username, comment_author, spam) 1281 1287 VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", 1282 $wassup_id,1283 $timestamp,1288 attribute_escape($wassup_id), 1289 attribute_escape($timestamp), 1284 1290 attribute_escape($ipAddress), 1285 1291 attribute_escape($hostname), … … 1287 1293 attribute_escape($userAgent), 1288 1294 attribute_escape($referrer), 1289 $search_phrase,1290 $searchpage,1291 $os,1292 $browser,1293 $language[0],1294 $screen_res,1295 $searchengine,1296 $spider,1297 $feed,1295 attribute_escape($search_phrase), 1296 attribute_escape($searchpage), 1297 attribute_escape($os), 1298 attribute_escape($browser), 1299 attribute_escape($language[0]), 1300 attribute_escape($screen_res), 1301 attribute_escape($searchengine), 1302 attribute_escape($spider), 1303 attribute_escape($feed), 1298 1304 attribute_escape($logged_user), 1299 1305 attribute_escape($comment_user), 1300 $spam1306 attribute_escape($spam) 1301 1307 )); 1302 1308 … … 1852 1858 $wassup_settings = get_option('wassup_settings'); 1853 1859 1854 if (isset($_POST[' submit']))1860 if (isset($_POST['wassup-submit'])) 1855 1861 { 1856 1862 $wassup_settings['wassup_widget_title'] = $_POST['wassup_widget_title']; … … 1875 1881 <div class="wrap" style="text-align:left"> 1876 1882 <h3>Wassup Widget</h3> 1877 <form action="" method="post">1878 1883 <p style="text-align:left"><input type="text" name="wassup_widget_title" size="20" value="<?php echo $wassup_settings['wassup_widget_title'] ?>" /> What title for the widget (default "Visitors Online")</p> 1879 1884 <p style="text-align:left"><input type="text" name="wassup_widget_ulclass" size="3" value="<?php echo $wassup_settings['wassup_widget_ulclass'] ?>" /> What style sheet class for <ul> attribute (default "links")</p> … … 1889 1894 <p style="text-align:left"><input type="checkbox" name="wassup_widget_topos" value="1" <?php if ($wassup_settings['wassup_widget_topos'] == 1) echo "CHECKED"; ?> /> Check if you want to show top operating systems (default Yes)</p> 1890 1895 <p style="text-align:left"><input type="text" name="wassup_widget_toposlimit" size="3" value="<?php echo $wassup_settings['wassup_widget_toposlimit'] ?>" /> How many top operating systems want to show (default 5)</p> 1891 <p style="text-align:left"><input type="submit" name="submit" value="Save Settings" /></p> 1892 </form> 1896 <p style="text-align:left"><input type="hidden" name="wassup-submit" id="wassup-submit" value="1" /> </p> 1893 1897 </div> 1894 1898 <?php … … 1900 1904 $wassup_settings['wassup_userlevel'] = 8; 1901 1905 update_option('wassup_settings', $wassup_settings); 1902 }1903 if ($wassup_settings['wassup_refresh'] == "") {1906 } 1907 if ($wassup_settings['wassup_refresh'] == "") { 1904 1908 $wassup_settings['wassup_refresh'] = 3; 1905 1909 update_option('wassup_settings', $wassup_settings);
