C:\xampp\htdocs\landing\wp-content\plugins\better-wp-security\core\core.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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
<?php

use iThemesSecurity\User_Groups;

/**
 * iThemes Security Core.
 *
 * Core class for iThemes Security sets up globals and other items and dispatches modules.
 *
 * @since   4.0
 *
 * @package iThemes_Security
 *
 * @global array  $itsec_globals Global variables for use throughout iThemes Security.
 * @global object $itsec_lockout Class for handling lockouts.
 *
 */
if ( ! class_exists'ITSEC_Core' ) ) {

    final class 
ITSEC_Core {

        private static 
$instance false;

        
/**
         * This number keeps track of data format changes and triggers data upgrade handlers.
         *
         * @access private
         */
        
private $plugin_build 4121;

        
/**
         * Used to distinguish between a user modifying settings and the API modifying settings (such as from Sync
         * requests).
         *
         * @access private
         */
        
private $interactive false;

        private 
$notices_loaded false;
        private 
$doing_data_upgrade false;

        
/** @var true|WP_Error|null */
        
private $setup_error;

        private
            
$itsec_files,
            
$itsec_notify,
            
$notifications,
            
$scheduler,
            
$sync_api,
            
$plugin_file,
            
$plugin_dir,
            
$plugin_name,
            
$current_time,
            
$current_time_gmt,
            
$is_iwp_call,
            
$wp_upload_dir,
            
$login_interstitial,
            
$version,
            
$importing false;


        
/**
         * Private constructor to make this a singleton
         *
         * @access private
         */
        
private function __construct() { }

        
/**
         * Function to instantiate our class and make it a singleton
         */
        
public static function get_instance() {
            if ( ! 
self::$instance ) {
                
self::$instance = new self;
            }

            return 
self::$instance;
        }

        
/**
         * Loads core functionality across both admin and frontend.
         *
         * Creates all plugin globals, registers activation and related hooks,
         * loads the text domain and loads all plugin modules
         *
         * @since  4.0
         *
         * @access private
         *
         * @param string $plugin_file The main plugin file
         * @param string $plugin_name The plugin name
         *
         */
        
public function init$plugin_file$plugin_name ) {
            global 
$itsec_globals$itsec_lockout;

            
$this->plugin_file      $plugin_file;
            
$this->plugin_dir       dirname$plugin_file ) . '/';
            
$this->plugin_name      $plugin_name;
            
$this->current_time     current_time'timestamp' );
            
$this->current_time_gmt current_time'timestamp'true );

            
$itsec_globals = array(
                
'plugin_dir'       => $this->plugin_dir,
                
'current_time'     => $this->current_time,
                
'current_time_gmt' => $this->current_time_gmt,
            );

            
register_activation_hook$this->plugin_file, array( 'ITSEC_Core''handle_activation' ) );
            
register_deactivation_hook$this->plugin_file, array( 'ITSEC_Core''handle_deactivation' ) );
            
register_uninstall_hook$this->plugin_file, array( 'ITSEC_Core''handle_uninstall' ) );

            require( 
$this->plugin_dir 'core/lib/settings.php' );
            require( 
$this->plugin_dir 'core/lib/storage.php' );
            require( 
$this->plugin_dir 'core/modules.php' );
            require( 
$this->plugin_dir 'core/lib.php' );
            require( 
$this->plugin_dir 'core/lib/log.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-mutex.php' );
            require( 
$this->plugin_dir 'core/rest.php' );

            
$this->setup_tables();

            
add_filter'user_has_cap', [ $this'user_has_cap' ], 10);

            ( new 
ITSEC_REST() )->run();

            
add_action'itsec-register-modules', array( $this'register_modules' ) );
            
ITSEC_Modules::init_modules();

            require( 
$this->plugin_dir 'core/lockout.php' );
            require( 
$this->plugin_dir 'core/files.php' );
            require( 
$this->plugin_dir 'core/notify.php' );
            require( 
$this->plugin_dir 'core/response.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-lib-user-activity.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-lib-password-requirements.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-lib-login-interstitial.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-lib-distributed-storage.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-lib-remote-messages.php' );

            require( 
$this->plugin_dir 'core/lib/class-itsec-scheduler.php' );
            require( 
$this->plugin_dir 'core/lib/class-itsec-job.php' );

            
$this->itsec_files  ITSEC_Files::get_instance();
            
$this->itsec_notify = new ITSEC_Notify();
            
$itsec_lockout      = new ITSEC_Lockout();

            
// Handle upgrade if needed.
            
