This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
wp-spamshield.php
7957 lines (7270 loc) · 440 KB
/
wp-spamshield.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: WP-SpamShield
Plugin URI: http://www.redsandmarketing.com/plugins/wp-spamshield/
Description: An extremely powerful and user-friendly all-in-one anti-spam plugin that <strong>eliminates comment spam, trackback spam, contact form spam, and registration spam</strong>. No CAPTCHA's, challenge questions, or other inconvenience to website visitors. Enjoy running a WordPress site without spam! Includes a spam-blocking contact form feature.
Author: Scott Allen
Version: 1.9.5.5
Author URI: http://www.redsandmarketing.com/
Text Domain: wp-spamshield
License: GPLv2
*/
/* Copyright 2014-2015 Scott Allen (email : wpspamshield [at] redsandmarketing [dot] com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* PLUGIN - BEGIN */
/***
* Note to any other PHP developers reading this:
* My use of the closing curly braces "}" is a little funky in that I indent them, I know. IMO it's easier to debug. Just know that it's on purpose even though it's not standard. One of my programming quirks, and just how I roll. :)
***/
/* Make sure plugin remains secure if called directly */
if( !defined( 'ABSPATH' ) ) {
if( !headers_sent() ) { header('HTTP/1.1 403 Forbidden'); }
die( 'ERROR: This plugin requires WordPress and will not function if called directly.' );
}
define( 'WPSS_VERSION', '1.9.5.5' );
define( 'WPSS_REQUIRED_WP_VERSION', '3.9' );
define( 'WPSS_REQUIRED_PHP_VERSION', '5.3' );
/***
* Setting important URL and PATH constants so the plugin can find things
* Constants prefixed with 'RSMP_' are shared with other RSM Plugins for efficiency.
***/
if( !defined( 'WPSS_DEBUG' ) ) { define( 'WPSS_DEBUG', FALSE ); } /* Do not change value unless developer asks you to - for debugging only. Change in wp-config.php. */
if( !defined( 'WPSS_EDGE' ) ) { define( 'WPSS_EDGE', FALSE ); }
if( !defined( 'WPSS_EOL' ) ) { $wpss_eol = defined( 'PHP_EOL' ) ? PHP_EOL : rs_wpss_eol(); define( 'WPSS_EOL', $wpss_eol ); }
if( !defined( 'WPSS_DS' ) ) { $wpss_ds = defined( 'DIRECTORY_SEPARATOR' ) ? DIRECTORY_SEPARATOR : rs_wpss_ds(); define( 'WPSS_DS', $wpss_ds ); }
if( !defined( 'WPSS_MEMORY_LIMIT' ) ) { define( 'WPSS_MEMORY_LIMIT', '128M' ); }
if( !defined( 'RSMP_SITE_URL' ) ) { define( 'RSMP_SITE_URL', untrailingslashit( site_url() ) ); }
if( !defined( 'RSMP_SITE_DOMAIN' ) ) { define( 'RSMP_SITE_DOMAIN', rs_wpss_get_domain( RSMP_SITE_URL ) ); }
if( !defined( 'RSMP_CONTENT_DIR_URL' ) ) { define( 'RSMP_CONTENT_DIR_URL', WP_CONTENT_URL ); }
if( !defined( 'RSMP_CONTENT_DIR_PATH' ) ) { define( 'RSMP_CONTENT_DIR_PATH', WP_CONTENT_DIR ); }
if( !defined( 'RSMP_PLUGINS_DIR_URL' ) ) { define( 'RSMP_PLUGINS_DIR_URL', WP_PLUGIN_URL ); }
if( !defined( 'RSMP_PLUGINS_DIR_PATH' ) ) { define( 'RSMP_PLUGINS_DIR_PATH', WP_PLUGIN_DIR ); }
if( !defined( 'RSMP_ADMIN_URL' ) ) { define( 'RSMP_ADMIN_URL', untrailingslashit( admin_url() ) ); }
if( !defined( 'WPSS_PLUGIN_BASENAME' ) ) { define( 'WPSS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); }
if( !defined( 'WPSS_PLUGIN_FILE_BASENAME' ) ) { define( 'WPSS_PLUGIN_FILE_BASENAME', trim( basename( __FILE__ ), '/' ) ); }
if( !defined( 'WPSS_PLUGIN_NAME' ) ) { define( 'WPSS_PLUGIN_NAME', trim( dirname( WPSS_PLUGIN_BASENAME ), '/' ) ); }
if( !defined( 'WPSS_PLUGIN_URL' ) ) { define( 'WPSS_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) ); }
if( !defined( 'WPSS_PLUGIN_FILE_URL' ) ) { define( 'WPSS_PLUGIN_FILE_URL', WPSS_PLUGIN_URL.'/'.WPSS_PLUGIN_FILE_BASENAME ); }
if( !defined( 'WPSS_PLUGIN_COUNTER_URL' ) ) { define( 'WPSS_PLUGIN_COUNTER_URL', WPSS_PLUGIN_URL . '/counter' ); }
if( !defined( 'WPSS_PLUGIN_CSS_URL' ) ) { define( 'WPSS_PLUGIN_CSS_URL', WPSS_PLUGIN_URL . '/css' ); }
if( !defined( 'WPSS_PLUGIN_DATA_URL' ) ) { define( 'WPSS_PLUGIN_DATA_URL', WPSS_PLUGIN_URL . '/data' ); }
if( !defined( 'WPSS_PLUGIN_IMG_URL' ) ) { define( 'WPSS_PLUGIN_IMG_URL', WPSS_PLUGIN_URL . '/img' ); }
if( !defined( 'WPSS_PLUGIN_JS_URL' ) ) { define( 'WPSS_PLUGIN_JS_URL', WPSS_PLUGIN_URL . '/js' ); }
if( !defined( 'WPSS_PLUGIN_PATH' ) ) { define( 'WPSS_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); }
if( !defined( 'WPSS_PLUGIN_FILE_PATH' ) ) { define( 'WPSS_PLUGIN_FILE_PATH', WPSS_PLUGIN_PATH.'/'.WPSS_PLUGIN_FILE_BASENAME ); }
if( !defined( 'WPSS_PLUGIN_COUNTER_PATH' ) ) { define( 'WPSS_PLUGIN_COUNTER_PATH', WPSS_PLUGIN_PATH . '/counter' ); }
if( !defined( 'WPSS_PLUGIN_CSS_PATH' ) ) { define( 'WPSS_PLUGIN_CSS_PATH', WPSS_PLUGIN_PATH . '/css' ); }
if( !defined( 'WPSS_PLUGIN_DATA_PATH' ) ) { define( 'WPSS_PLUGIN_DATA_PATH', WPSS_PLUGIN_PATH . '/data' ); }
if( !defined( 'WPSS_PLUGIN_IMG_PATH' ) ) { define( 'WPSS_PLUGIN_IMG_PATH', WPSS_PLUGIN_PATH . '/img' ); }
if( !defined( 'WPSS_PLUGIN_INCL_PATH' ) ) { define( 'WPSS_PLUGIN_INCL_PATH', WPSS_PLUGIN_PATH . '/includes' ); }
if( !defined( 'WPSS_PLUGIN_JS_PATH' ) ) { define( 'WPSS_PLUGIN_JS_PATH', WPSS_PLUGIN_PATH . '/js' ); }
if( !defined( 'WPSS_PLUGIN_LANG_PATH' ) ) { define( 'WPSS_PLUGIN_LANG_PATH', WPSS_PLUGIN_PATH . '/languages' ); }
if( !defined( 'WPSS_SERVER_ADDR' ) ) { define( 'WPSS_SERVER_ADDR', rs_wpss_get_server_addr() ); }
if( !defined( 'WPSS_SERVER_NAME' ) ) { define( 'WPSS_SERVER_NAME', rs_wpss_get_server_name() ); }
if( !defined( 'WPSS_SERVER_NAME_REV' ) ) { define( 'WPSS_SERVER_NAME_REV', strrev( WPSS_SERVER_NAME ) ); }
if( !defined( 'WPSS_SERVER_NAME_NODOT' ) ) { $wpss_server_name_nodot = str_replace( '.', '', WPSS_SERVER_NAME ); define( 'WPSS_SERVER_NAME_NODOT', $wpss_server_name_nodot ); }
if( !defined( 'RSMP_HASH_ALT' ) ) { $wpss_alt_prefix = rs_wpss_md5( WPSS_SERVER_NAME_NODOT ); define( 'RSMP_HASH_ALT', $wpss_alt_prefix ); }
if( !defined( 'RSMP_HASH' ) ) { $wpss_hash_prefix = defined( 'COOKIEHASH' ) ? COOKIEHASH : rs_wpss_md5( RSMP_SITE_URL ); define( 'RSMP_HASH', $wpss_hash_prefix ); }
if( !defined( 'WPSS_REF2XJS' ) ) { define( 'WPSS_REF2XJS', 'r3f5x9JS' ); }
if( !defined( 'WPSS_JSONST' ) ) { define( 'WPSS_JSONST', 'JS04X7' ); }
if( !defined( 'WPSS_SPH' ) ) { define( 'WPSS_SPH', 240 ); }
if( !defined( 'RSMP_DEBUG_SERVER_NAME' ) ) { define( 'RSMP_DEBUG_SERVER_NAME', '.redsandmarketing.com' ); }
if( !defined( 'RSMP_DEBUG_SERVER_NAME_REV' ) ) { define( 'RSMP_DEBUG_SERVER_NAME_REV', strrev( RSMP_DEBUG_SERVER_NAME ) ); }
if( !defined( 'RSMP_MDBUG_SERVER_NAME' ) ) { define( 'RSMP_MDBUG_SERVER_NAME', '.redsandmarketing.com' ); }
if( !defined( 'RSMP_MDBUG_SERVER_NAME_REV' ) ) { define( 'RSMP_MDBUG_SERVER_NAME_REV', strrev( RSMP_MDBUG_SERVER_NAME ) ); }
if( !defined( 'RSMP_RSM_URL' ) ) { define( 'RSMP_RSM_URL', 'http://www.redsandmarketing.com/' ); }
if( !defined( 'WPSS_HOME_URL' ) ) { define( 'WPSS_HOME_URL', RSMP_RSM_URL.'plugins/'.WPSS_PLUGIN_NAME.'/' ); }
if( !defined( 'WPSS_SUPPORT_URL' ) ) { define( 'WPSS_SUPPORT_URL', RSMP_RSM_URL.'plugins/'.WPSS_PLUGIN_NAME.'/support/' ); }
if( !defined( 'WPSS_WP_URL' ) ) { define( 'WPSS_WP_URL', 'https://wordpress.org/extend/plugins/'.WPSS_PLUGIN_NAME.'/' ); }
if( !defined( 'WPSS_WP_RATING_URL' ) ) { define( 'WPSS_WP_RATING_URL', 'https://wordpress.org/support/view/plugin-reviews/'.WPSS_PLUGIN_NAME ); }
if( !defined( 'WPSS_DONATE_URL' ) ) { define( 'WPSS_DONATE_URL', 'http://bit.ly/'.WPSS_PLUGIN_NAME.'-donate' ); }
if( !defined( 'WPSS_PHP_VERSION' ) ) { define( 'WPSS_PHP_VERSION', PHP_VERSION ); }
if( !defined( 'WPSS_WP_VERSION' ) ) { global $wp_version; define( 'WPSS_WP_VERSION', $wp_version ); }
if( !defined( 'RSMP_PHP_MEM_LIMIT' ) ) { $wpss_php_memory_limit = rs_wpss_format_bytes( ini_get( 'memory_limit' ) ); define( 'RSMP_PHP_MEM_LIMIT', $wpss_php_memory_limit ); }
/* INCLUDE POPULAR CACHE PLUGINS HERE (14) */
$popular_cache_plugins_default = array ( 'cachify', 'db-cache-reloaded', 'db-cache-reloaded-fix', 'gator-cache', 'hyper-cache', 'hyper-cache-extended', 'lite-cache', 'quick-cache', 'w3-total-cache', 'wp-fast-cache', 'wp-fastest-cache', 'wp-super-cache', 'zencache', 'zencache-pro' );
if( !defined( 'WPSS_POPULAR_CACHE_PLUGINS' ) ) { define( 'WPSS_POPULAR_CACHE_PLUGINS', serialize( $popular_cache_plugins_default ) ); }
/* SET THE DEFAULT CONSTANT VALUES HERE */
$wpss_options_default = array ( 'block_all_trackbacks' => 0, 'block_all_pingbacks' => 0, 'comment_logging' => 0, 'comment_logging_start_date' => 0, 'comment_logging_all' => 0, 'enhanced_comment_blacklist' => 0, 'enable_whitelist' => 0, 'comment_min_length' => 15, 'allow_proxy_users' => 1, 'hide_extra_data' => 0, 'registration_shield_disable' => 0, 'registration_shield_level_1' => 0, 'disable_cf7_shield' => 0, 'disable_gf_shield' => 0, 'disable_misc_form_shield' => 0, 'disable_email_encode' => 0, 'allow_comment_author_keywords' => 0, 'form_include_website' => 1, 'form_require_website' => 0, 'form_include_phone' => 1, 'form_require_phone' => 0, 'form_include_company' => 0, 'form_require_company' => 0, 'form_include_drop_down_menu' => 0, 'form_require_drop_down_menu' => 0, 'form_drop_down_menu_title' => '', 'form_drop_down_menu_item_1' => '', 'form_drop_down_menu_item_2' => '', 'form_drop_down_menu_item_3' => '', 'form_drop_down_menu_item_4' => '', 'form_drop_down_menu_item_5' => '', 'form_drop_down_menu_item_6' => '', 'form_drop_down_menu_item_7' => '', 'form_drop_down_menu_item_8' => '', 'form_drop_down_menu_item_9' => '', 'form_drop_down_menu_item_10' => '', 'form_message_width' => 40, 'form_message_height' => 10, 'form_message_min_length' => 25, 'form_response_thank_you_message' => __( 'Your message was sent successfully. Thank you.', WPSS_PLUGIN_NAME ), 'form_include_user_meta' => 1, 'promote_plugin_link' => 0, );
if( !defined( 'WPSS_OPTIONS_DEFAULT' ) ) { define( 'WPSS_OPTIONS_DEFAULT', serialize( $wpss_options_default ) ); }
$wpss_depr_options_default = array( 'wpss_version' => '', 'init_user_approve_run' => '', 'install_status' => '', 'warning_status' => '', 'regalert_status' => '', 'last_admin' => '', 'wpss_admins' => array(), 'reg_count' => 0, 'spam_count' => 0, 'wpssmid_cache' => array(), 'wpss_procdat' => array( 'total_tracked' => 0, 'total_wpss_time' => 0, 'avg_wpss_proc_time' => 0, 'total_comment_proc_time' => 0, 'avg_comment_proc_time' => 0, 'total_wpss_avg_tracked' => 0, 'total_avg_wpss_proc_time' => 0, 'avg2_wpss_proc_time' => 0 ), );
if( !defined( 'WPSS_DEPR_OPTIONS_DEFAULT' ) ) { define( 'WPSS_DEPR_OPTIONS_DEFAULT', serialize( $wpss_depr_options_default ) ); }
unset( $wpss_eol, $wpss_ds, $wpss_server_name_nodot, $wpss_alt_prefix, $wpss_hash_prefix, $wpss_php_memory_limit, $wpss_ua, $popular_cache_plugins_default, $wpss_options_default, $wpss_depr_options_default );
rs_wpss_set_memory();
/* Includes - BEGIN */
require_once( WPSS_PLUGIN_INCL_PATH.'/advanced.php' );
require_once( WPSS_PLUGIN_INCL_PATH.'/blacklists.php' );
require_once( WPSS_PLUGIN_INCL_PATH.'/class.wpss-security.php' );
/* require_once( WPSS_PLUGIN_INCL_PATH.'/class.wpss-utils.php' ); */
require_once( WPSS_PLUGIN_INCL_PATH.'/class.wpss-widget.php' );
/* Includes - END */
/* SET ADVANCED OPTIONS - Change be overridden in wp-config.php. Advanced users only. */
if( !defined( 'WPSS_COMPAT_MODE' ) ) { define( 'WPSS_COMPAT_MODE', FALSE ); }
if( !defined( 'WPSS_TEMP_BL_DISABLE' ) ) { define( 'WPSS_TEMP_BL_DISABLE', FALSE ); }
if( !defined( 'WPSS_TEMP_BL_CF_ONLY' ) ) { define( 'WPSS_TEMP_BL_CF_ONLY', FALSE ); }
if( !defined( 'WPSS_IP_BAN_ENABLE' ) ) { define( 'WPSS_IP_BAN_ENABLE', FALSE ); }
if( !defined( 'WPSS_IP_BAN_CLEAR' ) ) { define( 'WPSS_IP_BAN_CLEAR', FALSE ); }
if( !defined( 'WPSS_INIT_SPAM_COUNT' ) ) { define( 'WPSS_INIT_SPAM_COUNT', FALSE ); }
else {
global $wpss_init_spam_count;
$wpss_init_spam_count = is_int( WPSS_INIT_SPAM_COUNT ) ? WPSS_INIT_SPAM_COUNT : 0;
}
/* Standard Functions - BEGIN */
function rs_wpss_eol() {
return !empty( $is_IIS ) ? "\r\n" : "\n";
}
function rs_wpss_ds() {
return !empty( $is_IIS ) ? '\\' : '/';
}
function rs_wpss_start_session() {
global $wpss_session_id;
if( empty( $wpss_session_id ) ) { $wpss_session_id = session_id(); }
if( empty( $wpss_session_id ) && !headers_sent() ) { session_start(); $wpss_session_id = session_id(); }
}
function rs_wpss_end_session() {
session_destroy();
}
function rs_wpss_login( $user_login, $user = NULL ) {
if( !is_object( $user ) || empty( $user ) || empty( $user->ID ) ) { $user = wp_get_current_user(); }
if( !is_object( $user ) || empty( $user ) || empty( $user->ID ) ) { return; }
$user_id = $user->ID;
rs_wpss_update_user_ip( $user_id );
}
function rs_wpss_logout() {
rs_wpss_end_session();
}
function rs_wpss_update_user_ip( $user_id = NULL, $add_admin_ip = FALSE ) {
if( empty( $user_id ) ){ global $current_user; $user_id = $current_user->ID; }
if( empty( $user_id ) ){ return; }
/* IP / PROXY INFO - BEGIN */
global $wpss_ip_proxy_info;
if( empty( $wpss_ip_proxy_info ) ) { $wpss_ip_proxy_info = rs_wpss_ip_proxy_info(); }
extract( $wpss_ip_proxy_info );
/* IP / PROXY INFO - END */
if( !rs_wpss_is_valid_ip( $ip ) ) { return; }
$mtime = rs_wpss_microtime();
$user_ip = get_user_meta( $user_id, 'wpss_user_ip', TRUE );
if( empty( $user_ip ) ) { $user_ip = array(); }
$user_ip[$ip] = array( 'server' => $reverse_dns, 'time' => $mtime );
update_user_meta( $user_id, 'wpss_user_ip', $user_ip );
if( !empty( $add_admin_ip ) ) {
$admin_ips = get_option( 'spamshield_admins' );
if( empty( $admin_ips ) ) { $admin_ips = array(); }
$admin_ips[$ip] = $mtime;
update_option( 'spamshield_admins', $admin_ips );
}
}
function rs_wpss_set_memory() {
/***
* Boost memory limits
* WordPress' default is 40M, but it requires at least 64M to run smoothly on many sites. 128M+ is better.
***/
if( function_exists( 'memory_get_usage' ) && function_exists( 'ini_set' ) ) {
$current_limit = ini_get( 'memory_limit' );
$current_limit_int = intval( $current_limit );
if( FALSE !== strpos( $current_limit, 'G' ) ) { $current_limit_int *= 1024; }
$wpss_limit_int = intval( WPSS_MEMORY_LIMIT );
if( FALSE !== strpos( WPSS_MEMORY_LIMIT,'G' ) ) { $wpss_limit_int *= 1024; }
if( -1 != $current_limit && ( -1 == WPSS_MEMORY_LIMIT || $current_limit_int < $wpss_limit_int ) ) {
@ini_set( 'memory_limit', WPSS_MEMORY_LIMIT );
}
}
}
function rs_wpss_count_words( $string ) {
$string = trim( $string ); $char_count = rs_wpss_strlen( $string );
if( empty( $string ) || $char_count == 0 ) { $num_words = 0; } else { $exploded_string = preg_split( "~\s+~", $string ); $num_words = count( $exploded_string ); }
return $num_words;
}
function rs_wpss_strlen( $string ) {
/***
* Use this function instead of mb_strlen because some servers (often IIS) have mb_ functions disabled by default
* BUT mb_strlen is superior to strlen, so use it whenever possible
***/
return function_exists( 'mb_strlen' ) ? mb_strlen( $string, 'UTF-8' ) : strlen( $string );
}
function rs_wpss_casetrans( $type, $string ) {
/***
* Convert case using multibyte version if available, if not, use defaults
* Added 1.8.4
***/
switch ( $type ) {
case 'upper':
if( function_exists( 'mb_strtoupper' ) ) { return mb_strtoupper( $string, 'UTF-8' ); } else { return strtoupper( $string ); }
case 'lower':
if( function_exists( 'mb_strtolower' ) ) { return mb_strtolower( $string, 'UTF-8' ); } else { return strtolower( $string ); }
case 'ucfirst':
if( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
$strtmp = mb_strtoupper( mb_substr( $string, 0, 1, 'UTF-8' ), 'UTF-8' ) . mb_substr( $string, 1, NULL, 'UTF-8' );
if( rs_wpss_strlen( $string ) === rs_wpss_strlen( $strtmp ) ) { return $strtmp; } else { return ucfirst( $string ); } /* 1.9.5.1 - Added workaround for strange PHP bug in mb_substr() on some servers */
}
else { return ucfirst( $string ); }
case 'ucwords':
if( function_exists( 'mb_convert_case' ) ) { return mb_convert_case( $string, MB_CASE_TITLE, 'UTF-8' ); } else { return ucwords( $string ); }
/***
* Note differences in results between ucwords() and this.
* ucwords() will capitalize first characters without altering other characters, whereas this will lowercase everything, but capitalize the first character of each word.
* This works better for our purposes, but be aware of differences.
***/
default:
return $string;
}
}
function rs_wpss_substr_count( $haystack, $needle, $offset = 0, $length = NULL ) {
/* Has error correction built in */
$haystack_len = rs_wpss_strlen( $haystack );
$needle_len = rs_wpss_strlen( $needle );
if( $offset >= $haystack_len || $offset < 0 ) { $offset = 0; }
if( empty( $length ) || $length <= 0 ) { $length = $haystack_len; }
$haystack_len_offset_diff = $haystack_len - $offset;
if( $length > $haystack_len_offset_diff ) { $length = $haystack_len_offset_diff; }
$needle_instances = 0;
if( !empty( $needle ) && !empty( $haystack ) && $needle_len <= $haystack_len ) {
$needle_instances = substr_count( $haystack, $needle, $offset, $length );
}
return $needle_instances;
}
function rs_wpss_sort_unique( $arr ) {
/***
* Removes duplicates and orders the array.
***/
$arr_tmp = array_unique( $arr ); natcasesort( $arr_tmp ); $new_arr = array_values( $arr_tmp );
return $new_arr;
}
function rs_wpss_preg_quote( $string ) {
/* Prep for use in Regex, this plugin uses '~' as a delimiter exclusively, can be changed */
$regex_string = preg_quote( $string, '~' );
$regex_string = preg_replace( "~\s+~", "\s+", $regex_string );
return $regex_string;
}
function rs_wpss_md5( $string ) {
/***
* Use this function instead of hash for compatibility
* BUT hash is faster than md5, so use it whenever possible
***/
if( function_exists( 'hash' ) ) { $hash = hash( 'md5', $string ); } else { $hash = md5( $string ); }
return $hash;
}
function rs_wpss_get_wpss_eid( $args ) {
/***
* Creates unique temporary IDs from hash of data for both contact forms and comments.
* Added 1.7.7
* $type: 'comment','contact'
* $args: name, email, url, content
* 'eid' - Entity ID; 'ecid' - Entity Content ID
***/
$wpsseid = array( 'eid' => '', 'ecid' => '');
$wpsseid_args_data_str = implode( '', $args );
$wpsseid['eid'] = rs_wpss_md5( $wpsseid_args_data_str );
$wpsseid['ecid'] = rs_wpss_md5( $args['content'] );
return $wpsseid;
}
function rs_wpss_create_nonce( $action, $name = '_wpss_nonce' ) {
/***
* Creates a different nonce system than WordPress.
* 24 hours or 1 time use.
* Difference vs WP nonces: Nonce must exist in database, is not tied to a user ID, and is truly 1 time use.
* WP nonces don't work for every application. If a comment is posted, and a notification email is sent to admin with link to blacklist the IP, this works better.
***/
$i = wp_nonce_tick();
$timenow = time();
$nonce = substr( rs_wpss_md5( $i . $action . $name . RSMP_HASH . $timenow ), -12, 10 );
$spamshield_nonces = get_option( 'spamshield_nonces' );
if( empty( $spamshield_nonces ) ) { $spamshield_nonces = array(); }
else {
foreach( $spamshield_nonces as $i => $n ) {
if( $n['expire'] <= $timenow ) { unset( $spamshield_nonces[$i] ); }
}
}
$expire = $timenow + 86400; /* 24 hours */
$spamshield_nonces[] = array( 'nonce' => $nonce, 'action' => $action, 'name' => $name, 'expire' => $expire );
update_option( 'spamshield_nonces', $spamshield_nonces, FALSE );
return $nonce;
}
function rs_wpss_verify_nonce( $value, $action, $name = '_wpss_nonce' ) {
/***
* Verify a WP-SpamShield nonce.
* $value = value of nonce you're testing for
* $action = descriptive string used internally for what you're trying to do
* $name = identifier of nonce
***/
$nonce_valid = FALSE;
$timenow = time();
$spamshield_nonces = get_option( 'spamshield_nonces' );
if( empty( $spamshield_nonces ) ) { return FALSE; }
foreach( $spamshield_nonces as $i => $n ) {
if( $n['nonce'] === $value && $n['action'] === $action && $n['expire'] > $timenow ) {
unset( $spamshield_nonces[$i] );
$nonce_valid = TRUE;
}
elseif( $n['expire'] <= $timenow ) { unset( $spamshield_nonces[$i] ); }
}
update_option( 'spamshield_nonces', $spamshield_nonces, FALSE );
return $nonce_valid;
}
function rs_wpss_purge_nonces() {
/***
* Purge expired nonces. Keep the nonce cache clean.
***/
$timenow = time();
$spamshield_nonces = get_option( 'spamshield_nonces' );
if( empty( $spamshield_nonces ) ) { return FALSE; }
foreach( $spamshield_nonces as $i => $n ) {
if( $n['expire'] <= $timenow ) { unset( $spamshield_nonces[$i] ); }
}
update_option( 'spamshield_nonces', $spamshield_nonces, FALSE );
return TRUE;
}
function rs_wpss_microtime() {
return microtime( TRUE );
}
function rs_wpss_timer( $start = NULL, $end = NULL, $show_seconds = FALSE, $precision = 8, $no_format = FALSE, $raw = FALSE, $benchmark = FALSE ) {
/***
* $precision will default to 8 but can be set to anything - 1,2,3,4,5,6,etc.
* Use $no_format when clean numbers are needed for calculations. International formatting throws a wrench into things.
***/
if( empty( $start ) ) { return NULL; }
if( empty( $end ) ) { $end = rs_wpss_microtime(); }
$total_time = $end - $start;
if( empty( $no_format ) ) {
$total_time_for = rs_wpss_number_format( $total_time, $precision );
if( !empty( $show_seconds ) ) { $total_time_for .= ' seconds'; }
}
elseif( empty( $raw ) ) {
$total_time_for = number_format( $total_time, $precision );
}
else { $total_time_for = $total_time; }
if( TRUE === $benchmark ) {
rs_wpss_append_log_data( '$start_time: "'.$start.'" Line: '.__LINE__.' | '.__FUNCTION__.' | MEM USED: ' . rs_wpss_wp_memory_used() . ' | VER: ' . WPSS_VERSION, TRUE );
rs_wpss_append_log_data( '$end_time: "'.$end.'" Line: '.__LINE__.' | '.__FUNCTION__.' | MEM USED: ' . rs_wpss_wp_memory_used() . ' | VER: ' . WPSS_VERSION, TRUE );
rs_wpss_append_log_data( '$total_time: "'.$total_time_for.'" Line: '.__LINE__.' | '.__FUNCTION__.' | MEM USED: ' . rs_wpss_wp_memory_used() . ' | VER: ' . WPSS_VERSION, TRUE );
return $total_time_for;
}
return $total_time_for;
}
function rs_wpss_timer_bm( $start ) {
$total_time = rs_wpss_timer( $start, NULL, FALSE, 6, TRUE, FALSE, TRUE );
return $total_time;
}
function rs_wpss_number_format( $number, $precision = NULL ) {
/* $precision will default to NULL but can be set to anything - 1,2,3,4,5,6,etc. */
if( function_exists( 'number_format_i18n' ) ) { $number_for = number_format_i18n( $number, $precision ); }
else { $number_for = number_format( $number, $precision ); }
return $number_for;
}
function rs_wpss_format_bytes( $size, $precision = 2 ) {
if( !is_numeric( $size ) || empty( $size ) ) { return $size; }
$base = log($size) / log(1024);
$base_floor = floor($base);
$suffixes = array('', 'k', 'M', 'G', 'T');
$suffix = isset( $suffixes[$base_floor] ) ? $suffixes[$base_floor] : '';
if( empty($suffix) ) { return $size; }
$formatted_num = round(pow(1024, $base - $base_floor), $precision) . $suffix;
return $formatted_num;
}
function rs_wpss_wp_memory_used() {
return function_exists( 'memory_get_usage' ) ? rs_wpss_format_bytes( memory_get_usage() ) : 0;
}
function rs_wpss_date_diff( $start, $end ) {
$start_ts = strtotime($start);
$end_ts = strtotime($end);
$diff = ($end_ts-$start_ts);
$start_array = explode('-', $start);
$start_year = $start_array[0];
$end_array = explode('-', $end);
$end_year = $end_array[0];
$years = $end_year-$start_year;
if(($years%4) == 0) { $extra_days = ((($end_year-$start_year)/4)-1); } else { $extra_days = ((($end_year-$start_year)/4)); }
$extra_days = round($extra_days);
return round($diff/86400)+$extra_days;
}
function rs_wpss_scandir( $dir ) {
clearstatcache();
$dot_files = array( '..', '.' );
$dir_contents_raw = scandir( $dir );
$dir_contents = array_values( array_diff( $dir_contents_raw, $dot_files ) );
return $dir_contents;
}
function rs_wpss_get_domain( $url, $email_domain = FALSE ) {
/***
* Get domain from URL
* Filter URLs with nothing after http
* $email_domain will run through rs_wpss_get_email_domain()
***/
if( empty( $url ) || preg_match( "~^https?\:*/*$~i", $url ) ) { return ''; }
/* Fix poorly formed URLs so as not to throw errors when parsing */
$url = rs_wpss_fix_url( $url );
/* NOW start parsing */
$parsed = @parse_url( $url );
/* Filter URLs with no domain */
if( empty( $parsed['host'] ) ) { return ''; }
$domain = rs_wpss_casetrans( 'lower', $parsed['host'] );
if( !empty( $email_domain ) ) { $domain = rs_wpss_get_email_domain( $domain ); }
return $domain;
}
function rs_wpss_get_email_domain( $domain ) {
/***
* Get email domain for use in email addresses
* Strip 'www.' & 'm.' from beginning of domain
***/
if( empty( $domain ) ) { return ''; }
$domain = preg_replace( "~^(ww[w0-9]|m)\.~i", '', $domain );
return $domain;
}
function rs_wpss_get_domain_from_email( $email ) {
/* Get domain from email address */
if( empty( $email ) ) { return ''; }
$email_elements = explode( '@', $email );
$domain = $email_elements[1];
return $domain;
}
function rs_wpss_get_query_string( $url ) {
/***
* Get query string from URL
* Filter URLs with nothing after http
***/
if( empty( $url ) || preg_match( "~^https?\:*/*$~i", $url ) ) { return ''; }
/* Fix poorly formed URLs so as not to throw errors when parsing */
$url = rs_wpss_fix_url( $url );
/* NOW start parsing */
$parsed = @parse_url($url);
/* Filter URLs with no query string */
if( empty( $parsed['query'] ) ) { return ''; }
$query_str = $parsed['query'];
return $query_str;
}
function rs_wpss_get_query_args( $url ) {
/***
* Get query string array from URL
***/
if( empty( $url ) ) { return array(); }
$query_str = rs_wpss_get_query_string( $url );
parse_str( $query_str, $args );
return $args;
}
function rs_wpss_parse_links( $haystack, $type = 'url' ) {
/***
* Parse a body of content for links - extracts URLs and Anchor Text
* $type: 'url' for URLs, 'domain' for just Domains, 'url_at' for URLs from Anchor Text Links only, 'anchor_text' for Anchor Text
* Returns an array
***/
$parse_links_regex = "~(<\s*a\s+[a-z0-9\-_\.\?\='\"\:\(\)\{\}\s]*\s*href|\[(url|link))\s*\=\s*['\"]?\s*(https?\://[a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]+)\s*['\"]?\s*[a-z0-9\-_\.\?\='\"\:;\(\)\{\}\s]*\s*(>|\])([a-z0-9àáâãäåçèéêëìíîïñńņňòóôõöùúûü\-_\/\.\?\&\=\~\@\%\+\#\:;\!,'\(\)\{\}\s]*)(<|\[)\s*\/\s*a\s*(>|(url|link)\])~iu";
$search_http_regex ="~(?:^|\s+)(https?\://[a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]+)(?:$|\s+)~iu";
preg_match_all( $parse_links_regex, $haystack, $matches_links, PREG_PATTERN_ORDER );
$parsed_links_matches = $matches_links[3]; /* Array containing URLs parsed from Anchor Text Links in haystack text */
$parsed_anchortxt_matches = $matches_links[5]; /* Array containing Anchor Text parsed from Anchor Text Links in haystack text */
if( $type === 'url' || $type === 'domain' ) {
$url_haystack = preg_replace( "~\s~", ' - ', $haystack ); /* Workaround Added 1.3.8 */
preg_match_all( $search_http_regex, $url_haystack, $matches_http, PREG_PATTERN_ORDER );
$parsed_http_matches = $matches_http[1]; /* Array containing URLs parsed from haystack text */
$parsed_urls_all_raw = array_merge( $parsed_links_matches, $parsed_http_matches );
$parsed_urls_all = array_unique( $parsed_urls_all_raw );
if( $type === 'url' ) { $results = $parsed_urls_all; }
elseif( $type === 'domain' ) {
$parsed_urls_all_domains = array();
foreach( $parsed_urls_all as $u => $url_raw ) {
$url = rs_wpss_casetrans( 'lower', trim( stripslashes( $url_raw ) ) );
if( empty( $url ) ) { continue; }
$domain = rs_wpss_get_domain( $url );
if( !in_array( $domain, $parsed_urls_all_domains, TRUE ) ) { $parsed_urls_all_domains[] = $domain; }
}
$results = $parsed_urls_all_domains;
}
}
elseif( $type === 'url_at' ) { $results = $parsed_links_matches; }
elseif( $type === 'anchor_text' ) { $results = $parsed_anchortxt_matches; }
return $results;
}
function rs_wpss_fix_url( $url, $rem_frag = FALSE, $rem_query = FALSE, $rev = FALSE ) {
/***
* Fix poorly formed URLs so as not to throw errors or cause problems
***/
$url = trim( $url );
/* Too many forward slashes or colons after http */
$url = preg_replace( "~^(https?)\:+/+~i", "$1://", $url);
/* Too many dots */
$url = preg_replace( "~\.+~i", ".", $url);
/* Too many slashes after the domain */
$url = preg_replace( "~([a-z0-9]+)/+([a-z0-9]+)~i", "$1/$2", $url);
/* Remove fragments */
if( !empty( $rem_frag ) && strpos( $url, '#' ) !== FALSE ) { $url_arr = explode( '#', $url ); $url = $url_arr[0]; }
/* Remove query string completely */
if( !empty( $rem_query ) && strpos( $url, '?' ) !== FALSE ) { $url_arr = explode( '?', $url ); $url = $url_arr[0]; }
/* Reverse */
if( !empty( $rev ) ) { $url = strrev($url); }
return $url;
}
function rs_wpss_get_url() {
$url = rs_wpss_is_ssl() ? 'https://' : 'http://';
$url .= WPSS_SERVER_NAME.$_SERVER['REQUEST_URI'];
return $url;
}
function rs_wpss_is_ssl() {
if( !empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) { return TRUE; }
if( !empty( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { return TRUE; }
if( !empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) { return TRUE; }
if( !empty( $_SERVER['HTTP_X_FORWARDED_SSL'] ) && 'off' !== $_SERVER['HTTP_X_FORWARDED_SSL'] ) { return TRUE; }
return FALSE;
}
function rs_wpss_get_http_status( $url = NULL ) {
/***
* Check HTTP Status - Returns 3-digit response code
* Added 1.9.1
***/
$str_con_def = stream_context_get_options( stream_context_get_default() );
if( empty( $str_con_def ) ) { $str_con_def = array( 'http' => array( 'method' => 'GET' ) ); }
rs_wpss_stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ) );
$headers = @get_headers( $url );
rs_wpss_stream_context_set_default( $str_con_def );
return substr( $headers[0], 9, 3 );
}
function rs_wpss_stream_context_set_default( $arr ) {
/***
* Wrapper to prevent fatal errors upon activation in PHP 5.2 and below
* Function stream_context_set_default() was added in PHP 5.3
* Added 1.9.5.1
***/
if( function_exists( 'stream_context_set_default' ) ) { @stream_context_set_default( $arr ); }
}
function rs_wpss_get_rewrite_base() {
$root_url = rs_wpss_is_ssl() ? 'https://' : 'http://';
$root_url .= WPSS_SERVER_NAME;
$tmp = str_replace( $root_url, '', RSMP_SITE_URL );
$rewrite_base = !empty( $tmp ) ? trailingslashit( $tmp ) : '/';
return $rewrite_base;
}
function rs_wpss_get_server_addr() {
if( !empty( $_SERVER['SERVER_ADDR'] ) ) { $server_addr = $_SERVER['SERVER_ADDR']; } else { $server_addr = getenv('SERVER_ADDR'); }
if( empty( $server_addr ) ) { $server_addr = ''; }
return $server_addr;
}
function rs_wpss_get_ip_addr() {
global $wpss_ip_addr;
if( !empty( $wpss_ip_addr ) ) { return $wpss_ip_addr; }
if( !empty( $_SERVER['REMOTE_ADDR'] ) ) { $wpss_ip_addr = $_SERVER['REMOTE_ADDR']; } else { $wpss_ip_addr = getenv('REMOTE_ADDR'); }
if( empty( $wpss_ip_addr ) ) { $wpss_ip_addr = ''; }
return $wpss_ip_addr;
}
function rs_wpss_get_real_ip() {
/***
* Detect user's real IP when using reverse proxies, WAFs, load balancers, etc
***/
global $wpss_real_ip;
if( !empty( $wpss_real_ip ) ) { return $wpss_real_ip; }
if( !empty( $_SERVER['REMOTE_ADDR'] ) ) { $wpss_real_ip = $_SERVER['REMOTE_ADDR']; } else { $wpss_real_ip = getenv('REMOTE_ADDR'); }
if( empty( $wpss_real_ip ) ) { $wpss_real_ip = ''; }
/***
* TO DO: Add detection for reverse proxies: Incapsula, CloudFlare, Sucuri
* Detect Incapsula, and disable rs_wpss_ubl_cache - 1.8.9.6 *
* if( strpos( $reverse_dns_lc, '.ip.incapdns.net' ) !== FALSE ) { update_option( 'spamshield_ubl_cache_disable', TRUE ); }
***/
return $wpss_real_ip;
}
function rs_wpss_get_server_name() {
$wpss_site_domain = $server_name = '';
$wpss_env_http_host = getenv('HTTP_HOST');
$wpss_env_srvr_name = getenv('SERVER_NAME');
if ( !empty( $_SERVER['HTTP_HOST'] ) ) { $server_name = $_SERVER['HTTP_HOST']; }
elseif ( !empty( $wpss_env_http_host ) ) { $server_name = $wpss_env_http_host; }
elseif ( !empty( $_SERVER['SERVER_NAME'] ) ) { $server_name = $_SERVER['SERVER_NAME']; }
elseif ( !empty( $wpss_env_srvr_name ) ) { $server_name = $wpss_env_srvr_name; }
return rs_wpss_casetrans( 'lower', $server_name );
}
function rs_wpss_get_server_x_req_w() {
if( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) { $server_x_req_w = rs_wpss_casetrans( 'lower', $_SERVER['HTTP_X_REQUESTED_WITH'] ); } else { $server_x_req_w = ''; }
return $server_x_req_w;
}
function rs_wpss_get_query_arr($url) {
/* Get array of variables from query string */
$query_str = rs_wpss_get_query_string($url); /* 1.7.3 - Validates better */
if( !empty( $query_str ) ) { $query_arr = explode( '&', $query_str ); } else { $query_arr = ''; }
return $query_arr;
}
function rs_wpss_remove_query( $url, $skip_wp_args = FALSE ) {
/***
* For removing specific query argument(s)
* If you need URL fragments removed, or the entire query string removed, use rs_wpss_fix_url()
***/
$query_arr = rs_wpss_get_query_arr($url);
if( empty( $query_arr ) ) { return $url; }
$remove_args = array();
foreach( $query_arr as $i => $query_arg ) {
$query_arg_arr = explode( '=', $query_arg );
$key = $query_arg_arr[0];
if( !empty( $skip_wp_args ) && ( $key === 'p' || $key === 'page_id' ) ) { continue; } /* DO NOT ADD 'cpage', only 'p' and 'page_id'!! */
$remove_args[] = $key;
}
$clean_url = remove_query_arg( $remove_args, $url );
return $clean_url;
}
function rs_wpss_get_user_agent( $raw = FALSE, $lowercase = FALSE ) {
/***
* Gives User-Agent with filters
* If blank, gives an initialized var to eliminate need for testing if isset() everywhere
* Default is sanitized - use raw for testing, and sanitized for output
* Added option for raw & lowercase in 1.5
***/
global $wpss_user_agent;
if( !empty( $wpss_user_agent ) ) { return $wpss_user_agent; }
if( !empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
if( !empty ( $raw ) ) { $wpss_user_agent = trim( $_SERVER['HTTP_USER_AGENT'] ); } else { $wpss_user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); }
if( !empty ( $lowercase ) ) { $wpss_user_agent = rs_wpss_casetrans( 'lower', $wpss_user_agent ); }
}
else { $wpss_user_agent = ''; }
return $wpss_user_agent;
}
function rs_wpss_get_plugin_user_agent() {
return 'WP-SpamShield/'.WPSS_VERSION.' (WordPress/'.WPSS_WP_VERSION.') PHP/'.WPSS_PHP_VERSION.' ('.$_SERVER['SERVER_SOFTWARE'].')';
}
function rs_wpss_get_http_accept( $raw = FALSE, $lowercase = FALSE, $lang = FALSE ) {
/***
* Gives $_SERVER['HTTP_ACCEPT'] and $_SERVER['HTTP_ACCEPT_LANGUAGE'] with filters
* Default is sanitized
***/
$http_accept = $http_accept_language = '';
if( !empty( $_SERVER['HTTP_ACCEPT'] ) ) { $http_accept = $_SERVER['HTTP_ACCEPT']; }
if( !empty( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { $http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE']; }
$raw_serv_var = $http_accept;
if( !empty( $lang ) ) { $raw_serv_var = $http_accept_language; }
if( !empty( $raw_serv_var ) ) {
if( !empty ( $raw ) ) { $http_accept_var = trim( $raw_serv_var ); } else { $http_accept_var = sanitize_text_field( $raw_serv_var ); }
if( !empty ( $lowercase ) ) { $http_accept_var = rs_wpss_casetrans( 'lower', $http_accept_var ); }
}
else { $http_accept_var = ''; }
return $http_accept_var;
}
function rs_wpss_get_referrer( $raw = FALSE, $lowercase = FALSE, $init = FALSE ) {
/***
* Gives $_SERVER['HTTP_REFERER'] with filters
* Default is sanitized
***/
global $wpss_referrer;
if( !empty( $wpss_referrer ) ) { return $wpss_referrer; }
$http_referrer = $init_referrer = '';
$site_domain = WPSS_SERVER_NAME;
if( !empty( $_SERVER['HTTP_REFERER'] ) ) { $http_referrer = $_SERVER['HTTP_REFERER']; }
if( !empty( $_COOKIE['JCS_INENREF'] ) ) {
$init_referrer = $_COOKIE['JCS_INENREF'];
$init_referrer_no_query = rs_wpss_fix_url( $init_referrer, TRUE, TRUE ); /* Remove query string and fragments */
if( strpos( $init_referrer_no_query, $site_domain ) !== FALSE ) { $init_referrer = ''; } /* Tracking referrals from other sites only */
}
if( empty( $init_referrer ) && !empty( $_COOKIE['_referrer_og'] ) ) {
$init_referrer = $_COOKIE['_referrer_og'];
$init_referrer_no_query = rs_wpss_fix_url( $init_referrer, TRUE, TRUE ); /* Remove query string and fragments */
if( strpos( $init_referrer_no_query, $site_domain ) !== FALSE ) { $init_referrer = ''; } /* Tracking referrals from other sites only */
}
$wpss_referrer = $http_referrer;
if( !empty( $init ) ) { $wpss_referrer = $init_referrer; }
if( !empty( $wpss_referrer ) ) {
if( !empty ( $raw ) ) { $wpss_referrer = trim( $wpss_referrer ); } else { $wpss_referrer = esc_url_raw( $wpss_referrer ); }
if( !empty ( $lowercase ) ) { $wpss_referrer = rs_wpss_casetrans( 'lower', $wpss_referrer ); }
}
else { $wpss_referrer = ''; }
return $wpss_referrer;
}
function rs_wpss_get_error_type( $error_code ) {
/***
* Returns type of error - JavaScript/Cookies Layer or Algorithmic Layer - 'jsck' or 'algo'
* Added 1.8.9.6
***/
if( empty( $error_code ) ) { return FALSE; }
if( strpos( $error_code, 'COOKIE-' ) !== FALSE || strpos( $error_code, 'REF-2-1023-' ) !== FALSE || strpos( $error_code, 'JSONST-1000-' ) !== FALSE || strpos( $error_code, 'FVFJS-' ) !== FALSE || strpos( $error_code, 'JQHFT-' ) !== FALSE ) { return 'jsck'; }
else { return 'algo'; }
}
function rs_wpss_is_valid_ip( $ip, $incl_priv_res = FALSE, $ipv4_c_block = FALSE ) {
if( empty( $ip ) ) { return FALSE; }
if( !empty( $ipv4_c_block ) ) {
if( preg_match( "~^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}$~", $ip ) ) { return TRUE; } /* Valid C-Block check - checking for C-block: '123.456.78.' format */
}
if( function_exists( 'filter_var' ) ) {
if( empty( $incl_priv_res ) ) { if( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { return TRUE; } }
elseif( filter_var( $ip, FILTER_VALIDATE_IP ) ) { return TRUE; }
/* FILTER_FLAG_IPV4,FILTER_FLAG_IPV6,FILTER_FLAG_NO_PRIV_RANGE,FILTER_FLAG_NO_RES_RANGE */
}
elseif( preg_match( "~^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$~", $ip ) && !preg_match( "~^192\.168\.~", $ip ) ) { return TRUE; }
return FALSE;
}
function rs_wpss_is_google_domain($domain) {
/***
* Check if domain is a Google Domain
* Added 1.7.8
* Google Domains - updated at: https://www.google.com/supported_domains
***/
$google_domains = array(
'.com','.ad','.ae','.com.af','.com.ag','.com.ai','.al','.am','.co.ao','.com.ar','.as','.at','.com.au','.az','.ba','.com.bd','.be','.bf','.bg','.com.bh','.bi','.bj','.com.bn','.com.bo','.com.br','.bs','.bt','.co.bw','.by','.com.bz','.ca','.cd','.cf','.cg','.ch','.ci','.co.ck','.cl','.cm','.cn','.com.co','.co.cr','.com.cu','.cv','.com.cy','.cz','.de','.dj','.dk','.dm','.com.do','.dz','.com.ec','.ee','.com.eg','.es','.com.et','.fi','.com.fj','.fm','.fr','.ga','.ge','.gg','.com.gh','.com.gi','.gl','.gm','.gp','.gr','.com.gt','.gy','.com.hk','.hn','.hr','.ht','.hu','.co.id','.ie','.co.il','.im','.co.in','.iq','.is','.it','.je','.com.jm','.jo','.co.jp','.co.ke','.com.kh','.ki','.kg','.co.kr','.com.kw','.kz','.la','.com.lb','.li','.lk','.co.ls','.lt','.lu','.lv','.com.ly','.co.ma','.md','.me','.mg','.mk','.ml','.com.mm','.mn','.ms','.com.mt','.mu','.mv','.mw','.com.mx','.com.my','.co.mz','.com.na','.com.nf','.com.ng','.com.ni','.ne','.nl','.no','.com.np','.nr','.nu','.co.nz','.com.om','.com.pa','.com.pe','.com.pg','.com.ph','.com.pk','.pl','.pn','.com.pr','.ps','.pt','.com.py','.com.qa','.ro','.ru','.rw','.com.sa','.com.sb','.sc','.se','.com.sg','.sh','.si','.sk','.com.sl','.sn','.so','.sm','.sr','.st','.com.sv','.td','.tg','.co.th','.com.tj','.tk','.tl','.tm','.tn','.to','.com.tr','.tt','.com.tw','.co.tz','.com.ua','.co.ug','.co.uk','.com.uy','.co.uz','.com.vc','.co.ve','.vg','.co.vi','.com.vn','.vu','.ws','.rs','.co.za','.co.zm','.co.zw','.cat',
);
$google_dom_base = array( 'google', 'blogger', );
$tmp_slug = 'XXGOOGLEXX';
foreach( $google_domains as $i => $ext ) {
$domain_tmp_slug = $tmp_slug.$ext;
$regex_tmp = rs_wpss_get_regex_phrase( $domain_tmp_slug, '', 'domain' );
$regex_check_phrase = str_replace( $tmp_slug, '('.implode( '|', $google_dom_base ).')', $regex_tmp );
if( preg_match( $regex_check_phrase, $domain ) ) { return TRUE; }
}
return FALSE;
}
function rs_wpss_is_google_ip($ip) {
/***
* Check if domain is a Google IP
* Added 1.7.8
***/
if( preg_match( "~^(64\.233\.1([6-8][0-9]|9[0-1])|66\.102\.([0-9]|1[0-5])|66\.249\.(6[4-9]|[7-8][0-9]|9[0-5])|72\.14\.(19[2-9]|2[0-4][0-9]|25[0-5])|74\.125\.([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|209\.85\.(1(2[8-9]|[3-9][0-9])|2[0-4][0-9]|25[0-5])|216\.239\.(3[2-9]|[4-5][0-9]|6[0-3]))\.~", $ip ) ) { return TRUE; }
return FALSE;
}
function rs_wpss_get_regex_phrase( $input, $custom_delim = NULL, $flag = "N" ) {
/* Get Regex Phrase from an Array or String */
$flag_regex_arr = array(
"N" => "(^|[\s\.])(X)($|[\s\.\:,\!\?\@\/])",
"S" => "^(X)($|[\s\.\:,\!\?\@\/])",
"E" => "(^|[\s\.])(X)$",
"W" => "^(X)$",
"email_addr" => "^(X)$",
"email_prefix" => "^(X)",
"email_domain" => "\@((ww[w0-9]|m)\.)?(X)$",
"domain" => "^((ww[w0-9]|m)\.)?(X)$",
"authorkw" => "(^|\s+)(X)($|\s+)",
"atxtwrap" => "(<\s*a\s+[a-z0-9\-_\.\?\='\"\:\(\)\{\}\s]*\s*href|\[(url|link))\s*\=\s*['\"]?\s*(https?\:/+[a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]+)\s*['\"]?\s*[a-z0-9\-_\.\?\='\"\:;\(\)\{\}\s]*\s*(>|\])([a-z0-9àáâãäåçèéêëìíîïñńņňòóôõöùúûü\-_\/\.\?\&\=\~\@\%\+\#\:;\!,'\(\)\{\}\s]*\s+)?(X)([a-z0-9àáâãäåçèéêëìíîïñńņňòóôõöùúûü\-_\/\.\?\&\=\~\@\%\+\#\:;\!,'\(\)\{\}\s]*\s+)?(<|\[)\s*\/\s*a\s*(>|(url|link)\])",
/***
* REFERENCE: Parse full html links with this:
* $parse_links_regex = "~(<\s*a\s+[a-z0-9\-_\.\?\='\"\:\(\)\{\}\s]*\s*href|\[(url|link))\s*\=\s*['\"]?\s*(https?\:/+[a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]+)\s*['\"]?\s*[a-z0-9\-_\.\?\='\"\:;\(\)\{\}\s]*\s*(>|\])([a-z0-9àáâãäåçèéêëìíîïñńņňòóôõöùúûü\-_\/\.\?\&\=\~\@\%\+\#\:;\!,'\(\)\{\}\s]*)(<|\[)\s*\/\s*a\s*(>|(url|link)\])~iu";
***/
"linkwrap" => "(<\s*a\s+([a-z0-9\-_\.\?\='\"\:\(\)\{\}\s]*)\s*href|\[(url|link))\s*\=\s*(['\"])?\s*https?\:/+((ww[w0-9]|m)\.)?(X)/?([a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]*)(['\"])?(>|\])",
"httplinkwrap" => "(^|\b)https?\:/+((ww[w0-9]|m)\.)?(X)/?([a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]*)",
/***
* REFERENCE: Parse stripped http links with this:
* $search_http_regex ="~\s+(https?\://[a-z0-9\-_\/\.\?\&\=\~\@\%\+\#\:]+)\s+~i";
***/
"red_str" => "(X)", /* Red-flagged string */
"rgx_str" => "(X)", /* Regex-ready string */
);
if( is_array( $input) ) {
$regex_flag = $flag_regex_arr[$flag];
$regex_phrase_pre_arr = array();
foreach( $input as $i => $val ) {
if( $flag === "rgx_str" || $flag === "authorkw" || $flag === "atxtwrap" ) { $val_reg_pre = $val; } /* Variable must come in prepped for regex (preg_quoted) */
else { $val_reg_pre = rs_wpss_preg_quote($val); }
$regex_phrase_pre_arr[] = $val_reg_pre;
}
$regex_phrase_pre_str = implode( "|", $regex_phrase_pre_arr );
$regex_phrase_str = preg_replace( "~X~", $regex_phrase_pre_str, $regex_flag );
if( !empty( $custom_delim ) ) { $delim = $custom_delim; } else { $delim = "~"; }
$regex_phrase = $delim.$regex_phrase_str.$delim."iu"; /* UTF-8 enabled */
if( $flag === "email_addr" || $flag === "red_str" ) {
$regex_phrase = str_replace( '@gmail\.', '@g(oogle)?mail\.', $regex_phrase );
}
}
elseif( is_string( $input ) ) {
$val = $input;
$regex_flag = $flag_regex_arr[$flag];
if( $flag === "rgx_str" || $flag === "authorkw" || $flag === "atxtwrap" ) { $val_reg_pre = $val; } /* Variable must come in prepped for regex (preg_quoted) */
else { $val_reg_pre = rs_wpss_preg_quote($val); }
$regex_phrase_str = preg_replace( "~X~", $val_reg_pre, $regex_flag );
if( !empty( $custom_delim ) ) { $delim = $custom_delim; } else { $delim = "~"; }
$regex_phrase = $delim.$regex_phrase_str.$delim."iu"; /* UTF-8 enabled */
if( $flag === "email_addr" || $flag === "red_str" ) {
$regex_phrase = str_replace( '@gmail\.', '@g(oogle)?mail\.', $regex_phrase );
}
}
else { return $input; }
return $regex_phrase;
}
function rs_wpss_rbkmd( $dat, $mod = 'en', $exp = FALSE, $imp = FALSE, $case = NULL, $del = '~' ) {
if( !empty( $imp ) && is_array( $dat ) ) { $dat = implode( $del, $dat ); }
$lft = '.!:;1234567890|abcdefghijklmnopqrstuvwxyz{}()<>~@#$%^&*?,_-+= \/';
$rgt = 'ghiJVWXyz@#$%^&*?,_-+=1234567890ABCdefGHIjklMNOpqrSTUvwxYZabcDEF';
if( $mod === 'en' ) { $mod_dat = strtr( $dat, $lft, $rgt ); } else { $mod_dat = strtr( $dat, $rgt, $lft ); }
if( !empty( $case ) ) { $mod_dat = rs_wpss_casetrans( $case, $mod_dat ); }
if( !empty( $exp ) ) { $mod_dat = explode( $del, $mod_dat ); }
return $mod_dat;
}
function rs_wpss_is_plugin_active( $plug_bn ) {
/***
* Using this because is_plugin_active() only works in Admin
* ex. $plug_bn = 'folder/filename.php'; // Plugin Basename
***/
if( empty( $plug_bn ) ){ return FALSE; }
global $wpss_active_plugins,$wpss_conf_active_plugins;
/* Quick Check */
if( !empty( $wpss_conf_active_plugins[$plug_bn] ) ) { return TRUE; }
$wpss_conf_active_plugins = array();
/* Check known plugin constants and classes */
$plug_cncl = array(
/* Compatibility Fixes */
'autoptimize/autoptimize.php' => array( 'cn' => 'AUTOPTIMIZE_WP_CONTENT_NAME', 'cl' => 'autoptimizeConfig' ), 'commentluv/commentluv.php' => array( 'cn' => '', 'cl' => 'commentluv' ), 'si-contact-form/si-contact-form.php' => array( 'cn' => 'FSCF_VERSION', 'cl' => 'FSCF_Util' ), 'jetpack/jetpack.php' => array( 'cn' => 'JETPACK__VERSION', 'cl' => 'Jetpack' ), 'wp-spamfree/wp-spamfree.php' => array( 'cn' => '', 'cl' => 'wpSpamFree' ),
/* 3rd Party Forms, Membership & Registration */
'bbpress/bbpress.php' => array( 'cn' => '', 'cl' => 'bbPress' ), 'buddypress/bp-loader.php' => array( 'cn' => 'BP_PLUGIN_DIR', 'cl' => 'BuddyPress' ), 'contact-form-7/wp-contact-form-7.php' => array( 'cn' => 'WPCF7_VERSION', 'cl' => '' ), 'gravityforms/gravityforms.php' => array( 'cn' => 'GF_MIN_WP_VERSION', 'cl' => 'GFForms' ), 'mailchimp-for-wp/mailchimp-for-wp.php' => array( 'cn' => 'MC4WP_LITE_VERSION', 'cl' => 'MC4WP_Lite' ), 'ninja-forms/ninja-forms.php' => array( 'cn' => 'NF_PLUGIN_VERSION', 'cl' => 'Ninja_Forms' ),
/* Ecommerce Plugins */
'download-manager/download-manager.php' => array( 'cn' => 'WPDM_Version', 'cl' => '' ), 'easy-digital-downloads/easy-digital-downloads.php' => array( 'cn' => 'EDD_VERSION', 'cl' => '' ), 'ecwid-shopping-cart/ecwid-shopping-cart.php' => array( 'cn' => 'ECWID_DEMO_STORE_ID', 'cl' => '' ), 'eshop/eshop.php' => array( 'cn' => 'ESHOP_VERSION', 'cl' => '' ), 'ithemes-exchange/init.php' => array( 'cn' => '', 'cl' => 'IT_Exchange' ), 'jigoshop/jigoshop.php' => array( 'cn' => 'JIGOSHOP_VERSION', 'cl' => '' ), 'shopp/Shopp.php' => array( 'cn' => '', 'cl' => 'ShoppLoader' ), 'usc-e-shop/usc-e-shop.php' => array( 'cn' => 'USCES_VERSION', 'cl' => '' ), 'woocommerce/woocommerce.php' => array( 'cn' => 'WOOCOMMERCE_VERSION', 'cl' => 'WooCommerce' ), 'wordpress-ecommerce/marketpress.php' => array( 'cn' => 'MP_LITE', 'cl' => 'MarketPress' ), 'wordpress-simple-paypal-shopping-cart/wp_shopping_cart.php' => array( 'cn' => 'WP_CART_VERSION', 'cl' => '' ), 'wp-e-commerce/wp-shopping-cart.php' => array( 'cn' => 'WPSC_FILE_PATH', 'cl' => '' ),
/* All others */
'wordfence/wordfence.php' => array( 'cn' => 'WORDFENCE_VERSION', 'cl' => 'wordfence' ),
);
if( ( !empty( $plug_cncl[$plug_bn]['cn'] ) && defined( $plug_cncl[$plug_bn]['cn'] ) ) || ( !empty( $plug_cncl[$plug_bn]['cl'] ) && class_exists( $plug_cncl[$plug_bn]['cl'] ) ) ) { $wpss_conf_active_plugins[$plug_bn] = TRUE; return TRUE; }
/* No match yet, so now do standard check */
if( empty( $wpss_active_plugins ) ) { $wpss_active_plugins = get_option( 'active_plugins' ); }
if( in_array( $plug_bn, $wpss_active_plugins, TRUE ) ) { $wpss_conf_active_plugins[$plug_bn] = TRUE; return TRUE; }
return FALSE;
}
function rs_wpss_is_user_admin() {
global $wpss_user_can_manage_options;
if( empty( $wpss_user_can_manage_options ) ) { $wpss_user_can_manage_options = current_user_can( 'manage_options' ) ? 'YES' : 'NO' ; }
if( $wpss_user_can_manage_options === 'YES' ) { return TRUE; }
return FALSE;
}
function rs_wpss_error_txt( $case = 'UC' ) {
/* $case = 'def' (default - unaltered), 'UC' (uppercase) */
$default_txt = __( 'Error' );
if( $case === 'UC' ) { return rs_wpss_casetrans( 'upper', $default_txt ); } else { return $default_txt; }
}
function rs_wpss_blocked_txt( $case = 'def' ) {
/* $case = 'def' (default - unaltered), 'UCW' (uppercase words) */
$default_txt = __( 'SPAM BLOCKED', WPSS_PLUGIN_NAME );
if( $case === 'UCW' ) { return rs_wpss_casetrans( 'ucwords', $default_txt ); } else { return $default_txt; }
}
function rs_wpss_doc_txt() {
return __( 'Documentation', WPSS_PLUGIN_NAME );
}
function rs_wpss_is_lang_en_us( $strict = TRUE ) {
/* Test if site is set to use English (US) - the default - or another language/localization */
$wpss_locale = get_locale();
if( $strict !== TRUE ) {
/* Not strict - English, but localized translations may be in use */
if( !empty( $wpss_locale ) && !preg_match( "~^(en(_[a-z]{2})?)?$~i", $wpss_locale ) ) { $lang_en_us = FALSE; } else { $lang_en_us = TRUE; }
}
else {
/* Strict - English (US), no translation being used */
if( !empty( $wpss_locale ) && !preg_match( "~^(en(_us)?)?$~i", $wpss_locale ) ) { $lang_en_us = FALSE; } else { $lang_en_us = TRUE; }
}
return $lang_en_us;
}
function rs_wpss_wf_geoiploc( $ip = NULL, $disp = FALSE ) {
/***
* If WordFence installed, get GEO IP Location data
* Added 1.9.5.2
***/
if( TRUE === WPSS_COMPAT_MODE ) { return ''; } /* No GEO IP Location checks if Compatibility Mode is on */
global $wpss_geoiploc_data, $wpss_geolocation;
if( class_exists( 'wfUtils' ) && rs_wpss_is_plugin_active( 'wordfence/wordfence.php' ) ) {
/* $start = rs_wpss_microtime(); */
if( empty( $ip ) ) { $ip = rs_wpss_get_ip_addr(); }
if( ( empty( $_SESSION['wpss_geoiploc_data_'.RSMP_HASH] ) && empty( $wpss_geoiploc_data ) ) || ( empty( $_SESSION['wpss_geolocation_'.RSMP_HASH] ) && empty( $wpss_geolocation ) || empty( $_SESSION['wpss_geoiploc_ip_'.RSMP_HASH] ) || $_SESSION['wpss_geoiploc_ip_'.RSMP_HASH] !== $ip ) ) {
$wpss_geoiploc_data = wfUtils::getIPGeo( $ip );
/***
* $wpss_geoiploc_data = array( 'IP' => $ip, 'city' => $city, 'region' => $region, 'countryName' => $countryName, 'countryCode' => $countryCode, 'lat' => $lat, 'lon' => $long );
***/
if( empty( $wpss_geoiploc_data ) || !is_array( $wpss_geoiploc_data ) ) { return ''; }
extract( $wpss_geoiploc_data );
$city_region = !empty( $city ) && !empty( $region ) ? ' - '.$city.', '.$region : '';
$_SESSION['wpss_geoiploc_ip_'.RSMP_HASH] = $ip;
if( FALSE === $disp ) {
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
}
if( TRUE === $disp ) {
if( !empty( $_SESSION['wpss_geolocation_'.RSMP_HASH] ) ) {
$wpss_geolocation = $_SESSION['wpss_geolocation_'.RSMP_HASH];
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
}
elseif( !empty( $wpss_geolocation ) ) {
$_SESSION['wpss_geolocation_'.RSMP_HASH] = $wpss_geolocation;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
}
else {
$wpss_geolocation = $countryCode.' - '.$countryName.$city_region;
$_SESSION['wpss_geolocation_'.RSMP_HASH] = $wpss_geolocation;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geolocation;
}
}
else {
if( !empty( $_SESSION['wpss_geoiploc_data_'.RSMP_HASH] ) ) {
$wpss_geoiploc_data = $_SESSION['wpss_geoiploc_data_'.RSMP_HASH];
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
elseif( !empty( $wpss_geoiploc_data ) ) {
$_SESSION['wpss_geoiploc_data_'.RSMP_HASH] = $wpss_geoiploc_data;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
else {
$wpss_geoiploc_data = $countryCode.' - '.$countryName.$city_region;
$_SESSION['wpss_geoiploc_data_'.RSMP_HASH] = $wpss_geoiploc_data;
/* $rs_wpss_timer_bm( $start ); */
return $wpss_geoiploc_data;
}
}
}
return '';
}
function rs_wpss_wf_geoiploc_short( $ip = NULL ) {
global $wpss_geoloc_short;
if( empty ( $wpss_geoloc_short ) ) {
global $wpss_geolocation; if( empty ( $wpss_geolocation ) ) { $wpss_geolocation = rs_wpss_wf_geoiploc( $ip, TRUE ); }
if( empty( $wpss_geolocation ) ) { return ''; }
$tmp = explode( ' - ', $wpss_geolocation );
if( isset( $tmp[2] ) ) { unset( $tmp[2] ); }
$wpss_geoloc_short = implode( ' - ', $tmp );
}
return $wpss_geoloc_short;
}