| 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.4.5-wp2.2 |
|---|
| 7 | Author: Michele Marcucci |
|---|
| 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.4.5-wp2.2"; |
|---|
| 20 | define('WASSUPFOLDER', dirname(plugin_basename(__FILE__)), TRUE); |
|---|
| 21 | require_once(dirname(__FILE__).'/lib/main.php'); |
|---|
| 22 | $wpurl = get_bloginfo('wpurl'); |
|---|
| 23 | |
|---|
| 24 | if (isset($_GET['export'])) { |
|---|
| 25 | export_wassup(); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | function wassup_activation_error() { |
|---|
| 29 | echo '<p><strong>' . __("Sorry, Wassup requires WordPress 2.3 or higher to work.","wassup") . '</strong></p>'; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | global $wp_version; |
|---|
| 33 | //#This works only in WP2.2 or higher |
|---|
| 34 | if (version_compare($wp_version, '2.2', '<')) { |
|---|
| 35 | add_action('admin_notices', wassup_activation_error()); |
|---|
| 36 | exit(1); |
|---|
| 37 | } else { |
|---|
| 38 | register_activation_hook( __FILE__, 'wassup_install' ); |
|---|
| 39 | add_action('admin_head', 'add_wassup_css'); |
|---|
| 40 | add_action('init', 'add_wassup_scripts'); |
|---|
| 41 | add_action('wp_head', 'add_wassup_meta_info'); |
|---|
| 42 | add_action("widgets_init", "wassup_widget_init"); |
|---|
| 43 | add_action('admin_menu', 'wassup_add_pages'); |
|---|
| 44 | add_action('send_headers', 'wassupAppend'); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | //#initial wassup settings for options this is here because |
|---|
| 48 | //I need it in more then one function (using global) |
|---|
| 49 | $defaultWdata = array( |
|---|
| 50 | 'wassup_active' => "1", |
|---|
| 51 | 'wassup_loggedin' => "1", |
|---|
| 52 | 'wassup_spider' => "1", |
|---|
| 53 | 'wassup_attack' => "1", |
|---|
| 54 | 'wassup_spamcheck' => "1", |
|---|
| 55 | 'wassup_spam' => "1", |
|---|
| 56 | 'wassup_refspam' => "1", |
|---|
| 57 | 'wassup_exclude' => "", |
|---|
| 58 | 'wassup_savepath' => null, |
|---|
| 59 | 'wassup_wchart' => "1", |
|---|
| 60 | 'delete_auto' => "never", |
|---|
| 61 | 'delete_auto_size' => "0", |
|---|
| 62 | 'wassup_remind_mb' => "0", |
|---|
| 63 | 'wassup_remind_flag' => "0", |
|---|
| 64 | 'wassup_refresh' => "3", |
|---|
| 65 | 'wassup_userlevel' => "8", |
|---|
| 66 | 'wassup_screen_res' => "800", |
|---|
| 67 | 'wassup_default_type' => "everything", |
|---|
| 68 | 'wassup_default_limit' => "10", |
|---|
| 69 | 'wassup_widget_title' => "Visitors Online", |
|---|
| 70 | 'wassup_widget_ulclass' => "links", |
|---|
| 71 | 'wassup_widget_loggedin' => "1", |
|---|
| 72 | 'wassup_widget_comauth' => "1", |
|---|
| 73 | 'wassup_widget_search' => "1", |
|---|
| 74 | 'wassup_widget_searchlimit' => "5", |
|---|
| 75 | 'wassup_widget_ref' => "1", |
|---|
| 76 | 'wassup_widget_reflimit' => "5", |
|---|
| 77 | 'wassup_widget_topbr' => "1", |
|---|
| 78 | 'wassup_widget_topbrlimit' => "5", |
|---|
| 79 | 'wassup_widget_topos' => "1", |
|---|
| 80 | 'wassup_widget_toposlimit' => "5", |
|---|
| 81 | 'wassup_widget_chars' => "18" |
|---|
| 82 | ); |
|---|
| 83 | |
|---|
| 84 | //#add initial options and create table when Wassup activated |
|---|
| 85 | function wassup_install() { |
|---|
| 86 | global $wpdb, $defaultWdata; |
|---|
| 87 | //### add/update wassup settings to Wordpress options table |
|---|
| 88 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 89 | if (empty($wassup_settings)) { |
|---|
| 90 | //# initialize wassup settings to default values |
|---|
| 91 | add_option('wassup_settings', $defaultWdata, 'Options for WassUp'); |
|---|
| 92 | } else { |
|---|
| 93 | //# update wassup settings for 'spamcheck', 'refspam', and 'spam' |
|---|
| 94 | if (!isset($wassup_settings['wassup_spamcheck'])) { |
|---|
| 95 | $wassup_settings['wassup_spamcheck'] = "1"; |
|---|
| 96 | //#set wassup_spamcheck=0 if wassup_refspam=0 and wassup_spam=0 |
|---|
| 97 | if (!isset($wassup_settings['wassup_spam']) && !isset($wassup_settings['wassup_refspam'])) { |
|---|
| 98 | $wassup_settings['wassup_spam'] = "1"; |
|---|
| 99 | $wassup_settings['wassup_refspam'] = "1"; |
|---|
| 100 | } elseif ( $wassup_settings['wassup_spam'] == "0" && $wassup_settings['wassup_refspam'] == "0" ) { |
|---|
| 101 | $wassup_settings['wassup_spamcheck'] = "0"; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | //# update wassup settings for 'savepath' (default is null) |
|---|
| 105 | if (!isset($wassup_settings['wassup_savepath'])) { |
|---|
| 106 | $wassup_settings['wassup_savepath'] = null; |
|---|
| 107 | //$wassup_settings['wassup_savepath'] = "/tmp"; #debug |
|---|
| 108 | } |
|---|
| 109 | //#save wassup settings changes |
|---|
| 110 | update_option('wassup_settings', $wassup_settings); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | //### create/upgrade wassup table |
|---|
| 114 | $table_name = $wpdb->prefix . "wassup"; |
|---|
| 115 | if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { |
|---|
| 116 | CreateTable(); |
|---|
| 117 | } else { |
|---|
| 118 | UpdateTable(); |
|---|
| 119 | } |
|---|
| 120 | } //#end function wassup_install |
|---|
| 121 | |
|---|
| 122 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 123 | |
|---|
| 124 | function add_wassup_meta_info() { |
|---|
| 125 | global $version; |
|---|
| 126 | print '<meta name="wassup-version" content="'.$version.'" />'; |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | //Add jquery AJAX library and dependent scripts for all Wassup admin menus... |
|---|
| 130 | function add_wassup_scripts() { |
|---|
| 131 | global $wpurl; |
|---|
| 132 | if (stristr($_GET['page'],WASSUPFOLDER) !== FALSE) { |
|---|
| 133 | if ( function_exists('wp_deregister_script')) { |
|---|
| 134 | wp_deregister_script('jquery'); //removes old jquery vers. |
|---|
| 135 | } |
|---|
| 136 | // the safe way to load jquery into WP... |
|---|
| 137 | wp_register_script('jquery', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/jquery.js',FALSE,'1.2.2'); |
|---|
| 138 | if ($_GET['page'] == "wassup-spy") { |
|---|
| 139 | //the safe way to load a jquery dependent script into WP... |
|---|
| 140 | wp_enqueue_script('spy', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/spy.js', array('jquery'), '1.4'); |
|---|
| 141 | } elseif($_GET['page'] == "wassup-options") { |
|---|
| 142 | wp_enqueue_script('ui.tabs', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/js/ui.tabs.js', array('jquery'), '3'); |
|---|
| 143 | } else { |
|---|
| 144 | //the safe way to load a jquery dependent script into WP... |
|---|
| 145 | wp_enqueue_script('thickbox', $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.js', array('jquery'), '3'); |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | //Add the wassup stylesheet and other javascripts... |
|---|
| 151 | function add_wassup_css() { |
|---|
| 152 | global $wpurl; |
|---|
| 153 | $hash = wp_hash('wassup'); |
|---|
| 154 | $plugin_page = attribute_escape($_GET['page']); |
|---|
| 155 | if (stristr($plugin_page,'wassup') !== FALSE) { $plugin_page="wassup"; } |
|---|
| 156 | //Add css and javascript to wassup menu pages only... |
|---|
| 157 | if ($plugin_page == "wassup") { |
|---|
| 158 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 159 | //$siteurl = get_bloginfo('siteurl'); //not used |
|---|
| 160 | //$wpurl = get_bloginfo('wpurl'); //global |
|---|
| 161 | |
|---|
| 162 | echo '<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/wassup.css'.'" type="text/css" />'; |
|---|
| 163 | echo '<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/thickbox/thickbox.css'.'" type="text/css" />'; |
|---|
| 164 | echo '<link rel="stylesheet" href="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/ui.tabs.css'.'" type="text/css" />'; |
|---|
| 165 | |
|---|
| 166 | if ($_GET['page'] != "wassup-options" AND $_GET['page'] != "wassup-spy") { ?> |
|---|
| 167 | <script type='text/javascript'> |
|---|
| 168 | //<![CDATA[ |
|---|
| 169 | function selfRefresh(){ |
|---|
| 170 | location.href='?<?php print $_SERVER['QUERY_STRING']; ?>'; |
|---|
| 171 | } |
|---|
| 172 | setTimeout('selfRefresh()', <?php print ($wassup_settings['wassup_refresh'] * 60000); ?>); |
|---|
| 173 | //]]> |
|---|
| 174 | </script> |
|---|
| 175 | |
|---|
| 176 | <script type='text/javascript'> |
|---|
| 177 | //<![CDATA[ |
|---|
| 178 | var _countDowncontainer="0"; |
|---|
| 179 | var _currentSeconds="0"; |
|---|
| 180 | function ActivateCountDown(strContainerID, initialValue) { |
|---|
| 181 | _countDowncontainer = document.getElementById(strContainerID); |
|---|
| 182 | SetCountdownText(initialValue); |
|---|
| 183 | window.setTimeout("CountDownTick()", 1000); |
|---|
| 184 | } |
|---|
| 185 | function CountDownTick() { |
|---|
| 186 | SetCountdownText(_currentSeconds-1); |
|---|
| 187 | window.setTimeout("CountDownTick()", 1000); |
|---|
| 188 | } |
|---|
| 189 | function SetCountdownText(seconds) { |
|---|
| 190 | //store: |
|---|
| 191 | _currentSeconds = seconds; |
|---|
| 192 | //build text: |
|---|
| 193 | var strText = AddZero(seconds); |
|---|
| 194 | //apply: |
|---|
| 195 | if (_countDowncontainer) { //prevents error in "Options" submenu |
|---|
| 196 | _countDowncontainer.innerHTML = strText; |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | function AddZero(num) { |
|---|
| 200 | return ((num >= "0")&&(num < 10))?"0"+num:num+""; |
|---|
| 201 | } |
|---|
| 202 | //]]> |
|---|
| 203 | </script> |
|---|
| 204 | <script type="text/javascript"> |
|---|
| 205 | //<![CDATA[ |
|---|
| 206 | window.onload=WindowLoad; |
|---|
| 207 | function WindowLoad(event) { |
|---|
| 208 | ActivateCountDown("CountDownPanel", <?php print ($wassup_settings['wassup_refresh'] * 60); ?>); |
|---|
| 209 | } |
|---|
| 210 | //]]> |
|---|
| 211 | </script> |
|---|
| 212 | |
|---|
| 213 | <script type="text/javascript"> |
|---|
| 214 | //<![CDATA[ |
|---|
| 215 | jQuery(document).ready(function($){ |
|---|
| 216 | $("a.showhide").click(function(){ |
|---|
| 217 | var id = $(this).attr('id'); |
|---|
| 218 | $("div.navi" + id).toggle("slow"); |
|---|
| 219 | return false; |
|---|
| 220 | }); |
|---|
| 221 | $("a.toggleagent").click(function(){ |
|---|
| 222 | var id = $(this).attr('id'); |
|---|
| 223 | $("div.naviagent" + id).slideToggle("slow"); |
|---|
| 224 | return false; |
|---|
| 225 | }); |
|---|
| 226 | $("a.deleteID").click(function(){ |
|---|
| 227 | var id = $(this).attr('id'); |
|---|
| 228 | $.ajax({ |
|---|
| 229 | url: "<?php echo $wpurl; ?>/wp-content/plugins/<?php echo WASSUPFOLDER; ?>/lib/action.php?action=delete&hash=<?php echo $hash; ?>&id=" + id, |
|---|
| 230 | async: false |
|---|
| 231 | }) |
|---|
| 232 | $("div.delID" + id).fadeOut("slow"); |
|---|
| 233 | return false; |
|---|
| 234 | }); |
|---|
| 235 | $("a.show-search").toggle(function(){ |
|---|
| 236 | $("div.search-ip").slideDown("slow"); |
|---|
| 237 | $("a.show-search").html("<a href='#' class='show-search'>Hide Search</a>"); |
|---|
| 238 | },function() { |
|---|
| 239 | $("div.search-ip").slideUp("slow"); |
|---|
| 240 | $("a.show-search").html("<a href='#' class='show-search'>Search</a>"); |
|---|
| 241 | return false; |
|---|
| 242 | }); |
|---|
| 243 | $("a.show-topten").toggle(function(){ |
|---|
| 244 | $("div.topten").slideDown("slow"); |
|---|
| 245 | $("a.show-topten").html("<a href='#' class='show-topten'>Hide TopTen</a>"); |
|---|
| 246 | },function() { |
|---|
| 247 | $("div.topten").slideUp("slow"); |
|---|
| 248 | $("a.show-topten").html("<a href='#' class='show-topten'>Show TopTen</a>"); |
|---|
| 249 | return false; |
|---|
| 250 | }); |
|---|
| 251 | |
|---|
| 252 | $("a.toggle-all").toggle(function() { |
|---|
| 253 | $("div.togglenavi").slideDown("slow"); |
|---|
| 254 | $("a.toggle-all").html("<a href='#' class='toggle-all'>Collapse All</a>"); |
|---|
| 255 | },function() { |
|---|
| 256 | $("div.togglenavi").slideUp("slow"); |
|---|
| 257 | $("a.toggle-all").html("<a href='#' class='toggle-all'>Expand All</a>"); |
|---|
| 258 | return false; |
|---|
| 259 | }); |
|---|
| 260 | $("a.toggle-allcrono").toggle(function() { |
|---|
| 261 | $("div.togglecrono").slideUp("slow"); |
|---|
| 262 | $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'>Expand Cronology</a>"); |
|---|
| 263 | },function() { |
|---|
| 264 | $("div.togglecrono").slideDown("slow"); |
|---|
| 265 | $("a.toggle-allcrono").html("<a href='#' class='toggle-allcrono'>Collapse Cronology</a>"); |
|---|
| 266 | return false; |
|---|
| 267 | }); |
|---|
| 268 | }); //end jQuery(document).ready |
|---|
| 269 | //]]> |
|---|
| 270 | </script> |
|---|
| 271 | <?php } //end if page != wassup-options ?> |
|---|
| 272 | |
|---|
| 273 | <script type='text/javascript'> |
|---|
| 274 | //<![CDATA[ |
|---|
| 275 | function go() |
|---|
| 276 | { |
|---|
| 277 | box = document.forms["0"].navi; |
|---|
| 278 | destination = box.options[box.selectedindex].value; |
|---|
| 279 | if (destination) location.href = destination; |
|---|
| 280 | } |
|---|
| 281 | function go2() |
|---|
| 282 | { |
|---|
| 283 | box2 = document.forms["0"].type; |
|---|
| 284 | destination2 = box2.options[box2.selectedindex].value; |
|---|
| 285 | if (destination2) location.href = destination2; |
|---|
| 286 | } |
|---|
| 287 | //]]> |
|---|
| 288 | </script> |
|---|
| 289 | |
|---|
| 290 | <?php |
|---|
| 291 | if ($_GET['page'] == "wassup-spy") { |
|---|
| 292 | ?> |
|---|
| 293 | <script type="text/javascript"> |
|---|
| 294 | jQuery(document).ready(function($){ |
|---|
| 295 | $('#spyContainer > div:gt(4)').fadeEachDown(); // initial fade |
|---|
| 296 | $('#spyContainer').spy({ |
|---|
| 297 | limit: 10, |
|---|
| 298 | fadeLast: 5, |
|---|
| 299 | ajax: '<?php echo $wpurl."/wp-content/plugins/".WASSUPFOLDER."/lib/action.php?action=spy&hash=$hash"; ?>', |
|---|
| 300 | timeout: 2000, |
|---|
| 301 | 'timestamp': myTimestamp, |
|---|
| 302 | fadeInSpeed: 1100 }); |
|---|
| 303 | }); |
|---|
| 304 | |
|---|
| 305 | function myTimestamp() { |
|---|
| 306 | var d = new Date(); |
|---|
| 307 | var timestamp = d.getFullYear() + '-' + pad(d.getMonth()) + '-' + pad(d.getDate()); |
|---|
| 308 | timestamp += ' '; |
|---|
| 309 | timestamp += pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); |
|---|
| 310 | return timestamp; |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | // pad ensures the date looks like 2006-09-13 rather than 2006-9-13 |
|---|
| 314 | function pad(n) { |
|---|
| 315 | n = n.toString(); |
|---|
| 316 | return (n.length == 1 ? '0' + n : n); |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | //]]> |
|---|
| 320 | </script> |
|---|
| 321 | <?php } //end if page == "wassup-spy" |
|---|
| 322 | |
|---|
| 323 | } //end if plugin_page == "wassup" |
|---|
| 324 | } //end function add_wassup_css() |
|---|
| 325 | |
|---|
| 326 | //put WassUp in the top-level admin menu and add submenus.... |
|---|
| 327 | function wassup_add_pages() { |
|---|
| 328 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 329 | $userlevel = $wassup_settings['wassup_userlevel']; |
|---|
| 330 | if (empty($userlevel)) { $userlevel = 8; } |
|---|
| 331 | // add the default submenu first (important!)... |
|---|
| 332 | add_submenu_page(WASSUPFOLDER, __('Visitor Details', 'wassup'), __('Visitor Details', 'wassup'), $userlevel, WASSUPFOLDER, 'WassUp'); //<-- WASSUPFOLDER needed here for directory names that include a version number... |
|---|
| 333 | // then add top menu and other submenus... |
|---|
| 334 | add_menu_page('Wassup', 'WassUp', $userlevel, WASSUPFOLDER, 'Wassup'); |
|---|
| 335 | add_submenu_page(WASSUPFOLDER, __('Spy Visitors', 'wassup'), __('SPY Visitors', 'wassup'), $userlevel, 'wassup-spy', 'WassUp'); |
|---|
| 336 | add_submenu_page(WASSUPFOLDER, __('Current Visitors Online', 'wassup'), __('Current Visitors Online', 'wassup'), $userlevel, 'wassup-online', 'WassUp'); |
|---|
| 337 | add_submenu_page(WASSUPFOLDER, __('Options', 'wassup'), __('Options', 'wassup'), $userlevel, 'wassup-options', 'WassUp'); |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | function WassUp() { |
|---|
| 341 | global $wpdb, $version, $wpurl, $defaultWdata; |
|---|
| 342 | $hash = wp_hash('wassup'); |
|---|
| 343 | $table_name = $wpdb->prefix . "wassup"; |
|---|
| 344 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 345 | // RUN THE SAVE/RESET OPTIONS |
|---|
| 346 | if (isset($_POST['submit'])) { |
|---|
| 347 | if ($_POST['wassup_remind_flag'] == 1 AND $_POST['wassup_remind_mb'] == "") { |
|---|
| 348 | $wassup_settings['wassup_remind_flag'] = $_POST['wassup_remind_flag']; |
|---|
| 349 | $wassup_settings['wassup_remind_mb'] = 10; |
|---|
| 350 | } else { |
|---|
| 351 | $wassup_settings['wassup_remind_flag'] = $_POST['wassup_remind_flag']; |
|---|
| 352 | $wassup_settings['wassup_remind_mb'] = $_POST['wassup_remind_mb']; |
|---|
| 353 | } |
|---|
| 354 | $wassup_settings['wassup_active'] = $_POST['wassup_active']; |
|---|
| 355 | $wassup_settings['wassup_loggedin'] = $_POST['wassup_loggedin']; |
|---|
| 356 | $wassup_settings['wassup_spider'] = $_POST['wassup_spider']; |
|---|
| 357 | $wassup_settings['wassup_attack'] = $_POST['wassup_attack']; |
|---|
| 358 | $wassup_settings['wassup_spamcheck'] = $_POST['wassup_spamcheck']; |
|---|
| 359 | $wassup_settings['wassup_spam'] = $_POST['wassup_spam']; |
|---|
| 360 | $wassup_settings['wassup_refspam'] = $_POST['wassup_refspam']; |
|---|
| 361 | $wassup_settings['wassup_exclude'] = $_POST['wassup_exclude']; |
|---|
| 362 | $wassup_settings['delete_auto'] = $_POST['delete_auto']; |
|---|
| 363 | $wassup_settings['delete_auto_size'] = $_POST['delete_auto_size']; |
|---|
| 364 | $wassup_settings['wassup_screen_res'] = $_POST['wassup_screen_res']; |
|---|
| 365 | $wassup_settings['wassup_refresh'] = $_POST['wassup_refresh']; |
|---|
| 366 | $wassup_settings['wassup_userlevel'] = $_POST['wassup_userlevel']; |
|---|
| 367 | $wassup_settings['wassup_default_type'] = $_POST['wassup_default_type']; |
|---|
| 368 | $wassup_settings['wassup_default_limit'] = $_POST['wassup_default_limit']; |
|---|
| 369 | if ( $_POST['wassup_savepath'] != $wassup_settings['wassup_savepath'] ) { |
|---|
| 370 | if ( empty($_POST['wassup_savepath']) || rtrim($_POST['wassup_savepath'],"/") == wGetSessionpath() ) { |
|---|
| 371 | $wassup_settings['wassup_savepath'] = NULL; |
|---|
| 372 | } else { |
|---|
| 373 | $wassup_settings['wassup_savepath'] = rtrim($_POST['wassup_savepath'],"/"); |
|---|
| 374 | } |
|---|
| 375 | } |
|---|
| 376 | update_option('wassup_settings', $wassup_settings); |
|---|
| 377 | } elseif (isset($_POST['submit-spam'])) { |
|---|
| 378 | $wassup_settings['wassup_spamcheck'] = $_POST['wassup_spamcheck']; |
|---|
| 379 | $wassup_settings['wassup_spam'] = $_POST['wassup_spam']; |
|---|
| 380 | $wassup_settings['wassup_refspam'] = $_POST['wassup_refspam']; |
|---|
| 381 | update_option('wassup_settings', $wassup_settings); |
|---|
| 382 | } elseif (isset($_POST['reset-to-default'])) { |
|---|
| 383 | print_r($defaultWdata); |
|---|
| 384 | delete_option('wassup_settings'); |
|---|
| 385 | update_option('wassup_settings', $defaultWdata); |
|---|
| 386 | $wassup_settings = get_option('wassup_settings'); |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | if ($_GET['page'] == "wassup-spy") { |
|---|
| 391 | $class_spy="class='current'"; |
|---|
| 392 | } elseif ($_GET['page'] == "wassup-options") { |
|---|
| 393 | $class_opt="class='current'"; |
|---|
| 394 | } elseif ($_GET['page'] == "wassup-online") { |
|---|
| 395 | $class_ol="class='current'"; |
|---|
| 396 | } else { |
|---|
| 397 | $class_sub="class='current'"; |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | //for stringShortener calculated values and max-width...-Helene D. 11/27/07, 12/6/07 |
|---|
| 401 | if (!empty($wassup_settings['wassup_screen_res'])) { |
|---|
| 402 | $screen_res_size = (int) $wassup_settings['wassup_screen_res']; |
|---|
| 403 | } else { |
|---|
| 404 | $screen_res_size = 670; |
|---|
| 405 | } |
|---|
| 406 | $max_char_len = ($screen_res_size)/10; |
|---|
| 407 | $screen_res_size = $screen_res_size+20; //for wrap margins... |
|---|
| 408 | |
|---|
| 409 | //moved max-width to single "wrap" div and removed it from |
|---|
| 410 | // the individual spans and divs in style.php... |
|---|
| 411 | print '<div class="wrap" style="max-width:'.$screen_res_size.'px;" >'; |
|---|
| 412 | //#moved CreateTable/UpdateTable to "wassup_install" function... |
|---|
| 413 | |
|---|
| 414 | //for generating page link urls.... |
|---|
| 415 | //$wpurl = get_bloginfo('wpurl'); //global |
|---|
| 416 | $siteurl = get_bloginfo('siteurl'); |
|---|
| 417 | |
|---|
| 418 | if ($_GET['page'] == "wassup-online") { |
|---|
| 419 | $to_date = wassup_get_time(); |
|---|
| 420 | $from_date = strtotime('-3 minutes', $to_date); |
|---|
| 421 | print '<h2>Current Visitors Online</h2>'; |
|---|
| 422 | print '<p style="font-size:11px">Legend: <span class="box-log"> </span> Logged-in Users <span class="box-aut"> </span> Comments Authors <span class="box-spider"> </span> Spiders/bots</p><br />'."\n"; |
|---|
| 423 | print '<p style="font-size:11px;"><a href="#" class="toggle-all">Expand All</a></p>'; |
|---|
| 424 | $currenttot = $wpdb->get_var("SELECT COUNT(DISTINCT wassup_id) as currenttot FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date"); |
|---|
| 425 | $currenttot = $currenttot+0; //set to integer |
|---|
| 426 | print "<p style='font-size:11px;'>Visitors online: <strong>".$currenttot."</strong></p><br />"; |
|---|
| 427 | if ($currenttot > 0) { |
|---|
| 428 | $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_name WHERE timestamp BETWEEN $from_date AND $to_date GROUP BY ip ORDER BY max_timestamp DESC"); |
|---|
| 429 | foreach ($qryC as $cv) { |
|---|
| 430 | //$timestamp = $cv->max_timestamp; //redundant |
|---|
| 431 | $timed = gmdate("H:i:s", $cv->max_timestamp); |
|---|
| 432 | $ip = @explode(",", $cv->ip); |
|---|
| 433 | if ($cv->referrer != '') { |
|---|
| 434 | if (!eregi($wpurl, $cv->referrer) OR $cv->searchengine != "") { |
|---|
| 435 | if (!eregi($wpurl, $cv->referrer) AND $cv->searchengine == "") { |
|---|
| 436 | $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK"><span style="font-weight: bold;">'.stringShortener($cv->referrer, round($max_char_len*.8,0)).'</span></a>'; |
|---|
| 437 | } else { |
|---|
| 438 | $referrer = '<a href="'.$cv->referrer.'" target=_"BLANK">'.stringShortener($cv->referrer, round($max_char_len*.9,0)).'</a>'; |
|---|
| 439 | } |
|---|
| 440 | } else { |
|---|
| 441 | $referrer = "Direct hit"; |
|---|
| 442 | } |
|---|
| 443 | } else { |
|---|
| 444 | $referrer = "From your blog"; |
|---|
| 445 | } |
|---|
| 446 | $numurl = $wpdb->get_var("SELECT COUNT(DISTINCT id) as numurl FROM $table_name WHERE wassup_id='".$cv->wassup_id."'"); |
|---|
| 447 | ?> |
|---|
| 448 | <div class="sum"> |
|---|
| 449 | |
|---|