add_action'plugins_loaded', array( $this'handle_upgrade' ), - 100);
            
add_action'plugins_loaded', array( $this'continue_init' ), - 90 );

            
add_action'itsec_scheduler_register_events', array( $this'register_events' ) );
            
add_action'itsec_scheduled_clear-locks', array( 'ITSEC_Lib''delete_expired_locks' ) );
            
add_action'itsec_scheduled_clear-tokens', array( ITSEC_Lib_Opaque_Tokens::class, 'delete_expired_tokens' ) );
            
add_action'itsec_scheduled_flush-files', array( 'ITSEC_Files''flush_files' ) );
            
add_action'itsec_before_import', function () {
                
$this->importing true;
            } );
            
add_action'itsec_after_import', function () {
                
$this->importing false;
            } );
        }

        
/**
         * Handle dynamically granting the 'itsec_manage' cap to users in the necessary group.
         *
         * @param array   $has_caps
         * @param array   $requested_caps
         * @param array   $args
         * @param WP_User $user
         *
         * @return array
         */
        
public function user_has_cap$has_caps$requested_caps$args$user ) {
            if ( ! 
in_array'itsec_manage'$requested_capstrue ) ) {
                return 
$has_caps;
            }

            if ( isset( 
$has_caps['itsec_manage'] ) ) {
                return 
$has_caps;
            }

            if (
                
is_wp_error$this->setup_error ) ||
                
self::is_temp_disable_modules_set() ||
                ! 
ITSEC_Modules::get_container()->hasUser_Groups\Matcher::class ) ||
                ! 
$this->has_valid_manage_groups()
            ) {
                
$has_caps['itsec_manage'] = $user->has_capis_multisite() ? 'manage_network_options' 'manage_options' );

                return 
$has_caps;
            }

            
$group   ITSEC_Modules::get_setting'global''manage_group' );
            
$matcher ITSEC_Modules::get_container()->getUser_Groups\Matcher::class );

            if ( ! 
$matcher->matchesUser_Groups\Match_Target::for_user$user ), $group ) ) {
                return 
$has_caps;
            }

            
$has_caps['itsec_manage'] = true;

            return 
$has_caps;
        }

        
/**
         * Check if there are valid "Manage groups" selected.
         *
         * @return bool
         */
        
private function has_valid_manage_groups() {
            
$source ITSEC_Modules::get_container()->getUser_Groups\Matchables_Source::class );
            
$groups ITSEC_Modules::get_setting'global''manage_group' );

            foreach ( 
$groups as $group ) {
                if ( 
$source->has$group ) ) {
                    return 
true;
                }
            }

            return 
false;
        }

        
/**
         * Perform initialization that requires the plugins_loaded hook to be fired.
         */
        
public function continue_init() {
            global 
$itsec_lockout;

            if ( 
is_wp_error$this->setup_error ) ) {
                if ( ! 
current_user_canis_multisite() ? 'manage_network_options' 'manage_options' ) ) {
                    return;
                }

                
add_action'admin_notices', function () {
                    echo 
'<div class="notice notice-error">';
                    echo 
'<p>';
                    
esc_html_e'Cannot run iThemes Security. Error encountered during setup. Please try deactivating and reactivating iThemes Security. Contact support if the error persists.''better-wp-security' );
                    echo 
'</p>';

                    echo 
'<ol>';
                    foreach ( 
ITSEC_Lib::get_error_strings$this->setup_error ) as $string ) {
                        echo 
'<li>' $string '</li>';
                    }
                    echo 
'</ol>';
                    echo 
'</div>';
                } );

                return;
            }

            
$itsec_lockout->run();

            if ( 
is_admin() ) {
                require( 
$this->plugin_dir 'core/admin-pages/init.php' );

                
add_filter'plugin_action_links', array( $this'add_action_link' ), 10);
                
add_filter'plugin_row_meta', array( $this'add_plugin_meta_links' ), 10);
            }

            
add_action'wp_login_failed', array( 'ITSEC_Lib''handle_wp_login_failed' ) );
            
add_action'ithemes_sync_register_verbs', array( $this'register_sync_verbs' ) );

            
$this->setup_scheduler();
            
ITSEC_Modules::run_active_modules();

            
$this->login_interstitial = new ITSEC_Lib_Login_Interstitial();
            
$this->login_interstitial->run();

            if ( 
defined'ITSEC_USE_CRON' ) && ITSEC_USE_CRON !== ITSEC_Lib::use_cron() ) {
                
ITSEC_Modules::set_setting'global''use_cron'ITSEC_USE_CRON );
            }

            
