PageRenderTime 72ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/wassup/wassup.php

https://github.com/alx/alexgirard.com-blog
PHP | 2990 lines | 2137 code | 177 blank | 676 comment | 628 complexity | 5fff4a73495c4af5560905cd16522219 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. Plugin Name: WassUp
  4. Plugin URI: http://www.wpwp.org
  5. Description: Wordpress plugin to analyze your visitors traffic with real time stats, chart and a lot of chronological informations. It has sidebar Widget support to show current online visitors and other statistics.
  6. Version: 1.6.2
  7. Author: Michele Marcucci, Helene D.
  8. Author URI: http://www.michelem.org/
  9. Copyright (c) 2007 Michele Marcucci
  10. Released under the GNU General Public License (GPL)
  11. http://www.gnu.org/licenses/gpl.txt
  12. */
  13. //# Stop any attempt to call wassup.php directly. -Helene D. 1/27/08.
  14. if (preg_match('#'.basename(__FILE__) .'#', $_SERVER['PHP_SELF'])) {
  15. die('Permission Denied! You are not allowed to call this page directly.');
  16. }
  17. $version = "1.6.2";
  18. define('WASSUPFOLDER', dirname(plugin_basename(__FILE__)), TRUE);
  19. require_once(dirname(__FILE__).'/lib/wassup.class.php');
  20. require_once(dirname(__FILE__).'/lib/main.php');
  21. $wpurl = get_bloginfo('wpurl'); //global
  22. if (isset($_GET['export'])) {
  23. export_wassup();
  24. }
  25. global $wp_version;
  26. //#This works only in WP2.2 or higher
  27. if (version_compare($wp_version, '2.2', '<')) {
  28. wp_die( '<strong style="color:#c00;background-color:#dff;padding:5px;">'.__("Sorry, Wassup requires WordPress 2.2 or higher to work","wassup").'.</strong>');
  29. } elseif (function_exists('wp_cache_flush')) {
  30. //clear the WP cache
  31. wp_cache_flush(); //to prevent "cannot redeclare" errors???
  32. }
  33. //#add initial options and create table when Wassup activated
  34. // -Helene D. 2/26/08.
  35. function wassup_install() {
  36. global $wpdb;
  37. $table_name = $wpdb->prefix . "wassup";
  38. $table_tmp_name = $wpdb->prefix . "wassup_tmp";
  39. //### Add/update wassup settings in Wordpress options table
  40. $wassup_options = new wassupOptions; //#settings initialized here
  41. //# set hash
  42. $whash = $wassup_options->get_wp_hash();
  43. if (!empty($whash)) {
  44. $wassup_options->whash = $whash;
  45. }
  46. //# Add timestamp to optimize table once a day
  47. $wassup_options->wassup_optimize = wassup_get_time();
  48. //# set wmark and wip to null
  49. $wassup_options->wmark = 0; //#no preservation of delete/mark
  50. $wassup_options->wip = null;
  51. //### For upgrade of Wassup, manually initialize new settings
  52. //# initialize settings for 'spamcheck', 'refspam', and 'spam'
  53. if (!isset($wassup_options->wassup_spamcheck)) {
  54. $wassup_options->wassup_spamcheck = "0";
  55. //#set wassup_spamcheck=0 if wassup_refspam=0 and wassup_spam=0
  56. if (!isset($wassup_options->wassup_spam) && !isset($wassup_options->wassup_refspam)) {
  57. $wassup_options->wassup_spam = "1";
  58. $wassup_options->wassup_refspam = "1";
  59. } elseif ( $wassup_options->wassup_spam == "0" && $wassup_options->wassup_refspam == "0" ) {
  60. $wassup_options->wassup_spamcheck = "0";
  61. }
  62. }
  63. //# update wassup settings for 'savepath' (default is null)
  64. //$wassup_options->wassup_savepath = "/fakedirectory"; //#debug
  65. if (!isset($wassup_options->wassup_savepath)) {
  66. $wassup_options->wassup_savepath = null;
  67. }
  68. //# display google chart by default for upgrades from 1.4.4
  69. if (!isset($wassup_options->wassup_chart)) {
  70. $wassup_options->wassup_chart = 1;
  71. }
  72. //# assign top ten items for upgrades from 1.4.9 or less
  73. if (empty($wassup_options->wassup_top10)) {
  74. $wassup_options->wassup_top10 = serialize(array("topsearch"=>"1",
  75. "topreferrer"=>"1",
  76. "toprequest"=>"1",
  77. "topbrowser"=>"1",
  78. "topos"=>"1",
  79. "toplocale"=>"0",
  80. "topfeed"=>"0",
  81. "topcrawler"=>"0",
  82. "topvisitor"=>"0",
  83. "topreferrer_exclude"=>""));
  84. }
  85. //#upgrade from 1.6: new options wassup_time_format and wassup_hack
  86. if (!isset($wassup_options->wassup_time_format)) {
  87. $wassup_options->wassup_time_format = 24;
  88. }
  89. if (!isset($wassup_options->wassup_hack)) {
  90. $wassup_options->wassup_hack = 1;
  91. }
  92. $wassup_options->saveSettings();
  93. //### Detect problems with WassUp install and show warning
  94. //#
  95. //#Check for problems with 'session_savepath' and disable
  96. //# recording, if found. -Helene D. 2/24/08
  97. /*
  98. $sessionpath = $wassup_options->wassup_savepath;
  99. if (empty($sessionpath)) { $sessionpath = getSessionpath(); }
  100. //default to "/tmp" if no sessionpath value
  101. if (empty($sessionpath)) {
  102. $sessionpath = "/tmp";
  103. $wassup_options->wassup_savepath = $sessionpath;
  104. }
  105. if ($wassup_options->isWritableFolder($sessionpath) == false) {
  106. if ($wassup_options->wassup_active == "1") {
  107. $wassup_options->wassup_active = "0";
  108. $wassup_options->wassup_alert_message = __('WassUp has detected a problem with "session.save_path" setting in your Wordpress/PHP configuration. Statistics logging has been disabled as a result. To fix, go to admin menu, "Wassup-->Options-->Manage Files & Database" and modify "Temporary files location folder".','wassup');
  109. } else {
  110. $wassup_options->wassup_alert_message = __('WassUp has detected a problem with "session.save_path" setting in your Wordpress/PHP configuration. Please fix by modifying "Temporary files location folder" in admin menu, "Wassup-->Options-->Manage Files & Database".','wassup');
  111. }
  112. }
  113. $wassup_options->saveSettings();
  114. unset($sessionpath); //because "install" works in global scope
  115. */
  116. //# TODO:
  117. //###Detect known incompatible plugins like "wp_cache" and disable
  118. //# recordings and show warning message...
  119. //### Create/upgrade wassup MAIN table
  120. if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
  121. CreateTable($table_name);
  122. CreateTable($table_tmp_name);
  123. } else {
  124. UpdateTable(); //<== wassup_tmp is added here, if missing
  125. }
  126. } //#end function wassup_install
  127. //set global variables that are dependent on Wassup's wp_options values
  128. $wassup_settings = get_option('wassup_settings'); //temp only..
  129. $wassup_options = new wassupOptions;
  130. //$wassup_options->loadSettings(); //done automatically
  131. $whash = $wassup_options->whash; //global...
  132. //#Completely remove all wassup tables and options from Wordpress when
  133. //# the 'wassup_uninstall' option is set and plugin is deactivated.
  134. //# -Helene D. 2/26/08
  135. function wassup_uninstall() {
  136. global $wassup_options, $wpdb;
  137. if ($wassup_options->wassup_uninstall == "1") {
  138. $table_name = $wpdb->prefix . "wassup";
  139. $table_tmp_name = $wpdb->prefix . "wassup_tmp";
  140. //$wpdb->query("DROP TABLE IF EXISTS $table_name"); //incorrectly causes an activation error in Wordpress
  141. //$wpdb->query("DROP TABLE IF EXISTS $table_tmp_name"); //incorrectly causes an activation error in Wordpress
  142. mysql_query("DROP TABLE IF EXISTS $table_tmp_name");
  143. mysql_query("DROP TABLE IF EXISTS $table_name");
  144. $wassup_options->deleteSettings();
  145. }
  146. } //#end function wassup_uninstall
  147. function add_wassup_meta_info() {
  148. global $version;
  149. print '<meta name="wassup-version" content="'.$version.'" />';
  150. }
  151. //# Wassup init hook actions performed before headers are sent:
  152. //# -Load jquery AJAX library and dependent javascripts for admin menus
  153. //# -Load language/localization files for admin menus and widget
  154. //# -Set 'wassup' cookie for new visitor hits
  155. function wassup_init() {
  156. global $wpurl;
  157. //### Add wassup scripts to Wassup Admin pages...
  158. if (stristr($_GET['page'],'wassup') !== FALSE) {
  159. if ( function_exists('wp_deregister_script')) {
  160. //removes old jquery vers.
  161. wp_deregister_script('jquery');
  162. }
  163. // the safe way to load jquery into WP
  164. wp_register_script('jquery', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/jquery.js',FALSE,'1.2.6');
  165. if ($_GET['page'] == "wassup-spy") {
  166. //the safe way to load a jquery dependent script
  167. wp_enqueue_script('spy', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/spy.js', array('jquery'), '1.4');
  168. } elseif($_GET['page'] == "wassup-options") {
  169. wp_enqueue_script('ui.base', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/ui.base.js', array('jquery'), '3');
  170. wp_enqueue_script('ui.tabs', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/ui.tabs.js', array('jquery'), '3');
  171. } else {
  172. //the safe way to load a jquery dependent script
  173. wp_enqueue_script('thickbox', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.js', array('jquery'), '3');
  174. }
  175. }
  176. //Loading language file...
  177. //Doesn't work if the plugin file has its own directory.
  178. //Let's make it our way... load_plugin_textdomain() searches only in the wp-content/plugins dir.
  179. $currentLocale = get_locale();
  180. if(!empty($currentLocale)) {
  181. $moFile = dirname(__FILE__) . "/language/" . $currentLocale . ".mo";
  182. if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('wassup', $moFile);
  183. }
  184. //Set Wassup cookie for visitor hits before headers are sent
  185. //add_action('init', 'wassupPrepend');
  186. if (!is_admin()) { //exclude wordpress admin page visits
  187. wassupPrepend();
  188. }
  189. } // end function wassup_init
  190. //Add the wassup stylesheet and other javascripts...
  191. function add_wassup_css() {
  192. global $wpurl, $wassup_options, $whash;
  193. //assign a value to whash, if none
  194. if ($whash == "") {
  195. $whash = $wassup_options->get_wp_hash();
  196. $wassup_options->whash = $whash; //save new hash
  197. $wassup_options->saveSettings();
  198. }
  199. $plugin_page = attribute_escape($_GET['page']);
  200. if (stristr($plugin_page,'wassup') !== FALSE) { $plugin_page="wassup"; }
  201. //Add css and javascript to wassup menu pages only...
  202. if ($plugin_page == "wassup") {
  203. //$wassup_settings = get_option('wassup_settings');
  204. echo "\n".'<script type="text/javascript">var tb_pathToImage = "'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/loadingAnimation.gif";</script>';
  205. echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.css'.'" type="text/css" />';
  206. echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/ui.tabs.css'.'" type="text/css" />';
  207. echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/wassup.css'.'" type="text/css" />'."\n";
  208. if ($_GET['page'] != "wassup-options" AND $_GET['page'] != "wassup-spy") { ?>
  209. <script type='text/javascript'>
  210. //<![CDATA[
  211. function selfRefresh(){
  212. location.href='?<?php print $_SERVER['QUERY_STRING']; ?>';
  213. }
  214. setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000); ?>);
  215. //]]>
  216. </script>
  217. <script type='text/javascript'>
  218. //<![CDATA[
  219. var _countDowncontainer="0";
  220. var _currentSeconds="0";
  221. function ActivateCountDown(strContainerID, initialValue) {
  222. _countDowncontainer = document.getElementById(strContainerID);
  223. SetCountdownText(initialValue);
  224. window.setTimeout("CountDownTick()", 1000);
  225. }
  226. function CountDownTick() {
  227. SetCountdownText(_currentSeconds-1);
  228. window.setTimeout("CountDownTick()", 1000);
  229. }
  230. function SetCountdownText(seconds) {
  231. //store:
  232. _currentSeconds = seconds;
  233. //build text:
  234. var strText = AddZero(seconds);
  235. //apply:
  236. if (_countDowncontainer) { //prevents error in "Options" submenu
  237. _countDowncontainer.innerHTML = strText;
  238. }
  239. }
  240. function AddZero(num) {
  241. return ((num >= "0")&&(num < 10))?"0"+num:num+"";
  242. }
  243. //]]>
  244. </script>
  245. <script type="text/javascript">
  246. //<![CDATA[
  247. window.onload=WindowLoad;
  248. function WindowLoad(event) {
  249. ActivateCountDown("CountDownPanel", <?php print ($wassup_options->wassup_refresh * 60); ?>);
  250. }
  251. //]]>
  252. </script>
  253. <script type="text/javascript">
  254. //<![CDATA[
  255. jQuery(document).ready(function($){
  256. $("a.showhide").click(function(){
  257. var id = $(this).attr('id');
  258. $("div.navi" + id).toggle("slow");
  259. return false;
  260. });
  261. $("a.toggleagent").click(function(){
  262. var id = $(this).attr('id');
  263. $("div.naviagent" + id).slideToggle("slow");
  264. return false;
  265. });
  266. $("a.deleteID").click(function(){
  267. var id = $(this).attr('id');
  268. $.ajax({
  269. url: "<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=delete&whash='.$whash; ?>&id=" + id,
  270. async: false
  271. })
  272. $("div.delID" + id).fadeOut("slow");
  273. return false;
  274. });
  275. $("a.show-search").toggle(function(){
  276. $("div.search-ip").slideDown("slow");
  277. $("a.show-search").html("<a href='#' class='show-search'><?php _e("Hide Search", "wassup") ?></a>");
  278. },function() {
  279. $("div.search-ip").slideUp("slow");
  280. $("a.show-search").html("<a href='#' class='show-search'><?php _e("Search", "wassup") ?></a>");
  281. return false;
  282. });
  283. $("a.show-topten").toggle(function(){
  284. $("div.topten").slideDown("slow");
  285. $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Hide TopTen", "wassup") ?></a>");
  286. },function() {
  287. $("div.topten").slideUp("slow");
  288. $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Show TopTen", "wassup") ?></a>");
  289. return false;
  290. });
  291. $("a.toggle-all").toggle(function() {
  292. $("div.togglenavi").slideDown("slow");
  293. $("a.toggle-all").html("<a href='#' class='toggle-all'><?php _e("Collapse All", "wassup") ?></a>");
  294. },function() {
  295. $("div.togglenavi").slideUp("slow");
  296. $("a.toggle-all").html("<a href='#' class='toggle-all'><?php _e("Expand All", "wassup") ?></a>");
  297. return false;
  298. });
  299. $("a.toggle-allcrono").toggle(function() {
  300. $("div.togglecrono").slideUp("slow");
  301. $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'><?php _e("Expand Cronology", "wassup") ?></a>");
  302. },function() {
  303. $("div.togglecrono").slideDown("slow");
  304. $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'><?php _e("Collapse Cronology", "wassup") ?></a>");
  305. return false;
  306. });
  307. }); //end jQuery(document).ready
  308. //]]>
  309. </script>
  310. <?php } //end if page != wassup-options ?>
  311. <script type='text/javascript'>
  312. //<![CDATA[
  313. function go()
  314. {
  315. box = document.forms["0"].navi;
  316. destination = box.options[box.selectedindex].value;
  317. if (destination) location.href = destination;
  318. }
  319. function go2()
  320. {
  321. box2 = document.forms["0"].type;
  322. destination2 = box2.options[box2.selectedindex].value;
  323. if (destination2) location.href = destination2;
  324. }
  325. //]]>
  326. </script>
  327. <?php
  328. if ($_GET['page'] == "wassup-options") {
  329. //#Current active tabs are indentified after page reload with
  330. //# either $_GET['tab']=N or $_POST['submit-optionsN'] where
  331. //# N=tab number. The tab is then activated directly in
  332. //# "settings.php" with <li class="ui-tabs-selected">
  333. ?>
  334. <script type="text/javascript">
  335. //<![CDATA[
  336. jQuery(document).ready(function($) {
  337. $('#tabcontainer > ul').tabs({ fx: { opacity: 'toggle' } });
  338. });
  339. //]]>
  340. </script>
  341. <?php
  342. } elseif ($_GET['page'] == "wassup-spy") {
  343. //## Filter detail lists by visitor type...
  344. if (isset($_GET['spytype'])) {
  345. $spytype = htmlentities(attribute_escape($_GET['spytype']));
  346. $wassup_options->wassup_default_spy_type = $spytype;
  347. } elseif ($wassup_options->wassup_default_spy_type != '') {
  348. $spytype = $wassup_options->wassup_default_spy_type;
  349. }
  350. $wassup_options->saveSettings();
  351. ?>
  352. <script type="text/javascript">
  353. //<![CDATA[
  354. jQuery(document).ready(function($){
  355. $('#spyContainer > div:gt(4)').fadeEachDown(); // initial fade
  356. $('#spyContainer').spy({
  357. limit: 10,
  358. fadeLast: 5,
  359. ajax: '<?php echo $wpurl."/wp-content/plugins/".WASSUPFOLDER."/lib/action.php?action=spy&whash=$whash&spytype=$spytype"; ?>',
  360. timeout: 2000,
  361. 'timestamp': myTimestamp,
  362. fadeInSpeed: 1100 });
  363. });
  364. function myTimestamp() {
  365. var d = new Date();
  366. var timestamp = d.getFullYear() + '-' + pad(d.getMonth()) + '-' + pad(d.getDate());
  367. timestamp += ' ';
  368. timestamp += pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds());
  369. return timestamp;
  370. }
  371. // pad ensures the date looks like 2006-09-13 rather than 2006-9-13
  372. function pad(n) {
  373. n = n.toString();
  374. return (n.length == 1 ? '0' + n : n);
  375. }
  376. //]]>
  377. </script>
  378. <?php } //end if page == "wassup-spy"
  379. } //end if plugin_page == "wassup"
  380. } //end function add_wassup_css()
  381. //put WassUp in the top-level admin menu and add submenus....
  382. function wassup_add_pages() {
  383. global $wassup_options;
  384. $userlevel = $wassup_options->wassup_userlevel;
  385. if (empty($userlevel)) { $userlevel = 8; }
  386. // add the default submenu first (important!)...
  387. add_submenu_page(WASSUPFOLDER, __('Visitor Details', 'wassup'), __('Visitor Details', 'wassup'), $userlevel, WASSUPFOLDER, 'WassUp'); //<-- WASSUPFOLDER needed here for directory names that include a version number...
  388. // then add top menu and other submenus...
  389. add_menu_page('Wassup', 'WassUp', $userlevel, WASSUPFOLDER, 'Wassup');
  390. add_submenu_page(WASSUPFOLDER, __('Spy Visitors', 'wassup'), __('SPY Visitors', 'wassup'), $userlevel, 'wassup-spy', 'WassUp');
  391. add_submenu_page(WASSUPFOLDER, __('Current Visitors Online', 'wassup'), __('Current Visitors Online', 'wassup'), $userlevel, 'wassup-online', 'WassUp');
  392. add_submenu_page(WASSUPFOLDER, __('Options', 'wassup'), __('Options', 'wassup'), $userlevel, 'wassup-options', 'WassUp');
  393. }
  394. function WassUp() {
  395. global $wpdb, $wp_version, $version, $wpurl, $wassup_options, $whash;
  396. // Start getting time of execution to debug SQL query
  397. $mtime = microtime();
  398. $mtime = explode(" ",$mtime);
  399. $mtime = $mtime[1] + $mtime[0];
  400. $starttime = $mtime;
  401. // This could be commented out
  402. //#debug...
  403. //error_reporting(E_ALL | E_STRICT); //debug, E_STRICT=php5 only
  404. //ini_set('display_errors','On'); //debug
  405. //$wpdb->show_errors(); //debug
  406. $table_name = $wpdb->prefix . "wassup";
  407. $table_tmp_name = $wpdb->prefix . "wassup_tmp";
  408. $wassup_options->loadSettings(); //needed in case "update_option is run elsewhere in wassup (widget)
  409. // RUN THE SAVE/RESET OPTIONS
  410. $admin_message="";
  411. if (isset($_POST['submit-options']) ||
  412. isset($_POST['submit-options2']) ||
  413. isset($_POST['submit-options3'])) {
  414. if ($_POST['wassup_remind_flag'] == 1 AND $_POST['wassup_remind_mb'] == "") {
  415. $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag'];
  416. $wassup_options->wassup_remind_mb = 10;
  417. } else {
  418. $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag'];
  419. $wassup_options->wassup_remind_mb = $_POST['wassup_remind_mb'];
  420. }
  421. $wassup_options->wassup_active = $_POST['wassup_active'];
  422. $wassup_options->wassup_chart_type = $_POST['wassup_chart_type'];
  423. $wassup_options->wassup_loggedin = $_POST['wassup_loggedin'];
  424. $wassup_options->wassup_spider = $_POST['wassup_spider'];
  425. $wassup_options->wassup_attack = $_POST['wassup_attack'];
  426. $wassup_options->wassup_hack = $_POST['wassup_hack'];
  427. $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck'];
  428. $wassup_options->wassup_spam = $_POST['wassup_spam'];
  429. $wassup_options->wassup_refspam = $_POST['wassup_refspam'];
  430. $wassup_options->wassup_exclude = $_POST['wassup_exclude'];
  431. $wassup_options->wassup_exclude_url = $_POST['wassup_exclude_url'];
  432. $wassup_options->delete_auto = $_POST['delete_auto'];
  433. $wassup_options->delete_auto_size = $_POST['delete_auto_size'];
  434. $wassup_options->wassup_screen_res = $_POST['wassup_screen_res'];
  435. $wassup_options->wassup_refresh = $_POST['wassup_refresh'];
  436. $wassup_options->wassup_userlevel = $_POST['wassup_userlevel'];
  437. $wassup_options->wassup_dashboard_chart = $_POST['wassup_dashboard_chart'];
  438. $wassup_options->wassup_geoip_map = $_POST['wassup_geoip_map'];
  439. $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key'];
  440. $wassup_options->wassup_time_format = $_POST['wassup_time_format'];
  441. $wassup_options->wassup_default_type = $_POST['wassup_default_type'];
  442. $wassup_options->wassup_default_limit = $_POST['wassup_default_limit'];
  443. $top_ten = array("topsearch" => $_POST['topsearch'],
  444. "topreferrer" => $_POST['topreferrer'],
  445. "toprequest" => $_POST['toprequest'],
  446. "topbrowser" => $_POST['topbrowser'],
  447. "topos" => $_POST['topos'],
  448. "toplocale" => $_POST['toplocale'],
  449. "topvisitor" => $_POST['topvisitor'],
  450. "topfeed" => "0",
  451. "topcrawler" => "0",
  452. "topreferrer_exclude" => $_POST['topreferrer_exclude']);
  453. $wassup_options->wassup_top10 = serialize($top_ten);
  454. /* if ( $_POST['wassup_savepath'] != $wassup_options->wassup_savepath ) {
  455. if (empty($_POST['wassup_savepath']) || rtrim($_POST['wassup_savepath'],"/") == getSessionpath()) {
  456. $wassup_options->wassup_savepath = NULL;
  457. } else {
  458. $wassup_options->setSavepath($_POST['wassup_savepath']);
  459. }
  460. } */
  461. if ($wassup_options->saveSettings()) {
  462. $admin_message = __("Wassup options updated successfully","wassup")."." ;
  463. }
  464. } elseif (isset($_POST['submit-options4'])) { //uninstall checkbox
  465. $wassup_options->wassup_uninstall = $_POST['wassup_uninstall'];
  466. if ($wassup_options->saveSettings()) {
  467. $admin_message = __("Wassup uninstall option updated successfully","wassup")."." ;
  468. }
  469. } elseif (isset($_POST['submit-spam'])) {
  470. $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck'];
  471. $wassup_options->wassup_spam = $_POST['wassup_spam'];
  472. $wassup_options->wassup_refspam = $_POST['wassup_refspam'];
  473. if ($wassup_options->saveSettings()) {
  474. $admin_message = __("Wassup spam options updated successfully","wassup")."." ;
  475. }
  476. } elseif (isset($_POST['reset-to-default'])) {
  477. $wassup_options->loadDefaults();
  478. if ($wassup_options->saveSettings()) {
  479. $admin_message = __("Wassup options updated successfully","wassup")."." ;
  480. }
  481. }
  482. //#sets current tab style for Wassup admin submenu?
  483. if ($_GET['page'] == "wassup-spy") {
  484. $class_spy="class='current'";
  485. } elseif ($_GET['page'] == "wassup-options") {
  486. $class_opt="class='current'";
  487. } elseif ($_GET['page'] == "wassup-online") {
  488. $class_ol="class='current'";
  489. } else {
  490. $class_sub="class='current'";
  491. }
  492. //for stringShortener calculated values and max-width...-Helene D. 11/27/07, 12/6/07
  493. if (!empty($wassup_options->wassup_screen_res)) {
  494. $screen_res_size = (int) $wassup_options->wassup_screen_res;
  495. } else {
  496. $screen_res_size = 670;
  497. }
  498. $max_char_len = ($screen_res_size)/10;
  499. $screen_res_size = $screen_res_size+20; //for wrap margins...
  500. //for generating page link urls....
  501. //$wpurl = get_bloginfo('wpurl'); //global
  502. $siteurl = get_bloginfo('siteurl');
  503. //#display an admin message or an alert. This must be above "wrap"
  504. //# div. -Helene D. 2/26/08.
  505. if (!empty($admin_message)) {
  506. $wassup_options->showMessage($admin_message);
  507. } elseif (!empty($wassup_options->wassup_alert_message)) {
  508. $wassup_options->showMessage();
  509. //#show alert message only once, so remove it here...
  510. $wassup_options->wassup_alert_message = "";
  511. $wassup_options->saveSettings();
  512. }
  513. //#debug - display MySQL errors/warnings
  514. //$mysqlerror = $wpdb->print_error(); //debug
  515. //if (!empty($mysqlerror)) { $wassup_options->showMessage($mysqlerror); } //debug
  516. //moved max-width to single "wrap" div and removed it from
  517. // the individual spans and divs in style.php... ?>
  518. <div class="wrap" style="max-width:<?php echo $screen_res_size; ?>px;" >
  519. <?php // HERE IS THE VISITORS ONLINE VIEW
  520. if ($_GET['page'] == "wassup-online") { ?>
  521. <h2><?php _e("Current Visitors Online", "wassup"); ?></h2>
  522. <p class="legend"><?php echo __("Legend", "wassup").': <span class="box-log">&nbsp;&nbsp;</span> '.__("Logged-in Users", "wassup").' <span class="box-aut">&nbsp;&nbsp;</span> '.__("Comments Authors", "wassup").' <span class="box-spider">&nbsp;&nbsp;</span> '.__("Spiders/bots", "wassup"); ?></p><br />
  523. <p class="legend"><a href="#" class="toggle-all"><?php _e("Expand All","wassup"); ?></a></p>
  524. <?php
  525. $to_date = wassup_get_time();
  526. $from_date = strtotime('-3 minutes', $to_date);
  527. $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date");
  528. $currenttot = $currenttot+0; //set to integer
  529. print "<p class='legend'>".__("Visitors online", "wassup").": <strong>".$currenttot."</strong></p><br />";
  530. if ($currenttot > 0) {
  531. $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC");
  532. foreach ($qryC as $cv) {
  533. if ($wassup_options->wassup_time_format == 24) {
  534. $timed = gmdate("H:i:s", $cv->max_timestamp);
  535. } else {
  536. $timed = gmdate("h:i:s a", $cv->max_timestamp);
  537. }
  538. $ip_proxy = strpos($cv->ip,",");
  539. //if proxy, get 2nd ip...
  540. if ($ip_proxy !== false) {
  541. $ip = substr($cv->ip,(int)$ip_proxy+1);
  542. } else {
  543. $ip = $cv->ip;
  544. }
  545. if ($cv->referrer != '') {
  546. if (!eregi($wpurl, $cv->referrer) OR $cv->searchengine != "") {
  547. if (!eregi($wpurl, $cv->referrer) AND $cv->searchengine == "") {
  548. $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK"><span style="font-weight: bold;">'.stringShortener($cv->referrer, round($max_char_len*.8,0)).'</span></a>';
  549. } else {
  550. $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK">'.stringShortener($cv->referrer, round($max_char_len*.9,0)).'</a>';
  551. }
  552. } else {
  553. $referrer = __("From your blog", "wassup");
  554. }
  555. } else {
  556. $referrer = __("Direct hit", "wassup");
  557. }
  558. $numurl = $wpdb->get_var("SELECT COUNT(DISTINCT id) as numurl FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."'");
  559. ?>
  560. <div class="sum">
  561. <span class="sum-box"><?php if ($numurl >= 2) { ?><a href="#" class="showhide" id="<?php echo $cv->id ?>"><?php print $ip; ?></a><?php } else { ?><?php print $ip; ?><?php } ?></span>
  562. <div class="sum-det"><span class="det1">
  563. <?php
  564. //# html_entity_decode() links that were already
  565. //# "htmlentities-encoded" in database to prevent wacky links
  566. //# like "/imagegallery/?album=3&amp;amp;amp;gallery=13"
  567. print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))).'" target="_BLANK">';
  568. print stringShortener(urlencode(html_entity_decode($cv->urlrequested)), round($max_char_len*.9,0)); ?></a></span><br />
  569. <span class="det2"><strong><?php print $timed; ?> - </strong><?php print $referrer ?></span></div>
  570. </div>
  571. <?php // User is logged in or is a comment's author
  572. if ($cv->username != "" OR $cv->comment_author != "") {
  573. if ($cv->username != "") {
  574. $Ousername = '<li class="users"><span class="indent-li-agent">'.__("LOGGED IN USER", "wassup").': <strong>'.$cv->username.'</strong></span></li>';
  575. $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR", "wassup").': <strong>'.$cv->comment_author.'</strong></span></li>';
  576. $unclass = "userslogged";
  577. } elseif ($cv->comment_author != "") {
  578. $Ocomment_author = '<li class="users"><span class="indent-li-agent">'.__("COMMENT AUTHOR", "wassup").': <strong>'.$cv->comment_author.'</strong></span></li>';
  579. $unclass = "users";
  580. }
  581. ?>
  582. <ul class="<?php print $unclass; ?>">
  583. <?php print $Ousername; ?>
  584. <?php print $Ocomment_author; ?>
  585. </ul>
  586. <?php } ?>
  587. <div style="display: none;" class="togglenavi navi<?php echo $cv->id ?>">
  588. <ul class="url">
  589. <?php
  590. $qryCD = $wpdb->get_results("SELECT `timestamp`, urlrequested FROM $table_tmp_name WHERE wassup_id='".$cv->wassup_id."' ORDER BY `timestamp` ASC");
  591. $i=0;
  592. foreach ($qryCD as $cd) {
  593. $time2 = gmdate("H:i:s", $cd->timestamp);
  594. $num = ($i&1);
  595. $char_len = round($max_char_len*.9,0);
  596. if ($num == 0) $classodd = "urlodd"; else $classodd = "url";
  597. if ($i >= 1) {
  598. ?>
  599. <li class="<?php print $classodd; ?> navi<?php echo $cv->id ?>"><span class="indent-li"><?php print $time2; ?> -
  600. <?php
  601. print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cd->urlrequested))).'" target="_BLANK">';
  602. print stringShortener(urlencode(html_entity_decode($cd->urlrequested)), $char_len).'</a></span></li>'."\n";
  603. }
  604. $i++;
  605. } //end foreach qryCD
  606. print '</ul>';
  607. print '</div>';
  608. print '<p class="sum-footer"></p>';
  609. } //end foreach qryC
  610. } //end if currenttot ?>
  611. <br /><p class="legend"><a href="#" class="toggle-all"><?php _e("Expand All", "wassup"); ?></a></p>
  612. <?php // HERE IS THE SPY MODE VIEW
  613. } elseif ($_GET['page'] == "wassup-spy") {
  614. ?>
  615. <h2><?php _e("SPY Visitors", "wassup"); ?></h2>
  616. <p class="legend"><?php echo __("Legend", "wassup").': <span class="box-log">&nbsp;&nbsp;</span> '.__("Logged-in Users", "wassup").' <span class="box-aut">&nbsp;&nbsp;</span> '.__("Comments Authors", "wassup").' <span class="box-spider">&nbsp;&nbsp;</span> '.__("Spiders/bots", "wassup"); ?></p><br />
  617. <div>
  618. <a href="#?" onclick="return pauseSpy();"><span id="spy-pause"><?php _e("Pause", "wassup"); ?></span></a>
  619. <a href="#?" onclick="return playSpy();"><span id="spy-play"><?php _e("Play", "wassup"); ?></span></a>
  620. - <span style="font-size: 11px;"><?php _e('Spy items by','wassup'); ?>: <select name="navi" style="font-size: 11px;" onChange="window.location.href=this.options[this.selectedIndex].value;">
  621. <?php
  622. //## selectable filter by type of record (wassup_default_spy_type)
  623. if (isset($_GET['spytype'])) {
  624. $spytype = htmlentities(attribute_escape($_GET['spytype']));
  625. } elseif ($wassup_options->wassup_default_spy_type != '') {
  626. $spytype = $wassup_options->wassup_default_spy_type;
  627. }
  628. $selected=$spytype;
  629. $optionargs="?page=wassup-spy&spytype=";
  630. $wassup_options->showFormOptions("wassup_default_spy_type","$selected","$optionargs");
  631. ?>
  632. </select>
  633. </span>
  634. <br />&nbsp;<br /></div>
  635. <?php // GEO IP Map
  636. if ($wassup_options->wassup_geoip_map == 1 AND $wassup_options->wassup_googlemaps_key != "") { ?>
  637. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $wassup_options->wassup_googlemaps_key; ?>" type="text/javascript"></script>
  638. <div id="map" style="width: <?php echo ($screen_res_size*95/100); ?>px; height: 220px;border:2px solid #999;"></div>
  639. <script type="text/javascript">
  640. //<![CDATA[
  641. if (GBrowserIsCompatible()) {
  642. // Display the map, with some controls and set the initial location
  643. var map = new GMap2(document.getElementById("map"));
  644. map.addControl(new GSmallMapControl());
  645. map.addControl(new GMapTypeControl());
  646. //map.enableScrollWheelZoom();
  647. map.setCenter(new GLatLng(0,0),3);
  648. }
  649. // display a warning if the browser was not compatible
  650. else {
  651. alert("Sorry, the Google Maps API is not compatible with this browser");
  652. }
  653. //]]>
  654. </script>
  655. <p>&nbsp;</p>
  656. <? } //end if geoip_map
  657. ?>
  658. <div id="spyContainer">
  659. <?php
  660. //display the last few hits here. The rest will be added by spy.js
  661. $to_date = (wassup_get_time()-2);
  662. $from_date = ($to_date - 12*(60*60)); //display last 10 visits in 12 hours...
  663. spyview($from_date,$to_date,10,$spytype); ?>
  664. </div><br />
  665. <?php // HERE IS THE OPTIONS VIEW
  666. } elseif($_GET['page'] == "wassup-options") {
  667. //#moved content to external include file, "settings.php"
  668. //# to make "wassup" code easier to read and modify
  669. //# -Helene D. 1/15/08.
  670. include(dirname(__FILE__).'/lib/settings.php'); ?>
  671. <?php // HERE IS THE MAIN/DETAILS VIEW
  672. } else { ?>
  673. <h2><?php _e("Latest hits", "wassup"); ?></h2>
  674. <?php if ($wassup_options->wassup_active != 1) { ?>
  675. <p style="color:red; font-weight:bold;"><?php _e("WassUp recording is disabled", "wassup"); ?></p>
  676. <?php }
  677. $res = (int) $wassup_options->wassup_screen_res;
  678. if (empty($res)) $res=620;
  679. elseif ($res < 800) $res=620;
  680. elseif ($res < 1024) $res=740;
  681. elseif ($res < 1200) $res=1000;
  682. else $res=1000;
  683. //## GET parameters that change options settings
  684. if (isset($_GET['wchart']) || isset($_GET['wmark'])) {
  685. if (isset($_GET['wchart'])) {
  686. if ($_GET['wchart'] == 0) {
  687. $wassup_options->wassup_chart = 0;
  688. } else {
  689. $wassup_options->wassup_chart = 1;
  690. }
  691. }
  692. if (isset($_GET['wmark'])) {
  693. if ($_GET['wmark'] == 0) {
  694. $wassup_options->wmark = "0";
  695. $wassup_options->wip = "";
  696. } else {
  697. $wassup_options->wmark = "1";
  698. $wassup_options->wip = attribute_escape($_GET['wip']);
  699. }
  700. }
  701. $wassup_options->saveSettings();
  702. }
  703. //## GET params that filter detail display
  704. //
  705. //## Filter detail list by date range...
  706. $to_date = wassup_get_time();
  707. if (isset($_GET['last']) && $_GET['last'] != "") {
  708. $last = htmlentities(attribute_escape($_GET['last']));
  709. } else {
  710. $last = 1;
  711. }
  712. $from_date = strtotime('-'.$last.' day', $to_date);
  713. //## Filter detail lists by visitor type...
  714. if (isset($_GET['type'])) {
  715. $type = htmlentities(attribute_escape($_GET['type']));
  716. } elseif ($wassup_options->wassup_default_type != '') {
  717. $type = $wassup_options->wassup_default_type;
  718. }
  719. $whereis="";
  720. if ($type == 'spider') {
  721. $whereis = " AND spider!=''";
  722. } elseif ($type == 'nospider') {
  723. $whereis = " AND spider=''";
  724. } elseif ($type == 'spam') {
  725. $whereis = " AND spam>0";
  726. } elseif ($type == 'nospam') {
  727. $whereis = " AND spam=0";
  728. } elseif ($type == 'nospamspider') {
  729. $whereis = " AND spam=0 AND spider=''";
  730. } elseif ($type == 'searchengine') {
  731. $whereis = " AND searchengine!='' AND search!=''";
  732. } elseif ($type == 'referrer') {
  733. $whereis = " AND referrer!='' AND referrer NOT LIKE '%$wpurl%' AND searchengine='' AND search=''";
  734. } elseif ($type == 'comauthor') {
  735. $whereis = " AND comment_author!=''";
  736. } elseif ($type == 'loggedin') {
  737. $whereis = " AND username!=''";
  738. }
  739. //## Filter detail lists by a specific page and number
  740. //# of items per page...
  741. $items = 10; //default
  742. if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
  743. //$items = htmlentities(attribute_escape($_GET['limit']));
  744. $items = $_GET['limit'];
  745. } elseif ($wassup_options->wassup_default_limit != '') {
  746. $items = $wassup_options->wassup_default_limit;
  747. }
  748. if ((int)$items < 1 ) { $items = 10; }
  749. //# current page selections
  750. if (isset($_GET['pages']) && is_numeric($_GET['pages'])) {
  751. $pages = (int)$_GET['pages'];
  752. } else {
  753. $pages = 1;
  754. }
  755. if ( $pages > 1 ) {
  756. $limit = " LIMIT ".(($pages-1)*$items).",$items";
  757. } else {
  758. $limit = " LIMIT $items";
  759. }
  760. //## Filter detail lists by a searched item
  761. if (!empty($_GET['search'])) {
  762. $search = attribute_escape($_GET['search']);
  763. } else {
  764. $search = "";
  765. }
  766. // DELETE EVERY RECORD MARKED BY IP
  767. //# Delete limited to selected date range only. -Helene D. 3/4/08.
  768. if (!empty($_GET['deleteMARKED']) && $wassup_options->wmark == "1" ) {
  769. $rec_deleted = $wpdb->get_var("SELECT COUNT(ip) as deleted FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date");
  770. if (method_exists($wpdb,'prepare')) {
  771. $wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE ip='%s' AND `timestamp` BETWEEN %s AND %s", urlencode(attribute_escape($_GET['dip'])), $from_date, $to_date));
  772. } else {
  773. $wpdb->query("DELETE FROM $table_name WHERE ip='".urlencode(attribute_escape($_GET['dip']))."' AND `timestamp` BETWEEN $from_date AND $to_date");
  774. }
  775. echo '<p><strong>'.$rec_deleted.' '.__('records deleted','wassup').'</strong></p>';
  776. //reset wmark/deleteMarked after delete and
  777. // clean up $_SERVER['QUERY_STRING'] as it is
  778. // used in filter selections below...
  779. $remove_query= array("&dip=".$_GET['dip'],"&deleteMARKED=".$_GET['deleteMARKED'],"&wmark=1","&wip=".$_GET['wip']);
  780. $new_query = str_replace($remove_query,"",$_SERVER['QUERY_STRING']);
  781. $_SERVER['QUERY_STRING']=$new_query;
  782. $wassup_options->wmark = "0";
  783. $wassup_options->wip = null;
  784. $wassup_options->saveSettings();
  785. }
  786. // Instantiate class to count items
  787. $Tot = New MainItems;
  788. $Tot->tableName = $table_name;
  789. $Tot->from_date = $from_date;
  790. $Tot->to_date = $to_date;
  791. $Tot->whereis = $whereis;
  792. $Tot->Limit = $limit;
  793. $Tot->WpUrl = $wpurl;
  794. $itemstot = $Tot->calc_tot("count", $search, null, "DISTINCT");
  795. $pagestot = $Tot->calc_tot("count", $search, null, null);
  796. $spamtot = $Tot->calc_tot("count", $search, "AND spam>0");
  797. // Check if some records was marked
  798. if ($wassup_options->wmark == "1") {
  799. $markedtot = $Tot->calc_tot("count", $search, "AND ip LIKE '%".$wassup_options->wip."%'", "DISTINCT");
  800. }
  801. // Check if some records was searched
  802. if (!empty($search)) {
  803. $searchtot = $Tot->calc_tot("count", $search, null, "DISTINCT");
  804. } ?>
  805. <form><table width="100%">
  806. <tr>
  807. <td>
  808. <p class="legend">
  809. <?php if ($wassup_options->wassup_chart == "1") { ?>
  810. <a href="<?php echo '?page='.WASSUPFOLDER.'&wchart=0&last='.$last.'&limit='.$items.'&type='.$_GET['type'].'&search='.$search.'&pages='.$pages; ?>" style="text-decoration:none;">
  811. <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/chart_delete.png" style="padding:0px 6px 0 0;" alt="'.__('hide chart','wassup').'" title="'.__('Hide the chart and site usage','wassup'); ?>" /></a>
  812. <?php } else { ?>
  813. <a href="<?php echo '?page='.WASSUPFOLDER.'&wchart=1&last='.$last.'&limit='.$items.'&type='.$_GET['type'].'&search='.$search.'&pages='.$pages; ?>" style="text-decoration:none;">
  814. <img src="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/chart_add.png" style="padding:0px 6px 0 0;" alt="'.__('show chart','wassup').'" title="'.__('Show the chart and site usage','wassup'); ?>" /></a>
  815. <?php }
  816. //## Show selectable detail filters...
  817. if (isset($_GET['limit'])) {
  818. $new_limit = eregi_replace("\&limit=".$_GET['limit']."", "", $_SERVER['QUERY_STRING']);
  819. } else {
  820. $new_limit = $_SERVER['QUERY_STRING'];
  821. }
  822. if (isset($_GET['last'])) {
  823. $new_last = eregi_replace("\&last=".$_GET['last']."", "", $_SERVER['QUERY_STRING']);
  824. } else {
  825. $new_last = $_SERVER['QUERY_STRING'];
  826. }
  827. _e('Summary for the last','wassup'); ?>
  828. <select style="font-size: 11px;" name="last" onChange="window.location.href=this.options[this.selectedIndex].value;">
  829. <?php
  830. //## selectable filter by date range
  831. echo "
  832. <option value='?$new_last&last=1'".($_GET['last'] == 1 ? " SELECTED" : "").">".__('24 hours','wassup')."</option>
  833. <option value='?$new_last&last=7'".($_GET['last'] == 7 ? " SELECTED" : "").">".__('7 days','wassup')."</option>
  834. <option value='?$new_last&last=30'".($_GET['last'] == 30 ? " SELECTED" : "").">".__('1 month','wassup')."</option>
  835. <option value='?$new_last&last=365'".($_GET['last'] == 365 ? " SELECTED" : "").">".__('1 year','wassup')."</option>"; ?>
  836. </select></p>
  837. </td>
  838. <td align="right"><p style="font-size: 11px;"><?php _e('Items per page','wassup'); ?>: <select name="navi" style="font-size: 11px;" onChange="window.location.href=this.options[this.selectedIndex].value;">
  839. <?php
  840. //## selectable filter by number of items on page (default_limit)
  841. $selected=$items;
  842. $optionargs="?$new_limit&limit=";
  843. $wassup_options->showFormOptions("wassup_default_limit","$selected","$optionargs");
  844. ?>
  845. </select> - <?php _e('Show items by','wassup'); ?>: <select style="font-size: 11px;" name="type" onChange="window.location.href=this.options[this.selectedIndex].value;">
  846. <?php
  847. //## selectable filter by type of record (wassup_default_type)
  848. $selected=$type;
  849. $optionargs="?page=".WASSUPFOLDER."&type=";
  850. $wassup_options->showFormOptions("wassup_default_type","$selected","$optionargs");
  851. ?>
  852. </select>
  853. </p>
  854. </td>
  855. </tr>
  856. </table>
  857. </form>
  858. <?php // Print Site Usage
  859. if ($wassup_options->wassup_chart == 1) { ?>
  860. <div class='main-tabs'>
  861. <div id='usage'>
  862. <ul>
  863. <li><span style="border-bottom:2px solid #0077CC;"><?php echo $itemstot; ?></span> <small><?php _e('Visits','wassup'); ?></small></li>
  864. <li><span style="border-bottom:2px dashed #FF6D06;"><?php echo $pagestot; ?></span> <small><?php _e('Pageviews','wassup'); ?></small></li>
  865. <li><span><?php echo @number_format(($pagestot/$itemstot), 2); ?></span> <small><?php _e('Pages/Visits','wassup'); ?></small></li>
  866. <?php // Print spam usage only if enabled
  867. if ($wassup_options->wassup_spamcheck == 1) { ?>
  868. <li><span><a href="#TB_inline?height=180&width=300&inlineId=hiddenspam" class="thickbox"><?php echo $spamtot; ?></a></span> <span>(<?php echo @number_format(($spamtot*100/$pagestot), 2); ?>%)</span> <small><?php _e('Spams','wassup'); ?></small></li>
  869. <?php } ?>
  870. </ul>
  871. <?php
  872. // Print the Google chart!
  873. if ($pagestot > 20) {
  874. echo $Tot->TheChart($last, $res, "125", $search, $wassup_options->wassup_chart_type, "bg,s,ffffff")."";
  875. } else {
  876. echo '<div id="placeholder" align="center"><p style="padding-top:50px;">'.__('Too few records to print chart','wassup').'...</p></div>';
  877. } ?>
  878. </div>
  879. </div>
  880. <?php } //end if wassup_chart == 1
  881. if (!isset($_GET['limit']) OR $_GET['limit'] == 10 OR $_GET['limit'] == 20) {
  882. $expcol = '
  883. <table width="100%"><tr>
  884. <td align="left" class="legend"><a href="#" class="toggle-all">'.__('Expand All','wassup').'</a></td>
  885. <td align="right" class="legend"><a href="#" class="toggle-allcrono">'.__('Collapse Chronology','wassup').'</a></td>
  886. </tr></table><br />';
  887. }
  888. // MAIN QUERY
  889. $main = $Tot->calc_tot("main", $search);
  890. if ($itemstot > 0) {
  891. $p=new pagination();
  892. $p->items($itemstot);
  893. $p->limit($items);
  894. $p->currentPage($pages);
  895. $p->target("admin.php?page=".WASSUPFOLDER."&limit=$items&type=$type&last=$last&search=$search");
  896. $p->calculate();
  897. $p->adjacents(5);
  898. }
  899. // hidden spam options
  900. ?>
  901. <div id="hiddenspam" style="display:none;">
  902. <h2><?php _e('Spam Options','wassup'); ?></h2>
  903. <form action="" method="post">
  904. <p><input type="checkbox" name="wassup_spamcheck" value="1" <?php if($wassup_options->wassup_spamcheck == 1 ) print "CHECKED"; ?> /> <strong><?php _e('Enable/Disable Spam Check on Records','wassup'); ?></strong></p>
  905. <p style="padding-left:30px;"><input type="checkbox" name="wassup_spam" value="1" <?php if($wassup_options->wassup_spam == 1) print "CHECKED"; ?> /> <?php _e('Record Akismet comment spam attempts','wassup'); ?></p>
  906. <p style="padding-left:30px;"><input type="checkbox" name="wassup_refspam" value="1" <?php if($wassup_options->wassup_refspam == 1) print "CHECKED"; ?> /> <?php _e('Record referrer spam attempts','wassup'); ?></p>
  907. <p style="padding-left:0;"><input type="submit" name="submit-spam" value="<?php _e('Save Settings','wassup'); ?>" /></p>
  908. </form>
  909. </div>
  910. <table width="100%">
  911. <tr>
  912. <td align="left" class="legend">
  913. <?php
  914. // Marked items - Refresh
  915. if ($wassup_options->wmark == 1) echo '<a href="?'.$_SERVER['QUERY_STRING'].'&search='.$wassup_options->wip.'" title="'.__('Filter by marked IP','wassup').'"><strong>'.$markedtot.'</strong> '.__('show marked items','wassup').'</a> - ';
  916. if (!empty($search)) print "<strong>$searchtot</strong> ".__('Searched for','wassup').": <strong>$search</strong> - ";
  917. echo __('Auto refresh in','wassup').' <span id="CountDownPanel"></span> '.__('seconds','wassup'); ?>
  918. </td>
  919. <td align="right" class="legend"><a href="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=topten&whash='.$whash.'&from_date='.$from_date.'&to_date='.$to_date.'&width='.$res.'&height=400'; ?>" class="thickbox" title="Wassup <?php _e('Top Ten','wassup'); ?>"><?php _e('Show Top Ten','wassup'); ?></a> - <a href="#" class='show-search'><?php _e('Search','wassup'); ?></a></td>
  920. </tr>
  921. </table>
  922. <div class="search-ip" style="display: none;">
  923. <table border=0 width="100%">
  924. <tr valign="top">
  925. <td align="right">
  926. <form action="" method="get">
  927. <input type="hidden" name="page" value="<?php echo WASSUPFOLDER; ?>" />
  928. <input type="text" size="25" name="search" value="<?php if ($search != "") print $search; ?>" /><input type="submit" name="submit-search" value="search" />
  929. </form>
  930. </td>
  931. </tr>
  932. </table>
  933. </div>
  934. <?php
  935. //# Detailed List of Wassup Records...
  936. print $expcol;
  937. //# Show Page numbers/Links...
  938. if ($itemstot >= 10) {
  939. print "\n".'<div id="pag" align="center">'.$p->show().'</div><br />'."\n";
  940. }
  941. if ($itemstot > 0) {
  942. foreach ($main as $rk) {
  943. $timestampF = $rk->max_timestamp;
  944. $dateF = gmdate("d M Y", $timestampF);
  945. if ($wassup_options->wassup_time_format == 24) {
  946. $datetimeF = gmdate('Y-m-d H:i:s', $timestampF);
  947. $timeF = gmdate("H:i:s", $timestampF);
  948. } else {
  949. $datetimeF = gmdate('Y-m-d h:i:s a', $timestampF);
  950. $timeF = gmdate("h:i:s a", $timestampF);
  951. }
  952. //$ip = @explode(",", $rk->ip);
  953. $ip_proxy = strpos($rk->ip,",");
  954. //if proxy, get 2nd ip...
  955. if ($ip_proxy !== false) {
  956. $ip = substr($rk->ip,(int)$ip_proxy+1);
  957. } else {
  958. $ip = $rk->ip;
  959. }
  960. // Visitor Record - raw data (hidden)
  961. $raw_div="raw-".substr($rk->wassup_id,0,25).rand(0,99);
  962. echo "\n"; ?>
  963. <div id="<?php echo $raw_div; ?>" style="display:none; padding-top:7px;" >
  964. <h2><?php _e("Raw data","wassup"); ?>:</h2>
  965. <style type="text/css">.raw { color: #542; padding-left:5px; }</style>
  966. <ul style="list-style-type:none;padding:20px 0 0 30px;">
  967. <li><?php echo __("Visit type","wassup").': <span class="raw">';
  968. if ($rk->username != "") {
  969. echo __("Logged-in user","wassup").' - '.$rk->username;
  970. } elseif ($rk->spam == "1" || $rk->spam == "2" ) {
  971. _e("Spammer","wassup");
  972. } elseif ($rk->comment_author != "") {
  973. echo __("Comment author","wassup").' - '.$rk->comment_author;
  974. } elseif ($rk->feed != "") {
  975. echo __("Feed","wassup").' - '.$rk->feed;
  976. } elseif ($rk->spider != "") {
  977. echo __("Spider","wassup").' - '.$rk->spider;
  978. } else {
  979. _e("Regular visitor","wassup");
  980. }
  981. echo '</span>'; ?></li>
  982. <li><?php echo __("IP","wassup").': <span class="raw">'.$rk->ip.'</span>'; ?></li>
  983. <li><?php echo __("Hostname","wassup").': <span class="raw">'.$rk->hostname.'</span>'; ?></li>
  984. <li><?php echo __("Url Requested","wassup").': <span class="raw">'.htmlspecialchars(html_entity_decode(clean_url($rk->urlrequested))).'</span>'; ?></li>
  985. <li><?php echo __("User Agent","wassup").': <span class="raw">'.$rk->agent.'</span>'; ?></li>
  986. <li><?php echo __("Referrer","wassup").': <span class="raw">'.urldecode($rk->referrer).'</span>'; ?></li>
  987. <?php if ($rk->search != "") { ?>
  988. <li><?php echo __("Search Engine","wassup").': <span class="raw">'.$rk->searchengine.'</span> &nbsp; &nbsp; ';
  989. echo __("Search","wassup").': <span class="raw">'.$rk->search.'</span>'; ?></li>
  990. <?php }
  991. if ($rk->os != "") { ?>
  992. <li><?php echo __("OS","wassup").': <span class="raw">'.$rk->os.'</span>'; ?></li>
  993. <?php }
  994. if ($rk->browser != "") { ?>
  995. <li><?php echo __("Browser","wassup").': <span class="raw">'.$rk->browser.'</span>'; ?></li>
  996. <?php }
  997. if ($rk->language != "") { ?>
  998. <li><?php echo __("Locale/Language","wassup").': <span class="raw">'.$rk->language.'</span>'; ?></li>
  999. <?php } ?>
  1000. <li><?php echo 'Wassup ID'.': <span class="raw">'.$rk->wassup_id.'</span>'; ?></li>
  1001. <li><?php echo __("End timestamp","wassup").': <span class="raw">'.$datetimeF.' ( '.$rk->max_timestamp.' )</span>'; ?></li>
  1002. </ul>
  1003. </div> <!-- raw-wassup_id -->
  1004. <?php //Visitor Record - detail listing
  1005. if ($rk->referrer != '') {
  1006. if (!eregi($wpurl, $rk->referrer) OR $rk->searchengine != "") {
  1007. if (!eregi($wpurl, $rk->referrer) AND $rk->searchengine == "") {
  1008. $referrer = '<a href="'.$rk->referrer.'" target="_BLANK"><span style="font-weight: bold;">'.stringShortener($rk->referrer, round($max_char_len*.8,0)).'</span></a>';
  1009. } else {
  1010. $referrer = '<a href="'.$rk->referrer.'" target="_BLANK">'.stringShortener($rk->referrer, round($max_char_len*.9,0)).'</a>';
  1011. }
  1012. } else {
  1013. $referrer = __('From your blog','wassup');
  1014. }
  1015. } else {
  1016. $referrer = __('Direct hit','wassup');
  1017. }
  1018. $numurl = $wpdb->get_var("SELECT COUNT(DISTINCT id) as numurl FROM $table_name WHERE wassup_id='".$r

Large files files are truncated, but you can click here to view the full file