Wordfence Security – Firewall & Malware Scan - Version 5.3.9

Version Description

  • Premium Feature: Password Auditing. Audit the strength of your admin and user-level passwords against our GPU based auditing cluster. Easily alert users to weak passwords or force a password change.
  • Feature: Activity email summary. See options page to enable a weekly, bi-weekly or monthly activity summary.
  • Feature: Activity summary dashboard widget.
  • Fix: Fixed bug on plugin activation where the configuration table was being queried before it was created.
  • Improvement: Added .htaccess to wfcache directory.
  • Improvement: Switched to using wp_remote_post for Wordfence cloud API calls to improved SSL support and a more standards based approach.
Download this release

Release Info

Developer mmaunder
Plugin Icon 128x128 Wordfence Security – Firewall & Malware Scan
Version 5.3.9
Comparing to
See all releases

Code changes from version 5.3.8 to 5.3.9

css/activity-report-widget.css ADDED
@@ -0,0 +1,90 @@
1
+ #wordfence_activity_report_widget .inside h1,
2
+ #wordfence_activity_report_widget .inside h2,
3
+ #wordfence_activity_report_widget .inside h3,
4
+ #wordfence_activity_report_widget .inside h4 {
5
+ margin: 20px 0 4px;
6
+ color: #222 !important;
7
+ }
8
+
9
+ #wordfence_activity_report_widget .inside h1 {
10
+ float: right;
11
+ text-align: right;
12
+ font-size: 30px;
13
+ color: #444444 !important;
14
+ line-height: 1.1;
15
+ }
16
+
17
+ #wordfence_activity_report_widget .inside h2 {
18
+ font-size: 20px;
19
+ }
20
+
21
+ #wordfence_activity_report_widget .inside h4 {
22
+ font-size: 16px;
23
+ color: #666666 !important;
24
+ }
25
+
26
+ #wordfence_activity_report_widget .inside code {
27
+ background-color: transparent;
28
+ }
29
+
30
+ #wordfence_activity_report_widget table.wf-table {
31
+ width: 100%;
32
+ max-width: 100%;
33
+ border-collapse: collapse;
34
+ }
35
+
36
+ #wordfence_activity_report_widget table.wf-table th,
37
+ #wordfence_activity_report_widget table.wf-table td {
38
+ text-align: left;
39
+ padding: 6px 4px;
40
+ border: 1px solid #cccccc;
41
+ }
42
+
43
+ #wordfence_activity_report_widget table.wf-table thead th,
44
+ #wordfence_activity_report_widget table.wf-table thead td {
45
+ background-color: #222;
46
+ color: #FFFFFF;
47
+ font-weight: bold;
48
+ border-color: #474747;
49
+ }
50
+
51
+ #wordfence_activity_report_widget table.wf-table tbody tr.even td {
52
+ background-color: #eeeeee;
53
+ }
54
+
55
+ #wordfence_activity_report_widget .loginFailValidUsername {
56
+ color: #00c000;
57
+ font-weight: bold;
58
+ }
59
+
60
+ #wordfence_activity_report_widget .loginFailInvalidUsername {
61
+ color: #e74a2a;
62
+ font-weight: bold;
63
+ }
64
+
65
+ #wordfence_activity_report_widget .display-file-table-cell {
66
+ overflow: hidden;
67
+ }
68
+
69
+ #wordfence_activity_report_widget .display-file {
70
+ margin: 0px;
71
+ display: block;
72
+ font-size: 12px;
73
+ width: 100%;
74
+ overflow: auto;
75
+ white-space: nowrap;
76
+ }
77
+
78
+ #wordfence_activity_report_widget .recently-modified-files {
79
+ table-layout: fixed;
80
+ }
81
+
82
+ #wordfence_activity_report_widget .recently-modified-files th:nth-child(1),
83
+ #wordfence_activity_report_widget .recently-modified-files td:nth-child(1) {
84
+ width: 30%;
85
+ }
86
+
87
+ #wordfence_activity_report_widget .recently-modified-files th:nth-child(2),
88
+ #wordfence_activity_report_widget .recently-modified-files td:nth-child(2) {
89
+ width: 70%;
90
+ }
css/main.css CHANGED
@@ -142,8 +142,8 @@ div.wordfenceScanButton input.button-wf-grey {
142
}
143
table.wfSummaryParent { font-family: sans-serif; font-size: 14px; color: #000; z-index: 9;}
144
table.wfSummaryParent td { vertical-align: top; padding: 0; margin: 0; }
145
- table.wfSummaryParent table.wfSummaryChild th { font-weight: bold; text-align: right; font-family: Georgia, serif; color: #000; padding: 5px 10px 5px 0; border-top: 1px solid #CCC; }
146
- table.wfSummaryParent table.wfSummaryChild td { font-weight: normal; text-align: left; padding: 5px 0 5px 0; border-top: 1px solid #CCC; }
147
table.wfSummaryParent table.wfSC1 td { width: 300px; padding: 0px 25px 10px 0; }
148
table.wfSummaryParent table.wfSC2 th { width: 80px; }
149
table.wfSummaryParent table.wfSC2 td { width: 100px; }
@@ -155,8 +155,8 @@ div.wfIssue table.wfIssue td { padding: 2px; margin: 0; border-width: 0px; text-
155
div.wfIssue table.wfIssue th { padding: 2px; margin: 0; font-weight: bold; text-align: left; color: #777; }
156
div.wfIssue h2 { margin: 0px 0 5px 0; padding: 0; }
157
div.wfIssue table.wfIssueLinks td { border-width: 0px; text-align: left; padding-right: 10px; }
158
- .wfIssueOptions {
159
- border-top: 1px solid #CCC;
160
padding: 10px;
161
}
162
.wfIssueOptions a {
@@ -241,11 +241,11 @@ h3.wfConfigHeading {
241
width: 800px;
242
}
243
.consoleHeadText {
244
- font-size: 18px;
245
- font-family: Georgia, serif;
246
- font-style: italic;
247
- color: #555;
248
- font-weight: bold;
249
-webkit-font-smoothing: antialiased;
250
251
}
@@ -253,7 +253,7 @@ h3.wfConfigHeading {
253
.consoleInner { height: 116px; overflow: auto; z-index: 1; }
254
.bevelDiv1 { border: 1px solid #EFEFEF; }
255
.bevelDiv2 { border: 1px solid #AAA; }
256
- .bevelDiv3 { border: 1px solid #555;
257
background-color: #FFFFE0; /* #FFFFF0; /* #FFEBCD; #FFFACD; */
258
color: #000; padding: 5px; font-family: Arial; -webkit-font-smoothing: none; }
259
@@ -276,9 +276,9 @@ h3.wfConfigHeading {
276
clear: both;
277
visibility: hidden;
278
}
279
- .wfSummaryFinal {
280
-webkit-font-smoothing: antialiased;
281
- font-weight: bold;
282
color: #555;
283
}
284
input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
@@ -287,16 +287,16 @@ input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
287
}
288
#wordfenceWorking {
289
padding: 2px 8px 2px 24px;
290
- z-index: 100000;
291
- position: fixed;
292
- right: 2px;
293
- bottom: 2px;
294
- border: 1px solid #000;
295
- background-color: #F00;
296
- color: #FFF;
297
- font-size: 12px;
298
- font-weight: bold;
299
- font-family: Arial;
300
text-align: center;
301
background-image: url('../images/icons/ajaxRed16.gif');
302
background-position: 2px 2px;
@@ -322,10 +322,10 @@ input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
322
width: 1px;
323
}
324
.wfPaidOnlyNotice {
325
- width: 500px;
326
- background-color: #FFFFE0;
327
- border: 1px solid #000;
328
- padding: 10px;
329
margin: 20px;
330
}
331
.wfFalconNotice {
@@ -415,10 +415,10 @@ input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
415
border: 2px solid #999999 !important ; border-radius: 19px !important ;
416
position: absolute !important ; top: 0 !important ; bottom: 0 !important ; right: 46px !important ;
417
-moz-transition: all 0.3s ease-in 0s !important ; -webkit-transition: all 0.3s ease-in 0s !important ;
418
- -o-transition: all 0.3s ease-in 0s !important ; transition: all 0.3s ease-in 0s !important ;
419
- background-image: -moz-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
420
- background-image: -webkit-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
421
- background-image: -o-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
422
background-image: linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
423
box-shadow: 0 1px 1px white inset !important ;
424
}
@@ -426,9 +426,38 @@ input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
426
margin-left: 0 !important ;
427
}
428
.wfOnOffSwitch-checkbox:checked + .wfOnOffSwitch-label .wfOnOffSwitch-switch {
429
- right: 0px !important ;
430
}
431
#wordfenceConfigWarning {
432
clear: left;
433
margin-top: 5px;
434
}
142
}
143
table.wfSummaryParent { font-family: sans-serif; font-size: 14px; color: #000; z-index: 9;}
144
table.wfSummaryParent td { vertical-align: top; padding: 0; margin: 0; }
145
+ table.wfSummaryParent table.wfSummaryChild th { font-weight: bold; text-align: right; font-family: Georgia, serif; color: #000; padding: 5px 10px 5px 0; border-top: 1px solid #CCC; }
146
+ table.wfSummaryParent table.wfSummaryChild td { font-weight: normal; text-align: left; padding: 5px 0 5px 0; border-top: 1px solid #CCC; }
147
table.wfSummaryParent table.wfSC1 td { width: 300px; padding: 0px 25px 10px 0; }
148
table.wfSummaryParent table.wfSC2 th { width: 80px; }
149
table.wfSummaryParent table.wfSC2 td { width: 100px; }
155
div.wfIssue table.wfIssue th { padding: 2px; margin: 0; font-weight: bold; text-align: left; color: #777; }
156
div.wfIssue h2 { margin: 0px 0 5px 0; padding: 0; }
157
div.wfIssue table.wfIssueLinks td { border-width: 0px; text-align: left; padding-right: 10px; }
158
+ .wfIssueOptions {
159
+ border-top: 1px solid #CCC;
160
padding: 10px;
161
}
162
.wfIssueOptions a {
241
width: 800px;
242
}
243
.consoleHeadText {
244
+ font-size: 18px;
245
+ font-family: Georgia, serif;
246
+ font-style: italic;
247
+ color: #555;
248
+ font-weight: bold;
249
-webkit-font-smoothing: antialiased;
250
251
}
253
.consoleInner { height: 116px; overflow: auto; z-index: 1; }
254
.bevelDiv1 { border: 1px solid #EFEFEF; }
255
.bevelDiv2 { border: 1px solid #AAA; }
256
+ .bevelDiv3 { border: 1px solid #555;
257
background-color: #FFFFE0; /* #FFFFF0; /* #FFEBCD; #FFFACD; */
258
color: #000; padding: 5px; font-family: Arial; -webkit-font-smoothing: none; }
259
276
clear: both;
277
visibility: hidden;
278
}
279
+ .wfSummaryFinal {
280
-webkit-font-smoothing: antialiased;
281
+ font-weight: bold;
282
color: #555;
283
}
284
input.wfStartScanButton { width: 160px; text-align: left; padding-left: 20px; }
287
}
288
#wordfenceWorking {
289
padding: 2px 8px 2px 24px;
290
+ z-index: 100000;
291
+ position: fixed;
292
+ right: 2px;
293
+ bottom: 2px;
294
+ border: 1px solid #000;
295
+ background-color: #F00;
296
+ color: #FFF;
297
+ font-size: 12px;
298
+ font-weight: bold;
299
+ font-family: Arial;
300
text-align: center;
301
background-image: url('../images/icons/ajaxRed16.gif');
302
background-position: 2px 2px;
322
width: 1px;
323
}
324
.wfPaidOnlyNotice {
325
+ width: 500px;
326
+ background-color: #FFFFE0;
327
+ border: 1px solid #000;
328
+ padding: 10px;
329
margin: 20px;
330
}
331
.wfFalconNotice {
415
border: 2px solid #999999 !important ; border-radius: 19px !important ;
416
position: absolute !important ; top: 0 !important ; bottom: 0 !important ; right: 46px !important ;
417
-moz-transition: all 0.3s ease-in 0s !important ; -webkit-transition: all 0.3s ease-in 0s !important ;
418
+ -o-transition: all 0.3s ease-in 0s !important ; transition: all 0.3s ease-in 0s !important ;
419
+ background-image: -moz-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
420
+ background-image: -webkit-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
421
+ background-image: -o-linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
422
background-image: linear-gradient(center top, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 80%) !important ;
423
box-shadow: 0 1px 1px white inset !important ;
424
}
426
margin-left: 0 !important ;
427
}
428
.wfOnOffSwitch-checkbox:checked + .wfOnOffSwitch-label .wfOnOffSwitch-switch {
429
+ right: 0px !important ;
430
}
431
#wordfenceConfigWarning {
432
clear: left;
433
margin-top: 5px;
434
}
435
+
436
+ table.wf-table {
437
+ width: 100%;
438
+ max-width: 100%;
439
+ border-collapse: collapse;
440
+ }
441
+ table.wf-table th,
442
+ table.wf-table td {
443
+ padding: 6px 4px;
444
+ border: 1px solid #ccc;
445
+ }
446
+ table.wf-table thead th,
447
+ table.wf-table thead td {
448
+ background-color: #222;
449
+ color: #fff;
450
+ font-weight: bold;
451
+ border-color: #474747;
452
+ text-align: left;
453
+ }
454
+ table.wf-table tbody tr td {
455
+ background-color: #fff;
456
+ }
457
+ table.wf-table tbody tr.even td,
458
+ table.wf-table tbody tr:nth-child(2n) td {
459
+ background-color: #eee;
460
+ }
461
+ table.wf-table tbody tr:hover td {
462
+ background-color: #fffbd8;
463
+ }
js/admin.js CHANGED
@@ -1,1641 +1,1913 @@
1
- if(! window['wordfenceAdmin']){ //To compile for checking: java -jar /usr/local/bin/closure.jar --js=admin.js --js_output_file=test.js
2
- window['wordfenceAdmin'] = {
3
- loading16: '<div class="wfLoading16"></div>',
4
- loadingCount: 0,
5
- dbCheckTables: [],
6
- dbCheckCount_ok: 0,
7
- dbCheckCount_skipped: 0,
8
- dbCheckCount_errors: 0,
9
- issues: [],
10
- ignoreData: false,
11
- iconErrorMsgs: [],
12
- scanIDLoaded: 0,
13
- colorboxQueue: [],
14
- mode: '',
15
- visibleIssuesPanel: 'new',
16
- preFirstScanMsgsLoaded: false,
17
- newestActivityTime: 0, //must be 0 to force loading of all initially
18
- elementGeneratorIter: 1,
19
- reloadConfigPage: false,
20
- nonce: false,
21
- tickerUpdatePending: false,
22
- activityLogUpdatePending: false,
23
- lastALogCtime: 0,
24
- activityQueue: [],
25
- totalActAdded: 0,
26
- maxActivityLogItems: 1000,
27
- scanReqAnimation: false,
28
- debugOn: false,
29
- blockedCountriesPending: [],
30
- ownCountry: "",
31
- schedStartHour: false,
32
- currentPointer: false,
33
- countryMap: false,
34
- countryCodesToSave: "",
35
- performanceScale: 3,
36
- performanceMinWidth: 20,
37
- tourClosed: false,
38
- welcomeClosed: false,
39
- init: function(){
40
- this.nonce = WordfenceAdminVars.firstNonce;
41
- this.debugOn = WordfenceAdminVars.debugOn == '1' ? true : false;
42
- this.tourClosed = WordfenceAdminVars.tourClosed == '1' ? true : false;
43
- this.welcomeClosed = WordfenceAdminVars.welcomeClosed == '1' ? true : false;
44
- var startTicker = false;
45
- var self = this;
46
- if(jQuery('#wordfenceMode_scan').length > 0){
47
- this.mode = 'scan';
48
- jQuery('#wfALogViewLink').prop('href', WordfenceAdminVars.siteBaseURL + '?_wfsf=viewActivityLog&nonce=' + this.nonce);
49
- jQuery('#consoleActivity').scrollTop(jQuery('#consoleActivity').prop('scrollHeight'));
50
- jQuery('#consoleScan').scrollTop(jQuery('#consoleScan').prop('scrollHeight'));
51
- this.noScanHTML = jQuery('#wfNoScanYetTmpl').tmpl().html();
52
- this.loadIssues();
53
- this.startActivityLogUpdates();
54
- if(this.needTour()){
55
- this.scanTourStart();
56
- }
57
- } else if(jQuery('#wordfenceMode_activity').length > 0){
58
- this.mode = 'activity';
59
- this.setupSwitches('wfLiveTrafficOnOff', 'liveTrafficEnabled', function(){});
60
- jQuery('#wfLiveTrafficOnOff').change(function(){
61
- if(/^(?:falcon|php)#x2F;.test(WordfenceAdminVars.cacheType) ){
62
- jQuery('#wfLiveTrafficOnOff').attr('checked', false);
63
- self.colorbox('400px', "Live Traffic not available in high performance mode", "Please note that you can't enable live traffic when Falcon Engine or basic caching is enabled. This is done for performance reasons. If you want live traffic, go to the 'Performance Setup' menu and disable caching.");
64
- } else {
65
- self.updateSwitch('wfLiveTrafficOnOff', 'liveTrafficEnabled', function(){ window.location.reload(true); });
66
- }
67
- });
68
69
- if(WordfenceAdminVars.liveTrafficEnabled){
70
- this.activityMode = 'hit';
71
- } else {
72
- this.activityMode = 'loginLogout';
73
- this.switchTab(jQuery('#wfLoginLogoutTab'), 'wfTab1', 'wfDataPanel', 'wfActivity_loginLogout', function(){ WFAD.activityTabChanged(); });
74
- }
75
- startTicker = true;
76
- if(this.needTour()){
77
- this.tour('wfWelcomeContent3', 'wfHeading', 'top', 'left', "Learn about Site Performance", function(){ self.tourRedir('WordfenceSitePerf'); });
78
- }
79
- } else if(jQuery('#wordfenceMode_options').length > 0){
80
- this.mode = 'options';
81
- jQuery('.wfConfigElem').change(function(){ jQuery('#securityLevel').val('CUSTOM'); });
82
- this.updateTicker(true);
83
- startTicker = true;
84
- if(this.needTour()){
85
- this.tour('wfContentBasicOptions', 'wfMarkerBasicOptions', 'top', 'left', "Learn about Live Traffic Options", function(){
86
- self.tour('wfContentLiveTrafficOptions', 'wfMarkerLiveTrafficOptions', 'bottom', 'left', "Learn about Scanning Options", function(){
87
- self.tour('wfContentScansToInclude', 'wfMarkerScansToInclude', 'bottom', 'left', "Learn about Firewall Rules", function(){
88
- self.tour('wfContentFirewallRules', 'wfMarkerFirewallRules', 'bottom', 'left', "Learn about Login Security", function(){
89
- self.tour('wfContentLoginSecurity', 'wfMarkerLoginSecurity', 'bottom', 'left', "Learn about Other Options", function(){
90
- self.tour('wfContentOtherOptions', 'wfMarkerOtherOptions', 'bottom', 'left', false, false);
91
});
92
});
93
});
94
});
95
});
96
- }
97
- } else if(jQuery('#wordfenceMode_blockedIPs').length > 0){
98
- this.mode = 'blocked';
99
- this.staticTabChanged();
100
- this.updateTicker(true);
101
- startTicker = true;
102
- if(this.needTour()){
103
- this.tour('wfWelcomeContent4', 'wfHeading', 'top', 'left', "Learn about Cellphone Sign-in", function(){ self.tourRedir('WordfenceTwoFactor'); });
104
- }
105
- } else if(jQuery('#wordfenceMode_twoFactor').length > 0){
106
- this.mode = 'twoFactor';
107
- startTicker = false;
108
- if(this.needTour()){
109
- this.tour('wfWelcomeTwoFactor', 'wfHeading', 'top', 'left', "Learn how to Block Countries", function(){ self.tourRedir('WordfenceCountryBlocking'); });
110
- }
111
- this.loadTwoFactor();
112
113
- } else if(jQuery('#wordfenceMode_countryBlocking').length > 0){
114
- this.mode = 'countryBlocking';
115
- startTicker = false;
116
- if(this.needTour()){
117
- this.tour('wfWelcomeContentCntBlk', 'wfHeading', 'top', 'left', "Learn how to Schedule Scans", function(){ self.tourRedir('WordfenceScanSchedule'); });
118
- }
119
- } else if(jQuery('#wordfenceMode_rangeBlocking').length > 0){
120
- this.mode = 'rangeBlocking';
121
- startTicker = false;
122
- if(this.needTour()){
123
- this.tour('wfWelcomeContentRangeBlocking', 'wfHeading', 'top', 'left', "Learn how to Customize Wordfence", function(){ self.tourRedir('WordfenceSecOpt'); });
124
- }
125
- this.calcRangeTotal();
126
- this.loadBlockRanges();
127
- } else if(jQuery('#wordfenceMode_whois').length > 0){
128
- this.mode = 'whois';
129
- startTicker = false;
130
- if(this.needTour()){
131
- this.tour('wfWelcomeContentWhois', 'wfHeading', 'top', 'left', "Learn how to use Advanced Blocking", function(){ self.tourRedir('WordfenceRangeBlocking'); });
132
- }
133
- this.calcRangeTotal();
134
- this.loadBlockRanges();
135
136
- } else if(jQuery('#wordfenceMode_scanScheduling').length > 0){
137
- this.mode = 'scanScheduling';
138
- startTicker = false;
139
- this.sched_modeChange();
140
- if(this.needTour()){
141
- this.tour('wfWelcomeContentScanSched', 'wfHeading', 'top', 'left', "Learn about WHOIS", function(){ self.tourRedir('WordfenceWhois'); });
142
- }
143
- } else if(jQuery('#wordfenceMode_caching').length > 0){
144
- this.mode = 'caching';
145
- startTicker = false;
146
- if(this.needTour()){
147
- this.tour('wfWelcomeContentCaching', 'wfHeading', 'top', 'left', "Learn about IP Blocking", function(){ self.tourRedir('WordfenceBlockedIPs'); });
148
- }
149
- this.loadCacheExclusions();
150
- } else {
151
- this.mode = false;
152
- }
153
- if(this.mode){ //We are in a Wordfence page
154
- if(startTicker){
155
- this.updateTicker();
156
- this.liveInt = setInterval(function(){ self.updateTicker(); }, WordfenceAdminVars.actUpdateInterval);
157
- }
158
- jQuery(document).bind('cbox_closed', function(){ self.colorboxIsOpen = false; self.colorboxServiceQueue(); });
159
- }
160
- },
161
- needTour: function(){
162
- if( (! this.tourClosed) && this.welcomeClosed) {
163
- return true;
164
- } else {
165
- return false;
166
- }
167
- },
168
- sendTestEmail: function(email){
169
- var self = this;
170
- this.ajax('wordfence_sendTestEmail', { email: email }, function(res){
171
- if(res.result){
172
- self.colorbox('400px', "Test Email Sent", "Your test email was sent to the requested email address. The result we received from the WordPress wp_mail() function was: " +
173
- res.result + "<br /><br />A 'True' result means WordPress thinks the mail was sent without errors. A 'False' result means that WordPress encountered an error sending your mail. Note that it's possible to get a 'True' response with an error elsewhere in your mail system that may cause emails to not be delivered.");
174
- }
175
- });
176
- },
177
- loadAvgSitePerf: function(){
178
- var self = this;
179
- this.ajax('wordfence_loadAvgSitePerf', { limit: jQuery('#wfAvgPerfNum').val() }, function(res){
180
- res['scale'] = self.performanceScale;
181
- res['min'] = self.performanceMinWidth;
182
- jQuery('#wfAvgSitePerfContent').empty();
183
- var newElem = jQuery('#wfAvgPerfTmpl').tmpl(res);
184
- newElem.prependTo('#wfAvgSitePerfContent').fadeIn();
185
- });
186
- },
187
- updateSwitch: function(elemID, configItem, cb){
188
- var setting = jQuery('#' + elemID).is(':checked');
189
- this.updateConfig(configItem, jQuery('#' + elemID).is(':checked') ? 1 : 0, cb);
190
- },
191
- setupSwitches: function(elemID, configItem, cb){
192
- jQuery('.wfOnOffSwitch-checkbox').change(function(){
193
- jQuery.data(this, 'lastSwitchChange', (new Date()).getTime());
194
- });
195
- var self = this;
196
- jQuery('div.wfOnOffSwitch').mouseup( function(){
197
- var elem = jQuery(this);
198
- setTimeout(function(){
199
- var checkedElem = elem.find('.wfOnOffSwitch-checkbox');
200
- if((new Date()).getTime() - jQuery.data(checkedElem[0], 'lastSwitchChange') > 300){
201
- checkedElem.prop('checked', ! checkedElem.is(':checked') );
202
- self.updateSwitch(elemID, configItem, cb);
203
- }
204
- }, 50);
205
- });
206
- },
207
- scanTourStart: function(){
208
- var self = this;
209
- this.tour('wfWelcomeContent1', 'wfHeading', 'top', 'left', "Continue the Tour", function(){
210
- self.tour('wfWelcomeContent2', 'wfHeading', 'top', 'left', "Learn how to use Wordfence", function(){
211
- self.tour('wfWelcomeContent3', 'wfHeading', 'top', 'left', "Learn about Live Traffic", function(){ self.tourRedir('WordfenceActivity'); });
212
});
213
- });
214
- },
215
- tourRedir: function(menuItem){
216
- window.location.href = 'admin.php?page=' + menuItem;
217
- },
218
- updateConfig: function(key, val, cb){
219
- this.ajax('wordfence_updateConfig', { key: key, val: val }, function(){ cb(); });
220
- },
221
- tourFinish: function(){
222
- this.ajax('wordfence_tourClosed', {}, function(res){});
223
- },
224
- downgradeLicense: function(){
225
- this.colorbox('400px', "Confirm Downgrade", "Are you sure you want to downgrade your Wordfence Premium License? This will disable all Premium features and return you to the free version of Wordfence. <a href=\"https://www.wordfence.com/manage-wordfence-api-keys/\" target=\"_blank\">Click here to renew your paid membership</a> or click the button below to confirm you want to downgrade.<br /><br /><input type=\"button\" value=\"Downgrade and disable Premium features\" onclick=\"WFAD.downgradeLicenseConfirm();\" /><br />");
226
- },
227
- downgradeLicenseConfirm: function(){
228
- jQuery.colorbox.close();
229
- this.ajax('wordfence_downgradeLicense', {}, function(res){ location.reload(true); });
230
- },
231
- tour: function(contentID, elemID, edge, align, buttonLabel, buttonCallback){
232
- var self = this;
233
- if(this.currentPointer){
234
- this.currentPointer.pointer('destroy');
235
- this.currentPointer = false;
236
- }
237
- var options = {
238
- buttons: function(event, t){
239
- var buttonElem = jQuery('<div id="wfTourButCont"><a id="pointer-close" style="margin-left:5px" class="button-secondary">End the Tour</a></div><div><a id="wfRateLink" href="http://wordpress.org/extend/plugins/wordfence/" target="_blank" style="font-size: 10px; font-family: Verdana;">Help spread the word by rating us 5&#9733; on WordPress.org</a></div>');
240
- buttonElem.find('#pointer-close').bind('click.pointer', function (evtObj) {
241
- var evtSourceElem = evtObj.srcElement ? evtObj.srcElement : evtObj.target;
242
- if(evtSourceElem.id == 'wfRateLink'){
243
- return true;
244
- }
245
- self.tourFinish();
246
- t.element.pointer('close');
247
- return false;
248
- });
249
- return buttonElem;
250
- },
251
- close: function(){},
252
- content: jQuery('#' + contentID).tmpl().html(),
253
- pointerWidth: 400,
254
- position: {
255
- edge: edge,
256
- align: align
257
- }
258
- };
259
- this.currentPointer = jQuery('#' + elemID).pointer(options).pointer('open');
260
- if(buttonLabel && buttonCallback){
261
- jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + buttonLabel + '</a>');
262
- jQuery('#pointer-primary').click(buttonCallback);
263
- }
264
- },
265
- startTourAgain: function(){
266
- var self = this;
267
- this.ajax('wordfence_startTourAgain', {}, function(res){
268
- self.tourClosed = false;
269
- self.scanTourStart();
270
- });
271
- },
272
- showLoading: function(){
273
- this.loadingCount++;
274
- if(this.loadingCount == 1){
275
- jQuery('<div id="wordfenceWorking">Wordfence is working...</div>').appendTo('body');
276
- }
277
- },
278
- removeLoading: function(){
279
- this.loadingCount--;
280
- if(this.loadingCount == 0){
281
- jQuery('#wordfenceWorking').remove();
282
- }
283
- },
284
- startActivityLogUpdates: function(){
285
- var self = this;
286
- setInterval(function(){
287
- self.updateActivityLog();
288
- }, parseInt(WordfenceAdminVars.actUpdateInterval));
289
- },
290
- updateActivityLog: function(){
291
- if(this.activityLogUpdatePending){
292
- return;
293
- }
294
- this.activityLogUpdatePending = true;
295
- var self = this;
296
- this.ajax('wordfence_activityLogUpdate', {
297
- lastctime: this.lastALogCtime
298
- }, function(res){ self.doneUpdateActivityLog(res); }, function(){ self.activityLogUpdatePending = false; }, true);
299
300
- },
301
- doneUpdateActivityLog: function(res){
302
- this.actNextUpdateAt = (new Date()).getTime() + parseInt(WordfenceAdminVars.actUpdateInterval);
303
- if(res.ok){
304
- if(res.items.length > 0){
305
- this.activityQueue.push.apply(this.activityQueue, res.items);
306
- this.lastALogCtime = res.items[res.items.length - 1].ctime;
307
- this.processActQueue(res.currentScanID);
308
- }
309
- }
310
- this.activityLogUpdatePending = false;
311
- },
312
- processActQueue: function(currentScanID){
313
- if(this.activityQueue.length > 0){
314
- this.addActItem(this.activityQueue.shift());
315
- this.totalActAdded++;
316
- if(this.totalActAdded > this.maxActivityLogItems){
317
- jQuery('#consoleActivity div:first').remove();
318
- this.totalActAdded--;
319
- }
320
- var timeTillNextUpdate = this.actNextUpdateAt - (new Date()).getTime();
321
- var maxRate = 50 / 1000; //Rate per millisecond
322
- var bulkTotal = 0;
323
- while(this.activityQueue.length > 0 && this.activityQueue.length / timeTillNextUpdate > maxRate ){
324
- var item = this.activityQueue.shift();
325
- if(item){
326
- bulkTotal++;
327
- this.addActItem(item);
328
}
329
- }
330
- this.totalActAdded += bulkTotal;
331
- if(this.totalActAdded > this.maxActivityLogItems){
332
- jQuery('#consoleActivity div:lt(' + bulkTotal + ')').remove();
333
- this.totalActAdded -= bulkTotal;
334
- }
335
- var minDelay = 100;
336
- var delay = minDelay;
337
- if(timeTillNextUpdate < 1){
338
- delay = minDelay;
339
- } else {
340
- delay = Math.round(timeTillNextUpdate / this.activityQueue.length);
341
- if(delay < minDelay){ delay = minDelay; }
342
- }
343
- var self = this;
344
- setTimeout(function(){ self.processActQueue(); }, delay);
345
- }
346
- jQuery('#consoleActivity').scrollTop(jQuery('#consoleActivity').prop('scrollHeight'));
347
- },
348
- processActArray: function(arr){
349
- for(var i = 0; i < arr.length; i++){
350
- this.addActItem(arr[i]);
351
- }
352
- },
353
- addActItem: function(item){
354
- if(! item){ return; }
355
- if(! item.msg){ return; }
356
- if(item.msg.indexOf('SUM_') == 0){
357
- this.processSummaryLine(item);
358
- jQuery('#consoleSummary').scrollTop(jQuery('#consoleSummary').prop('scrollHeight'));
359
- jQuery('#wfStartingScan').addClass('wfSummaryOK').html('Done.');
360
- } else if(this.debugOn || item.level < 4){
361
-
362
- var html = '<div class="wfActivityLine';
363
- if(this.debugOn){
364
- html += ' wf' + item.type;
365
- }
366
- html += '">[' + item.date + ']&nbsp;' + item.msg + '</div>';
367
- jQuery('#consoleActivity').append(html);
368
- if(/Scan complete\./i.test(item.msg)){
369
- this.loadIssues();
370
- }
371
- }
372
- },
373
- processSummaryLine: function(item){
374
- var msg, summaryUpdated;
375
- if(item.msg.indexOf('SUM_START:') != -1){
376
- msg = item.msg.replace('SUM_START:', '');
377
- jQuery('#consoleSummary').append('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg">' + msg + '</div><div class="wfSummaryResult"><div class="wfSummaryLoading"></div></div><div class="wfClear"></div>');
378
- summaryUpdated = true;
379
- } else if(item.msg.indexOf('SUM_ENDBAD') != -1){
380
- msg = item.msg.replace('SUM_ENDBAD:', '');
381
- jQuery('div.wfSummaryMsg:contains("' + msg + '")').next().addClass('wfSummaryBad').html('Problems found.');
382
- summaryUpdated = true;
383
- } else if(item.msg.indexOf('SUM_ENDFAILED') != -1){
384
- msg = item.msg.replace('SUM_ENDFAILED:', '');
385
- jQuery('div.wfSummaryMsg:contains("' + msg + '")').next().addClass('wfSummaryBad').html('Failed.');
386
- summaryUpdated = true;
387
- } else if(item.msg.indexOf('SUM_ENDOK') != -1){
388
- msg = item.msg.replace('SUM_ENDOK:', '');
389
- jQuery('div.wfSummaryMsg:contains("' + msg + '")').next().addClass('wfSummaryOK').html('Secure.');
390
- summaryUpdated = true;
391
- } else if(item.msg.indexOf('SUM_ENDSUCCESS') != -1){
392
- msg = item.msg.replace('SUM_ENDSUCCESS:', '');
393
- jQuery('div.wfSummaryMsg:contains("' + msg + '")').next().addClass('wfSummaryOK').html('Success.');
394
- summaryUpdated = true;
395
- } else if(item.msg.indexOf('SUM_ENDERR') != -1){
396
- msg = item.msg.replace('SUM_ENDERR:', '');
397
- jQuery('div.wfSummaryMsg:contains("' + msg + '")').next().addClass('wfSummaryErr').html('An error occurred.');
398
- summaryUpdated = true;
399
- } else if(item.msg.indexOf('SUM_DISABLED:') != -1){
400
- msg = item.msg.replace('SUM_DISABLED:', '');
401
- jQuery('#consoleSummary').append('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg">' + msg + '</div><div class="wfSummaryResult">Disabled [<a href="admin.php?page=WordfenceSecOpt">Visit Options to Enable</a>]</div><div class="wfClear"></div>');
402
- summaryUpdated = true;
403
- } else if(item.msg.indexOf('SUM_PAIDONLY:') != -1){
404
- msg = item.msg.replace('SUM_PAIDONLY:', '');
405
- jQuery('#consoleSummary').append('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg">' + msg + '</div><div class="wfSummaryResult"><a href="https://www.wordfence.com/wordfence-signup/" target="_blank">Paid Members Only</a></div><div class="wfClear"></div>');
406
- summaryUpdated = true;
407
- } else if(item.msg.indexOf('SUM_FINAL:') != -1){
408
- msg = item.msg.replace('SUM_FINAL:', '');
409
- jQuery('#consoleSummary').append('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg wfSummaryFinal">' + msg + '</div><div class="wfSummaryResult wfSummaryOK">Scan Complete.</div><div class="wfClear"></div>');
410
- } else if(item.msg.indexOf('SUM_PREP:') != -1){
411
- msg = item.msg.replace('SUM_PREP:', '');
412
- jQuery('#consoleSummary').empty().html('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg">' + msg + '</div><div class="wfSummaryResult" id="wfStartingScan"><div class="wfSummaryLoading"></div></div><div class="wfClear"></div>');
413
- } else if(item.msg.indexOf('SUM_KILLED:') != -1){
414
- msg = item.msg.replace('SUM_KILLED:', '');
415
- jQuery('#consoleSummary').empty().html('<div class="wfSummaryLine"><div class="wfSummaryDate">[' + item.date + ']</div><div class="wfSummaryMsg">' + msg + '</div><div class="wfSummaryResult wfSummaryOK">Scan Complete.</div><div class="wfClear"></div>');
416
- }
417
- },
418
- processActQueueItem: function(){
419
- var item = this.activityQueue.shift();
420
- if(item){
421
- jQuery('#consoleActivity').append('<div class="wfActivityLine wf' + item.type + '">[' + item.date + ']&nbsp;' + item.msg + '</div>');
422
- this.totalActAdded++;
423
- if(this.totalActAdded > this.maxActivityLogItems){
424
- jQuery('#consoleActivity div:first').remove();
425
- this.totalActAdded--;
426
- }
427
- if(item.msg == 'Scan complete.'){
428
- this.loadIssues();
429
- }
430
- }
431
- },
432
- updateTicker: function(forceUpdate){
433
- if( (! forceUpdate) && this.tickerUpdatePending){
434
- return;
435
- }
436
- this.tickerUpdatePending = true;
437
- var self = this;
438
- var alsoGet = '';
439
- var otherParams = '';
440
- if(this.mode == 'activity' && /^(?:404|hit|human|ruser|gCrawler|crawler|loginLogout)#x2F;.test(this.activityMode)){
441
- alsoGet = 'logList_' + this.activityMode;
442
- otherParams = this.newestActivityTime;
443
- } else if(this.mode == 'perfStats'){
444
- alsoGet = 'perfStats';
445
- otherParams = this.newestActivityTime;
446
- }
447
- this.ajax('wordfence_ticker', {
448
- alsoGet: alsoGet,
449
- otherParams: otherParams
450
- }, function(res){ self.handleTickerReturn(res); }, function(){ self.tickerUpdatePending = false; }, true);
451
- },
452
- handleTickerReturn: function(res){
453
- this.tickerUpdatePending = false;
454
- var newMsg = "";
455
- var oldMsg = jQuery('#wfLiveStatus').text();
456
- if( res.msg ){
457
- newMsg = res.msg;
458
- } else {
459
- newMsg = "Idle";
460
- }
461
- if(newMsg && newMsg != oldMsg){
462
- jQuery('#wfLiveStatus').hide().html(newMsg).fadeIn(200);
463
- }
464
- var haveEvents, newElem;
465
- if(this.mode == 'activity'){
466
- if(res.alsoGet != 'logList_' + this.activityMode){ return; } //user switched panels since ajax request started
467
- if(res.events.length > 0){
468
- this.newestActivityTime = res.events[0]['ctime'];
469
- }
470
- haveEvents = false;
471
- if(jQuery('#wfActivity_' + this.activityMode + ' .wfActEvent').length > 0){
472
- haveEvents = true;
473
- }
474
- if(res.events.length > 0){
475
- if(! haveEvents){
476
- jQuery('#wfActivity_' + this.activityMode).empty();
477
- }
478
- for(i = res.events.length - 1; i >= 0; i--){
479
- var elemID = '#wfActEvent_' + res.events[i].id;
480
- if(jQuery(elemID).length < 1){
481
- res.events[i]['activityMode'] = this.activityMode;
482
- if(this.activityMode == 'loginLogout'){
483
- newElem = jQuery('#wfLoginLogoutEventTmpl').tmpl(res.events[i]);
484
- } else {
485
- newElem = jQuery('#wfHitsEventTmpl').tmpl(res.events[i]);
486
}
487
- jQuery(newElem).find('.wfTimeAgo').data('wfctime', res.events[i].ctime);
488
- newElem.prependTo('#wfActivity_' + this.activityMode).fadeIn();
489
}
490
}
491
- this.reverseLookupIPs();
492
- } else {
493
- if(! haveEvents){
494
- jQuery('#wfActivity_' + this.activityMode).html('<div>No events to report yet.</div>');
495
}
496
- }
497
- var self = this;
498
- jQuery('.wfTimeAgo').each(function(idx, elem){
499
- jQuery(elem).html(self.makeTimeAgo(res.serverTime - jQuery(elem).data('wfctime')) + ' ago');
500
- });
501
- } else if(this.mode == 'perfStats'){
502
- haveEvents = false;
503
- if(jQuery('#wfPerfStats .wfPerfEvent').length > 0){
504
- haveEvents = true;
505
- }
506
- if(res.events.length > 0){
507
- if(! haveEvents){
508
- jQuery('#wfPerfStats').empty();
509
- }
510
- var curLength = parseInt(jQuery('#wfPerfStats').css('width'));
511
- if(res.longestLine > curLength){
512
- jQuery('#wfPerfStats').css('width', (res.longestLine + 200) + 'px');
513
- }
514
- this.newestActivityTime = res.events[0]['ctime'];
515
- for(var i = res.events.length - 1; i >= 0; i--){
516
- res.events[i]['scale'] = this.performanceScale;
517
- res.events[i]['min'] = this.performanceMinWidth;
518
- newElem = jQuery('#wfPerfStatTmpl').tmpl(res.events[i]);
519
- jQuery(newElem).find('.wfTimeAgo').data('wfctime', res.events[i].ctime);
520
- newElem.prependTo('#wfPerfStats').fadeIn();
521
- }
522
- } else {
523
- if(! haveEvents){
524
- jQuery('#wfPerfStats').html('<p>No events to report yet.</p>');
525
}
526
- }
527
- jQuery('.wfTimeAgo').each(function(idx, elem){
528
- jQuery(elem).html(self.makeTimeAgo(res.serverTime - jQuery(elem).data('wfctime')) + ' ago');
529
});
530
- }
531
- },
532
- reverseLookupIPs: function(){
533
- var ips = [];
534
- jQuery('.wfReverseLookup').each(function(idx, elem){
535
- var txt = jQuery(elem).text();
536
- if(/^\d+\.\d+\.\d+\.\d+#x2F;.test(txt) && (! jQuery(elem).data('wfReverseDone'))){
537
- jQuery(elem).data('wfReverseDone', true);
538
- ips.push(jQuery(elem).text());
539
- }
540
- });
541
- if(ips.length < 1){ return; }
542
- var uni = {};
543
- var uniqueIPs = [];
544
- for(var i = 0; i < ips.length; i++){
545
- if(! uni[ips[i]]){
546
- uni[ips[i]] = true;
547
- uniqueIPs.push(ips[i]);
548
- }
549
- }
550
- this.ajax('wordfence_reverseLookup', {
551
- ips: uniqueIPs.join(',')
552
- },
553
- function(res){
554
- if(res.ok){
555
- jQuery('.wfReverseLookup').each(function(idx, elem){
556
- var txt = jQuery(elem).text();
557
- for(var ip in res.ips){
558
- if(txt == ip){
559
- if(res.ips[ip]){
560
- jQuery(elem).html('<strong>Hostname:</strong>&nbsp;' + res.ips[ip]);
561
- } else {
562
- jQuery(elem).html('');
563
- }
564
- }
565
- }
566
- });
567
}
568
- }, false, false);
569
- },
570
- killScan: function(){
571
- var self = this;
572
- this.ajax('wordfence_killScan', {}, function(res){
573
- if(res.ok){
574
- self.colorbox('400px', "Kill requested", "A termination request has been sent to any running scans.");
575
- } else {
576
- self.colorbox('400px', "Kill failed", "We failed to send a termination request.");
577
- }
578
- });
579
- },
580
- startScan: function(){
581
- var scanReqAnimation = setInterval(function(){
582
- var str = jQuery('#wfStartScanButton1').prop('value');
583
- var ch = str.charAt(str.length - 1);
584
- if(ch == '/'){ ch = '-'; }
585
- else if(ch == '-'){ ch = '\\'; }
586
- else if(ch == '\\'){ ch = '|'; }
587
- else if(ch == '|'){ ch = '/'; }
588
- else {ch = '/'; }
589
- jQuery('#wfStartScanButton1,#wfStartScanButton2').prop('value', "Requesting a New Scan " + ch);
590
- }, 100);
591
- setTimeout(function(res){
592
- clearInterval(scanReqAnimation);
593
- jQuery('#wfStartScanButton1,#wfStartScanButton2').prop('value', "Start a Wordfence Scan");
594
- }, 3000);
595
- this.ajax('wordfence_scan', {}, function(res){ } );
596
- },
597
- loadIssues: function(callback){
598
- if(this.mode != 'scan'){
599
- return;
600
- }
601
- var self = this;
602
- this.ajax('wordfence_loadIssues', { }, function(res){
603
- self.displayIssues(res, callback);
604
- });
605
- },
606
- sev2num: function(str){
607
- if(/wfProbSev1/.test(str)){
608
- return 1;
609
- } else if(/wfProbSev2/.test(str)){
610
- return 2;
611
- } else {
612
- return 0;
613
- }
614
- },
615
- displayIssues: function(res, callback){
616
- var self = this;
617
- try {
618
- res.summary['lastScanCompleted'] = res['lastScanCompleted'];
619
- } catch(err){
620
- res.summary['lastScanCompleted'] = 'Never';
621
- }
622
- jQuery('.wfIssuesContainer').hide();
623
- for(var issueStatus in res.issuesLists){
624
- var containerID = 'wfIssues_dataTable_' + issueStatus;
625
- var tableID = 'wfIssuesTable_' + issueStatus;
626
- if(jQuery('#' + containerID).length < 1){
627
- //Invalid issue status
628
- continue;
629
- }
630
- if(res.issuesLists[issueStatus].length < 1){
631
- if(issueStatus == 'new'){
632
- if(res.lastScanCompleted == 'ok'){
633
- jQuery('#' + containerID).html('<p style="font-size: 20px; color: #0A0;">Congratulations! No security problems were detected by Wordfence.</p>');
634
- } else if(res['lastScanCompleted']){
635
- //jQuery('#' + containerID).html('<p style="font-size: 12px; color: #A00;">The latest scan failed: ' + res.lastScanCompleted + '</p>');
636
} else {
637
- jQuery('#' + containerID).html();
638
}
639
-
640
- } else {
641
- jQuery('#' + containerID).html('<p>There are currently <strong>no issues</strong> being ignored on this site.</p>');
642
- }
643
- continue;
644
- }
645
- jQuery('#' + containerID).html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="' + tableID + '"></table>');
646
-
647
- jQuery.fn.dataTableExt.oSort['severity-asc'] = function(y,x){ x = WFAD.sev2num(x); y = WFAD.sev2num(y); if(x < y){ return 1; } if(x > y){ return -1; } return 0; };
648
- jQuery.fn.dataTableExt.oSort['severity-desc'] = function(y,x){ x = WFAD.sev2num(x); y = WFAD.sev2num(y); if(x > y){ return 1; } if(x < y){ return -1; } return 0; };
649
-
650
- jQuery('#' + tableID).dataTable({
651
- "bFilter": false,
652
- "bInfo": false,
653
- "bPaginate": false,
654
- "bLengthChange": false,
655
- "bAutoWidth": false,
656
- "aaData": res.issuesLists[issueStatus],
657
- "aoColumns": [
658
- {
659
- "sTitle": '<div class="th_wrapp">Severity</div>',
660
- "sWidth": '128px',
661
- "sClass": "center",
662
- "sType": 'severity',
663
- "fnRender": function(obj) {
664
- var cls = 'wfProbSev' + obj.aData.severity;
665
- return '<span class="' + cls + '"></span>';
666
}
667
- },
668
- {
669
- "sTitle": '<div class="th_wrapp">Issue</div>',
670
- "bSortable": false,
671
- "sWidth": '400px',
672
- "sType": 'html',
673
- fnRender: function(obj){
674
- var tmplName = 'issueTmpl_' + obj.aData.type;
675
- return jQuery('#' + tmplName).tmpl(obj.aData).html();
676
- }
677
- }
678
- ]
679
- });
680
- }
681
- if(callback){
682
- jQuery('#wfIssues_' + this.visibleIssuesPanel).fadeIn(500, function(){ callback(); });
683
- } else {
684
- jQuery('#wfIssues_' + this.visibleIssuesPanel).fadeIn(500);
685
- }
686
- return true;
687
- },
688
- ajax: function(action, data, cb, cbErr, noLoading){
689
- if(typeof(data) == 'string'){
690
- if(data.length > 0){
691
- data += '&';
692
- }
693
- data += 'action=' + action + '&nonce=' + this.nonce;
694
- } else if(typeof(data) == 'object'){
695
- data['action'] = action;
696
- data['nonce'] = this.nonce;
697
- }
698
- if(! cbErr){
699
- cbErr = function(){};
700
- }
701
- var self = this;
702
- if(! noLoading){
703
- this.showLoading();
704
- }
705
- jQuery.ajax({
706
- type: 'POST',
707
- url: WordfenceAdminVars.ajaxURL,
708
- dataType: "json",
709
- data: data,
710
- success: function(json){
711
- if(! noLoading){
712
- self.removeLoading();
713
- }
714
- if(json && json.nonce){
715
- self.nonce = json.nonce;
716
- }
717
- if(json && json.errorMsg){
718
- self.colorbox('400px', 'An error occurred', json.errorMsg);
719
- }
720
- cb(json);
721
- },
722
- error: function(){
723
- if(! noLoading){
724
- self.removeLoading();
725
- }
726
- cbErr();
727
- }
728
- });
729
- },
730
- colorbox: function(width, heading, body){
731
- this.colorboxQueue.push([width, heading, body]);
732
- this.colorboxServiceQueue();
733
- },
734
- colorboxServiceQueue: function(){
735
- if(this.colorboxIsOpen){ return; }
736
- if(this.colorboxQueue.length < 1){ return; }
737
- var elem = this.colorboxQueue.shift();
738
- this.colorboxOpen(elem[0], elem[1], elem[2]);
739
- },
740
- colorboxOpen: function(width, heading, body){
741
- this.colorboxIsOpen = true;
742
- jQuery.colorbox({ width: width, html: "<h3>" + heading + "</h3><p>" + body + "</p>"});
743
- },
744
- scanRunningMsg: function(){ this.colorbox('400px', "A scan is running", "A scan is currently in progress. Please wait until it finishes before starting another scan."); },
745
- errorMsg: function(msg){ this.colorbox('400px', "An error occurred:", msg); },
746
- bulkOperation: function(op){
747
- var self = this;
748
- if(op == 'del' || op == 'repair'){
749
- var ids = jQuery('input.wf' + op + 'Checkbox:checked').map(function(){ return jQuery(this).val(); }).get();
750
- if(ids.length < 1){
751
- this.colorbox('400px', "No files were selected", "You need to select files to perform a bulk operation. There is a checkbox in each issue that lets you select that file. You can then select a bulk operation and hit the button to perform that bulk operation.");
752
- return;
753
- }
754
- if(op == 'del'){
755
- this.colorbox('400px', "Are you sure you want to delete?", "Are you sure you want to delete a total of " + ids.length + " files? Do not delete files on your system unless you're ABSOLUTELY sure you know what you're doing. If you delete the wrong file it could cause your WordPress website to stop functioning and you will probably have to restore from backups. If you're unsure, Cancel and work with your hosting provider to clean your system of infected files.<br /><br /><input type=\"button\" value=\"Delete Files\" onclick=\"WFAD.bulkOperationConfirmed('" + op + "');\" />&nbsp;&nbsp;<input type=\"button\" value=\"Cancel\" onclick=\"jQuery.colorbox.close();\" /><br />");
756
- } else if(op == 'repair'){
757
- this.colorbox('400px', "Are you sure you want to repair?", "Are you sure you want to repair a total of " + ids.length + " files? Do not repair files on your system unless you're sure you have reviewed the differences between the original file and your version of the file in the files you are repairing. If you repair a file that has been customized for your system by a developer or your hosting provider it may leave your system unusable. If you're unsure, Cancel and work with your hosting provider to clean your system of infected files.<br /><br /><input type=\"button\" value=\"Repair Files\" onclick=\"WFAD.bulkOperationConfirmed('" + op + "');\" />&nbsp;&nbsp;<input type=\"button\" value=\"Cancel\" onclick=\"jQuery.colorbox.close();\" /><br />");
758
- }
759
- } else {
760
- return;
761
- }
762
- },
763
- bulkOperationConfirmed: function(op){
764
- jQuery.colorbox.close();
765
- var self = this;
766
- this.ajax('wordfence_bulkOperation', {
767
- op: op,
768
- ids: jQuery('input.wf' + op + 'Checkbox:checked').map(function(){ return jQuery(this).val(); }).get()
769
- }, function(res){ self.doneBulkOperation(res); });
770
- },
771
- doneBulkOperation: function(res){
772
- var self = this;
773
- if(res.ok){
774
- this.loadIssues(function(){ self.colorbox('400px', res.bulkHeading, res.bulkBody); });
775
- } else {
776
- this.loadIssues(function(){});
777
- }
778
- },
779
- deleteFile: function(issueID){
780
- var self = this;
781
- this.ajax('wordfence_deleteFile', {
782
- issueID: issueID
783
- }, function(res){ self.doneDeleteFile(res); });
784
- },
785
- doneDeleteFile: function(res){
786
- var cb = false;
787
- var self = this;
788
- if(res.ok){
789
- this.loadIssues(function(){ self.colorbox('400px', "Success deleting file", "The file " + res.file + " was successfully deleted."); });
790
- } else if(res.cerrorMsg){
791
- this.loadIssues(function(){ self.colorbox('400px', 'An error occurred', res.cerrorMsg); });
792
- }
793
- },
794
- restoreFile: function(issueID){
795
- var self = this;
796
- this.ajax('wordfence_restoreFile', {
797
- issueID: issueID
798
- }, function(res){ self.doneRestoreFile(res); });
799
- },
800
- doneRestoreFile: function(res){
801
- var self = this;
802
- if(res.ok){
803
- this.loadIssues(function(){ self.colorbox("400px", "File restored OK", "The file " + res.file + " was restored succesfully."); });
804
- } else if(res.cerrorMsg){
805
- this.loadIssues(function(){ self.colorbox('400px', 'An error occurred', res.cerrorMsg); });
806
- }
807
- },
808
- deleteIssue: function(id){
809
- var self = this;
810
- this.ajax('wordfence_deleteIssue', { id: id }, function(res){
811
- self.loadIssues();
812
- });
813
- },
814
- updateIssueStatus: function(id, st){
815
- var self = this;
816
- this.ajax('wordfence_updateIssueStatus', { id: id, 'status': st }, function(res){
817
- if(res.ok){
818
- self.loadIssues();
819
- }
820
- });
821
- },
822
- updateAllIssues: function(op){ // deleteIgnored, deleteNew, ignoreAllNew
823
- var head = "Please confirm";
824
- var body;
825
- if(op == 'deleteIgnored'){
826
- body = "You have chosen to remove all ignored issues. Once these issues are removed they will be re-scanned by Wordfence and if they have not been fixed, they will appear in the 'new issues' list. Are you sure you want to do this?";
827
- } else if(op == 'deleteNew'){
828
- body = "You have chosen to mark all new issues as fixed. If you have not really fixed these issues, they will reappear in the new issues list on the next scan. If you have not fixed them and want them excluded from scans you should choose to 'ignore' them instead. Are you sure you want to mark all new issues as fixed?";
829
- } else if(op == 'ignoreAllNew'){
830
- body = "You have chosen to ignore all new issues. That means they will be excluded from future scans. You should only do this if you're sure all new issues are not a problem. Are you sure you want to ignore all new issues?";
831
- } else {
832
- return;
833
- }
834
- this.colorbox('450px', head, body + '<br /><br /><center><input type="button" name="but1" value="Cancel" onclick="jQuery.colorbox.close();" />&nbsp;&nbsp;&nbsp;<input type="button" name="but2" value="Yes I\'m sure" onclick="jQuery.colorbox.close(); WFAD.confirmUpdateAllIssues(\'' + op + '\');" /><br />');
835
- },
836
- confirmUpdateAllIssues: function(op){
837
- var self = this;
838
- this.ajax('wordfence_updateAllIssues', { op: op }, function(res){ self.loadIssues(); });
839
- },
840
- es: function(val){
841
- if(val){
842
- return val;
843
- } else {
844
- return "";
845
- }
846
- },
847
- noQuotes: function(str){
848
- return str.replace(/"/g,'&#34;').replace(/\'/g, '&#145;');
849
- },
850
- commify: function(num){
851
- return ("" + num).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
852
- },
853
- switchToLiveTab: function(elem){
854
- jQuery('.wfTab1').removeClass('selected');
855
- jQuery(elem).addClass('selected');
856
- jQuery('.wfDataPanel').hide();
857
- var self = this;
858
- jQuery('#wfActivity').fadeIn(function(){ self.completeLiveTabSwitch(); });
859
- },
860
- completeLiveTabSwitch: function(){
861
- this.ajax('wordfence_loadActivityLog', {}, function(res){
862
- var html = '<a href="#" class="wfALogMailLink" onclick="WFAD.emailActivityLog(); return false;"></a><a href="#" class="wfALogReloadLink" onclick="WFAD.reloadActivityData(); return false;"></a>';
863
- if(res.events && res.events.length > 0){
864
- jQuery('#wfActivity').empty();
865
- for(var i = 0; i < res.events.length; i++){
866
- var timeTaken = '0.0000';
867
- if(res.events[i + 1]){
868
- timeTaken = (res.events[i].ctime - res.events[i + 1].ctime).toFixed(4);
869
- }
870
- var red = "";
871
- if(res.events[i].type == 'error'){
872
- red = ' class="wfWarn" ';
873
- }
874
- html += '<div ' + red + 'class="wfALogEntry"><span ' + red + 'class="wfALogTime">[' + res.events[i].type + '&nbsp;:&nbsp;' + timeTaken + '&nbsp;:&nbsp;' + res.events[i].timeAgo + ' ago]</span>&nbsp;' + res.events[i].msg + "</div>";
875
- }
876
- jQuery('#wfActivity').html(html);
877
- } else {
878
- jQuery('#wfActivity').html("<p>&nbsp;&nbsp;No activity to report yet. Please complete your first scan.</p>");
879
- }
880
- });
881
- },
882
- emailActivityLog: function(){
883
- this.colorbox('400px', 'Email Wordfence Activity Log', "Enter the email address you would like to send the Wordfence activity log to. Note that the activity log may contain thousands of lines of data. This log is usually only sent to a member of the Wordfence support team. It also contains your PHP configuration from the phpinfo() function for diagnostic data.<br /><br /><input type='text' value='support@wordfence.com' size='20' id='wfALogRecip' /><input type='button' value='Send' onclick=\"WFAD.completeEmailActivityLog();\" /><input type='button' value='Cancel' onclick='jQuery.colorbox.close();' /><br /><br />");
884
- },
885
- completeEmailActivityLog: function(){
886
- jQuery.colorbox.close();
887
- var email = jQuery('#wfALogRecip').val();
888
- if(! /^[^@]+@[^@]+#x2F;.test(email)){
889
- alert("Please enter a valid email address.");
890
- return;
891
- }
892
- var self = this;
893
- this.ajax('wordfence_sendActivityLog', { email: jQuery('#wfALogRecip').val() }, function(res){
894
- if(res.ok){
895
- self.colorbox('400px', 'Activity Log Sent', "Your Wordfence activity log was sent to " + email + "<br /><br /><input type='button' value='Close' onclick='jQuery.colorbox.close();' /><br /><br />");
896
- }
897
- });
898
- },
899
- reloadActivityData: function(){
900
- jQuery('#wfActivity').html('<div class="wfLoadingWhite32"></div>'); //&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />
901
- this.completeLiveTabSwitch();
902
- },
903
- switchToSummaryTab: function(elem){
904
- jQuery('.wfTab1').removeClass('selected');
905
- jQuery(elem).addClass('selected');
906
- jQuery('.wfDataPanel').hide();
907
- jQuery('#wfSummaryTables').fadeIn();
908
- },
909
- switchIssuesTab: function(elem, type){
910
- jQuery('.wfTab2').removeClass('selected');
911
- jQuery('.wfIssuesContainer').hide();
912
- jQuery(elem).addClass('selected');
913
- this.visibleIssuesPanel = type;
914
- jQuery('#wfIssues_' + type).fadeIn();
915
- },
916
- switchTab: function(tabElement, tabClass, contentClass, selectedContentID, callback){
917
- jQuery('.' + tabClass).removeClass('selected');
918
- jQuery(tabElement).addClass('selected');
919
- jQuery('.' + contentClass).hide().html('<div class="wfLoadingWhite32"></div>');
920
- var func = function(){};
921
- if(callback){
922
- func = function(){ callback(); };
923
- }
924
- jQuery('#' + selectedContentID).fadeIn(func);
925
- },
926
- activityTabChanged: function(){
927
- var mode = jQuery('.wfDataPanel:visible')[0].id.replace('wfActivity_','');
928
- if(! mode){ return; }
929
- this.activityMode = mode;
930
- this.reloadActivities();
931
- },
932
- reloadActivities: function(){
933
- jQuery('#wfActivity_' + this.activityMode).html('<div class="wfLoadingWhite32"></div>');
934
- this.newestActivityTime = 0;
935
- this.updateTicker(true);
936
- },
937
- staticTabChanged: function(){
938
- var mode = jQuery('.wfDataPanel:visible')[0].id.replace('wfActivity_','');
939
- if(! mode){ return; }
940
- this.activityMode = mode;
941
-
942
- var self = this;
943
- this.ajax('wordfence_loadStaticPanel', {
944
- mode: this.activityMode
945
- }, function(res){
946
- self.completeLoadStaticPanel(res);
947
- });
948
- },
949
- completeLoadStaticPanel: function(res){
950
- var contentElem = '#wfActivity_' + this.activityMode;
951
- jQuery(contentElem).empty();
952
- if(res.results && res.results.length > 0){
953
- var tmpl;
954
- if(this.activityMode == 'topScanners' || this.activityMode == 'topLeechers'){
955
- tmpl = '#wfLeechersTmpl';
956
- } else if(this.activityMode == 'blockedIPs'){
957
- tmpl = '#wfBlockedIPsTmpl';
958
- } else if(this.activityMode == 'lockedOutIPs'){
959
- tmpl = '#wfLockedOutIPsTmpl';
960
- } else if(this.activityMode == 'throttledIPs'){
961
- tmpl = '#wfThrottledIPsTmpl';
962
- } else { return; }
963
- var i, j, chunk = 1000;
964
- var bigArray = res.results.slice(0);
965
- res.results = false;
966
- for(i = 0, j = bigArray.length; i < j; i += chunk){
967
- res.results = bigArray.slice(i, i + chunk);
968
- jQuery(tmpl).tmpl(res).appendTo(contentElem);
969
- }
970
- this.reverseLookupIPs();
971
- } else {
972
- if(this.activityMode == 'topScanners' || this.activityMode == 'topLeechers'){
973
- jQuery(contentElem).html("No site hits have been logged yet. Check back soon.");
974
- } else if(this.activityMode == 'blockedIPs'){
975
- jQuery(contentElem).html("No IP addresses have been blocked yet. If you manually block an IP address or if Wordfence automatically blocks one, it will appear here.");
976
- } else if(this.activityMode == 'lockedOutIPs'){
977
- jQuery(contentElem).html("No IP addresses have been locked out from signing in or using the password recovery system.");
978
- } else if(this.activityMode == 'throttledIPs'){
979
- jQuery(contentElem).html("No IP addresses have been throttled yet. If an IP address accesses the site too quickly and breaks one of the Wordfence rules, it will appear here.");
980
- } else { return; }
981
- }
982
- },
983
- ucfirst: function(str){
984
- str = "" + str;
985
- return str.charAt(0).toUpperCase() + str.slice(1);
986
- },
987
- makeIPTrafLink: function(IP){
988
- return WordfenceAdminVars.siteBaseURL + '?_wfsf=IPTraf&nonce=' + this.nonce + '&IP=' + encodeURIComponent(IP);
989
- },
990
- makeDiffLink: function(dat){
991
- return WordfenceAdminVars.siteBaseURL + '?_wfsf=diff&nonce=' + this.nonce +
992
- '&file=' + encodeURIComponent(this.es(dat['file'])) +
993
- '&cType=' + encodeURIComponent(this.es(dat['cType'])) +
994
- '&cKey=' + encodeURIComponent(this.es(dat['cKey'])) +
995
- '&cName=' + encodeURIComponent(this.es(dat['cName'])) +
996
- '&cVersion=' + encodeURIComponent(this.es(dat['cVersion']));
997
- },
998
- makeViewFileLink: function(file){
999
- return WordfenceAdminVars.siteBaseURL + '?_wfsf=view&nonce=' + this.nonce + '&file=' + encodeURIComponent(file);
1000
- },
1001
- makeTimeAgo: function(t){
1002
- var months = Math.floor(t / (86400 * 30));
1003
- var days = Math.floor(t / 86400);
1004
- var hours = Math.floor(t / 3600);
1005
- var minutes = Math.floor(t / 60);
1006
- if(months > 0){
1007
- days -= months * 30;
1008
- return this.pluralize(months, 'month', days, 'day');
1009
- } else if(days > 0){
1010
- hours -= days * 24;
1011
- return this.pluralize(days, 'day', hours, 'hour');
1012
- } else if(hours > 0) {
1013
- minutes -= hours * 60;
1014
- return this.pluralize(hours, 'hour', minutes, 'min');
1015
- } else if(minutes > 0) {
1016
- //t -= minutes * 60;
1017
- return this.pluralize(minutes, 'minute');
1018
- } else {
1019
- return Math.round(t) + " seconds";
1020
- }
1021
- },
1022
- pluralize: function(m1, t1, m2, t2){
1023
- if(m1 != 1) {
1024
- t1 = t1 + 's';
1025
- }
1026
- if(m2 != 1) {
1027
- t2 = t2 + 's';
1028
- }
1029
- if(m1 && m2){
1030
- return m1 + ' ' + t1 + ' ' + m2 + ' ' + t2;
1031
- } else {
1032
- return m1 + ' ' + t1;
1033
- }
1034
- },
1035
- calcRangeTotal: function(){
1036
- var range = jQuery('#ipRange').val();
1037
- if(! range){ return; }
1038
- range = range.replace(/ /g, '');
1039
- if(range && /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*\-\s*\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#x2F;.test(range)){
1040
- var ips = range.split('-');
1041
- var total = this.inet_aton(ips[1]) - this.inet_aton(ips[0]) + 1;
1042
- if(total < 1){
1043
- jQuery('#wfShowRangeTotal').html("<span style=\"color: #F00;\">Invalid. Starting IP is greater than ending IP.</span>");
1044
- return;
1045
- }
1046
- jQuery('#wfShowRangeTotal').html("<span style=\"color: #0A0;\">Valid: " + total + " addresses in range.</span>");
1047
- } else {
1048
- jQuery('#wfShowRangeTotal').empty();
1049
- }
1050
- },
1051
- loadBlockRanges: function(){
1052
- var self = this;
1053
- this.ajax('wordfence_loadBlockRanges', {}, function(res){ self.completeLoadBlockRanges(res); });
1054
-
1055
- },
1056
- completeLoadBlockRanges: function(res){
1057
- jQuery('#currentBlocks').empty();
1058
- if(res.results && res.results.length > 0){
1059
- jQuery('#wfBlockedRangesTmpl').tmpl(res).prependTo('#currentBlocks');
1060
- } else {
1061
- jQuery('#currentBlocks').html("You have not blocked any IP ranges or other patterns yet.");
1062
- }
1063
- },
1064
- whois: function(val){
1065
- val = val.replace(' ','');
1066
- if( ! /\w+/.test(val)){
1067
- this.colorbox('300px', "Enter a valid IP or domain", "Please enter a valid IP address or domain name for your whois lookup.");
1068
- return;
1069
- }
1070
- var self = this;
1071
- jQuery('#whoisbutton').attr('disabled', 'disabled');
1072
- jQuery('#whoisbutton').attr('value', 'Loading...');
1073
- this.ajax('wordfence_whois', {
1074
- val: val
1075
- }, function(res){
1076
- jQuery('#whoisbutton').removeAttr('disabled');
1077
- jQuery('#whoisbutton').attr('value', 'Look up IP or Domain');
1078
- if(res.ok){
1079
- self.completeWhois(res);
1080
- }
1081
- });
1082
- },
1083
- completeWhois: function(res){
1084
- if(res.ok && res.result && res.result.rawdata && res.result.rawdata.length > 0){
1085
- var rawhtml = "";
1086
- for(var i = 0; i < res.result.rawdata.length; i++){
1087
- res.result.rawdata[i] = jQuery('<div />').text(res.result.rawdata[i]).html();
1088
- res.result.rawdata[i] = res.result.rawdata[i].replace(/([^\s\t\r\n:;]+@[^\s\t\r\n:;\.]+\.[^\s\t\r\n:;]+)/, "<a href=\"mailto:$1\">$1<\/a>");
1089
- res.result.rawdata[i] = res.result.rawdata[i].replace(/(https?:\/\/[^\/]+[^\s\r\n\t]+)/, "<a target=\"_blank\" href=\"$1\">$1<\/a>");
1090
- var redStyle = "";
1091
- if(this.getQueryParam('wfnetworkblock')){
1092
- redStyle = " style=\"color: #F00;\"";
1093
}
1094
var self = this;
1095
- function wfm21(str, ipRange, offset, totalStr){
1096
- var ips = ipRange.split(/\s*\-\s*/);
1097
- var ip1num = self.inet_aton(ips[0]);
1098
- var ip2num = self.inet_aton(ips[1]);
1099
- var totalIPs = ip2num - ip1num + 1;
1100
- return "<a href=\"admin.php?page=WordfenceRangeBlocking&wfBlockRange=" + ipRange + "\"" + redStyle + ">" + ipRange + " [<strong>" + totalIPs + "</strong> addresses in this network. Click to block this network]<\/a>";
1101
}
1102
-
1103
- res.result.rawdata[i] = res.result.rawdata[i].replace(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} - \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/, wfm21);
1104
- rawhtml += res.result.rawdata[i] + "<br />";
1105
- }
1106
- jQuery('#wfrawhtml').html(rawhtml);
1107
- } else {
1108
- jQuery('#wfrawhtml').html('<span style="color: #F00;">Sorry, but no data for that IP or domain was found.</span>');
1109
- }
1110
- },
1111
- blockIPUARange: function(ipRange, uaRange, referer, reason){
1112
- if(! /\w+/.test(reason)){
1113
- this.colorbox('300px', "Please specify a reason", "You forgot to include a reason you're blocking this IP range. We ask you to include this for your own record keeping.");
1114
- return;
1115
- }
1116
- ipRange = ipRange.replace(/ /g, '');
1117
- if(ipRange){
1118
- if(! /^\d+\.\d+\.\d+\.\d+\-\d+\.\d+\.\d+\.\d+#x2F;.test(ipRange)){
1119
- this.colorbox('300px', 'Specify a valid IP range', "Please specify a valid IP address range in the form of \"1.2.3.4 - 1.2.3.5\" without quotes. Make sure the dash between the IP addresses in a normal dash (a minus sign on your keyboard) and not another character that looks like a dash.");
1120
- return;
1121
- }
1122
- }
1123
- if( ! (/\w+/.test(ipRange) || /\w+/.test(uaRange) || /\w+/.test(referer)) ){
1124
- this.colorbox('300px', 'Specify an IP range or Browser pattern', "Please specify either an IP address range or a web browser pattern to match.");
1125
- return;
1126
- }
1127
- var self = this;
1128
- this.ajax('wordfence_blockIPUARange', {
1129
- ipRange: ipRange,
1130
- uaRange: uaRange,
1131
- referer: referer,
1132
- reason: reason
1133
- }, function(res){
1134
- if(res.ok){
1135
- self.loadBlockRanges();
1136
- return;
1137
}
1138
- });
1139
- },
1140
- unblockRange: function(id){
1141
- var self = this;
1142
- this.ajax('wordfence_unblockRange', {
1143
- id: id
1144
- }, function(res){
1145
- self.loadBlockRanges();
1146
- });
1147
- },
1148
- blockIP: function(IP, reason){
1149
- var self = this;
1150
- this.ajax('wordfence_blockIP', {
1151
- IP: IP,
1152
- reason: reason
1153
- }, function(res){
1154
- if(res.errorMsg){
1155
- return;
1156
} else {
1157
- self.reloadActivities();
1158
- }
1159
- });
1160
- },
1161
- blockIPTwo: function(IP, reason, perm){
1162
- var self = this;
1163
- this.ajax('wordfence_blockIP', {
1164
- IP: IP,
1165
- reason: reason,
1166
- perm: (perm ? '1' : '0')
1167
- }, function(res){
1168
- if(res.errorMsg){
1169
return;
1170
- } else {
1171
- self.staticTabChanged();
1172
}
1173
- });
1174
- },
1175
- unlockOutIP: function(IP){
1176
- var self = this;
1177
- this.ajax('wordfence_unlockOutIP', {
1178
- IP: IP
1179
- }, function(res){ self.staticTabChanged(); });
1180
- },
1181
- unblockIP: function(IP){
1182
- var self = this;
1183
- this.ajax('wordfence_unblockIP', {
1184
- IP: IP
1185
- }, function(res){
1186
- self.reloadActivities();
1187
- });
1188
- },
1189
- unblockIPTwo: function(IP){
1190
- var self = this;
1191
- this.ajax('wordfence_unblockIP', {
1192
- IP: IP
1193
- }, function(res){
1194
- self.staticTabChanged();
1195
});
1196
- },
1197
- permBlockIP: function(IP){
1198
- var self = this;
1199
- this.ajax('wordfence_permBlockIP', {
1200
- IP: IP
1201
- }, function(res){ self.staticTabChanged(); });
1202
- },
1203
- makeElemID: function(){
1204
- return 'wfElemGen' + this.elementGeneratorIter++;
1205
- },
1206
- pulse: function(sel){
1207
- jQuery(sel).fadeIn(function(){
1208
- setTimeout(function(){ jQuery(sel).fadeOut(); }, 2000);
1209
- });
1210
- },
1211
- getCacheStats: function(){
1212
- var self = this;
1213
- this.ajax('wordfence_getCacheStats', {}, function(res){
1214
- if(res.ok){
1215
- self.colorbox('400px', res.heading, res.body);
1216
- }
1217
- });
1218
- },
1219
- clearPageCache: function(){
1220
- var self = this;
1221
- this.ajax('wordfence_clearPageCache', {}, function(res){
1222
- if(res.ok){
1223
- self.colorbox('400px', res.heading, res.body);
1224
- }
1225
- });
1226
- },
1227
- switchToFalcon: function(){
1228
- var self = this;
1229
- this.ajax('wordfence_checkFalconHtaccess', {
1230
- }, function(res){
1231
- if(res.ok){
1232
- self.colorbox('400px', "Enabling Falcon Engine", 'First read this <a href="http://www.wordfence.com/introduction-to-wordfence-falcon-engine/" target="_blank">Introduction to Falcon Engine</a>. Falcon modifies your website configuration file which is called your .htaccess file. To enable Falcon we ask that you make a backup of this file. This is a safety precaution in case for some reason Falcon is not compatible with your site.<br /><br /><a href="' + WordfenceAdminVars.ajaxURL + '?action=wordfence_downloadHtaccess&nonce=' + self.nonce + '" onclick="jQuery(\'#wfNextBut\').prop(\'disabled\', false); return true;">Click here to download a backup copy of your .htaccess file now</a><br /><br /><input type="button" name="but1" id="wfNextBut" value="Click to Enable Falcon Engine" disabled="disabled" onclick="WFAD.confirmSwitchToFalcon(0);" />');
1233
- } else if(res.nginx){
1234
- self.colorbox('400px', "Enabling Falcon Engine", 'You are using an Nginx web server and using a FastCGI processor like PHP5-FPM. To use Falcon you will need to manually modify your nginx.conf configuration file and reload your Nginx server for the changes to take effect. You can find the <a href="http://www.wordfence.com/blog/2014/05/nginx-wordfence-falcon-engine-php-fpm-fastcgi-fast-cgi/" target="_blank">rules you need to make these changes to nginx.conf on this page on wordfence.com</a>. Once you have made these changes, compressed cached files will be served to your visitors directly from Nginx making your site extremely fast. When you have made the changes and reloaded your Nginx server, you can click the button below to enable Falcon.<br /><br /><input type="button" name="but1" id="wfNextBut" value="Click to Enable Falcon Engine" onclick="WFAD.confirmSwitchToFalcon(1);" />');
1235
- } else if(res.err){
1236
- self.colorbox('400px', "We encountered a problem", "We can't modify your .htaccess file for you because: " + res.err + "<br /><br />Advanced users: If you would like to manually enable Falcon yourself by editing your .htaccess, you can add the rules below to the beginning of your .htaccess file. Then click the button below to enable Falcon. Don't do this unless you understand website configuration.<br /><textarea style='width: 300px; height:100px;' readonly>" + jQuery('<div/>').text(res.code).html() + "</textarea><br /><input type='button' value='Enable Falcon after manually editing .htaccess' onclick='WFAD.confirmSwitchToFalcon(1);' />");
1237
- }
1238
- });
1239
- },
1240
- confirmSwitchToFalcon: function(noEditHtaccess){
1241
- jQuery.colorbox.close();
1242
- var cacheType = 'falcon';
1243
- var self = this;
1244
- this.ajax('wordfence_saveCacheConfig', {
1245
- cacheType: cacheType,
1246
- noEditHtaccess: noEditHtaccess
1247
- }, function(res){
1248
- if(res.ok){
1249
- self.colorbox('400px', res.heading, res.body);
1250
}
1251
- }
1252
- );
1253
- },
1254
- saveCacheConfig: function(){
1255
- var cacheType = jQuery('input:radio[name=cacheType]:checked').val();
1256
- if(cacheType == 'falcon'){
1257
- return this.switchToFalcon();
1258
- }
1259
- var self = this;
1260
- this.ajax('wordfence_saveCacheConfig', {
1261
- cacheType: cacheType
1262
- }, function(res){
1263
- if(res.ok){
1264
- self.colorbox('400px', res.heading, res.body);
1265
}
1266
- }
1267
- );
1268
- },
1269
- saveCacheOptions: function(){
1270
- var self = this;
1271
- this.ajax('wordfence_saveCacheOptions', {
1272
- allowHTTPSCaching: (jQuery('#wfallowHTTPSCaching').is(':checked') ? 1 : 0),
1273
- addCacheComment: (jQuery('#wfaddCacheComment').is(':checked') ? 1 : 0),
1274
- clearCacheSched: (jQuery('#wfclearCacheSched').is(':checked') ? 1 : 0)
1275
- }, function(res){
1276
- if(res.updateErr){
1277
- self.colorbox('400px', "You need to manually update your .htaccess", res.updateErr + "<br />Your option was updated but you need to change the Wordfence code in your .htaccess to the following:<br /><textarea style='width: 300px; height: 120px;'>" + jQuery('<div/>').text(res.code).html() + '</textarea>');
1278
}
1279
- }
1280
- );
1281
- },
1282
- saveConfig: function(){
1283
- var qstr = jQuery('#wfConfigForm').serialize();
1284
- var self = this;
1285
- jQuery('.wfSavedMsg').hide();
1286
- jQuery('.wfAjax24').show();
1287
- this.ajax('wordfence_saveConfig', qstr, function(res){
1288
- jQuery('.wfAjax24').hide();
1289
- if(res.ok){
1290
- if(res['paidKeyMsg']){
1291
- self.colorbox('400px', "Congratulations! You have been upgraded to Premium Scanning.", "You have upgraded to a Premium API key. Once this page reloads, you can choose which premium scanning options you would like to enable and then click save. Click the button below to reload this page now.<br /><br /><center><input type='button' name='wfReload' value='Reload page and enable Premium options' onclick='window.location.reload(true);' /></center>");
1292
return;
1293
- } else if(res['reload'] == 'reload' || WFAD.reloadConfigPage){
1294
- self.colorbox('400px', "Please reload this page", "You selected a config option that requires a page reload. Click the button below to reload this page to update the menu.<br /><br /><center><input type='button' name='wfReload' value='Reload page' onclick='window.location.reload(true);' /></center>");
1295
return;
1296
- } else {
1297
- self.pulse('.wfSavedMsg');
1298
}
1299
- } else if(res.errorMsg){
1300
- return;
1301
- } else {
1302
- self.colorbox('400px', 'An error occurred', 'We encountered an error trying to save your changes.');
1303
- }
1304
- });
1305
- },
1306
- changeSecurityLevel: function(){
1307
- var level = jQuery('#securityLevel').val();
1308
- for(var k in WFSLevels[level].checkboxes){
1309
- if(k != 'liveTraf_ignorePublishers'){
1310
- jQuery('#' + k).prop("checked", WFSLevels[level].checkboxes[k]);
1311
- }
1312
- }
1313
- for(var k in WFSLevels[level].otherParams){
1314
- if(! /^(?:apiKey|securityLevel|alertEmails|liveTraf_ignoreUsers|liveTraf_ignoreIPs|liveTraf_ignoreUA|liveTraf_hitsMaxSize|maxMem|maxExecutionTime|actUpdateInterval)#x2F;.test(k)){
1315
- jQuery('#' + k).val(WFSLevels[level].otherParams[k]);
1316
- }
1317
- }
1318
- },
1319
- clearAllBlocked: function(op){
1320
- if(op == 'blocked'){
1321
- body = "Are you sure you want to clear all blocked IP addresses and allow visitors from those addresses to access the site again?";
1322
- } else if(op == 'locked'){
1323
- body = "Are you sure you want to clear all locked IP addresses and allow visitors from those addresses to sign in again?";
1324
- } else {
1325
- return;
1326
- }
1327
- this.colorbox('450px', "Please confirm", body +
1328
- '<br /><br /><center><input type="button" name="but1" value="Cancel" onclick="jQuery.colorbox.close();" />&nbsp;&nbsp;&nbsp;' +
1329
- '<input type="button" name="but2" value="Yes I\'m sure" onclick="jQuery.colorbox.close(); WFAD.confirmClearAllBlocked(\'' + op + '\');"><br />');
1330
- },
1331
- confirmClearAllBlocked: function(op){
1332
- var self = this;
1333
- this.ajax('wordfence_clearAllBlocked', { op: op }, function(res){
1334
- self.staticTabChanged();
1335
- });
1336
- },
1337
- setOwnCountry: function(code){
1338
- this.ownCountry = (code + "").toUpperCase();
1339
- },
1340
- loadBlockedCountries: function(str){
1341
- var codes = str.split(',');
1342
- for(var i = 0; i < codes.length; i++){
1343
- jQuery('#wfCountryCheckbox_' + codes[i]).prop('checked', true);
1344
- }
1345
- },
1346
- saveCountryBlocking: function(){
1347
- var action = jQuery('#wfBlockAction').val();
1348
- var redirURL = jQuery('#wfRedirURL').val();
1349
- var bypassRedirURL = jQuery('#wfBypassRedirURL').val();
1350
- var bypassRedirDest = jQuery('#wfBypassRedirDest').val();
1351
- var bypassViewURL = jQuery('#wfBypassViewURL').val();
1352
-
1353
- if(action == 'redir' && (! /^https?:\/\/[^\/]+/i.test(redirURL))){
1354
- this.colorbox('400px', "Please enter a URL for redirection", "You have chosen to redirect blocked countries to a specific page. You need to enter a URL in the text box provided that starts with http:// or https://");
1355
- return;
1356
- }
1357
- if( bypassRedirURL || bypassRedirDest ){
1358
- if(! (bypassRedirURL && bypassRedirDest)){
1359
- this.colorbox('400px', "Missing data from form", "If you want to set up a URL that will bypass country blocking, you must enter a URL that a visitor can hit and the destination they will be redirected to. You have only entered one of these components. Please enter both.");
1360
- return;
1361
- }
1362
- if(bypassRedirURL == bypassRedirDest){
1363
- this.colorbox('400px', "URLs are the same", "The URL that a user hits to bypass country blocking and the URL they are redirected to are the same. This would cause a circular redirect. Please fix this.");
1364
- return;
1365
- }
1366
- }
1367
- if(bypassRedirURL && (! /^(?:\/|http:\/\/)/.test(bypassRedirURL))){ this.invalidCountryURLMsg(bypassRedirURL); return; }
1368
- if(bypassRedirDest && (! /^(?:\/|http:\/\/)/.test(bypassRedirDest))){ this.invalidCountryURLMsg(bypassRedirDest); return; }
1369
- if(bypassViewURL && (! /^(?:\/|http:\/\/)/.test(bypassViewURL))){ this.invalidCountryURLMsg(bypassViewURL); return; }
1370
1371
- var codesArr = [];
1372
- var ownCountryBlocked = false;
1373
- var self = this;
1374
- jQuery('.wfCountryCheckbox').each(function(idx, elem){
1375
- if(jQuery(elem).is(':checked')){
1376
- var code = jQuery(elem).val();
1377
- codesArr.push(code);
1378
- if(code == self.ownCountry){
1379
- ownCountryBlocked = true;
1380
}
1381
- }
1382
- });
1383
- this.countryCodesToSave = codesArr.join(',');
1384
- if(ownCountryBlocked){
1385
- this.colorbox('400px', "Please confirm blocking yourself", "You are about to block your own country. This could lead to you being locked out. Please make sure that your user profile on this machine has a current and valid email address and make sure you know what it is. That way if you are locked out, you can send yourself an unlock email. If you're sure you want to block your own country, click 'Confirm' below, otherwise click 'Cancel'.<br />" +
1386
- '<input type="button" name="but1" value="Confirm" onclick="jQuery.colorbox.close(); WFAD.confirmSaveCountryBlocking();" />&nbsp;<input type="button" name="but1" value="Cancel" onclick="jQuery.colorbox.close();" />');
1387
- } else {
1388
- this.confirmSaveCountryBlocking();
1389
- }
1390
- },
1391
- invalidCountryURLMsg: function(URL){
1392
- this.colorbox('400px', "Invalid URL", "URL's that you provide for bypassing country blocking must start with '/' or 'http://' without quotes. The URL that is invalid is: " + URL);
1393
- return;
1394
- },
1395
- confirmSaveCountryBlocking: function(){
1396
- var action = jQuery('#wfBlockAction').val();
1397
- var redirURL = jQuery('#wfRedirURL').val();
1398
- var loggedInBlocked = jQuery('#wfLoggedInBlocked').is(':checked') ? '1' : '0';
1399
- var loginFormBlocked = jQuery('#wfLoginFormBlocked').is(':checked') ? '1' : '0';
1400
- var restOfSiteBlocked = jQuery('#wfRestOfSiteBlocked').is(':checked') ? '1' : '0';
1401
- var bypassRedirURL = jQuery('#wfBypassRedirURL').val();
1402
- var bypassRedirDest = jQuery('#wfBypassRedirDest').val();
1403
- var bypassViewURL = jQuery('#wfBypassViewURL').val();
1404
1405
- jQuery('.wfAjax24').show();
1406
- var self = this;
1407
- this.ajax('wordfence_saveCountryBlocking', {
1408
- blockAction: action,
1409
- redirURL: redirURL,
1410
- loggedInBlocked: loggedInBlocked,
1411
- loginFormBlocked: loginFormBlocked,
1412
- restOfSiteBlocked: restOfSiteBlocked,
1413
- bypassRedirURL: bypassRedirURL,
1414
- bypassRedirDest: bypassRedirDest,
1415
- bypassViewURL: bypassViewURL,
1416
- codes: this.countryCodesToSave
1417
- }, function(res){
1418
- jQuery('.wfAjax24').hide();
1419
- self.pulse('.wfSavedMsg');
1420
});
1421
- },
1422
- paidUsersOnly: function(msg){
1423
- var pos = jQuery('#paidWrap').position();
1424
- var width = jQuery('#paidWrap').width();
1425
- var height = jQuery('#paidWrap').height();
1426
- jQuery('<div style="position: absolute; left: ' + pos.left + 'px; top: ' + pos.top + 'px; background-color: #FFF; width: ' + width + 'px; height: ' + height + 'px;"><div class="paidInnerMsg">' + msg + ' <a href="https://www.wordfence.com/wordfence-signup/" target="_blank">Click here to upgrade and gain access to this feature.</div></div>').insertAfter('#paidWrap').fadeTo(10000, 0.7);
1427
- },
1428
- sched_modeChange: function(){
1429
- var self = this;
1430
- if(jQuery('#schedMode').val() == 'auto'){
1431
- jQuery('.wfSchedCheckbox').attr('disabled', true);
1432
- } else {
1433
- jQuery('.wfSchedCheckbox').attr('disabled', false);
1434
- }
1435
- },
1436
- sched_shortcut: function(mode){
1437
- if(jQuery('#schedMode').val() == 'auto'){
1438
- this.colorbox('400px', 'Change the scan mode', "You need to change the scan mode to manually scheduled scans if you want to select scan times.");
1439
- return;
1440
- }
1441
- jQuery('.wfSchedCheckbox').prop('checked', false);
1442
- if(this.schedStartHour === false){
1443
- this.schedStartHour = Math.floor((Math.random()*24));
1444
- } else {
1445
- this.schedStartHour++;
1446
- if(this.schedStartHour > 23){
1447
- this.schedStartHour = 0;
1448
- }
1449
- }
1450
- if(mode == 'onceDaily'){
1451
- for(var i = 0; i <= 6; i++){
1452
- jQuery('#wfSchedDay_' + i + '_' + this.schedStartHour).attr('checked', true);
1453
- }
1454
- } else if(mode == 'twiceDaily'){
1455
- var secondHour = this.schedStartHour + 12;
1456
- if(secondHour >= 24){ secondHour = secondHour - 24; }
1457
- for(var i = 0; i <= 6; i++){
1458
- jQuery('#wfSchedDay_' + i + '_' + this.schedStartHour).attr('checked', true);
1459
- jQuery('#wfSchedDay_' + i + '_' + secondHour).attr('checked', true);
1460
- }
1461
- } else if(mode == 'oddDaysWE'){
1462
- var startDay = Math.floor((Math.random()));
1463
- jQuery('#wfSchedDay_1_' + this.schedStartHour).attr('checked', true);
1464
- jQuery('#wfSchedDay_3_' + this.schedStartHour).attr('checked', true);
1465
- jQuery('#wfSchedDay_5_' + this.schedStartHour).attr('checked', true);
1466
- jQuery('#wfSchedDay_6_' + this.schedStartHour).attr('checked', true);
1467
- jQuery('#wfSchedDay_0_' + this.schedStartHour).attr('checked', true);
1468
- } else if(mode == 'weekends'){
1469
- var startDay = Math.floor((Math.random()));
1470
- jQuery('#wfSchedDay_6_' + this.schedStartHour).attr('checked', true);
1471
- jQuery('#wfSchedDay_0_' + this.schedStartHour).attr('checked', true);
1472
- } else if(mode == 'every6hours'){
1473
- for(var i = 0; i <= 6; i++){
1474
- for(var hour = this.schedStartHour; hour < this.schedStartHour + 24; hour = hour + 6){
1475
- var displayHour = hour;
1476
- if(displayHour >= 24){ displayHour = displayHour - 24; }
1477
- jQuery('#wfSchedDay_' + i + '_' + displayHour).attr('checked', true);
1478
}
1479
- }
1480
- }
1481
1482
- },
1483
- sched_save: function(){
1484
- var schedMode = jQuery('#schedMode').val();
1485
- var schedule = [];
1486
- for(var day = 0; day <= 6; day++){
1487
- var hours = [];
1488
- for(var hour = 0; hour <= 23; hour++){
1489
- var elemID = '#wfSchedDay_' + day + '_' + hour;
1490
- hours[hour] = jQuery(elemID).is(':checked') ? '1' : '0';
1491
- }
1492
- schedule[day] = hours.join(',');
1493
- }
1494
- var scheduleTxt = schedule.join('|');
1495
- var self = this;
1496
- this.ajax('wordfence_saveScanSchedule', {
1497
- schedMode: schedMode,
1498
- schedTxt: scheduleTxt
1499
- }, function(res){
1500
- jQuery('#wfScanStartTime').html(res.nextStart);
1501
- jQuery('.wfAjax24').hide();
1502
- self.pulse('.wfSaveMsg');
1503
});
1504
- },
1505
- twoFacStatus: function(msg){
1506
- jQuery('#wfTwoFacMsg').html(msg);
1507
- jQuery('#wfTwoFacMsg').fadeIn(function(){
1508
- setTimeout(function(){ jQuery('#wfTwoFacMsg').fadeOut(); }, 2000);
1509
- });
1510
- },
1511
- addTwoFactor: function(username, phone){
1512
- var self = this;
1513
- this.ajax('wordfence_addTwoFactor', {
1514
- username: username,
1515
- phone: phone
1516
- }, function(res){
1517
- if(res.ok){
1518
- self.twoFacStatus('User added! Check the user\'s phone to get the activation code.');
1519
- jQuery('<div id="twoFacCont_' + res.userID + '">' + jQuery('#wfTwoFacUserTmpl').tmpl(res).html() + '</div>').prependTo(jQuery('#wfTwoFacUsers'));
1520
- }
1521
- });
1522
- },
1523
- twoFacActivate: function(userID, code){
1524
- var self = this;
1525
- this.ajax('wordfence_twoFacActivate', {
1526
- userID: userID,
1527
- code: code
1528
- }, function(res){
1529
- if(res.ok){
1530
- jQuery('#twoFacCont_' + res.userID).html(
1531
- jQuery('#wfTwoFacUserTmpl').tmpl(res)
1532
);
1533
- self.twoFacStatus('Cellphone Sign-in activated for user.');
1534
- }
1535
- });
1536
- },
1537
- delTwoFac: function(userID){
1538
- this.ajax('wordfence_twoFacDel', {
1539
- userID: userID
1540
- }, function(res){
1541
- if(res.ok){
1542
- jQuery('#twoFacCont_' + res.userID).fadeOut(function(){ jQuery(this).remove(); });
1543
- }
1544
- });
1545
- },
1546
- loadTwoFactor: function(){
1547
- this.ajax('wordfence_loadTwoFactor', {}, function(res){
1548
- if(res.users && res.users.length > 0){
1549
- for(var i = 0; i < res.users.length; i++){
1550
- jQuery('<div id="twoFacCont_' + res.users[i].userID + '">' +
1551
- jQuery('#wfTwoFacUserTmpl').tmpl(res.users[i]).html() +
1552
- + '</div>').appendTo(jQuery('#wfTwoFacUsers'));
1553
}
1554
- }
1555
- });
1556
- },
1557
- getQueryParam: function(name){
1558
- name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
1559
- var regexS = "[\\?&]" + name + "=([^&#]*)";
1560
- var regex = new RegExp(regexS);
1561
- var results = regex.exec(window.location.search);
1562
- if(results == null){
1563
- return "";
1564
- } else {
1565
- return decodeURIComponent(results[1].replace(/\+/g, " "));
1566
- }
1567
- },
1568
- inet_aton: function(dot) {
1569
- var d = dot.split('.');
1570
- return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]);
1571
- },
1572
- inet_ntoa: function(num){
1573
- var d = num % 256;
1574
- for(var i = 3; i > 0; i--) {
1575
- num = Math.floor(num/256);
1576
- d = num%256 + '.' + d;
1577
- }
1578
- return d;
1579
- },
1580
- removeCacheExclusion: function(id){
1581
- this.ajax('wordfence_removeCacheExclusion', { id: id }, function(res){ window.location.reload(true); });
1582
- },
1583
- addCacheExclusion: function(patternType, pattern){
1584
- if(/^https?:\/\//.test(pattern)){
1585
- this.colorbox('400px', "Incorrect pattern for exclusion", "You can not enter full URL's for exclusion from caching. You entered a full URL that started with http:// or https://. You must enter relative URL's e.g. /exclude/this/page/. You can also enter text that might be contained in the path part of a URL or at the end of the path part of a URL.");
1586
- return;
1587
- }
1588
-
1589
- this.ajax('wordfence_addCacheExclusion', {
1590
- patternType: patternType,
1591
- pattern: pattern
1592
- }, function(res){
1593
- if(res.ok){ //Otherwise errorMsg will get caught
1594
window.location.reload(true);
1595
}
1596
- });
1597
- },
1598
- loadCacheExclusions: function(){
1599
- this.ajax('wordfence_loadCacheExclusions', {}, function(res){
1600
- if(res.ex instanceof Array && res.ex.length > 0){
1601
- for(var i = 0; i < res.ex.length; i++){
1602
- var newElem = jQuery('#wfCacheExclusionTmpl').tmpl(res.ex[i]);
1603
- newElem.prependTo('#wfCacheExclusions').fadeIn();
1604
- }
1605
- jQuery('<h2>Cache Exclusions</h2>').prependTo('#wfCacheExclusions');
1606
- } else {
1607
- jQuery('<h2>Cache Exclusions</h2><p style="width: 500px;">There are not currently any exclusions. If you have a site that does not change often, it is perfectly normal to not have any pages you want to exclude from the cache.</p>').prependTo('#wfCacheExclusions');
1608
- }
1609
1610
- });
1611
- },
1612
- exportSettings: function(){
1613
- var self = this;
1614
- this.ajax('wordfence_exportSettings', {}, function(res){
1615
- if(res.ok && res.token){
1616
- self.colorbox('400px', "Export Successful", "We successfully exported your site settings. To import your site settings on another site, copy and paste the token below into the import text box on the destination site. Keep this token secret. It is like a password. If anyone else discovers the token it will allow them to import your settings excluding your API key.<br /><br />Token:<input type=\"text\" size=\"20\" value=\"" + res.token + "\" onclick=\"this.select();\" /><br />");
1617
- } else if(res.err){
1618
- self.colorbox('400px', "Error during Export", res.err);
1619
- } else {
1620
- self.colorbox('400px', "An unknown error occurred", "An unknown error occurred during the export. We received an undefined error from your web server.");
1621
- }
1622
- });
1623
- },
1624
- importSettings: function(token){
1625
- var self = this;
1626
- this.ajax('wordfence_importSettings', { token: token }, function(res){
1627
- if(res.ok){
1628
- self.colorbox('400px', "Import Successful", "You successfully imported " + res.totalSet + " options. Your import is complete. Please reload this page or click the button below to reload it:<br /><br /><input type=\"button\" value=\"Reload Page\" onclick=\"window.location.reload(true);\" />");
1629
- } else if(res.err){
1630
- self.colorbox('400px', "Error during Import", res.err);
1631
- } else {
1632
- self.colorbox('400px', "Error during Export", "An unknown error occurred during the import");
1633
}
1634
- });
1635
}
1636
- };
1637
- window['WFAD'] = window['wordfenceAdmin'];
1638
- }
1639
- jQuery(function(){
1640
- wordfenceAdmin.init();
1641
- });
1
+ (function($) {
2
+ if (!window['wordfenceAdmin']) { //To compile for checking: java -jar /usr/local/bin/closure.jar --js=admin.js --js_output_file=test.js
3
+ window['wordfenceAdmin'] = {
4
+ loading16: '<div class="wfLoading16"></div>',
5
+ loadingCount: 0,
6
+ dbCheckTables: [],
7
+ dbCheckCount_ok: 0,
8
+ dbCheckCount_skipped: 0,
9
+ dbCheckCount_errors: 0,
10
+ issues: [],
11
+ ignoreData: false,
12
+ iconErrorMsgs: [],
13
+ scanIDLoaded: 0,
14
+ colorboxQueue: [],
15
+ mode: '',
16
+ visibleIssuesPanel: 'new',
17
+ preFirstScanMsgsLoaded: false,
18
+ newestActivityTime: 0, //must be 0 to force loading of all initially
19
+ elementGeneratorIter: 1,
20
+ reloadConfigPage: false,
21
+ nonce: false,
22
+ tickerUpdatePending: false,
23
+ activityLogUpdatePending: false,
24
+ lastALogCtime: 0,
25
+ activityQueue: [],
26
+ totalActAdded: 0,
27
+ maxActivityLogItems: 1000,
28
+ scanReqAnimation: false,
29
+ debugOn: false,
30
+ blockedCountriesPending: [],
31
+ ownCountry: "",
32
+ schedStartHour: false,
33
+ currentPointer: false,
34
+ countryMap: false,
35
+ countryCodesToSave: "",
36
+ performanceScale: 3,
37
+ performanceMinWidth: 20,
38
+ tourClosed: false,
39
+ welcomeClosed: false,
40
+ passwdAuditUpdateInt: false,
41
+ init: function() {
42
+ this.nonce = WordfenceAdminVars.firstNonce;
43
+ this.debugOn = WordfenceAdminVars.debugOn == '1' ? true : false;
44
+ this.tourClosed = WordfenceAdminVars.tourClosed == '1' ? true : false;
45
+ this.welcomeClosed = WordfenceAdminVars.welcomeClosed == '1' ? true : false;
46
+ var startTicker = false;
47
+ var self = this;
48
+ if (jQuery('#wordfenceMode_scan').length > 0) {
49
+ this.mode = 'scan';
50
+ jQuery('#wfALogViewLink').prop('href', WordfenceAdminVars.siteBaseURL + '?_wfsf=viewActivityLog&nonce=' + this.nonce);
51
+ jQuery('#consoleActivity').scrollTop(jQuery('#consoleActivity').prop('scrollHeight'));
52
+ jQuery('#consoleScan').scrollTop(jQuery('#consoleScan').prop('scrollHeight'));
53
+ this.noScanHTML = jQuery('#wfNoScanYetTmpl').tmpl().html();
54
+ this.loadIssues();
55
+ this.startActivityLogUpdates();
56
+ if (this.needTour()) {
57
+ this.scanTourStart();
58
+ }
59
+ } else if (jQuery('#wordfenceMode_activity').length > 0) {
60
+ this.mode = 'activity';
61
+ this.setupSwitches('wfLiveTrafficOnOff', 'liveTrafficEnabled', function() {
62
+ });
63
+ jQuery('#wfLiveTrafficOnOff').change(function() {
64
+ if (/^(?:falcon|php)#x2F;.test(WordfenceAdminVars.cacheType)) {
65
+ jQuery('#wfLiveTrafficOnOff').attr('checked', false);
66
+ self.colorbox('400px', "Live Traffic not available in high performance mode", "Please note that you can't enable live traffic when Falcon Engine or basic caching is enabled. This is done for performance reasons. If you want live traffic, go to the 'Performance Setup' menu and disable caching.");
67
+ } else {
68
+ self.updateSwitch('wfLiveTrafficOnOff', 'liveTrafficEnabled', function() {
69
+ window.location.reload(true);
70
+ });
71
+ }
72
+ });
73
74
+ if (WordfenceAdminVars.liveTrafficEnabled) {
75
+ this.activityMode = 'hit';
76
+ } else {
77
+ this.activityMode = 'loginLogout';
78
+ this.switchTab(jQuery('#wfLoginLogoutTab'), 'wfTab1', 'wfDataPanel', 'wfActivity_loginLogout', function() {
79
+ WFAD.activityTabChanged();
80
+ });
81
+ }
82
+ startTicker = true;
83
+ if (this.needTour()) {
84
+ this.tour('wfWelcomeContent3', 'wfHeading', 'top', 'left', "Learn about Site Performance", function() {
85
+ self.tourRedir('WordfenceSitePerf');
86
+ });
87
+ }
88
+ } else if (jQuery('#wordfenceMode_options').length > 0) {
89
+ this.mode = 'options';
90
+ jQuery('.wfConfigElem').change(function() {
91
+ jQuery('#securityLevel').val('CUSTOM');
92
+ });
93
+ this.updateTicker(true);
94
+ startTicker = true;
95
+ if (this.needTour()) {
96
+ this.tour('wfContentBasicOptions', 'wfMarkerBasicOptions', 'top', 'left', "Learn about Live Traffic Options", function() {
97
+ self.tour('wfContentLiveTrafficOptions', 'wfMarkerLiveTrafficOptions', 'bottom', 'left', "Learn about Scanning Options", function() {
98
+ self.tour('wfContentScansToInclude', 'wfMarkerScansToInclude', 'bottom', 'left', "Learn about Firewall Rules", function() {
99
+ self.tour('wfContentFirewallRules', 'wfMarkerFirewallRules', 'bottom', 'left', "Learn about Login Security", function() {
100
+ self.tour('wfContentLoginSecurity', 'wfMarkerLoginSecurity', 'bottom', 'left', "Learn about Other Options", function() {
101
+ self.tour('wfContentOtherOptions', 'wfMarkerOtherOptions', 'bottom', 'left', false, false);
102
+ });
103
});
104
});
105
});
106
});
107
+ }
108
+ } else if (jQuery('#wordfenceMode_blockedIPs').length > 0) {
109
+ this.mode = 'blocked';
110
+ this.staticTabChanged();
111
+ this.updateTicker(true);
112
+ startTicker = true;
113
+ if (this.needTour()) {
114
+ this.tour('wfWelcomeContent4', 'wfHeading', 'top', 'left', "Learn about Auditing Passwords", function() {
115
+ self.tourRedir('WordfencePasswdAudit');
116
+ });
117
+ }
118
+ } else if (jQuery('#wordfenceMode_passwd').length > 0) {
119
+ this.mode = 'passwd';
120
+ startTicker = false;
121
+ this.doPasswdAuditUpdate();
122
+ if (this.needTour()) {
123
+ this.tour('wfWelcomePasswd', 'wfHeading', 'top', 'left', "Learn about Cellphone Sign-in", function() {
124
+ self.tourRedir('WordfenceTwoFactor');
125
+ });
126
+ }
127
+ } else if (jQuery('#wordfenceMode_twoFactor').length > 0) {
128
+ this.mode = 'twoFactor';