do_action'itsec_initialized' );

            
ITSEC_Lib_Remote_Messages::init();
            
$this->run_integrations();
        }

        
/**
         * Register our tables with {@see wpdb}.
         */
        
private function setup_tables() {
            global 
$wpdb;

            
$wpdb->global_tables array_merge$wpdb->global_tablesITSEC_Schema::TABLES );
        }

        private function 
setup_scheduler() {

            if ( 
$this->scheduler ) {
                return;
            }

            
$choices = array(
                
'ITSEC_Scheduler_Cron'      => $this->plugin_dir 'core/lib/class-itsec-scheduler-cron.php',
                
'ITSEC_Scheduler_Page_Load' => $this->plugin_dir 'core/lib/class-itsec-scheduler-page-load.php',
            );

            if ( 
ITSEC_Lib::use_cron() ) {
                
$class 'ITSEC_Scheduler_Cron';
            } else {
                
$class 'ITSEC_Scheduler_Page_Load';
            }

            require_once( 
$choices$class ] );

            
$this->scheduler = new $class();
            
self::get_scheduler()->run();
        }

        
/**
         * Get the required capability to manage ITSEC.
         *
         * @return string
         */
        
public static function get_required_cap() {
            return 
apply_filters'itsec_cap_required''itsec_manage' );
        }

        
/**
         * Does the current user have permission to manage ITSEC.
         *
         * @return bool
         */
        
public static function current_user_can_manage() {
            return 
current_user_canself::get_required_cap() );
        }

        
/**
         * Retrieve the global instance of the files utility.
         *
         * @return ITSEC_Files
         */
        
public static function get_itsec_files() {
            
$self self::get_instance();

            return 
$self->itsec_files;
        }

        
/**
         * Retrieve the global instance of the user notification utility.
         *
         * @return ITSEC_Notify
         */
        
public static function get_itsec_notify() {
            
$self self::get_instance();

            return 
$self->itsec_notify;
        }

        
/**
         * Set the notification center instance.
         *
         * @param ITSEC_Notification_Center $center
         */
        
public static function set_notification_centerITSEC_Notification_Center $center ) {
            
self::get_instance()->notifications $center;
        }

        
/**
         * Get the notification center instance.
         *
         * @return ITSEC_Notification_Center
         */
        
public static function get_notification_center() {
            return 
self::get_instance()->notifications;
        }

        
/**
         * Set the scheduler to use.
         *
         * @param ITSEC_Scheduler $scheduler
         */
        
public static function set_schedulerITSEC_Scheduler $scheduler ) {
            
self::get_instance()->scheduler $scheduler;
        }

        
/**
         * Get the scheduler.
         *
         * @return ITSEC_Scheduler
         */
        
public static function get_scheduler() {

            
$self self::get_instance();

            if ( ! 
$self->scheduler ) {
                
$self->setup_scheduler();
            }

            return 
$self->scheduler;
        }

        
/**
         * Get the login interstitial library instance.
         *
         * @return ITSEC_Lib_Login_Interstitial
         */
        
public static function get_login_interstitial() {
            return 
self::get_instance()->login_interstitial;
        }

        
/**
         * Retrieve the global instance of the Sync API.
         *
         * The API is not available until iThemes Sync verbs have been registered ( init#11 ).
         *
         * @return Ithemes_Sync_API|null
         */
        
public static function get_sync_api() {
            
$self self::get_instance();

            return 
$self->sync_api;
        }

        
/**
         * Check if an import is in progress.
         *
         * @return bool
         */
        
public static function is_importing() {
            return 
self::get_instance()->importing;
        }

        
/**
         * Register ITSEC verbs with sync.
         *
         * @param Ithemes_Sync_API $sync_api
         */
        
public function register_sync_verbs$sync_api ) {
            
// For use by the itsec-get-everything verb as it has to run other verbs to get their details.
            
$this->sync_api $sync_api;

            
$sync_api->register'itsec-get-everything''Ithemes_Sync_Verb_ITSEC_Get_Everything'dirname__FILE__ ) . '/sync-verbs/itsec-get-everything.php' );
        }

        
/**
         * Register events.
         *
         * @param ITSEC_Scheduler $scheduler
         */
        
public function register_events$scheduler ) {
            
$scheduler->scheduleITSEC_Scheduler::S_DAILY'clear-locks' );
            
$scheduler->scheduleITSEC_Scheduler::S_DAILY'health-check' );
            
