| 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.3 |
|---|
| 7 | Author: Michele Marcucci, Helene D. |
|---|
| 8 | Author URI: http://www.michelem.org/ |
|---|
| 9 | |
|---|
| 10 | Copyright (c) 2007 Michele Marcucci |
|---|
| 11 | Released under the GNU General Public License (GPL) |
|---|
| 12 | http://www.gnu.org/licenses/gpl.txt |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | //# Stop any attempt to call wassup.php directly. -Helene D. 1/27/08. |
|---|
| 16 | if (preg_match('#'.basename(__FILE__) .'#', $_SERVER['PHP_SELF'])) { |
|---|
| 17 | die('Permission Denied! You are not allowed to call this page directly.'); |
|---|
| 18 | } |
|---|
| 19 | $version = "1.6.3"; |
|---|
| 20 | define('WASSUPFOLDER', dirname(plugin_basename(__FILE__)), TRUE); |
|---|
| 21 | require_once(dirname(__FILE__).'/lib/wassup.class.php'); |
|---|
| 22 | require_once(dirname(__FILE__).'/lib/main.php'); |
|---|
| 23 | $wpurl = get_bloginfo('wpurl'); //global |
|---|
| 24 | |
|---|
| 25 | if (isset($_GET['export'])) { |
|---|
| 26 | export_wassup(); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | global $wp_version; |
|---|
| 30 | |
|---|
| 31 | //#This works only in WP2.2 or higher |
|---|
| 32 | if (version_compare($wp_version, '2.2', '<')) { |
|---|
| 33 | wp_die( '<strong style="color:#c00;background-color:#dff;padding:5px;">'.__("Sorry, Wassup requires WordPress 2.2 or higher to work","wassup").'.</strong>'); |
|---|
| 34 | } elseif (function_exists('wp_cache_flush')) { |
|---|
| 35 | //clear the WP cache |
|---|
| 36 | wp_cache_flush(); //to prevent "cannot redeclare" errors??? |
|---|
| 37 | } |
|---|
| 38 | //#add initial options and create table when Wassup activated |
|---|
| 39 | // -Helene D. 2/26/08. |
|---|
| 40 | function wassup_install() { |
|---|
| 41 | global $wpdb; |
|---|
| 42 | $table_name = $wpdb->prefix . "wassup"; |
|---|
| 43 | $table_tmp_name = $wpdb->prefix . "wassup_tmp"; |
|---|
| 44 | |
|---|
| 45 | //### Add/update wassup settings in Wordpress options table |
|---|
| 46 | $wassup_options = new wassupOptions; //#settings initialized here |
|---|
| 47 | |
|---|
| 48 | //# set hash |
|---|
| 49 | $whash = $wassup_options->get_wp_hash(); |
|---|
| 50 | if (!empty($whash)) { |
|---|
| 51 | $wassup_options->whash = $whash; |
|---|
| 52 | } |
|---|
| 53 | //# Add timestamp to optimize table once a day |
|---|
| 54 | $wassup_options->wassup_optimize = wassup_get_time(); |
|---|
| 55 | |
|---|
| 56 | //# set wmark and wip to null |
|---|
| 57 | $wassup_options->wmark = 0; //#no preservation of delete/mark |
|---|
| 58 | $wassup_options->wip = null; |
|---|
| 59 | |
|---|
| 60 | //### For upgrade of Wassup, manually initialize new settings |
|---|
| 61 | //# initialize settings for 'spamcheck', 'refspam', and 'spam' |
|---|
| 62 | if (!isset($wassup_options->wassup_spamcheck)) { |
|---|
| 63 | $wassup_options->wassup_spamcheck = "0"; |
|---|
| 64 | //#set wassup_spamcheck=0 if wassup_refspam=0 and wassup_spam=0 |
|---|
| 65 | if (!isset($wassup_options->wassup_spam) && !isset($wassup_options->wassup_refspam)) { |
|---|
| 66 | $wassup_options->wassup_spam = "1"; |
|---|
| 67 | $wassup_options->wassup_refspam = "1"; |
|---|
| 68 | } elseif ( $wassup_options->wassup_spam == "0" && $wassup_options->wassup_refspam == "0" ) { |
|---|
| 69 | $wassup_options->wassup_spamcheck = "0"; |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | //# update wassup settings for 'savepath' (default is null) |
|---|
| 74 | //$wassup_options->wassup_savepath = "/fakedirectory"; //#debug |
|---|
| 75 | if (!isset($wassup_options->wassup_savepath)) { |
|---|
| 76 | $wassup_options->wassup_savepath = null; |
|---|
| 77 | } |
|---|
| 78 | //# display google chart by default for upgrades from 1.4.4 |
|---|
| 79 | if (!isset($wassup_options->wassup_chart)) { |
|---|
| 80 | $wassup_options->wassup_chart = 1; |
|---|
| 81 | } |
|---|
| 82 | //# assign top ten items for upgrades from 1.4.9 or less |
|---|
| 83 | if (empty($wassup_options->wassup_top10)) { |
|---|
| 84 | $wassup_options->wassup_top10 = serialize(array("topsearch"=>"1", |
|---|
| 85 | "topreferrer"=>"1", |
|---|
| 86 | "toprequest"=>"1", |
|---|
| 87 | "topbrowser"=>"1", |
|---|
| 88 | "topos"=>"1", |
|---|
| 89 | "toplocale"=>"0", |
|---|
| 90 | "topfeed"=>"0", |
|---|
| 91 | "topcrawler"=>"0", |
|---|
| 92 | "topvisitor"=>"0", |
|---|
| 93 | "topreferrer_exclude"=>"")); |
|---|
| 94 | } |
|---|
| 95 | //#upgrade from 1.6: new options wassup_time_format and wassup_hack |
|---|
| 96 | if (!isset($wassup_options->wassup_time_format)) { |
|---|
| 97 | $wassup_options->wassup_time_format = 24; |
|---|
| 98 | } |
|---|
| 99 | if (!isset($wassup_options->wassup_hack)) { |
|---|
| 100 | $wassup_options->wassup_hack = 1; |
|---|
| 101 | } |
|---|
| 102 | $wassup_options->saveSettings(); |
|---|
| 103 | |
|---|
| 104 | //### Detect problems with WassUp install and show warning |
|---|
| 105 | //# |
|---|
| 106 | //#Check for problems with 'session_savepath' and disable |
|---|
| 107 | //# recording, if found. -Helene D. 2/24/08 |
|---|
| 108 | /* |
|---|
| 109 | $sessionpath = $wassup_options->wassup_savepath; |
|---|
| 110 | if (empty($sessionpath)) { $sessionpath = getSessionpath(); } |
|---|
| 111 | //default to "/tmp" if no sessionpath value |
|---|
| 112 | if (empty($sessionpath)) { |
|---|
| 113 | $sessionpath = "/tmp"; |
|---|
| 114 | $wassup_options->wassup_savepath = $sessionpath; |
|---|
| 115 | } |
|---|
| 116 | if ($wassup_options->isWritableFolder($sessionpath) == false) { |
|---|
| 117 | if ($wassup_options->wassup_active == "1") { |
|---|
| 118 | $wassup_options->wassup_active = "0"; |
|---|
| 119 | $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'); |
|---|
| 120 | } else { |
|---|
| 121 | $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'); |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | $wassup_options->saveSettings(); |
|---|
| 125 | unset($sessionpath); //because "install" works in global scope |
|---|
| 126 | */ |
|---|
| 127 | //# TODO: |
|---|
| 128 | //###Detect known incompatible plugins like "wp_cache" and disable |
|---|
| 129 | //# recordings and show warning message... |
|---|
| 130 | |
|---|
| 131 | //### Create/upgrade wassup MAIN table |
|---|
| 132 | if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { |
|---|
| 133 | CreateTable($table_name); |
|---|
| 134 | CreateTable($table_tmp_name); |
|---|
| 135 | } else { |
|---|
| 136 | UpdateTable(); //<== wassup_tmp is added here, if missing |
|---|
| 137 | } |
|---|
| 138 | } //#end function wassup_install |
|---|
| 139 | |
|---|
| 140 | //set global variables that are dependent on Wassup's wp_options values |
|---|
| 141 | $wassup_settings = get_option('wassup_settings'); //temp only.. |
|---|
| 142 | $wassup_options = new wassupOptions; |
|---|
| 143 | //$wassup_options->loadSettings(); //done automatically |
|---|
| 144 | $whash = $wassup_options->whash; //global... |
|---|
| 145 | |
|---|
| 146 | //#Completely remove all wassup tables and options from Wordpress when |
|---|
| 147 | //# the 'wassup_uninstall' option is set and plugin is deactivated. |
|---|
| 148 | //# -Helene D. 2/26/08 |
|---|
| 149 | function wassup_uninstall() { |
|---|
| 150 | global $wassup_options, $wpdb; |
|---|
| 151 | if ($wassup_options->wassup_uninstall == "1") { |
|---|
| 152 | $table_name = $wpdb->prefix . "wassup"; |
|---|
| 153 | $table_tmp_name = $wpdb->prefix . "wassup_tmp"; |
|---|
| 154 | //$wpdb->query("DROP TABLE IF EXISTS $table_name"); //incorrectly causes an activation error in Wordpress |
|---|
| 155 | //$wpdb->query("DROP TABLE IF EXISTS $table_tmp_name"); //incorrectly causes an activation error in Wordpress |
|---|
| 156 | mysql_query("DROP TABLE IF EXISTS $table_tmp_name"); |
|---|
| 157 | mysql_query("DROP TABLE IF EXISTS $table_name"); |
|---|
| 158 | $wassup_options->deleteSettings(); |
|---|
| 159 | } |
|---|
| 160 | } //#end function wassup_uninstall |
|---|
| 161 | |
|---|
| 162 | function add_wassup_meta_info() { |
|---|
| 163 | global $version; |
|---|
| 164 | print '<meta name="wassup-version" content="'.$version.'" />'; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | //# Wassup init hook actions performed before headers are sent: |
|---|
| 168 | //# -Load jquery AJAX library and dependent javascripts for admin menus |
|---|
| 169 | //# -Load language/localization files for admin menus and widget |
|---|
| 170 | //# -Set 'wassup' cookie for new visitor hits |
|---|
| 171 | function wassup_init() { |
|---|
| 172 | global $wpurl; |
|---|
| 173 | |
|---|
| 174 | //### Add wassup scripts to Wassup Admin pages... |
|---|
| 175 | if (stristr($_GET['page'],'wassup') !== FALSE) { |
|---|
| 176 | if ( function_exists('wp_deregister_script')) { |
|---|
| 177 | //removes old jquery vers. |
|---|
| 178 | wp_deregister_script('jquery'); |
|---|
| 179 | } |
|---|
| 180 | // the safe way to load jquery into WP |
|---|
| 181 | wp_register_script('jquery', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/jquery.js',FALSE,'1.2.6'); |
|---|
| 182 | if ($_GET['page'] == "wassup-spy") { |
|---|
| 183 | //the safe way to load a jquery dependent script |
|---|
| 184 | wp_enqueue_script('spy', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/spy.js', array('jquery'), '1.4'); |
|---|
| 185 | } elseif($_GET['page'] == "wassup-options") { |
|---|
| 186 | wp_enqueue_script('ui.base', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/ui.base.js', array('jquery'), '3'); |
|---|
| 187 | wp_enqueue_script('ui.tabs', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/ui.tabs.js', array('jquery'), '3'); |
|---|
| 188 | } else { |
|---|
| 189 | //the safe way to load a jquery dependent script |
|---|
| 190 | wp_enqueue_script('thickbox', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.js', array('jquery'), '3'); |
|---|
| 191 | } |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | //Loading language file... |
|---|
| 195 | //Doesn't work if the plugin file has its own directory. |
|---|
| 196 | //Let's make it our way... load_plugin_textdomain() searches only in the wp-content/plugins dir. |
|---|
| 197 | $currentLocale = get_locale(); |
|---|
| 198 | if(!empty($currentLocale)) { |
|---|
| 199 | $moFile = dirname(__FILE__) . "/language/" . $currentLocale . ".mo"; |
|---|
| 200 | if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('wassup', $moFile); |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | //Set Wassup cookie for visitor hits before headers are sent |
|---|
| 204 | //add_action('init', 'wassupPrepend'); |
|---|
| 205 | if (!is_admin()) { //exclude wordpress admin page visits |
|---|
| 206 | wassupPrepend(); |
|---|
| 207 | } |
|---|
| 208 | } // end function wassup_init |
|---|
| 209 | |
|---|
| 210 | //Add the wassup stylesheet and other javascripts... |
|---|
| 211 | function add_wassup_css() { |
|---|
| 212 | global $wpurl, $wassup_options, $whash; |
|---|
| 213 | |
|---|
| 214 | //assign a value to whash, if none |
|---|
| 215 | if ($whash == "") { |
|---|
| 216 | $whash = $wassup_options->get_wp_hash(); |
|---|
| 217 | $wassup_options->whash = $whash; //save new hash |
|---|
| 218 | $wassup_options->saveSettings(); |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | $plugin_page = attribute_escape($_GET['page']); |
|---|
| 222 | |
|---|
| 223 | if (stristr($plugin_page,'wassup') !== FALSE) { $plugin_page="wassup"; } |
|---|
| 224 | //Add css and javascript to wassup menu pages only... |
|---|
| 225 | if ($plugin_page == "wassup") { |
|---|
| 226 | //$wassup_settings = get_option('wassup_settings'); |
|---|
| 227 | echo "\n".'<script type="text/javascript">var tb_pathToImage = "'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/loadingAnimation.gif";</script>'; |
|---|
| 228 | echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.css'.'" type="text/css" />'; |
|---|
| 229 | echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/ui.tabs.css'.'" type="text/css" />'; |
|---|
| 230 | echo "\n".'<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/wassup.css'.'" type="text/css" />'."\n"; |
|---|
| 231 | |
|---|
| 232 | if ($_GET['page'] != "wassup-options" AND $_GET['page'] != "wassup-spy") { ?> |
|---|
| 233 | <script type='text/javascript'> |
|---|
| 234 | //<![CDATA[ |
|---|
| 235 | function selfRefresh(){ |
|---|
| 236 | location.href='?<?php print $_SERVER['QUERY_STRING']; ?>'; |
|---|
| 237 | } |
|---|
| 238 | setTimeout('selfRefresh()', <?php print ($wassup_options->wassup_refresh * 60000); ?>); |
|---|
| 239 | //]]> |
|---|
| 240 | </script> |
|---|
| 241 | |
|---|
| 242 | <script type='text/javascript'> |
|---|
| 243 | //<![CDATA[ |
|---|
| 244 | var _countDowncontainer="0"; |
|---|
| 245 | var _currentSeconds="0"; |
|---|
| 246 | function ActivateCountDown(strContainerID, initialValue) { |
|---|
| 247 | _countDowncontainer = document.getElementById(strContainerID); |
|---|
| 248 | SetCountdownText(initialValue); |
|---|
| 249 | window.setTimeout("CountDownTick()", 1000); |
|---|
| 250 | } |
|---|
| 251 | function CountDownTick() { |
|---|
| 252 | SetCountdownText(_currentSeconds-1); |
|---|
| 253 | window.setTimeout("CountDownTick()", 1000); |
|---|
| 254 | } |
|---|
| 255 | function SetCountdownText(seconds) { |
|---|
| 256 | //store: |
|---|
| 257 | _currentSeconds = seconds; |
|---|
| 258 | //build text: |
|---|
| 259 | var strText = AddZero(seconds); |
|---|
| 260 | //apply: |
|---|
| 261 | if (_countDowncontainer) { //prevents error in "Options" submenu |
|---|
| 262 | _countDowncontainer.innerHTML = strText; |
|---|
| 263 | } |
|---|
| 264 | } |
|---|
| 265 | function AddZero(num) { |
|---|
| 266 | return ((num >= "0")&&(num < 10))?"0"+num:num+""; |
|---|
| 267 | } |
|---|
| 268 | //]]> |
|---|
| 269 | </script> |
|---|
| 270 | <script type="text/javascript"> |
|---|
| 271 | //<![CDATA[ |
|---|
| 272 | window.onload=WindowLoad; |
|---|
| 273 | function WindowLoad(event) { |
|---|
| 274 | ActivateCountDown("CountDownPanel", <?php print ($wassup_options->wassup_refresh * 60); ?>); |
|---|
| 275 | } |
|---|
| 276 | //]]> |
|---|
| 277 | </script> |
|---|
| 278 | |
|---|
| 279 | <script type="text/javascript"> |
|---|
| 280 | //<![CDATA[ |
|---|
| 281 | jQuery(document).ready(function($){ |
|---|
| 282 | $("a.showhide").click(function(){ |
|---|
| 283 | var id = $(this).attr('id'); |
|---|
| 284 | $("div.navi" + id).toggle("slow"); |
|---|
| 285 | return false; |
|---|
| 286 | }); |
|---|
| 287 | $("a.toggleagent").click(function(){ |
|---|
| 288 | var id = $(this).attr('id'); |
|---|
| 289 | $("div.naviagent" + id).slideToggle("slow"); |
|---|
| 290 | return false; |
|---|
| 291 | }); |
|---|
| 292 | $("a.deleteID").click(function(){ |
|---|
| 293 | var id = $(this).attr('id'); |
|---|
| 294 | $.ajax({ |
|---|
| 295 | url: "<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=delete&whash='.$whash; ?>&id=" + id, |
|---|
| 296 | async: false |
|---|
| 297 | }) |
|---|
| 298 | $("div.delID" + id).fadeOut("slow"); |
|---|
| 299 | return false; |
|---|
| 300 | }); |
|---|
| 301 | $("a.show-search").toggle(function(){ |
|---|
| 302 | $("div.search-ip").slideDown("slow"); |
|---|
| 303 | $("a.show-search").html("<a href='#' class='show-search'><?php _e("Hide Search", "wassup") ?></a>"); |
|---|
| 304 | },function() { |
|---|
| 305 | $("div.search-ip").slideUp("slow"); |
|---|
| 306 | $("a.show-search").html("<a href='#' class='show-search'><?php _e("Search", "wassup") ?></a>"); |
|---|
| 307 | return false; |
|---|
| 308 | }); |
|---|
| 309 | $("a.show-topten").toggle(function(){ |
|---|
| 310 | $("div.topten").slideDown("slow"); |
|---|
| 311 | $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Hide TopTen", "wassup") ?></a>"); |
|---|
| 312 | },function() { |
|---|
| 313 | $("div.topten").slideUp("slow"); |
|---|
| 314 | $("a.show-topten").html("<a href='#' class='show-topten'><?php _e("Show TopTen", "wassup") ?></a>"); |
|---|
| 315 | return false; |
|---|
| 316 | }); |
|---|
| 317 | |
|---|
| 318 | $("a.toggle-all").toggle(function() { |
|---|
| 319 | $("div.togglenavi").slideDown("slow"); |
|---|
| 320 | $("a.toggle-all").html("<a href='#' class='toggle-all'><?php _e("Collapse All", "wassup") ?></a>"); |
|---|
| 321 | },function() { |
|---|
| 322 | $("div.togglenavi").slideUp("slow"); |
|---|
| 323 | $("a.toggle-all").html("<a href='#' class='toggle-all'><?php _e("Expand All", "wassup") ?></a>"); |
|---|
| 324 | return false; |
|---|
| 325 | }); |
|---|
| 326 | $("a.toggle-allcrono").toggle(function() { |
|---|
| 327 | $("div.togglecrono").slideUp("slow"); |
|---|
| 328 | $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'><?php _e("Expand Cronology", "wassup") ?></a>"); |
|---|
| 329 | },function() { |
|---|
| 330 | $("div.togglecrono").slideDown("slow"); |
|---|
| 331 | $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'><?php _e("Collapse Cronology", "wassup") ?></a>"); |
|---|
| 332 | return false; |
|---|
| 333 | }); |
|---|
| 334 | }); //end jQuery(document).ready |
|---|
| 335 | //]]> |
|---|
| 336 | </script> |
|---|
| 337 | <?php } //end if page != wassup-options ?> |
|---|
| 338 | |
|---|
| 339 | <script type='text/javascript'> |
|---|
| 340 | //<![CDATA[ |
|---|
| 341 | function go() |
|---|
| 342 | { |
|---|
| 343 | box = document.forms["0"].navi; |
|---|
| 344 | destination = box.options[box.selectedindex].value; |
|---|
| 345 | if (destination) location.href = destination; |
|---|
| 346 | } |
|---|
| 347 | function go2() |
|---|
| 348 | { |
|---|
| 349 | box2 = document.forms["0"].type; |
|---|
| 350 | destination2 = box2.options[box2.selectedindex].value; |
|---|
| 351 | if (destination2) location.href = destination2; |
|---|
| 352 | } |
|---|
| 353 | //]]> |
|---|
| 354 | </script> |
|---|
| 355 | |
|---|
| 356 | <?php |
|---|
| 357 | if ($_GET['page'] == "wassup-options") { |
|---|
| 358 | //#Current active tabs are indentified after page reload with |
|---|
| 359 | //# either $_GET['tab']=N or $_POST['submit-optionsN'] where |
|---|
| 360 | //# N=tab number. The tab is then activated directly in |
|---|
| 361 | //# "settings.php" with <li class="ui-tabs-selected"> |
|---|
| 362 | ?> |
|---|
| 363 | <script type="text/javascript"> |
|---|
| 364 | //<![CDATA[ |
|---|
| 365 | jQuery(document).ready(function($) { |
|---|
| 366 | $('#tabcontainer > ul').tabs({ fx: { opacity: 'toggle' } }); |
|---|
| 367 | }); |
|---|
| 368 | //]]> |
|---|
| 369 | </script> |
|---|
| 370 | <?php |
|---|
| 371 | } elseif ($_GET['page'] == "wassup-spy") { |
|---|
| 372 | //## Filter detail lists by visitor type... |
|---|
| 373 | if (isset($_GET['spytype'])) { |
|---|
| 374 | $spytype = htmlentities(attribute_escape($_GET['spytype'])); |
|---|
| 375 | $wassup_options->wassup_default_spy_type = $spytype; |
|---|
| 376 | } elseif ($wassup_options->wassup_default_spy_type != '') { |
|---|
| 377 | $spytype = $wassup_options->wassup_default_spy_type; |
|---|
| 378 | } |
|---|
| 379 | $wassup_options->saveSettings(); |
|---|
| 380 | ?> |
|---|
| 381 | <script type="text/javascript"> |
|---|
| 382 | //<![CDATA[ |
|---|
| 383 | jQuery(document).ready(function($){ |
|---|
| 384 | $('#spyContainer > div:gt(4)').fadeEachDown(); // initial fade |
|---|
| 385 | $('#spyContainer').spy({ |
|---|
| 386 | limit: 10, |
|---|
| 387 | fadeLast: 5, |
|---|
| 388 | ajax: '<?php echo $wpurl."/wp-content/plugins/".WASSUPFOLDER."/lib/action.php?action=spy&whash=$whash&spytype=$spytype"; ?>', |
|---|
| 389 | timeout: 2000, |
|---|
| 390 | 'timestamp': myTimestamp, |
|---|
| 391 | fadeInSpeed: 1100 }); |
|---|
| 392 | }); |
|---|
| 393 | |
|---|
| 394 | function myTimestamp() { |
|---|
| 395 | var d = new Date(); |
|---|
| 396 | var timestamp = d.getFullYear() + '-' + pad(d.getMonth()) + '-' + pad(d.getDate()); |
|---|
| 397 | timestamp += ' '; |
|---|
| 398 | timestamp += pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); |
|---|
| 399 | return timestamp; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | // pad ensures the date looks like 2006-09-13 rather than 2006-9-13 |
|---|
| 403 | function pad(n) { |
|---|
| 404 | n = n.toString(); |
|---|
| 405 | return (n.length == 1 ? '0' + n : n); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | //]]> |
|---|
| 409 | </script> |
|---|
| 410 | <?php } //end if page == "wassup-spy" |
|---|
| 411 | |
|---|
| 412 | } //end if plugin_page == "wassup" |
|---|
| 413 | } //end function add_wassup_css() |
|---|
| 414 | |
|---|
| 415 | //put WassUp in the top-level admin menu and add submenus.... |
|---|
| 416 | function wassup_add_pages() { |
|---|
| 417 | global $wassup_options; |
|---|
| 418 | $userlevel = $wassup_options->wassup_userlevel; |
|---|
| 419 | if (empty($userlevel)) { $userlevel = 8; } |
|---|
| 420 | // add the default submenu first (important!)... |
|---|
| 421 | add_submenu_page(WASSUPFOLDER, __('Visitor Details', 'wassup'), __('Visitor Details', 'wassup'), $userlevel, WASSUPFOLDER, 'WassUp'); //<-- WASSUPFOLDER needed here for directory names that include a version number... |
|---|
| 422 | // then add top menu and other submenus... |
|---|
| 423 | add_menu_page('Wassup', 'WassUp', $userlevel, WASSUPFOLDER, 'Wassup'); |
|---|
| 424 | add_submenu_page(WASSUPFOLDER, __('Spy Visitors', 'wassup'), __('SPY Visitors', 'wassup'), $userlevel, 'wassup-spy', 'WassUp'); |
|---|
| 425 | add_submenu_page(WASSUPFOLDER, __('Current Visitors Online', 'wassup'), __('Current Visitors Online', 'wassup'), $userlevel, 'wassup-online', 'WassUp'); |
|---|
| 426 | add_submenu_page(WASSUPFOLDER, __('Options', 'wassup'), __('Options', 'wassup'), $userlevel, 'wassup-options', 'WassUp'); |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | function WassUp() { |
|---|
| 430 | global $wpdb, $wp_version, $version, $wpurl, $wassup_options, $whash; |
|---|
| 431 | |
|---|
| 432 | // Start getting time of execution to debug SQL query |
|---|
| 433 | $mtime = microtime(); |
|---|
| 434 | $mtime = explode(" ",$mtime); |
|---|
| 435 | $mtime = $mtime[1] + $mtime[0]; |
|---|
| 436 | $starttime = $mtime; |
|---|
| 437 | // This could be commented out |
|---|
| 438 | |
|---|
| 439 | //#debug... |
|---|
| 440 | //error_reporting(E_ALL | E_STRICT); //debug, E_STRICT=php5 only |
|---|
| 441 | //ini_set('display_errors','On'); //debug |
|---|
| 442 | //$wpdb->show_errors(); //debug |
|---|
| 443 | |
|---|
| 444 | $table_name = $wpdb->prefix . "wassup"; |
|---|
| 445 | $table_tmp_name = $wpdb->prefix . "wassup_tmp"; |
|---|
| 446 | $wassup_options->loadSettings(); //needed in case "update_option is run elsewhere in wassup (widget) |
|---|
| 447 | |
|---|
| 448 | // RUN THE SAVE/RESET OPTIONS |
|---|
| 449 | $admin_message=""; |
|---|
| 450 | if (isset($_POST['submit-options']) || |
|---|
| 451 | isset($_POST['submit-options2']) || |
|---|
| 452 | isset($_POST['submit-options3'])) { |
|---|
| 453 | if ($_POST['wassup_remind_flag'] == 1 AND $_POST['wassup_remind_mb'] == "") { |
|---|
| 454 | $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag']; |
|---|
| 455 | $wassup_options->wassup_remind_mb = 10; |
|---|
| 456 | } else { |
|---|
| 457 | $wassup_options->wassup_remind_flag = $_POST['wassup_remind_flag']; |
|---|
| 458 | $wassup_options->wassup_remind_mb = $_POST['wassup_remind_mb']; |
|---|
| 459 | } |
|---|
| 460 | $wassup_options->wassup_active = $_POST['wassup_active']; |
|---|
| 461 | $wassup_options->wassup_chart_type = $_POST['wassup_chart_type']; |
|---|
| 462 | $wassup_options->wassup_loggedin = $_POST['wassup_loggedin']; |
|---|
| 463 | $wassup_options->wassup_spider = $_POST['wassup_spider']; |
|---|
| 464 | $wassup_options->wassup_attack = $_POST['wassup_attack']; |
|---|
| 465 | $wassup_options->wassup_hack = $_POST['wassup_hack']; |
|---|
| 466 | $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck']; |
|---|
| 467 | $wassup_options->wassup_spam = $_POST['wassup_spam']; |
|---|
| 468 | $wassup_options->wassup_refspam = $_POST['wassup_refspam']; |
|---|
| 469 | $wassup_options->wassup_exclude = $_POST['wassup_exclude']; |
|---|
| 470 | $wassup_options->wassup_exclude_url = $_POST['wassup_exclude_url']; |
|---|
| 471 | $wassup_options->delete_auto = $_POST['delete_auto']; |
|---|
| 472 | $wassup_options->delete_auto_size = $_POST['delete_auto_size']; |
|---|
| 473 | $wassup_options->wassup_screen_res = $_POST['wassup_screen_res']; |
|---|
| 474 | $wassup_options->wassup_refresh = $_POST['wassup_refresh']; |
|---|
| 475 | $wassup_options->wassup_userlevel = $_POST['wassup_userlevel']; |
|---|
| 476 | $wassup_options->wassup_dashboard_chart = $_POST['wassup_dashboard_chart']; |
|---|
| 477 | $wassup_options->wassup_geoip_map = $_POST['wassup_geoip_map']; |
|---|
| 478 | $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key']; |
|---|
| 479 | $wassup_options->wassup_time_format = $_POST['wassup_time_format']; |
|---|
| 480 | $wassup_options->wassup_default_type = $_POST['wassup_default_type']; |
|---|
| 481 | $wassup_options->wassup_default_limit = $_POST['wassup_default_limit']; |
|---|
| 482 | $top_ten = array("topsearch" => $_POST['topsearch'], |
|---|
| 483 | "topreferrer" => $_POST['topreferrer'], |
|---|
| 484 | "toprequest" => $_POST['toprequest'], |
|---|
| 485 | "topbrowser" => $_POST['topbrowser'], |
|---|
| 486 | "topos" => $_POST['topos'], |
|---|
| 487 | "toplocale" => $_POST['toplocale'], |
|---|
| 488 | "topvisitor" => $_POST['topvisitor'], |
|---|
| 489 | "topfeed" => "0", |
|---|
| 490 | "topcrawler" => "0", |
|---|
| 491 | "topreferrer_exclude" => $_POST['topreferrer_exclude']); |
|---|
| 492 | $wassup_options->wassup_top10 = serialize($top_ten); |
|---|
| 493 | /* if ( $_POST['wassup_savepath'] != $wassup_options->wassup_savepath ) { |
|---|
| 494 | if (empty($_POST['wassup_savepath']) || rtrim($_POST['wassup_savepath'],"/") == getSessionpath()) { |
|---|
| 495 | $wassup_options->wassup_savepath = NULL; |
|---|
| 496 | } else { |
|---|
| 497 | $wassup_options->setSavepath($_POST['wassup_savepath']); |
|---|
| 498 | } |
|---|
| 499 | } */ |
|---|
| 500 | if ($wassup_options->saveSettings()) { |
|---|
| 501 | $admin_message = __("Wassup options updated successfully","wassup")."." ; |
|---|
| 502 | } |
|---|
| 503 | } elseif (isset($_POST['submit-options4'])) { //uninstall checkbox |
|---|
| 504 | $wassup_options->wassup_uninstall = $_POST['wassup_uninstall']; |
|---|
| 505 | if ($wassup_options->saveSettings()) { |
|---|
| 506 | $admin_message = __("Wassup uninstall option updated successfully","wassup")."." ; |
|---|
| 507 | } |
|---|
| 508 | } elseif (isset($_POST['submit-spam'])) { |
|---|
| 509 | $wassup_options->wassup_spamcheck = $_POST['wassup_spamcheck']; |
|---|
| 510 | $wassup_options->wassup_spam = $_POST['wassup_spam']; |
|---|
| 511 | $wassup_options->wassup_refspam = $_POST['wassup_refspam']; |
|---|
| 512 | if ($wassup_options->saveSettings()) { |
|---|
| 513 | $admin_message = __("Wassup spam options updated successfully","wassup")."." ; |
|---|
| 514 | } |
|---|
| 515 | } elseif (isset($_POST['reset-to-default'])) { |
|---|
| 516 | $wassup_options->loadDefaults(); |
|---|
| 517 | if ($wassup_options->saveSettings()) { |
|---|
| 518 | $admin_message = __("Wassup options updated successfully","wassup")."." ; |
|---|
| 519 | } |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | //#sets current tab style for Wassup admin submenu? |
|---|
| 523 | if ($_GET['page'] == "wassup-spy") { |
|---|
| 524 | $class_spy="class='current'"; |
|---|
| 525 | } elseif ($_GET['page'] == "wassup-options") { |
|---|
| 526 | $class_opt="class='current'"; |
|---|
| 527 | } elseif ($_GET['page'] == "wassup-online") { |
|---|
| 528 | $class_ol="class='current'"; |
|---|
| 529 | } else { |
|---|
| 530 | $class_sub="class='current'"; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | //for stringShortener calculated values and max-width...-Helene D. 11/27/07, 12/6/07 |
|---|
| 534 | if (!empty($wassup_options->wassup_screen_res)) { |
|---|
| 535 | $screen_res_size = (int) $wassup_options->wassup_screen_res; |
|---|
| 536 | } else { |
|---|
| 537 | $screen_res_size = 670; |
|---|
| 538 | } |
|---|
| 539 | $max_char_len = ($screen_res_size)/10; |
|---|
| 540 | $screen_res_size = $screen_res_size+20; //for wrap margins... |
|---|
| 541 | |
|---|
| 542 | //for generating page link urls.... |
|---|
| 543 | //$wpurl = get_bloginfo('wpurl'); //global |
|---|
| 544 | $siteurl = get_bloginfo('siteurl'); |
|---|
| 545 | |
|---|
| 546 | //#display an admin message or an alert. This must be above "wrap" |
|---|
| 547 | //# div. -Helene D. 2/26/08. |
|---|
| 548 | if (!empty($admin_message)) { |
|---|
| 549 | $wassup_options->showMessage($admin_message); |
|---|
| 550 | } elseif (!empty($wassup_options->wassup_alert_message)) { |
|---|
| 551 | $wassup_options->showMessage(); |
|---|
| 552 | //#show alert message only once, so remove it here... |
|---|
| 553 | $wassup_options->wassup_alert_message = ""; |
|---|
| 554 | $wassup_options->saveSettings(); |
|---|
| 555 | } |
|---|
| 556 | //#debug - display MySQL errors/warnings |
|---|
| 557 | //$mysqlerror = $wpdb->print_error(); //debug |
|---|
| 558 | //if (!empty($mysqlerror)) { $wassup_options->showMessage($mysqlerror); } //debug |
|---|
| 559 | |
|---|
| 560 | //moved max-width to single "wrap" div and removed it from |
|---|
| 561 | // the individual spans and divs in style.php... ?> |
|---|
| 562 | <div class="wrap" style="max-width:<?php echo $screen_res_size; ?>px;" > |
|---|
| 563 | |
|---|
| 564 | <?php // HERE IS THE VISITORS ONLINE VIEW |
|---|
| 565 | if ($_GET['page'] == "wassup-online") { ?> |
|---|
| 566 | <h2><?php _e("Current Visitors Online", "wassup"); ?></h2> |
|---|
| 567 | <p class="legend"><?php echo __("Legend", "wassup").': <span class="box-log"> </span> '.__("Logged-in Users", "wassup").' <span class="box-aut"> </span> '.__("Comments Authors", "wassup").' <span class="box-spider"> </span> '.__("Spiders/bots", "wassup"); ?></p><br /> |
|---|
| 568 | <p class="legend"><a href="#" class="toggle-all"><?php _e("Expand All","wassup"); ?></a></p> |
|---|
| 569 | <?php |
|---|
| 570 | $to_date = wassup_get_time(); |
|---|
| 571 | $from_date = strtotime('-3 minutes', $to_date); |
|---|
| 572 | $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_tmp_name WHERE `timestamp` BETWEEN $from_date AND $to_date"); |
|---|
| 573 | $currenttot = $currenttot+0; //set to integer |
|---|
| 574 | print "<p class='legend'>".__("Visitors online", "wassup").": <strong>".$currenttot."</strong></p><br />"; |
|---|
| 575 | if ($currenttot > 0) { |
|---|
| 576 | $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"); |
|---|
| 577 | foreach ($qryC |
|---|