Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../models/firewall
File: wfFirewall.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class wfFirewall
[2] Fix | Delete
{
[3] Fix | Delete
const FIREWALL_MODE_DISABLED = 'disabled';
[4] Fix | Delete
const FIREWALL_MODE_LEARNING = 'learning-mode';
[5] Fix | Delete
const FIREWALL_MODE_ENABLED = 'enabled';
[6] Fix | Delete
[7] Fix | Delete
const PROTECTION_MODE_EXTENDED = 'extended';
[8] Fix | Delete
const PROTECTION_MODE_BASIC = 'basic';
[9] Fix | Delete
[10] Fix | Delete
const RULE_MODE_COMMUNITY = 'community';
[11] Fix | Delete
const RULE_MODE_PREMIUM = 'premium';
[12] Fix | Delete
[13] Fix | Delete
const BLACKLIST_MODE_DISABLED = 'disabled';
[14] Fix | Delete
const BLACKLIST_MODE_ENABLED = 'enabled';
[15] Fix | Delete
[16] Fix | Delete
const UPDATE_FAILURE_RATELIMIT = 'ratelimit';
[17] Fix | Delete
const UPDATE_FAILURE_UNREACHABLE = 'unreachable';
[18] Fix | Delete
const UPDATE_FAILURE_FILESYSTEM = 'filesystem';
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Returns a string suitable for display of the firewall status.
[22] Fix | Delete
*
[23] Fix | Delete
* @param null|string $status
[24] Fix | Delete
* @param null|string $protection
[25] Fix | Delete
* @return string
[26] Fix | Delete
*/
[27] Fix | Delete
public function displayText($status = null, $protection = null) {
[28] Fix | Delete
if ($status === null) { $status = $this->firewallMode(); }
[29] Fix | Delete
if ($protection === null) { $protection = $this->protectionMode(); }
[30] Fix | Delete
[31] Fix | Delete
switch ($status) {
[32] Fix | Delete
case self::FIREWALL_MODE_ENABLED:
[33] Fix | Delete
$statusText = __('Enabled', 'wordfence');
[34] Fix | Delete
break;
[35] Fix | Delete
case self::FIREWALL_MODE_LEARNING:
[36] Fix | Delete
$statusText = __('Learning Mode', 'wordfence');
[37] Fix | Delete
break;
[38] Fix | Delete
default:
[39] Fix | Delete
return __('Disabled', 'wordfence');
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
switch ($protection) {
[43] Fix | Delete
case self::PROTECTION_MODE_EXTENDED:
[44] Fix | Delete
$protectionText = __('Extended Protection', 'wordfence');
[45] Fix | Delete
break;
[46] Fix | Delete
default:
[47] Fix | Delete
$protectionText = __('Basic Protection', 'wordfence');
[48] Fix | Delete
break;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
return sprintf('%s (%s)', $statusText, $protectionText);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Syncs the status from WAF to the wfConfig table if $toDatabase is true, the reverse if false.
[56] Fix | Delete
*
[57] Fix | Delete
* @param bool $toDatabase
[58] Fix | Delete
*/
[59] Fix | Delete
public function syncStatus($toDatabase = true) {
[60] Fix | Delete
if ($toDatabase) {
[61] Fix | Delete
try {
[62] Fix | Delete
$status = wfWAF::getInstance()->getStorageEngine()->getConfig('wafStatus');
[63] Fix | Delete
if (in_array($status, array(self::FIREWALL_MODE_DISABLED, self::FIREWALL_MODE_LEARNING, self::FIREWALL_MODE_ENABLED))) {
[64] Fix | Delete
wfConfig::set('waf_status', $status);
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
catch (Exception $e) {
[68] Fix | Delete
//Ignore
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
else {
[72] Fix | Delete
try {
[73] Fix | Delete
$status = wfConfig::get('waf_status');
[74] Fix | Delete
if (in_array($status, array(self::FIREWALL_MODE_DISABLED, self::FIREWALL_MODE_LEARNING, self::FIREWALL_MODE_ENABLED))) {
[75] Fix | Delete
wfWAF::getInstance()->getStorageEngine()->setConfig('wafStatus', $status);
[76] Fix | Delete
}
[77] Fix | Delete
}
[78] Fix | Delete
catch (Exception $e) {
[79] Fix | Delete
//Ignore
[80] Fix | Delete
}
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Tests the WAF configuration and returns true if successful.
[86] Fix | Delete
*
[87] Fix | Delete
* @return bool
[88] Fix | Delete
*/
[89] Fix | Delete
public function testConfig() {
[90] Fix | Delete
try {
[91] Fix | Delete
wfWAF::getInstance()->getStorageEngine()->isDisabled();
[92] Fix | Delete
}
[93] Fix | Delete
catch (Exception $e) {
[94] Fix | Delete
return false;
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
return true;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Returns a normalized percentage (i.e., in the range [0, 1]) to the corresponding display percentage
[102] Fix | Delete
* based on license type.
[103] Fix | Delete
*
[104] Fix | Delete
* @param float $percentage
[105] Fix | Delete
* @param bool $adjust Whether or not to adjust the range to [0, 0.7]
[106] Fix | Delete
* @return float
[107] Fix | Delete
*/
[108] Fix | Delete
protected function _normalizedPercentageToDisplay($percentage, $adjust = true) {
[109] Fix | Delete
if (wfConfig::get('isPaid') || !$adjust) {
[110] Fix | Delete
return round($percentage, 2);
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
return round($percentage * 0.70, 2);
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Returns the percentage calculation of the overall firewall status, which is displayed under "Firewall"
[118] Fix | Delete
* on the Dashboard page.
[119] Fix | Delete
*
[120] Fix | Delete
* @return float
[121] Fix | Delete
*/
[122] Fix | Delete
public function overallStatus() {
[123] Fix | Delete
try {
[124] Fix | Delete
$wafStatus = $this->wafStatus();
[125] Fix | Delete
$bruteForceStatus = $this->bruteForceStatus();
[126] Fix | Delete
[127] Fix | Delete
$percentage = 0.0;
[128] Fix | Delete
$percentage += $wafStatus * 0.80;
[129] Fix | Delete
$percentage += $bruteForceStatus * 0.20;
[130] Fix | Delete
return $this->_normalizedPercentageToDisplay($percentage, false);
[131] Fix | Delete
}
[132] Fix | Delete
catch (Exception $e) {
[133] Fix | Delete
//Ignore, return 0%
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
return 0.0;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
public function statusList($section = null) {
[140] Fix | Delete
$statusList = array();
[141] Fix | Delete
$wafStatusList = $this->wafStatusList($section);
[142] Fix | Delete
$bruteForceStatusList = $this->bruteForceStatusList();
[143] Fix | Delete
[144] Fix | Delete
foreach ($wafStatusList as $entry) {
[145] Fix | Delete
$entry['percentage'] *= 0.8;
[146] Fix | Delete
$statusList[] = $entry;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
foreach ($bruteForceStatusList as $entry) {
[150] Fix | Delete
$entry['percentage'] *= 0.2;
[151] Fix | Delete
$statusList[] = $entry;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
return array_filter($statusList);
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Returns the percentage calculation of the WAF status, which is displayed under "Web Application
[159] Fix | Delete
* Firewall" on the Firewall page.
[160] Fix | Delete
*
[161] Fix | Delete
* @return float
[162] Fix | Delete
*/
[163] Fix | Delete
public function wafStatus() {
[164] Fix | Delete
try {
[165] Fix | Delete
$ruleStatus = $this->ruleStatus(true);
[166] Fix | Delete
$blacklistStatus = $this->blacklistStatus();
[167] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[168] Fix | Delete
$extendedProtection = $wafEnabled && WFWAF_AUTO_PREPEND && !WFWAF_SUBDIRECTORY_INSTALL;
[169] Fix | Delete
$rateLimitingAdvancedBlockingEnabled = wfConfig::get('firewallEnabled', 1);
[170] Fix | Delete
[171] Fix | Delete
if (!$wafEnabled) {
[172] Fix | Delete
return 0.0;
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
$percentage = 0.0;
[176] Fix | Delete
$percentage += $this->_normalizedPercentageToDisplay($ruleStatus * 0.35, true);
[177] Fix | Delete
$percentage += $blacklistStatus * 0.35;
[178] Fix | Delete
$percentage += ($extendedProtection ? 0.20 : 0.0);
[179] Fix | Delete
$percentage += ($rateLimitingAdvancedBlockingEnabled ? 0.10 : 0.0);
[180] Fix | Delete
return $this->_normalizedPercentageToDisplay($percentage, false);
[181] Fix | Delete
}
[182] Fix | Delete
catch (Exception $e) {
[183] Fix | Delete
//Ignore, return 0%
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
return 0.0;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
public function wafStatusList($section = null) {
[190] Fix | Delete
$statusList = array();
[191] Fix | Delete
try {
[192] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[193] Fix | Delete
if (!$wafEnabled) {
[194] Fix | Delete
return array(
[195] Fix | Delete
array(
[196] Fix | Delete
'percentage' => 1.0,
[197] Fix | Delete
'title' => __('Enable firewall.', 'wordfence'),
[198] Fix | Delete
),
[199] Fix | Delete
);
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
// Get percent of rules enabled.
[203] Fix | Delete
$ruleStatus = $this->ruleStatusDescription(true);
[204] Fix | Delete
$premiumStatus = array();
[205] Fix | Delete
if (!wfConfig::get('isPaid')) {
[206] Fix | Delete
$premiumStatus = array(
[207] Fix | Delete
'percentage' => 0.30,
[208] Fix | Delete
'title' => __('Enable Premium Rules.', 'wordfence'),
[209] Fix | Delete
);
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
if ($section === 'rules') {
[213] Fix | Delete
if ($ruleStatus) {
[214] Fix | Delete
$ruleStatus['percentage'] = $this->_normalizedPercentageToDisplay($ruleStatus['percentage']);
[215] Fix | Delete
}
[216] Fix | Delete
return array_filter(array($ruleStatus, $premiumStatus));
[217] Fix | Delete
}
[218] Fix | Delete
if ($premiumStatus) {
[219] Fix | Delete
$premiumStatus['percentage'] *= 0.35;
[220] Fix | Delete
$premiumStatus['percentage'] = $this->_normalizedPercentageToDisplay($premiumStatus['percentage'], false);
[221] Fix | Delete
}
[222] Fix | Delete
if ($ruleStatus) {
[223] Fix | Delete
$ruleStatus['percentage'] *= 0.35;
[224] Fix | Delete
$ruleStatus['percentage'] = $this->_normalizedPercentageToDisplay($ruleStatus['percentage']);
[225] Fix | Delete
}
[226] Fix | Delete
$statusList = array_merge($statusList, array($ruleStatus), array($premiumStatus));
[227] Fix | Delete
[228] Fix | Delete
$blacklistStatus = $this->blacklistStatusDescription();
[229] Fix | Delete
if ($section === 'blacklist') {
[230] Fix | Delete
return array_filter(array($blacklistStatus));
[231] Fix | Delete
}
[232] Fix | Delete
if ($blacklistStatus) {
[233] Fix | Delete
$blacklistStatus['percentage'] *= 0.35;
[234] Fix | Delete
$blacklistStatus['percentage'] = $this->_normalizedPercentageToDisplay($blacklistStatus['percentage'], false);
[235] Fix | Delete
}
[236] Fix | Delete
$statusList = array_merge($statusList, array($blacklistStatus));
[237] Fix | Delete
[238] Fix | Delete
$extendedProtection = $wafEnabled && WFWAF_AUTO_PREPEND && !WFWAF_SUBDIRECTORY_INSTALL;
[239] Fix | Delete
if (!$extendedProtection) {
[240] Fix | Delete
$statusList[] = array(
[241] Fix | Delete
'percentage' => $this->_normalizedPercentageToDisplay(0.20, false),
[242] Fix | Delete
'title' => __('Optimize the Wordfence Firewall.', 'wordfence'),
[243] Fix | Delete
);
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
$rateLimitingAdvancedBlockingEnabled = wfConfig::get('firewallEnabled', 1);
[247] Fix | Delete
if (!$rateLimitingAdvancedBlockingEnabled) {
[248] Fix | Delete
$statusList[] = array(
[249] Fix | Delete
'percentage' => $this->_normalizedPercentageToDisplay(0.10, false),
[250] Fix | Delete
'title' => __('Enable Rate Limiting and Advanced Blocking.', 'wordfence'),
[251] Fix | Delete
);
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
return array_filter($statusList);
[255] Fix | Delete
}
[256] Fix | Delete
catch (Exception $e) {
[257] Fix | Delete
//Ignore, return 0%
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
if (!WFWAF_OPERATIONAL) {
[261] Fix | Delete
return array(array('percentage' => 1.0, 'title' => __('Repair the Wordfence Firewall configuration.', 'wordfence')));
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
return array();
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Returns the status of the WAF.
[269] Fix | Delete
*
[270] Fix | Delete
* @return string
[271] Fix | Delete
*/
[272] Fix | Delete
public function firewallMode() {
[273] Fix | Delete
try {
[274] Fix | Delete
return (!WFWAF_ENABLED ? 'disabled' : wfWAF::getInstance()->getStorageEngine()->getConfig('wafStatus'));
[275] Fix | Delete
}
[276] Fix | Delete
catch (Exception $e) {
[277] Fix | Delete
//Ignore
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
return self::FIREWALL_MODE_DISABLED;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Returns the current protection mode configured for the WAF.
[285] Fix | Delete
*
[286] Fix | Delete
* @return string
[287] Fix | Delete
*/
[288] Fix | Delete
public function protectionMode() {
[289] Fix | Delete
if (defined('WFWAF_AUTO_PREPEND') && WFWAF_AUTO_PREPEND) {
[290] Fix | Delete
return self::PROTECTION_MODE_EXTENDED;
[291] Fix | Delete
}
[292] Fix | Delete
return self::PROTECTION_MODE_BASIC;
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
/**
[296] Fix | Delete
* Returns whether or not this installation is in a subdirectory of another WordPress site with the WAF already optimized.
[297] Fix | Delete
*
[298] Fix | Delete
* @return bool
[299] Fix | Delete
*/
[300] Fix | Delete
public function isSubDirectoryInstallation() {
[301] Fix | Delete
if (defined('WFWAF_SUBDIRECTORY_INSTALL') && WFWAF_SUBDIRECTORY_INSTALL) {
[302] Fix | Delete
return true;
[303] Fix | Delete
}
[304] Fix | Delete
return false;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
/**
[308] Fix | Delete
* Returns the percentage calculation of the firewall rule status, which is displayed under "Firewall Rules" on the
[309] Fix | Delete
* Firewall page.
[310] Fix | Delete
*
[311] Fix | Delete
* The calculation is the number of rules enabled divided by the total number of rules. If the WAF is in learning
[312] Fix | Delete
* mode, no rules are enforced, so it's clamped to 0%.
[313] Fix | Delete
*
[314] Fix | Delete
* @param bool $round Round the percentage (in the range [0, 1]) to be only whole percentages.
[315] Fix | Delete
* @return float
[316] Fix | Delete
*/
[317] Fix | Delete
public function ruleStatus($round = false) {
[318] Fix | Delete
try {
[319] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[320] Fix | Delete
if (!$wafEnabled) {
[321] Fix | Delete
return 0.0;
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
/*$learningMode = !!wfWAF::getInstance()->isInLearningMode();
[325] Fix | Delete
if ($learningMode) {
[326] Fix | Delete
return 0.0;
[327] Fix | Delete
}*/
[328] Fix | Delete
[329] Fix | Delete
$rules = wfWAF::getInstance()->getRules();
[330] Fix | Delete
$disabledRules = (array) wfWAF::getInstance()->getStorageEngine()->getConfig('disabledRules');
[331] Fix | Delete
/** @var wfWAFRule $rule */
[332] Fix | Delete
$enabledCount = 0;
[333] Fix | Delete
foreach ($rules as $ruleID => $rule) {
[334] Fix | Delete
if (isset($disabledRules[$ruleID]) && $disabledRules[$ruleID]) {
[335] Fix | Delete
continue;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
$enabledCount++;
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
$percentEnabled = (count($rules) == 0 ? 0 : $enabledCount / count($rules));
[342] Fix | Delete
if ($round) {
[343] Fix | Delete
return round($percentEnabled, 2);
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
return $this->_normalizedPercentageToDisplay($percentEnabled);
[347] Fix | Delete
}
[348] Fix | Delete
catch (Exception $e) {
[349] Fix | Delete
//Ignore, return 0%
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
return 0.0;
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
/**
[356] Fix | Delete
* @param bool $round
[357] Fix | Delete
* @return array
[358] Fix | Delete
*/
[359] Fix | Delete
public function ruleStatusDescription($round = false) {
[360] Fix | Delete
try {
[361] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[362] Fix | Delete
if (!$wafEnabled) {
[363] Fix | Delete
return array(
[364] Fix | Delete
'percentage' => 1.0,
[365] Fix | Delete
'title' => __('Enable firewall.', 'wordfence'),
[366] Fix | Delete
);
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
/*$learningMode = !!wfWAF::getInstance()->isInLearningMode();
[370] Fix | Delete
if ($learningMode) {
[371] Fix | Delete
return 0.0;
[372] Fix | Delete
}*/
[373] Fix | Delete
[374] Fix | Delete
$rules = wfWAF::getInstance()->getRules();
[375] Fix | Delete
$disabledRules = (array) wfWAF::getInstance()->getStorageEngine()->getConfig('disabledRules');
[376] Fix | Delete
/** @var wfWAFRule $rule */
[377] Fix | Delete
$enabledCount = 0;
[378] Fix | Delete
foreach ($rules as $ruleID => $rule) {
[379] Fix | Delete
if (isset($disabledRules[$ruleID]) && $disabledRules[$ruleID]) {
[380] Fix | Delete
continue;
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
$enabledCount++;
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
$percentEnabled = 1.0 - ((float) (count($rules) == 0 ? 0 : $enabledCount / count($rules)));
[387] Fix | Delete
if ($percentEnabled === 0.0) {
[388] Fix | Delete
return array();
[389] Fix | Delete
}
[390] Fix | Delete
$reenbleCount = count($rules) - $enabledCount;
[391] Fix | Delete
return array(
[392] Fix | Delete
'percentage' => ($round ? round($percentEnabled, 2) : $percentEnabled),
[393] Fix | Delete
'title' => sprintf(_n('Re-enable %d firewall rule.', 'Re-enable %d firewall rules.', $reenbleCount, 'wordfence'), number_format_i18n($reenbleCount)),
[394] Fix | Delete
);
[395] Fix | Delete
}
[396] Fix | Delete
catch (Exception $e) {
[397] Fix | Delete
//Ignore, return 0%
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
return array(
[401] Fix | Delete
'percentage' => 1.0,
[402] Fix | Delete
'title' => __('Enable firewall.', 'wordfence'),
[403] Fix | Delete
);
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
/**
[407] Fix | Delete
* Returns the rule feed that is in use.
[408] Fix | Delete
*
[409] Fix | Delete
* @return string
[410] Fix | Delete
*/
[411] Fix | Delete
public function ruleMode() {
[412] Fix | Delete
if (wfConfig::get('isPaid')) {
[413] Fix | Delete
return self::RULE_MODE_PREMIUM;
[414] Fix | Delete
}
[415] Fix | Delete
return self::RULE_MODE_COMMUNITY;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* Returns 100% if the blacklist is enabled, 0% if not.
[420] Fix | Delete
*
[421] Fix | Delete
* @return float
[422] Fix | Delete
*/
[423] Fix | Delete
public function blacklistStatus() {
[424] Fix | Delete
try {
[425] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[426] Fix | Delete
if (!$wafEnabled) {
[427] Fix | Delete
return 0.0;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
return $this->blacklistMode() == self::BLACKLIST_MODE_ENABLED ? 1.0 : 0.0;
[431] Fix | Delete
}
[432] Fix | Delete
catch (Exception $e) {
[433] Fix | Delete
//Ignore, return 0%
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
return 0.0;
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
/**
[440] Fix | Delete
* Returns 100% if the blacklist is enabled, 0% if not.
[441] Fix | Delete
*
[442] Fix | Delete
* @return array
[443] Fix | Delete
*/
[444] Fix | Delete
public function blacklistStatusDescription() {
[445] Fix | Delete
try {
[446] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[447] Fix | Delete
if (!$wafEnabled) {
[448] Fix | Delete
return array(
[449] Fix | Delete
'percentage' => 1.0,
[450] Fix | Delete
'title' => __('Enable Firewall.', 'wordfence'),
[451] Fix | Delete
);
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
if ($this->blacklistMode() == self::BLACKLIST_MODE_ENABLED) {
[455] Fix | Delete
return array();
[456] Fix | Delete
}
[457] Fix | Delete
return array(
[458] Fix | Delete
'percentage' => 1.0,
[459] Fix | Delete
'title' => __('Enable Real-Time IP Blocklist.', 'wordfence'),
[460] Fix | Delete
);
[461] Fix | Delete
}
[462] Fix | Delete
catch (Exception $e) {
[463] Fix | Delete
//Ignore, return 0%
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
return array(
[467] Fix | Delete
'percentage' => 1.0,
[468] Fix | Delete
'title' => __('Enable Real-Time IP Blocklist.', 'wordfence'),
[469] Fix | Delete
);
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
/**
[473] Fix | Delete
* Returns the blacklist mode.
[474] Fix | Delete
*
[475] Fix | Delete
* @return string
[476] Fix | Delete
*/
[477] Fix | Delete
public function blacklistMode() {
[478] Fix | Delete
$blacklistEnabled = false;
[479] Fix | Delete
try {
[480] Fix | Delete
$wafEnabled = !(!WFWAF_ENABLED || wfWAF::getInstance()->getStorageEngine()->isDisabled());
[481] Fix | Delete
$blacklistEnabled = $wafEnabled && !wfWAF::getInstance()->getStorageEngine()->getConfig('disableWAFBlacklistBlocking');
[482] Fix | Delete
}
[483] Fix | Delete
catch (Exception $e) {
[484] Fix | Delete
//Do nothing
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
if (wfConfig::get('isPaid') && $blacklistEnabled) {
[488] Fix | Delete
return self::BLACKLIST_MODE_ENABLED;
[489] Fix | Delete
}
[490] Fix | Delete
return self::BLACKLIST_MODE_DISABLED;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
/**
[494] Fix | Delete
* Returns a percentage rating for the brute force protection status. This includes both the WFSN enabled status
[495] Fix | Delete
* and the status of individual login security options. These options are available to all, so they are always
[496] Fix | Delete
* in the range [0,1].
[497] Fix | Delete
*
[498] Fix | Delete
* @return float
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function