$scheduler->scheduleITSEC_Scheduler::S_DAILY'clear-tokens' );
            
$scheduler->scheduleITSEC_Scheduler::S_HOURLY'flush-files' );
        }

        
/**
         * Register core modules.
         */
        
public function register_modules() {
            
$path dirname__FILE__ );

            
ITSEC_Modules::register_module'feature-flags'"$path/modules/feature-flags"'always-active' );
            
ITSEC_Modules::register_module'security-check'"$path/modules/security-check"'always-active' );
            
ITSEC_Modules::register_module'global'"$path/modules/global"'always-active' );
            
ITSEC_Modules::register_module'notification-center'"$path/modules/notification-center"'always-active' );
            
ITSEC_Modules::register_module'user-groups'"$path/modules/user-groups"'always-active' );
            
ITSEC_Modules::register_module'privacy'"$path/modules/privacy"'always-active' );
            
ITSEC_Modules::register_module'404-detection'"$path/modules/404-detection" );
            
ITSEC_Modules::register_module'admin-user'"$path/modules/admin-user"'always-active' );
            
ITSEC_Modules::register_module'away-mode'"$path/modules/away-mode" );
            
ITSEC_Modules::register_module'ban-users'"$path/modules/ban-users"'default-active' );
            include( 
"$path/modules/ban-users/init.php" ); // Provides the itsec_ban_users_handle_new_blacklisted_ip function which is always needed.
            
ITSEC_Modules::register_module'content-directory'"$path/modules/content-directory"'always-active' );
            
ITSEC_Modules::register_module'database-prefix'"$path/modules/database-prefix"'always-active' );
            
ITSEC_Modules::register_module'backup'"$path/modules/backup"'default-active' );
            
ITSEC_Modules::register_module'core'"$path/modules/core"'always-active' );
            
ITSEC_Modules::register_module'email-confirmation'"$path/modules/email-confirmation"'always-active' );
            
ITSEC_Modules::register_module'file-change'"$path/modules/file-change" );
            
ITSEC_Modules::register_module'file-permissions'"$path/modules/file-permissions"'always-active' );
            
ITSEC_Modules::register_module'hide-backend'"$path/modules/hide-backend"'always-active' );
            
ITSEC_Modules::register_module'brute-force'"$path/modules/brute-force"'default-active' );

            if ( 
is_multisite() ) {
                
ITSEC_Modules::register_module'multisite-tweaks'"$path/modules/multisite-tweaks" );
            }

            
ITSEC_Modules::register_module'network-brute-force'"$path/modules/ipcheck"'default-active' );

            if ( ! 
defined'ITSEC_DISABLE_PASSWORD_REQUIREMENTS' ) || ! ITSEC_DISABLE_PASSWORD_REQUIREMENTS ) {
                
ITSEC_Modules::register_module'password-requirements'"$path/modules/password-requirements/"'always-active' );
            }

            
ITSEC_Modules::register_module'ssl'"$path/modules/ssl" );
            
ITSEC_Modules::register_module'strong-passwords'"$path/modules/strong-passwords"'always-active' );
            
ITSEC_Modules::register_module'system-tweaks'"$path/modules/system-tweaks" );
            
ITSEC_Modules::register_module'wordpress-salts'"$path/modules/salts"'always-active' );
            
ITSEC_Modules::register_module'wordpress-tweaks'"$path/modules/wordpress-tweaks"'default-active' );
            
ITSEC_Modules::register_module'file-writing'"$path/modules/file-writing"'always-active' );
            
ITSEC_Modules::register_module'malware'"$path/modules/malware"'always-active' );
            
ITSEC_Modules::register_module'security-check-pro'"$path/modules/security-check-pro"self::is_pro() ? 'always-active' 'default-inactive' );
            
ITSEC_Modules::register_module'sync-connect'"$path/modules/sync-connect"'always-active' );
            
ITSEC_Modules::register_module'site-scanner'"$path/modules/site-scanner"'always-active' );

            if ( ! 
ITSEC_Core::is_pro() ) {
                
ITSEC_Modules::register_module'pro-module-upsells'"$path/modules/pro"'always-active' );
            }
        }

        
/**
         * Runs any global ITSEC integrations.
         */
        
private function run_integrations() {
            if ( 
function_exists'restrict_content_pro' ) ) {
                require_once 
self::get_core_dir() . '/integrations/rcp.php';
            }
        }

        
