-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwassup.php
4144 lines (4092 loc) · 168 KB
/
wassup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: WassUp Real Time Analytics
Plugin URI: http://www.wpwp.org
Description: Analyze your website traffic with accurate, real-time stats, live views, visitor counts, top stats, IP geolocation, customizable tracking, and more. For Wordpress 2.2+
Version: 1.9.4.5
Author: Michele Marcucci, Helene Duncker
Author URI: http://www.michelem.org/
Text Domain: wassup
Domain Path: /language
License: GPL2
Copyright (c) 2007-2020 Michele Marcucci
Released under the GNU General Public License GPLv2 or later
http://www.gnu.org/licenses/gpl-2.0.html
Disclaimer:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*/
//-------------------------------------------------
//# No direct requests for plugin file "wassup.php"
$wassupfile=preg_replace('/\\\\/','/',__FILE__); //for windows
//abort if this is direct request for file
if((!empty($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME'])===realpath($wassupfile)) ||
(!empty($_SERVER['PHP_SELF']) && preg_match('#'.str_replace('#','\#',preg_quote($_SERVER['PHP_SELF'])).'$#',$wassupfile)>0)){
//try track this uri request for "wassup.php"
if(!headers_sent()){
//can't track 403-forbidden, so use 404 instead
//location value triggers redirect to WordPress' 404 error page so Wassup can track this attempt to access itself (original uri request is lost)
header('Location: /?p=404page&werr=wassup403'.'&wf='.basename($wassupfile));
exit;
}else{
//'wp_die' is undefined here
die('<strong>Sorry. Unable to display requested page.</strong>');
}
//abort if no WordPress
}elseif(!defined('ABSPATH') || empty($GLOBALS['wp_version'])){
//'wp_die' is undefined here
die("Bad Request: ".htmlspecialchars(preg_replace('/(�*37;?|&?#0*37;?|�*38;?#0*37;?|%)(?:[01][0-9A-F]|7F)/i','',$_SERVER['REQUEST_URI'])));
}
//-------------------------------------------------
//### Setup and startup functions
/**
* Set up WassUp environment in Wordpress
* @since v1.9
*/
function wassup_init($init_settings=false){
global $wp_version,$wassup_options,$wdebug_mode;
//define wassup globals & constants
if(!defined('WASSUPVERSION')){
define('WASSUPVERSION','1.9.4.5');
define('WASSUPDIR',dirname(preg_replace('/\\\\/','/',__FILE__)));
}
//turn on debugging in Wassup (global)...Use cautiously! May display errors from other plugins, not just WassUp
$wdebug_mode=false;
if(defined('WP_DEBUG') && WP_DEBUG==true) $wdebug_mode=true;
if($wdebug_mode){
$active_plugins=maybe_serialize(get_option('active_plugins'));
//turn off debug mode if this is ajax action request @since v1.9.2
if((!empty($_REQUEST['action']) && isset($_REQUEST['wajax'])) || (defined('DOING_AJAX') && DOING_AJAX)){
$wdebug_mode=false;
@wassup_disable_errors();
}elseif(isset($_REQUEST['wc-ajax']) && preg_match('#/woocommerce\.php#',$active_plugins)>0){ //woocommerce ajax
$wdebug_mode=false;
@wassup_disable_errors();
}else{
//allow error_reporting when WP_DEBUG is not set @since v1.9.4.4
if(!defined("WP_DEBUG") || WP_DEBUG===false){
@wassup_enable_errors();
}
if(headers_sent()){
//an error was likely displayed to screen
echo "\n".'<!-- wassup_init start -->';
}
}
}
//load language translation
if(empty($GLOBALS['locale']) || strlen($GLOBALS['locale'])>5) $current_locale=get_locale();
else $current_locale=$GLOBALS['locale'];
if(!empty($current_locale) && $current_locale !="en_US"){
$moFile=WASSUPDIR."/language/".$current_locale.".mo";
if(@is_readable($moFile)){
load_textdomain('wassup',$moFile);
}elseif(strlen($current_locale)<6){
//try load translation file with language code x2 as locale @since v1.9.3
$lang_only=substr($current_locale,0,2).'_'.strtoupper(substr($current_locale,0,2));
if($lang_only != $current_locale && preg_match('/^[a-z]{2}_[A-Z]{2}$/',$lang_only)>0){
$moFile=WASSUPDIR."/language/".$lang_only."mo";
if(@is_readable($moFile))
load_textdomain('wassup',$moFile);
}
}
}
//check Wordpress and PHP compatibility and load compatibility modules before using 'plugins_url' function
$php_vers=phpversion();
$is_compatible=true;
if(version_compare($wp_version,'4.5','<') || version_compare($php_vers,'5.2','<')){
include_once(WASSUPDIR.'/lib/compatibility.php');
$is_compatible=wassup_check_compatibility();
}
//load required modules
if($is_compatible){
if(!class_exists('wassupOptions')) require_once(WASSUPDIR.'/lib/wassup.class.php');
define('WASSUPURL',plugins_url(basename(WASSUPDIR)));
//additional modules are loaded as needed
//require_once(WASSUPDIR.'/lib/wassupadmin.php');
//require_once(WASSUPDIR.'/lib/main.php');
//include_once(WASSUPDIR.'/lib/uadetector.class.php');
//initialize wassup settings for new multisite subsites
if($init_settings){
$wassup_options=new wassupOptions(true);
//save settings only if this is a network subsite
if(is_multisite() && !is_network_admin() && !is_main_site() && $wassup_options->network_activated_plugin()){
if(empty($wassup_options->wassup_version) || $wassup_options->wassup_version !=WASSUPVERSION){
$wassup_options->wassup_version=WASSUPVERSION;
$wassup_options->saveSettings();
}
}
}else{
//Load existing wassup wp_option settings, if any
$wassup_settings=get_option('wassup_settings');
if(count($wassup_settings)>1 && !empty($wassup_settings['wassup_version']) && $wassup_settings['wassup_version']==WASSUPVERSION){
$wassup_options=new wassupOptions;
}else{
//'else' shouldn't happen unless 'wassup_settings' wp_option record is corrupted or deleted/locked by another application
$wassup_options=new wassupOptions(true);
//corruption maybe caused by a 'wassup_install' interrupt or time out before update is done, so try re-save settings @since v1.9.2
//$wassup_options->wassup_version=WASSUPVERSION;
$wassup_options->saveSettings();
}
}
}else{
if(function_exists('is_network_admin') && is_network_admin()){
add_action('network_admin_notices','wassup_show_compat_message');
}else{
add_action('admin_notices','wassup_show_compat_message');
}
}
if($wdebug_mode && headers_sent()){
//an error message was likely displayed to screen
echo "\n"."<!-- is_compatible=$is_compatible \ncurrent_local=$current_locale \ninit_settings=$init_settings \nwassup_init end -->"."\n";
}
return $is_compatible;
} //end wassup_init
/**
* Install or upgrade Wassup plugin.
* - check wordpress compatibility
* - set initial plugin settings
* - check for multisite and set initial wassup network settings
* - create/upgrade Wassup tables.
* - save wassup settings and wassup network settings.
* @todo - enable network activation for subdomain networks
* @param boolean (for multisite network activation)
* @return void
*/
function wassup_install($network_wide=false) {
global $wpdb,$wp_version,$wassup_options,$wdebug_mode;
$wassup_settings=get_option('wassup_settings'); //save old settings
$wassup_network_settings=array();
//first check Wordpress compatibility via 'wassup_init'
if(!defined('WASSUPURL')){
if(!wassup_init(true)){
wassup_show_compat_message();
exit(1);
}
}
//additional install/upgrade functions in "upgrade.php" module
if (file_exists(WASSUPDIR.'/lib/upgrade.php')) {
require_once(WASSUPDIR.'/lib/upgrade.php');
} else {
echo sprintf(__("File %s does not exist!","wassup"),WASSUPDIR.'/lib/upgrade.php');
exit(1);
}
//initialize/update wassup_settings in wp_options
if(empty($wassup_options) || empty($wassup_options->wassup_version) || $wassup_options->wassup_version != WASSUPVERSION){
$wassup_options=new wassupOptions(true);
}
//network-wide settings for multisite @since v1.9
if(is_multisite()){
if(is_network_admin()){
$network_wide=true;
//no network activation in subdomain networks, subdomain sites must activate Wassup separately @TODO
if(is_subdomain_install()){
//long error message is NOT displaying for network activation error in WordPress 4.6.1, so use 'wp_die' instead of 'echo/exit' @since v1.9.1
$err = __("Sorry! \"Network Activation\" is DISABLED for subdomain networks.","wassup");
$err .= ' '.sprintf(__("%s must be activated on each subdomain site separately.","wassup"),'<strong>Wassup Plugin</strong>');
$err .=' <br/>'.__("Activate plugin on your parent domain (main site) to set default options for your network.","wassup");
$err .= '<br/><br/><a href="'.network_admin_url("plugins.php").'">'.__("Back to Plugins","wassup").'</a>';
wp_die($err);
}
$wassup_network_settings=wassup_network_install($network_wide);
}else{
$network_wide=false;
$wassup_network_settings=wassup_network_install($network_wide);
$subsite_settings=wassup_subsite_install($wassup_network_settings);
if(!empty($subsite_settings)) $wassup_options->loadSettings($subsite_settings);
}
}else{
$network_wide=false;
}
//set table names
//reset Wassup table name if wpdb prefix has changed @since v1.9
if(empty($wassup_options->wassup_table) || !wassupDb::table_exists($wassup_options->wassup_table)){
if($network_wide){
if(empty($wassup_network_settings['wassup_table']) || !wassupDb::table_exists($wassup_network_settings['wassup_table'])) $wassup_table=$wpdb->base_prefix . "wassup";
else $wassup_table= $wassup_network_settings['wassup_table'];
}else{
$wassup_table=$wpdb->prefix . "wassup";
}
}else{
$wassup_table=$wassup_options->wassup_table;
}
$wassup_meta_table=$wassup_table."_meta";
$wassup_options->wassup_table=$wassup_table;
//Important! Turn off 'wassup_active' setting during upgrade
$active_status=1;
if(!empty($wassup_settings)){
//save current 'wassup_active' setting prior to upgrade for later restore
$active_status=$wassup_settings['wassup_active'];
if($network_wide && !empty($wassup_network_settings['wassup_active'])){
$wassup_network_settings['wassup_active']="0";
update_site_option('wassup_network_settings',$wassup_network_settings);
}elseif(!empty($active_status)){
$wassup_options->wassup_active="0";
$wassup_options->saveSettings();
}
//cancel all scheduled Wassup wp-cron jobs in case Wassup wp-cron jobs not previously canceled
if(!empty($wassup_options->wassup_upgraded) || (!empty($wassup_options->wassup_version) && version_compare($wassup_options->wassup_version,"1.9",">="))){
wassup_cron_terminate();
}
}
//Do the table upgrade
$admin_message="";
$wsuccess=false;
//upgrade table for new version of WassUp, after reset-to-default, or when table structure is outdated
if(empty($wassup_options->wassup_version) || WASSUPVERSION != $wassup_options->wassup_version || $wassup_options->wassup_upgraded==0 || !wassup_upgradeCheck()){
//increase script timeout to 16 minutes to prevent activation failure due to script timeout (browser timeout can still occur)
$stimeout=ini_get("max_execution_time");
if(is_numeric($stimeout) && $stimeout>0 && $stimeout < 990){
//check for 'set_time_limit' in disabled functions before changing script timeout
$disabled_funcs=ini_get('disable_functions');
if((empty($disabled_funcs) || strpos($disabled_funcs,'set_time_limit')===false) && !ini_get('safe_mode')){
@set_time_limit(990);
}
}
//do the table upgrade
$wassup_options->wassup_upgraded=0;
$wsuccess=wassup_tableInstaller($wassup_table);
if($wsuccess){
$admin_message=__("Database created/upgraded successfully","wassup");
}else{
$admin_message=__("An error occurred during the upgrade. WassUp table structure may not have been updated properly.","wassup");
}
}else{
//separate message for re-activation without table upgrade @since v1.9
$admin_message=__("activation successful","wassup");
if(!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'plugin-install.php')==false){
if(!is_multisite() || is_main_site() || is_network_admin()) $admin_message=__("activation successful. No upgrade necessary.","wassup");
}
}
//verify that main table is installed, then save settings
$wassup_table=$wassup_options->wassup_table; //in case changed
$wassup_meta_table=$wassup_table."_meta";
if(wassupDb::table_exists($wassup_options->wassup_table)){
$wassup_options->wassup_alert_message=$admin_message;
//update settings
if($wsuccess){
//update network settings
if($network_wide){
if(!is_subdomain_install()) $wassup_network_settings['wassup_table']=$wassup_table;
else unset($wassup_network_settings['wassup_table']);
$wassup_network_settings['wassup_active']=1;
update_site_option('wassup_network_settings',$wassup_network_settings);
}
//update site settings
//check the upgrade timestamp to prevent repeat of 'wassup_settings_install()' (runs in 'upgrade.php')
if(empty($wassup_options->wassup_upgraded) || ((int)time() - (int)$wassup_options->wassup_upgraded) >180){
wassup_settings_install($wassup_table);
}
$wassup_upgraded=time();
$wassup_options->wassup_version=WASSUPVERSION;
}elseif(!wassup_upgradeCheck($wassup_table)){
//table not upgraded - exit with error
if(!empty($admin_message)) $error_msg=$admin_message;
else $error_msg='<strong style="color:#c00;padding:5px;">'.sprintf(__("%s: database upgrade failed!","wassup"),"Wassup ".WASSUPVERSION).'</strong>';
if($wdebug_mode) $error_msg .=" <br/>wassup table: $wassup_table wassup_meta table: $wassup_meta_table";
echo $error_msg;
exit(1);
}
$wassup_options->wassup_active=$active_status;
$wassup_options->saveSettings();
//schedule regular cleanup of temp recs @since v1.9
if(!empty($active_status)) wassup_cron_startup();
}else{
//table not upgraded - exit with error
$error_msg='<strong style="color:#c00;padding:5px;">'.sprintf(__("%s: plugin install/upgrade failed!","wassup"),"Wassup ".WASSUPVERSION).'</strong>';
if($wdebug_mode) $error_msg .=" <br/>wassup table: $wassup_table wassup_meta table: $wassup_meta_table";
echo $error_msg;
exit(1); //exit with error
}
} //end wassup_install
/**
* Completely remove all wassup tables and options from Wordpress and deactivate plugin, if needed.
*
* NOTES:
* - no Wassup classes, globals, constants or functions are used during uninstall per Wordpress 'uninstall' hook requirement
* - no compatibility functions are loaded, so use 'function_exists' check for functions after Wordpress 2.2
* @param boolean (for multisite uninstall)
* @return void
*/
function wassup_uninstall($network_wide=false){
global $wpdb,$wp_version,$current_user;
$wassup_network_settings=array();
if(empty($current_user->ID)) wp_get_current_user();
//for multisite uninstall,
if(function_exists('is_multisite') && is_multisite()){
if($network_wide || is_network_admin()){
$network_wide=true;
$subsite_ids=$wpdb->get_col(sprintf("SELECT `blog_id` FROM `$wpdb->blogs` WHERE `site_id`='%d' ORDER BY `blog_id` DESC",$GLOBALS['current_blog']->site_id));
}
if(empty($subsite_ids) || is_wp_error($subsite_ids)){
$network_wide=false;
$subsite_ids = array("0"); //current site uninstall
}
}else{ //for single-site uninstall
$network_wide=false;
$subsite_ids = array("0");
}
//wassup should not be active during network uninstall
if($network_wide){
$wassup_network_settings=get_site_option('wassup_network_settings');
if(!empty($wassup_network_settings['wassup_active'])){
$wassup_network_settings['wassup_active']="0";
update_site_option('wassup_network_settings',$wassup_network_settings);
}
}
//remove tables and settings for each subsite (or single-site)
foreach($subsite_ids as $subsite_id){
if($network_wide) switch_to_blog($subsite_id);
$wassup_settings = get_option('wassup_settings');
//first, stop recording (when plugin is still running)
if(!$network_wide && !empty($wassup_settings['wassup_active'])){
$wassup_settings['wassup_active']="0";
update_option('wassup_settings',$wassup_settings);
}
//wp-ajax actions may persist, so remove it
remove_action('wp_ajax_wassup_action_handler','wassup_action_handler');
//wp-cron actions may persist, so remove them
remove_action('wassup_scheduled_cleanup','wassup_temp_cleanup');
remove_action('wassup_scheduled_purge','wassup_auto_cleanup');
remove_action('wassup_scheduled_dbtasks',array('wassupDb','scheduled_dbtask'));
//scheduled tasks in wp-cron persist, so remove them
if(version_compare($wp_version,'3.0','>')){
wp_clear_scheduled_hook('wassup_scheduled_cleanup');
wp_clear_scheduled_hook('wassup_scheduled_purge');
wp_clear_scheduled_hook('wassup_scheduled_dbtasks');
if(!is_multisite() || is_main_site() || empty($wassup_network_settings['wassup_table'])){
remove_action('wassup_scheduled_optimize',array('wassupDb','scheduled_dbtask'));
wp_clear_scheduled_hook('wassup_scheduled_optimize');
}
}
//aside widgets persist, so remove them
$wassup_widgets=array('wassup_online','wassup_topstats');
foreach ($wassup_widgets AS $wwidget){
if(function_exists('unregister_widget')){
unregister_widget($wwidget."Widget");
}else{
wp_unregister_sidebar_widget($wwidget);
}
//cleanup aside widget options from wp_option
$deleted=$wpdb->query(sprintf("DELETE FROM {$wpdb->prefix}options WHERE `option_name` LIKE 'widget_%s'",$wwidget.'%'));
}
//if plugin is still running, deactivate it
if(function_exists('is_plugin_active') && function_exists('deactivate_plugins')){
$wfile=preg_replace('/\\\\/','/',__FILE__);
$wassupplugin=plugin_basename($wfile);
if(is_plugin_active($wassupplugin)){
deactivate_plugins($wassupplugin);
}elseif(is_plugin_active(basename(dirname(__FILE__)))){
deactivate_plugins(basename(dirname(__FILE__)));
}
}
//remove wassup tables
//$wassup_table = $wassup_settings['wassup_table'];
$wassup_table = $wpdb->prefix."wassup";
$table_tmp_name = $wassup_table."_tmp";
$table_meta_name = $wassup_table."_meta";
//purge wassup tables- WARNING: this is a permanent erase!!
if(version_compare($wp_version,'3.1','>')){
$dropped=$wpdb->query("DROP TABLE IF EXISTS $table_meta_name");
$dropped=$wpdb->query("DROP TABLE IF EXISTS $table_tmp_name");
$dropped=$wpdb->query("DROP TABLE IF EXISTS $wassup_table");
}
//make sure tables were dropped (compatibility code) @since v1.9.2
if($wpdb->get_var(sprintf("SHOW TABLES LIKE '%s'",like_escape($wassup_table)))==$wassup_table){
//"if exists" in wpdb::query caused error in early versions of Wordpress
if($wpdb->get_var(sprintf("SHOW TABLES LIKE '%s'",like_escape($table_meta_name)))==$table_meta_name){
$dropped=$wpdb->query("DROP TABLE $table_meta_name");
}
if($wpdb->get_var(sprintf("SHOW TABLES LIKE '%s'",like_escape($table_tmp_name)))==$table_tmp_name){
$dropped=$wpdb->query("DROP TABLE $table_tmp_name");
}
$dropped=$wpdb->query("DROP TABLE $wassup_table");
}
//delete settings from wp_option and wp_usermeta tables
delete_option('wassup_settings');
//only current_user's settings are deleted here, all other users' wassup_settings are deleted outside foreach loop
if(function_exists('delete_user_option')) {
delete_user_option($current_user->ID,'_wassup_settings');
}else{
delete_usermeta($current_user->ID,$wpdb->prefix.'_wassup_settings');
}
} //end foreach
//lastly, delete network settings & users' settings
if($network_wide){
restore_current_blog();
delete_site_option('wassup_network_settings');
$deleted=$wpdb->query(sprintf("DELETE FROM `%s` WHERE `meta_key` LIKE '%%_wassup_settings'",$wpdb->base_prefix."usermeta"));
}elseif(!function_exists('is_multisite') || !is_multisite()){
//delete 'wassup_settings' from wp_usermeta for all users in single-site install
$deleted=$wpdb->query(sprintf("DELETE FROM `%s` WHERE `meta_key` LIKE '%%_wassup_settings'",$wpdb->prefix."usermeta"));
}
} //end wassup_uninstall
/** Stop Wassup wp-cron and wp-ajax on deactivation. @since v1.9 */
function wassup_deactivate(){
global $wp_version;
//wp-ajax action may persist, so remove it
remove_action('wp_ajax_wassup_action_handler','wassup_action_handler');
//wassup_cron_terminate();
//wp-cron actions may persist, so remove them
remove_action('wassup_scheduled_cleanup','wassup_temp_cleanup');
remove_action('wassup_scheduled_purge','wassup_auto_cleanup');
remove_action('wassup_scheduled_dbtasks',array('wassupDb','scheduled_dbtask'));
//scheduled tasks in wp-cron persist, so remove them
if(version_compare($wp_version,'3.0','>')){
wp_clear_scheduled_hook('wassup_scheduled_cleanup');
wp_clear_scheduled_hook('wassup_scheduled_purge');
wp_clear_scheduled_hook('wassup_scheduled_dbtasks');
if(!is_multisite() || is_main_site() || empty($wassup_network_settings['wassup_table'])){
remove_action('wassup_scheduled_optimize',array('wassupDb','scheduled_dbtask'));
wp_clear_scheduled_hook('wassup_scheduled_optimize');
}
}
}
/**
* Start Wassup plugin
* -assign plugin functions to Wordpress init (preload)
* @since v1.9
*/
function wassup_start(){
//startup wassup
add_action('init','wassup_preload',11);
add_action('login_init','wassup_preload',11); //separate action
add_action('admin_init','wassup_admin_preload',11);
add_action('plugins_loaded','wassup_load');
}
/**
* Perform plugin tasks for before http headers are sent.
* -block obvious xss and sql injection attempts on Wassup itself
* -initialize new network subsite settings (via 'wassup_init'), if any
* -setup maintenance tasks for wp-ajax/wp_cron/wp_login hook actions
* -start wassup tracking
*/
function wassup_preload(){
global $wp_version,$current_user,$wassup_options,$wdebug_mode;
//block any obvious sql injection attempts involving WassUp
$request_uri=$_SERVER['REQUEST_URI'];
if(!$request_uri) $request_uri=$_SERVER['SCRIPT_NAME']; // IIS
if(stristr($request_uri,'wassup')!==false && strstr($request_uri,'err=wassup403')===false){
$error_msg="";
//don't test logged-in user requests
if(!is_user_logged_in()){
if(preg_match('/(<|<?|�*60;?|%3C)scr(ipt|[^0-9a-z\-_])/i',$request_uri)>0){
$error_msg=__('Bad request!','wassup');
if($wdebug_mode) $error_msg .=" xss not allowed.";
}elseif(preg_match('/[&?][^=]+=\-[19]+|(select|update|delete|alter|drop|union|create)[ %&][^w]+wp_/i',str_replace(array('\\','\','"','%22','"','"',''','\'','`','`'),'',$request_uri))>0){
$error_msg=__('Bad request!','wassup');
if($wdebug_mode) $error_msg .=" special chars not allowed.";
}
}
//abort bad requests
if(!empty($error_msg)){
if($wdebug_mode){
wp_die($error_msg.' :'.esc_attr(preg_replace('/(�*37;?|&?#0*37;?|�*38;?#0*37;?|%)(?:[01][0-9A-F]|7F)/i','---',$_SERVER['REQUEST_URI'])));
}
//redirect bad requests to 404 error page
if(!headers_sent()) header('Location: /?p=404page&werr=wassup403');
else wp_die($error_msg);
exit;
}
}
//load Wassup settings and includes
if(!defined('WASSUPURL')){
//load Wassup settings for new network subsites
if(function_exists('is_network_admin') && !is_network_admin() && !is_main_site()) $is_compatible=wassup_init(true);
else $is_compatible=wassup_init();
if(!$is_compatible){ //do nothing
return;
}
}
if($wdebug_mode && headers_sent()){
//an error message was likely displayed to screen
echo "\n".'<!-- wassup_preload start -->';
}
//fix for object error seen in support forum, but redundant to fix already in 'wassup_init' @since v1.9.2
if(empty($wassup_options)){
if(!class_exists('wassupOptions')) require_once(WASSUPDIR.'/lib/wassup.class.php');
$wassup_options=new wassupOptions;
if(empty($wassup_options)) return; //nothing to do
}
//reset wassup user settings at login @since v1.9
add_action('wp_login',array($wassup_options,'resetUserSettings'),9,2);
//assign action handler for wp-ajax operations @since v1.9.1
if(!function_exists('wassup_action_handler')){
require_once(WASSUPDIR .'/lib/action.php');
}
add_action('wp_ajax_wassup_action_handler','wassup_action_handler');
//for backward compatibility with older versions of Wordpress
//..runs 'admin_init' hook functions for Wordpress 2.2 - 2.5
if(function_exists('wassup_compat_preload')){
wassup_compat_preload();
}
//Start maintenance tasks & visitor tracking
if(!empty($wassup_options) && $wassup_options->is_recording_active()){
//add actions for wp-cron scheduled tasks - @since v1.9
if(!has_action('wassup_scheduled_dbtasks')) add_action('wassup_scheduled_dbtasks',array('wassupDb','scheduled_dbtask'),10,1);
if(!is_multisite() || is_main_site() || !$wassup_options->network_activated_plugin()){
if (!has_action('wassup_scheduled_optimize')) add_action('wassup_scheduled_optimize',array('wassupDb','scheduled_dbtask'),10,1);
}
//add custom actions for cleanup of inactive wassup_tmp records and expired cache records, if needed
if(!has_action('wassup_scheduled_cleanup')) add_action('wassup_scheduled_cleanup','wassup_temp_cleanup');
if(!empty($wassup_options->delete_auto) && $wassup_options->delete_auto !="never"){
if(!has_action('wassup_scheduled_purge')) add_action('wassup_scheduled_purge','wassup_auto_cleanup');
}
//track visitors
wassupPrepend();
}
if($wdebug_mode && headers_sent()){
//an error message was likely displayed to screen
echo "\n".'<!-- wassup_preload end -->'."\n";
}
} // end wassup_preload
/**
* Perform plugin actions for before start of page rendering.
* - load Wassup widgets
* - load footer tag/javascripts
*/
function wassup_load() {
global $wassup_options;
if(!defined('WASSUPURL')){
if(!wassup_init()) return; //nothing to do
}
//load widgets and visitor tracking footer scripts
if(!empty($wassup_options)){
if($wassup_options->is_recording_active()){
add_action("widgets_init",'wassup_widget_init',9);
if(is_admin()) add_action('admin_footer','wassup_foot');
else add_action('wp_footer','wassup_foot');
}
//load admin interface
if(is_admin()){
if(!function_exists('wassup_admin_load')) require_once(WASSUPDIR.'/lib/wassupadmin.php');
wassup_admin_load();
}
}
} //end wassup_load
//-------------------------------------------------
//### Admin functions
// WassUp admin panels and menus display functions are in a separate module, "wassupadmin.php" @since v1.9.1
/**
* Perform plugin admin tasks for before http headers are sent.
* - run 'initialize settings' for new network subsites, if needed
* - hook function for plugin deactivation actions
* - run Wassup ajax requests manually, if needed
* - run export request, if any
* - hook function for javascript libraries and frameworks load
* @since v1.9
*/
function wassup_admin_preload() {
global $wpdb, $wp_version, $wassup_options, $wdebug_mode;
if(!defined('WASSUPURL')){
//initializes new network subsites settings, if needed
if(function_exists('is_network_admin') && !is_network_admin() && !is_main_site()) $is_compatible=wassup_init(true);
else $is_compatible=wassup_init();
if(!$is_compatible) return; //nothing to do
}
//uninstall on deactivation when 'wassup_uninstall' option is set...applies to multisite subdomains and Wordpress 2.x setups only
if(!empty($wassup_options->wassup_uninstall)){
register_deactivation_hook(__FILE__,'wassup_uninstall');
}else{
register_deactivation_hook(__FILE__,'wassup_deactivate');
}
if(!empty($_GET['page']) && stristr($_GET['page'],"wassup")!==false){
//manually run ajax action handler for Wassup ajax only
if(!empty($_REQUEST['action']) && isset($_REQUEST['wajax'])){
if(!defined('DOING_AJAX') || !DOING_AJAX){ //superfluous test..applies to 'admin-ajax.php' requests only
do_action('wp_ajax_wassup_action_handler',$_REQUEST['action']);
}
exit;
}
//do export early
if(isset($_REQUEST['export'])){
export_wassup();
}
}
//wassup scripts and css
add_action('admin_enqueue_scripts','wassup_add_scripts',12);
} //end wassup_admin_preload
/**
* Loads javascript and css files for Wassup admin pages.
* - Enqueues "spia.js", "jquery-ui.js" (various), "jquery-migrate.js" (also queues "jquery.js")
* - adds "thickbox.js"
* - Enqueues "wassup.js" and "wassup.css" for Wassup panels
*/
function wassup_add_scripts(){
global $wp_version,$wdebug_mode;
$vers=WASSUPVERSION;
if($wdebug_mode) $vers.='b'.rand(0,9999);
if(!empty($_GET['page']) && stristr($_GET['page'],'wassup') !== FALSE){
$wassuppage=wassupURI::get_menu_arg();
wp_register_script('wassup',WASSUPURL.'/js/wassup.js',array(),$vers);
if($wassuppage == "wassup-spia" || $wassuppage=="wassup-spy"){
wp_enqueue_script('spia', WASSUPURL.'/js/spia.js', array('jquery','wassup'), $vers);
}elseif($wassuppage == "wassup-options" || $wassuppage == "wassup-donate"){
//use Wordpress' jquery-ui.js only when current
if(version_compare($wp_version,'4.5','>=') || !function_exists('wassup_compat_add_scripts')){
wp_enqueue_script('jquery-ui-dialog');
wp_enqueue_script('jquery-ui-tabs');
}
//never use Wordpress' jquery-ui.css
wp_dequeue_style('jquery-ui-tabs.css');
wp_dequeue_style('jquery-ui-theme.css');
wp_dequeue_style('jquery-ui-dialog.css');
wp_dequeue_style('jquery-ui-core.css');
wp_dequeue_style('jquery-ui.css');
}
//use Wordpress' copy of Thickbox @since v1.9.4.4
add_thickbox(); //Wordpress 2.5+ function
//enqueue jquery-migrate.js (and 'jquery.js')
wp_enqueue_script('jquery-migrate');
wp_enqueue_script('wassup');
//queue wassup stylesheet
wp_enqueue_style('wassup', WASSUPURL.'/css/wassup.css',array(),$vers);
}elseif(strpos($_SERVER['REQUEST_URI'],'/widgets.php')!==false || strpos($_SERVER['REQUEST_URI'],'/customize.php')!==false){
//customizer css for wassup-widget control style
wp_enqueue_style('wassup',WASSUPURL.'/css/wassup.css',array(),$vers);
} //end if GET['page']
} //end wassup_add_scripts
/**
* Check validity of export request then run 'wassupDb::backup_table' to export WassUp main table data into SQL format
* @param integer
* @return void
*/
function export_wassup(){
global $wpdb, $current_user, $wassup_options, $wdebug_mode;
//#1st verify that export request is valid
if(!isset($_REQUEST['export'])) return;
$exportdata=false;
$badrequest=false;
$err_msg="";
$wassup_user_settings=array();
//user must be logged in to export @since v1.9
if(!is_object($current_user) || empty($current_user->ID)){
$user=wp_get_current_user();
}
if(!empty($current_user->ID)){
$wassup_user_settings=get_user_option('_wassup_settings',$current_user->ID);
//wp_nonce validation of export request @since v1.9
if(empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'],'wassupexport-'.$current_user->ID)) {
$err_msg=__("Export ERROR: nonce failure!","wassup");
}
}else{
$err_msg=__("Export ERROR: login required!","wassup");
}
//abort invalid export requests
if($err_msg){
if(empty($current_user->ID)){
wp_die($err_msg);
}else{
wassup_log_message($err_msg);
wp_safe_redirect(wassupURI::get_admin_url('admin.php?page=wassup-options&tab=3'));
}
exit;
}
$err_msg="";
$wassup_table=$wassup_options->wassup_table;
$wherecondition="";
//omit spam records from export @since v1.9.1
if(empty($wassup_options->export_spam)){
$wherecondition =" AND `spam`='0'";
}
//for multisite compatibility
if($wassup_options->network_activated_plugin()){
if(!is_network_admin() && !empty($GLOBALS['current_blog']->blog_id)) $wherecondition .= sprintf(" AND `subsite_id`=%d",(int)$GLOBALS['current_blog']->blog_id);
}
//sorted by record id field
$wherecondition .= ' ORDER BY `id`';
$start_id=0;
if(isset($_REQUEST['startid']) && is_numeric($_REQUEST['startid'])){
$start_id=(int)$_REQUEST['startid'];
}
//# check for records before exporting...
$numrecords=0;
$exportdata=false;
$numrecords=$wpdb->get_var(sprintf("SELECT COUNT(`wassup_id`) FROM `%s` WHERE `id` > %d %s",esc_attr($wassup_table),$start_id,$wherecondition));
if(!is_numeric($numrecords)) $numrecords=0;
if($numrecords > 0){
//too big for export, abort @TODO
if($numrecords > 9999999){
$err_msg=__("Too much data for Wassup export! Use a separate MySQL Db tool instead.","wassup");
}else{
//Could take a long time, so increase script execution time-limit to 11 min
$stimeout=ini_get('max_execution_time');
if(is_numeric($stimeout) && $stimeout>0 && $stimeout < 660){
$disabled_funcs=ini_get('disable_functions');
if((empty($disabled_funcs) || strpos($disabled_funcs,'set_time_limit')===false) && !ini_get('safe_mode')){
$stimeout=11*60;
@set_time_limit($stimeout);
}
}
//do the export
if($_REQUEST['export']=="csv"){
wassupDb::export_records($wassup_table,$start_id,"$wherecondition","csv");
}else{
wassupDb::export_records($wassup_table,$start_id,"$wherecondition","sql");
}
}
}else{
//failed export message
$err_msg=__("ERROR: Nothing to Export.","wassup");
} //end if numrecords > 0
//if get here, something went wrong with export
if(!empty($err_msg)){
wassup_log_message($err_msg);
}
//reload screen to show error message
$reload_uri=remove_query_arg(array('export','whash','type','_wpnonce'));
wp_safe_redirect($reload_uri);
exit;
} //end export_wassup
/** Save summary message from export or other action in either wassup_meta or user_metadata @since v1.9.4 */
function wassup_log_message($msg,$msgtype="",$msgkey="0"){
global $current_user;
//msgtype,msgkey parameters for wassup_meta msg
if(!empty($msgtype)){
$expire=time()+86401; //24-hour expire
if(empty($msgkey) && !empty($_REQUEST['mid'])){
$msgkey=$_REQUEST['mid'];
}
$saved=wassupDb::update_wassupmeta($msgkey,$msgtype,$msg,$expire);
}else{
if(!is_object($current_user) || empty($current_user->ID)){
$user=wp_get_current_user();
}
$wassup_user_settings=get_user_option('_wassup_settings',$current_user->ID);
$wassup_user_settings['ualert_message']=$msg;
update_user_option($current_user->ID,'_wassup_settings',$wassup_user_settings);
}
}
/** Turns off all error notices except fatal errors. */
function wassup_disable_errors(){
error_reporting(E_ERROR);
ini_set('display_errors','Off');
}
/** Turns on all error notices */
function wassup_enable_errors(){
global $wp_version, $wdebug_mode;
//don't use 'strict standards' in old Wordpress versions (part of E_ALL since PHP 5.4)
$php_vers=phpversion();
if(version_compare($php_vers,'5.4','>=')){
//turn off deprecated notices in PHP7
if(version_compare($php_vers,'7.0','>=')){
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED );
}elseif(version_compare($wp_version,'4.0','<')){
error_reporting(E_ALL & ~E_STRICT);
}else{
error_reporting(E_ALL);
}
}elseif(version_compare($wp_version,'4.0','<')){
error_reporting(E_ALL & ~E_STRICT);
}else{
error_reporting(E_ALL);
}
if(!empty($wdebug_mode)){
//don't set display_errors unless WP_DEBUG is not set @since v1.9.4.4
if(!defined('WP_DEBUG') || !defined("WP_DEBUG_DISPLAY")){
ini_set('display_errors','On');
}
}
} //end wassup_enable_errors
if (!function_exists('microtime_float')) {
function microtime_float() { //replicates microtime(true) from PHP5
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
}
//-------------------------------------------------
//### Tracking functions
/** Start tracking: check for cookie, assign 'wassupappend' to action hook to record tracking */
function wassupPrepend() {
global $wpdb,$wp_version,$wassup_options,$current_user,$wscreen_res,$wdebug_mode;
if(empty($wassup_options)) $wassup_options=new wassupOptions;
//wassup must be active for recording to begin
if(empty($wassup_options) || !$wassup_options->is_recording_active()){ //do nothing
return;
}
//don't track ajax requests from some plugins @since v1.9.4
$active_plugins=maybe_serialize(get_option('active_plugins'));
//don't track Woocommerce ajax requests
if(isset($_REQUEST['wc-ajax']) && preg_match('#/woocommerce\.php#',$active_plugins)>0){
return;
}
//suppress php7 deprecated notices @since v1.9.4.4
if(!$wdebug_mode){
$errmode_reset=error_reporting();
$errdisplay_reset=ini_get('display_errors');
wassup_disable_errors();
}
$wassup_table=$wassup_options->wassup_table;
$wassup_tmp_table=$wassup_table."_tmp";
$wscreen_res="";
//session tracking with cookie
$session_timeout=false;
$wassup_timer=0;
$wassup_id="";
$subsite_id=(!empty($GLOBALS['current_blog']->blog_id)?$GLOBALS['current_blog']->blog_id:0);
$cookie_subsite=0;
$cookieUser="";
$sessionhash=$wassup_options->whash;
//in case whash was reset
if(!isset($_COOKIE['wassup'.$sessionhash])) $sessionhash=wassup_get_sessionhash();
if(isset($_COOKIE['wassup'.$sessionhash])){
//use cookie separator '##' instead of '::' to avoid conflict with ipv6 address notation @since v1.9
$cookie_data = explode('##',esc_attr(base64_decode(urldecode($_COOKIE['wassup'.$sessionhash]))));
if(count($cookie_data)>3){
$wassup_id = $cookie_data[0];
$wassup_timer=(int)$cookie_data[1] - time();
if(!empty($cookie_data[2])){
$wscreen_res = $cookie_data[2];
}
//username in wassup cookie @since v1.8.3
if(!empty($cookie_data[5])) $cookieUser=$cookie_data[5];
if($wassup_timer <= 0 || $wassup_timer > 86400){
$session_timeout=true;
}
//don't reuse wassup_id when subsite changed
if(is_multisite()){
if(preg_match('/^([0-9]+)b_/',$wassup_id,$pcs)>0) $cookie_subsite=$pcs[1];
if($subsite_id != $cookie_subsite) $wassup_id="";
}
}
}
//for tracking 404 hits when it is 1st visit record
$urlRequested=$_SERVER['REQUEST_URI'];
$req_code=200;
if(is_404()){
$req_code=404;
}elseif(function_exists('http_response_code')){
$req_code=http_response_code(); //PHP 5.4+ function
}elseif(isset($_SERVER['REDIRECT_STATUS'])){
$req_code=(int)$_SERVER['REDIRECT_STATUS'];
}
//get screen resolution from cookie or browser header data, if any
if (empty($wscreen_res) && isset($_COOKIE['wassup_screen_res'.$sessionhash])) {
$wscreen_res = esc_attr(trim($_COOKIE['wassup_screen_res'.$sessionhash]));
if ($wscreen_res == "x") $wscreen_res="";
}
if (empty($wscreen_res) && isset($_SERVER['HTTP_UA_PIXELS'])) {
//resolution in IE/IEMobile header sometimes
$wscreen_res = str_replace('X',' x ',$_SERVER['HTTP_UA_PIXELS']);
}
if (empty($wscreen_res) || preg_match('/(\d+\sx\s\d+)/i',$wscreen_res)==0){
$wscreen_res = "";
$ua=(!empty($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:"");
if(stristr($urlRequested,'login.php')!==false){
add_action('login_footer','wassup_foot');
}elseif(strstr($ua,'MSIE')===false && strstr($ua,'rv:11')===false && strstr($ua,'Edge/')===false){
//place wassup tag and javascript in document head
if(is_admin()){
add_action('admin_head','wassup_head');
}else{
add_action('wp_head','wassup_head');
}
}
}
$timenow=current_time('timestamp');
//check if user is logged-in
$logged_user="";
if(empty($current_user->user_login)) $user=wp_get_current_user();
if(!empty($current_user->user_login)){
$logged_user=$current_user->user_login;
//for recent successful login.. undo hack attempt label
//wassup timer is additional check in case this is successful hack
if(!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'wp-login.php')>0 && $wassup_timer >=0 && $wassup_timer < 5401){
if(empty($wassup_id)) $wsession_id=wassup_get_sessionid();
else $wsession_id=$wassup_id;
//retroactively undo "hack attempt" label
$wassup_dbtask[]=sprintf("UPDATE `$wassup_table` SET `username`='%s', `spam`='0' WHERE `wassup_id`='%s' AND `spam`!='0' AND `timestamp`>'%d'",$logged_user,$wsession_id,$timenow-90);
}
//timeout logged-in users after 10 mins to trigger save into temp for online counts @since v1.9.2
if($wassup_timer > 5361){ //for 1st save/cookie reset
$session_timeout=true;
}elseif($wassup_timer < 4801){ //timeout after ~10 mins
$session_timeout=true; //...for save to temp
}
}
//Track visitor
//Exclude for logged-in user in admin area (unless session_timeout is set)
if(!is_admin() || empty($logged_user) || $session_timeout || $req_code !=200 || empty($wassup_id)){
//use 'send_headers' hook for feed, media, and files except when request is wp-admin which doesn't run this hook
if(is_feed() || preg_match('#[=/\?&](feed|atom)#',$urlRequested)>0){
if(is_feed() && !headers_sent()){
add_action('send_headers','wassupAppend');
}else{
wassupAppend($req_code);
}
}elseif(preg_match('/(\.(3gp|7z|f4[pv]|mp[34])(?:[\?#]|$))/i',$urlRequested)>0){
//this is audio, video, or archive file request
if(!is_admin() && !headers_sent()){
add_action('send_headers','wassupAppend');
}else{
wassupAppend($req_code);
}
}elseif(preg_match('/([^\?#&]+\.([a-z]{1,4}))(?:[\?#]|$)/i',$urlRequested)>0 && basename($urlRequested)!="robots.txt"){
//this is multimedia or specific file request
if(!is_admin() && !headers_sent()){
add_action('send_headers','wassupAppend');
}else{
wassupAppend($req_code);
}
}elseif(!is_admin()){
//use 'send_headers' hook for cookie write or 404 and shutdown hook for all others
if(empty($wassup_id) || $req_code!=200){
if(!headers_sent()){
add_action('send_headers','wassupAppend',15);
}else{
add_action('shutdown','wassupAppend',1);
}
}elseif($session_timeout && ($wassup_timer <=0 || $wassup_timer >86400) && !headers_sent()){
//for cookie re-write
add_action('send_headers','wassupAppend',15);
}else{
add_action('shutdown','wassupAppend',1);
}
}else{
//use 'admin_footer' hook for admin area hits @since v1.9.1
add_action('admin_footer','wassupAppend',15);
}
//add tracking for login page separately since 'shutdown' hook doesn't seem to run on login page @since v1.9.1
if(empty($logged_user) && stristr($urlRequested,'login.php')!==FALSE){
add_action('login_footer','wassupAppend',15);
}
} //end if !is_admin
//do retroactive update, if any
if(!empty($wassup_dbtask)){
$args=array('dbtasks'=>$wassup_dbtask);
wassupDb::scheduled_dbtask($args);
}
//restore default error_reporting @since v1.9.4.4
if(!$wdebug_mode && isset($errmode_reset)){
error_reporting($errmode_reset);
@ini_set('display_errors',$errdisplay_reset);
}
} //end wassupPrepend
/**
* Track visitors: collect browser/visitor data and save record in wassup table
* @param string (http request code)
*/
function wassupAppend($req_code=0) {
global $wpdb,$wp_version,$current_user,$wassup_options,$wscreen_res,$wdebug_mode;
if(!defined('WASSUPURL')){
if(!wassup_init()) return; //nothing to do
}
//wassup must be active for recording to begin
if(empty($wassup_options) || !$wassup_options->is_recording_active()){ //nothing to do
return;