/**
         * Add action link to plugin page.
         *
         * Adds plugin settings link to plugin page in WordPress admin area.
         *
         * @since 4.0
         *
         * @param array  $links Array of WordPress links
         * @param string $file  String name of current file
         *
         * @return array Array of WordPress links
         */
        
public function add_action_link$links$file ) {

            static 
$this_plugin;

            if ( empty( 
$this_plugin ) ) {
                
$this_plugin str_replaceWP_PLUGIN_DIR '/'''self::get_plugin_file() );
            }

            if ( 
$file == $this_plugin ) {
                
$settings_link '<a href="' esc_urlself::get_settings_page_url() ) . '">' __'Settings''better-wp-security' ) . '</a>';
                
array_unshift$links$settings_link );
            }

            return 
$links;
        }

        
/**
         * Adds links to the plugin row meta
         *
         * @since 4.0
         *
         * @param array  $meta        Existing meta
         * @param string $plugin_file the wp plugin slug (path)
         *
         * @return array
         */
        
public function add_plugin_meta_links$meta$plugin_file ) {

            
$plugin_base str_replaceWP_PLUGIN_DIR '/'''self::get_plugin_file() );

            if ( 
$plugin_base == $plugin_file ) {

                
$meta apply_filters'itsec_meta_links'$meta );

            }

            return 
$meta;
        }

        
/**
         * Dispatch a request to upgrade the data schema to another version.
         *
         * @param int|bool $build The version of the data storage format. Pass false to default to the current version.
         *
         * @return true|WP_Error|null
         */
        
public function handle_upgrade$build false ) {

            if ( 
func_num_args() === && self::get_saved_plugin_build() >= $this->plugin_build ) {
                return 
null;
            }

            
$this->doing_data_upgrade true;

            require_once( 
self::get_core_dir() . '/setup.php' );
            
self::get_instance()->setup_error ITSEC_Setup::handle_upgrade$build );

            return 
self::get_instance()->setup_error;
        }

        public static function 
handle_activation() {
            require_once( 
self::get_core_dir() . '/setup.php' );
            
self::get_instance()->setup_error ITSEC_Setup::handle_activation();
        }

        public static function 
handle_deactivation() {
            require_once( 
self::get_core_dir() . '/setup.php' );
            
ITSEC_Setup::handle_deactivation();
        }

        public static function 
handle_uninstall() {
            require_once( 
self::get_core_dir() . '/setup.php' );
            
ITSEC_Setup::handle_uninstall();
        }

        
/**
         * Register a notice to be displayed in the WordPress admin.
         *
         * @param callable $callback  Function that will render a notice.
         * @param bool     $all_pages Display the notice on all pages or only on ITSEC, plugins, and upgrade page.
         */
        
public static function add_notice$callback$all_pages false ) {
            
_deprecated_function__METHOD__'6.0.0''ITSEC_Lib_Admin_Notices::register' );

            global 
$pagenow$plugin_page;

            if ( ! 
$all_pages && ! in_array$pagenow, array( 'plugins.php''update-core.php' ) ) && ( ! isset( $plugin_page ) || ! in_array$plugin_page, array( 'itsec''itsec-logs' ) ) ) ) {
                return;
            }

            
$self self::get_instance();

            if ( ! 
$self->notices_loaded ) {
                
wp_enqueue_style'itsec-notice'plugins_url'core/css/itsec_notice.css'ITSEC_Core::get_core_dir() ), array(), '20160609' );
                
wp_enqueue_script'itsec-notice'plugins_url'core/js/itsec-notice.js'ITSEC_Core::get_core_dir() ), array(), '20160512' );

                
$self->notices_loaded true;
            }

            if ( 
is_multisite() ) {
                
add_action'network_admin_notices'$callback );
            } else {
                
add_action'admin_notices'$callback );
            }
        }

        public static function 
get_plugin_file() {
            
$self self::get_instance();

            return 
$self->plugin_file;
        }

        public static function 
set_plugin_file$plugin_file ) {
            
$self              self::get_instance();
            
$self->plugin_file $plugin_file;
            
$self->plugin_dir  dirname$plugin_file ) . '/';
        }

        
/**
         * Get the build the plugin is running on.
         *
         * @return int
         */
        
public static function get_plugin_build() {
            
$self self::get_instance();

            return 
$self->plugin_build;
        }

        
/**
         * Get the build the database is running.
         *
         * @param bool $use_cache
         *
         * @return int
         */
        
public static function get_saved_plugin_build$use_cache true ) {
            if ( 
$use_cache ) {
                return 
ITSEC_Modules::get_setting'global''build' );
            }

            
$storage get_site_option'itsec-storage' );

            if ( ! 
$storage ) {
                return 
0;
            }

            if ( ! isset( 
$storage['global']['build'] ) ) {
                return 
0;
            }

            return (int) 
$storage['global']['build'];
        }

        public static function 
get_plugin_dir() {
            
$self self::get_instance();

            return 
$self->plugin_dir;
        }

        public static function 
get_core_dir() {
            return 
self::get_plugin_dir() . 'core/';
        }

        public static function 
get_plugin_name() {
            
$self self::get_instance();

            return 
$self->plugin_name;
        }

        
/**
         * Is this an iThemes Security Pro installation.
         *
         * This value is not cached.
         *
         * @return bool
         */
        
public static function is_pro() {
            return 
is_dirself::get_plugin_dir() . 'pro' );
        }

        
/**
         * Is this an actively licensed Pro installation.
         *
         * @return bool
         */
        
public static function is_licensed() {
            if ( ! 
self::is_pro() ) {
                return 
false;
            }

            if ( ! isset( 
$GLOBALS['ithemes_updater_path'] ) ) {
                return 
false;
            }

            include_once( 
$GLOBALS['ithemes_updater_path'] . '/keys.php' );
            include_once( 
$GLOBALS['ithemes_updater_path'] . '/packages.php' );

            if ( ! 
class_exists'Ithemes_Updater_Packages' ) ) {
                return 
false;
            }

            
$package_details Ithemes_Updater_Packages::get_full_details();

            if ( empty( 
$package_details['packages']['ithemes-security-pro/ithemes-security-pro.php']['status'] ) ) {
                return 
false;
            }

            if ( empty( 
$package_details['packages']['ithemes-security-pro/ithemes-security-pro.php']['user'] ) ) {
                return 
false;
            }

            return 
'active' === $package_details['packages']['ithemes-security-pro/ithemes-security-pro.php']['status'];
        }

        
/**
         * Gets the URL iThemes Security was licensed for.
         *
         * @return string
         */
        
public static function get_licensed_url() {
            if ( ! 
self::is_licensed() || ! function_exists'ithemes_updater_get_licensed_site_url' ) ) {
                return 
'';
            }

            if ( ! 
ithemes_updater_is_licensed_site_url_confirmed() ) {
                return 
'';
            }

            
$hostname ithemes_updater_get_licensed_site_url();

            if ( ! 
$hostname ) {
                return 
'';
            }

            return 
$hostname;
        }

        
/**
         * Get the current local timestamp.
         *
         * This value will be the same throughout the entire request.
         *
         * @return int
         */
        
public static function get_current_time() {
            
$self self::get_instance();

            return 
$self->current_time;
        }

        
/**
         * Get the current UTC timestamp.
         *
         * This value will be the same throughout the entire request.
         *
         * @return int
         */
        
public static function get_current_time_gmt() {
            
$self self::get_instance();

            return 
$self->current_time_gmt;
        }

        
/**
         * Get the UTC offset in seconds.
         *
         * @return int
         */
        
public static function get_time_offset() {
            
$self self::get_instance();

            return 
$self->current_time $self->current_time_gmt;
        }

        public static function 
get_settings_page_url() {
            
$url network_admin_url'admin.php?page=itsec' );

            return 
$url;
        }

        public static function 
get_logs_page_url$filters false$deprecated false ) {
            
$url network_admin_url'admin.php?page=itsec-logs' );

            if ( 
is_string$filters ) ) {
                
_deprecated_argument__METHOD__'6.7.0'__'Passing a module as a single parameter is no longer supported. Pass a filters array instead.''better-wp-security' ) );

                
$filters           = array();
                
$filters['module'] = $filters;
            }

            if ( 
$deprecated ) {
                
_deprecated_argument__METHOD__'6.7.0'__'Passing the log type as the second parameter is no longer supported. Pass a filters array instead.''better-wp-security' ) );
                
$filters['type'] = $deprecated;
            }

            if ( 
$filters ) {
                
$formatted = array();

                foreach ( 
$filters as $filter => $value ) {
                    
$formatted[] = rawurlencode"{$filter}|{$value});
                }

                
$url add_query_arg( array( 'filters' => $formatted ), $url );
            }

            return 
$url;
        }

        public static function 
get_backup_creation_page_url() {
            
$url network_admin_url'admin.php?page=itsec&module=backup' );

            
$url apply_filters'itsec-filter-backup-creation-page-url'$url );

            return 
$url;
        }

        public static function 
get_security_check_page_url() {
            return 
network_admin_url'admin.php?page=itsec&module=security-check' );
        }

        public static function 
get_settings_module_url$module ) {
            return 
network_admin_url'admin.php?page=itsec&module=' $module );
        }

        
/**
         * Specify whether there is a user modifying settings or if an API is modifying settings.
         *
         * @param bool $interactive
         */
        
public static function set_interactive$interactive true ) {
            
$self              self::get_instance();
            
$self->interactive = (bool) $interactive;
        }

        
/**
         * Is a user modifying settings or the API modifying settings (such as from Sync requests).
         *
         * @return bool
         */
        
public static function is_interactive() {
            
$self self::get_instance();

            return 
$self->interactive;
        }

        
/**
         * Determine whether the current request is an Infinite WP API call.
         *
         * @return bool
         */
        
public static function is_iwp_call() {
            
$self self::get_instance();

            if ( isset( 
$self->is_iwp_call ) ) {
                return 
$self->is_iwp_call;
            }


            
$self->is_iwp_call false;

            if ( 
false && ! ITSEC_Modules::get_setting'global''infinitewp_compatibility' ) ) {
                return 
false;
            }


            
$post_data = @file_get_contents'php://input' );

            if ( ! empty( 
$post_data ) ) {
                
$data base64_decode$post_data );

                if ( 
false !== strpos$data's:10:"iwp_action";' ) ) {
                    
$self->is_iwp_call true;
                }
            }

            return 
$self->is_iwp_call;
        }

        
/**
         * Get the configured WordPress upload directory of the main site.
         *
         * This value is cached for both the lifetime of the request and possibly indefinitely when WordPress is
         * using an object cache.
         *
         * @return array
         * @see wp_upload_dir
         *
         */
        
public static function get_wp_upload_dir() {
            
$self self::get_instance();

            if ( isset( 
$self->wp_upload_dir ) ) {
                return 
$self->wp_upload_dir;
            }

            
$wp_upload_dir get_site_transient'itsec_wp_upload_dir' );

            if ( ! 
is_array$wp_upload_dir ) || ! isset( $wp_upload_dir['basedir'] ) || ! is_dir$wp_upload_dir['basedir'] ) ) {
                if ( 
is_multisite() ) {
                    
switch_to_blog);
                    
$wp_upload_dir wp_upload_dir();
                    
restore_current_blog();
                } else {
                    
$wp_upload_dir wp_upload_dir();
                }

                
set_site_transient'itsec_wp_upload_dir'$wp_upload_dirDAY_IN_SECONDS );
            }

            
$self->wp_upload_dir $wp_upload_dir;

            return 
$self->wp_upload_dir;
        }

        
/**
         * Set a new upload directory and ensure the previously cached value is cleared.
         *
         * @param string $old_dir
         * @param string $new_dir
         */
        
public static function update_wp_upload_dir$old_dir$new_dir ) {
            
$self self::get_instance();

            
// Prime caches.
            
self::get_wp_upload_dir();

            
$self->wp_upload_dir str_replace$old_dir$new_dir$self->wp_upload_dir );

            
// Ensure that the transient will be regenerated on the next page load.
            
delete_site_transient'itsec_wp_upload_dir' );
        }

        
/**
         * Retrieve and/or create a directory for ITSEC to store data.
         *
         * @param string $dir    Optionally specify an additional sub-directory.
         * @param bool   $public Whether to get the public version of the directory.
         *
         * @return string
         */
        
public static function get_storage_dir$dir ''$public false ) {

            require_once( 
self::get_core_dir() . '/lib/class-itsec-lib-directory.php' );

            
$wp_upload_dir self::get_wp_upload_dir();

            
$storage_dir $wp_upload_dir['basedir'];

            if ( 
$public ) {
                
$storage_dir .= '/ithemes-security-public/';
            } else {
                
$storage_dir .= '/ithemes-security/';
            }

            
$dir $storage_dir $dir;
            
$dir rtrim$dir'/' );

            
ITSEC_Lib_Directory::create$dir );

            return 
$dir;
        }

        
/**
         * Get the URL to the directory that ITSEC stores data in.
         *
         * @param string $dir
         * @param bool   $public Whether to get the public version of the directory.
         *
         * @return string
         */
        
public static function get_storage_url$dir ''$public false ) {

            
self::get_storage_dir$dir );

            
$upload_dir self::get_wp_upload_dir();
            
$base       untrailingslashit$upload_dir['baseurl'] );

            
$url $base;

            if ( 
$public ) {
                
$url .= '/ithemes-security-public/';
            } else {
                
$url .= '/ithemes-security/';
            }

            return 
$url $dir;
        }

        public static function 
doing_data_upgrade() {
            
$self self::get_instance();

            return 
$self->doing_data_upgrade;
        }

        public static function 
is_ajax_request() {
            if ( 
function_exists'wp_doing_ajax' ) ) {
                return 
wp_doing_ajax();
            }

            return 
defined'DOING_AJAX' ) && DOING_AJAX;
        }

        public static function 
is_xmlrpc_request() {
            return 
defined'XMLRPC_REQUEST' ) && XMLRPC_REQUEST;
        }

        
/**
         * Is this a WordPress REST API request.
         *
         * This function is suitable to be used immediately, not just after REST_REQUEST has been defined.
         *
         * @return bool
         */
        
public static function is_rest_api_request() {
            if ( isset( 
$GLOBALS['__itsec_core_is_rest_api_request'] ) ) {
                return 
$GLOBALS['__itsec_core_is_rest_api_request'];
            }

            if ( ! 
function_exists'rest_get_url_prefix' ) ) {
                
$GLOBALS['__itsec_core_is_rest_api_request'] = false;

                return 
false;
            }

            if ( 
defined'REST_REQUEST' ) && REST_REQUEST ) {
                
$GLOBALS['__itsec_core_is_rest_api_request'] = true;

                return 
true;
            }

            
$home_path parse_urlget_option'home' ), PHP_URL_PATH );
            
$home_path trim$home_path'/' );

            if ( 
'' === $home_path ) {
                
$rest_api_path '/' rest_get_url_prefix() . '/';
            } else {
                
$rest_api_path "/$home_path/" rest_get_url_prefix() . '/';
            }

            if ( 
=== strpos$_SERVER['REQUEST_URI'], $rest_api_path ) ) {
                
$GLOBALS['__itsec_core_is_rest_api_request'] = true;
            } else {
                
$GLOBALS['__itsec_core_is_rest_api_request'] = false;
            }

            return 
$GLOBALS['__itsec_core_is_rest_api_request'];
        }

        
/**
         * Is this a request to wp-admin/admin-post.php?
         *
         * @return bool
         */
        
public static function is_admin_post_php_request() {
            if ( 
'wp-admin/admin-post.php' === ITSEC_Lib::get_request_path() ) {
                return 
true;
            }

            return 
false;
        }

        
/**
         * Is the current request being made by a WordPress API.
         *
         * @param bool $include_ajax           Whether to include Ajax requests as a subset of API requests.
         * @param bool $include_admin_post_php Whether to include wp-admin/admin-post.php requests as a subset of API
         *                                     requests.
         *
         * @return bool
         */
        
public static function is_api_request$include_ajax true$include_admin_post_php true ) {
            if ( 
$include_ajax && self::is_ajax_request() ) {
                return 
true;
            }

            if ( 
$include_admin_post_php && self::is_admin_post_php_request() ) {
                return 
true;
            }

            if ( 
self::is_rest_api_request() || self::is_xmlrpc_request() ) {
                return 
true;
            }

            return 
false;
        }

        
/**
         * Check to see if the define to disable all active modules is set.
         *
         * Note that the ITSEC_DISABLE_MODULES should only be used to gain access to a site that you are locked out of.
         * Once logged in, you should remove the define to re-enable the protections offered by iThemes Security.
         *
         * @return bool true if the define is set to a truthy value, false otherwise.
         */
        
public static function is_temp_disable_modules_set() {
            if ( 
defined'ITSEC_DISABLE_MODULES' ) && ITSEC_DISABLE_MODULES ) {
                return 
true;
            }

            return 
false;
        }

        
/**
         * Get the actual version string of the plugin.
         *
         * This should be used rarely. Any decision flows based off a "version" should be made using the Plugin Build.
         *
         * @return string
         */
        
public static function get_plugin_version() {
            
$self self::get_instance();

            if ( ! isset( 
$self->version ) ) {
                
$data get_file_data$self->plugin_file, array(
                    
'Version' => 'Version'
                
) );

                
$self->version $data['Version'];
            }

            return 
$self->version;
        }

        public static function 
is_test_suite$suite '' ) {
            if ( ! 
defined'ITSEC_TEST_SUITE' ) ) {
                return 
false;
            }

            return 
$suite ITSEC_TEST_SUITE === $suite true;
        }
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586