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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wordfenceClass.php
'wfCrawlers',
[500] Fix | Delete
'wfBadLeechers',
[501] Fix | Delete
'wfBlockedIPLog',
[502] Fix | Delete
'wfBlocks', //Removed in 7.0.1 but left in in case migrating from really old
[503] Fix | Delete
'wfHits',
[504] Fix | Delete
'wfLocs',
[505] Fix | Delete
'wfLogins',
[506] Fix | Delete
'wfReverseCache',
[507] Fix | Delete
);
[508] Fix | Delete
[509] Fix | Delete
foreach ($tables_with_ips as $ip_table) {
[510] Fix | Delete
$ptable = wfDB::networkTable($ip_table);
[511] Fix | Delete
$tableExists = $wpdb->get_col($wpdb->prepare(<<<SQL
[512] Fix | Delete
SELECT TABLE_NAME FROM information_schema.TABLES
[513] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[514] Fix | Delete
AND TABLE_NAME=%s
[515] Fix | Delete
SQL
[516] Fix | Delete
, $ptable));
[517] Fix | Delete
if (!$tableExists) {
[518] Fix | Delete
continue;
[519] Fix | Delete
}
[520] Fix | Delete
[521] Fix | Delete
$result = $wpdb->get_row("SHOW FIELDS FROM {$ptable} where field = 'IP'");
[522] Fix | Delete
if (!$result || strtolower($result->Type) == 'binary(16)') {
[523] Fix | Delete
continue;
[524] Fix | Delete
}
[525] Fix | Delete
[526] Fix | Delete
$db->queryWriteIgnoreError("ALTER TABLE {$ptable} MODIFY IP BINARY(16)");
[527] Fix | Delete
[528] Fix | Delete
// Just to be sure we don't corrupt the data if the alter fails.
[529] Fix | Delete
$result = $wpdb->get_row("SHOW FIELDS FROM {$ptable} where field = 'IP'");
[530] Fix | Delete
if (!$result || strtolower($result->Type) != 'binary(16)') {
[531] Fix | Delete
continue;
[532] Fix | Delete
}
[533] Fix | Delete
$db->queryWriteIgnoreError("UPDATE {$ptable} SET IP = CONCAT(LPAD(CHAR(0xff, 0xff), 12, CHAR(0)), LPAD(
[534] Fix | Delete
CHAR(
[535] Fix | Delete
CAST(IP as UNSIGNED) >> 24 & 0xFF,
[536] Fix | Delete
CAST(IP as UNSIGNED) >> 16 & 0xFF,
[537] Fix | Delete
CAST(IP as UNSIGNED) >> 8 & 0xFF,
[538] Fix | Delete
CAST(IP as UNSIGNED) & 0xFF
[539] Fix | Delete
),
[540] Fix | Delete
4,
[541] Fix | Delete
CHAR(0)
[542] Fix | Delete
))");
[543] Fix | Delete
}
[544] Fix | Delete
[545] Fix | Delete
//Country reassignment moved to the GeoIP file sync segment
[546] Fix | Delete
[547] Fix | Delete
if (wfConfig::get('other_hideWPVersion')) {
[548] Fix | Delete
wfUtils::hideReadme();
[549] Fix | Delete
}
[550] Fix | Delete
[551] Fix | Delete
$colsFor610 = array(
[552] Fix | Delete
'attackLogTime' => '`attackLogTime` double(17,6) unsigned NOT NULL AFTER `id`',
[553] Fix | Delete
'statusCode' => '`statusCode` int(11) NOT NULL DEFAULT 0 AFTER `jsRun`',
[554] Fix | Delete
'action' => "`action` varchar(64) NOT NULL DEFAULT '' AFTER `UA`",
[555] Fix | Delete
'actionDescription' => '`actionDescription` text AFTER `action`',
[556] Fix | Delete
'actionData' => '`actionData` text AFTER `actionDescription`',
[557] Fix | Delete
);
[558] Fix | Delete
[559] Fix | Delete
$hitTable = wfDB::networkTable('wfHits');
[560] Fix | Delete
foreach ($colsFor610 as $col => $colDefintion) {
[561] Fix | Delete
$count = $wpdb->get_col($wpdb->prepare(<<<SQL
[562] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[563] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[564] Fix | Delete
AND COLUMN_NAME=%s
[565] Fix | Delete
AND TABLE_NAME=%s
[566] Fix | Delete
SQL
[567] Fix | Delete
, $col, $hitTable));
[568] Fix | Delete
if (!$count) {
[569] Fix | Delete
$wpdb->query("ALTER TABLE $hitTable ADD COLUMN $colDefintion");
[570] Fix | Delete
}
[571] Fix | Delete
}
[572] Fix | Delete
[573] Fix | Delete
$has404 = $wpdb->get_col($wpdb->prepare(<<<SQL
[574] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[575] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[576] Fix | Delete
AND COLUMN_NAME='is404'
[577] Fix | Delete
AND TABLE_NAME=%s
[578] Fix | Delete
SQL
[579] Fix | Delete
, $hitTable));
[580] Fix | Delete
if ($has404) {
[581] Fix | Delete
$wpdb->query(<<<SQL
[582] Fix | Delete
UPDATE $hitTable
[583] Fix | Delete
SET statusCode= CASE
[584] Fix | Delete
WHEN is404=1 THEN 404
[585] Fix | Delete
ELSE 200
[586] Fix | Delete
END
[587] Fix | Delete
SQL
[588] Fix | Delete
);
[589] Fix | Delete
[590] Fix | Delete
$wpdb->query("ALTER TABLE $hitTable DROP COLUMN `is404`");
[591] Fix | Delete
}
[592] Fix | Delete
[593] Fix | Delete
$loginsTable = wfDB::networkTable('wfLogins');
[594] Fix | Delete
$hasHitID = $wpdb->get_col($wpdb->prepare(<<<SQL
[595] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[596] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[597] Fix | Delete
AND COLUMN_NAME='hitID'
[598] Fix | Delete
AND TABLE_NAME=%s
[599] Fix | Delete
SQL
[600] Fix | Delete
, $loginsTable));
[601] Fix | Delete
if (!$hasHitID) {
[602] Fix | Delete
$wpdb->query("ALTER TABLE $loginsTable ADD COLUMN hitID int(11) DEFAULT NULL AFTER `id`, ADD INDEX(hitID)");
[603] Fix | Delete
}
[604] Fix | Delete
[605] Fix | Delete
if (!WFWAF_SUBDIRECTORY_INSTALL) {
[606] Fix | Delete
wfWAFConfig::set('wafDisabled', false);
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
// Call this before creating the index in cases where the wp-cron isn't running.
[610] Fix | Delete
self::trimWfHits(true);
[611] Fix | Delete
$hitsTable = wfDB::networkTable('wfHits');
[612] Fix | Delete
$hasAttackLogTimeIndex = $wpdb->get_var($wpdb->prepare(<<<SQL
[613] Fix | Delete
SELECT COLUMN_KEY FROM information_schema.COLUMNS
[614] Fix | Delete
WHERE TABLE_SCHEMA = DATABASE()
[615] Fix | Delete
AND TABLE_NAME = %s
[616] Fix | Delete
AND COLUMN_NAME = 'attackLogTime'
[617] Fix | Delete
SQL
[618] Fix | Delete
, $hitsTable));
[619] Fix | Delete
[620] Fix | Delete
if (!$hasAttackLogTimeIndex) {
[621] Fix | Delete
$wpdb->query("ALTER TABLE $hitsTable ADD INDEX `attackLogTime` (`attackLogTime`)");
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
//6.1.16
[625] Fix | Delete
$allowed404s = wfConfig::get('allowed404s', '');
[626] Fix | Delete
if (!wfConfig::get('allowed404s6116Migration', false)) {
[627] Fix | Delete
if (!preg_match('/(?:^|\b)browserconfig\.xml(?:\b|$)/i', $allowed404s)) {
[628] Fix | Delete
if (strlen($allowed404s) > 0) {
[629] Fix | Delete
$allowed404s .= "\n";
[630] Fix | Delete
}
[631] Fix | Delete
$allowed404s .= "/browserconfig.xml";
[632] Fix | Delete
wfConfig::set('allowed404s', $allowed404s);
[633] Fix | Delete
}
[634] Fix | Delete
[635] Fix | Delete
wfConfig::set('allowed404s6116Migration', 1);
[636] Fix | Delete
}
[637] Fix | Delete
if (wfConfig::get('email_summary_interval') == 'biweekly') {
[638] Fix | Delete
wfConfig::set('email_summary_interval', 'weekly');
[639] Fix | Delete
}
[640] Fix | Delete
[641] Fix | Delete
//6.2.0
[642] Fix | Delete
wfConfig::migrateCodeExecutionForUploadsPHP7();
[643] Fix | Delete
[644] Fix | Delete
//6.2.3
[645] Fix | Delete
if (!WFWAF_SUBDIRECTORY_INSTALL && class_exists('wfWAFIPBlocksController')) {
[646] Fix | Delete
wfWAFIPBlocksController::setNeedsSynchronizeConfigSettings(); //changed slightly for 7.0.1
[647] Fix | Delete
}
[648] Fix | Delete
[649] Fix | Delete
//6.2.8
[650] Fix | Delete
wfCache::removeCaching();
[651] Fix | Delete
[652] Fix | Delete
//6.2.10
[653] Fix | Delete
$snipCacheTable = wfDB::networkTable('wfSNIPCache');
[654] Fix | Delete
$hasType = $wpdb->get_col($wpdb->prepare(<<<SQL
[655] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[656] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[657] Fix | Delete
AND COLUMN_NAME='type'
[658] Fix | Delete
AND TABLE_NAME=%s
[659] Fix | Delete
SQL
[660] Fix | Delete
, $snipCacheTable));
[661] Fix | Delete
if (!$hasType) {
[662] Fix | Delete
$wpdb->query("ALTER TABLE `{$snipCacheTable}` ADD `type` INT UNSIGNED NOT NULL DEFAULT '0'");
[663] Fix | Delete
$wpdb->query("ALTER TABLE `{$snipCacheTable}` ADD INDEX (`type`)");
[664] Fix | Delete
}
[665] Fix | Delete
[666] Fix | Delete
//6.3.5
[667] Fix | Delete
$fileModsTable = wfDB::networkTable('wfFileMods');
[668] Fix | Delete
$hasStoppedOn = $wpdb->get_col($wpdb->prepare(<<<SQL
[669] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[670] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[671] Fix | Delete
AND COLUMN_NAME='stoppedOnSignature'
[672] Fix | Delete
AND TABLE_NAME=%s
[673] Fix | Delete
SQL
[674] Fix | Delete
, $fileModsTable));
[675] Fix | Delete
if (!$hasStoppedOn) {
[676] Fix | Delete
$wpdb->query("ALTER TABLE {$fileModsTable} ADD COLUMN stoppedOnSignature VARCHAR(255) NOT NULL DEFAULT ''");
[677] Fix | Delete
$wpdb->query("ALTER TABLE {$fileModsTable} ADD COLUMN stoppedOnPosition INT UNSIGNED NOT NULL DEFAULT '0'");
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
$blockedIPLogTable = wfDB::networkTable('wfBlockedIPLog');
[681] Fix | Delete
$hasType = $wpdb->get_col($wpdb->prepare(<<<SQL
[682] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[683] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[684] Fix | Delete
AND COLUMN_NAME='blockType'
[685] Fix | Delete
AND TABLE_NAME=%s
[686] Fix | Delete
SQL
[687] Fix | Delete
, $blockedIPLogTable));
[688] Fix | Delete
if (!$hasType) {
[689] Fix | Delete
$wpdb->query("ALTER TABLE {$blockedIPLogTable} ADD blockType VARCHAR(50) NOT NULL DEFAULT 'generic'");
[690] Fix | Delete
$wpdb->query("ALTER TABLE {$blockedIPLogTable} DROP PRIMARY KEY");
[691] Fix | Delete
$wpdb->query("ALTER TABLE {$blockedIPLogTable} ADD PRIMARY KEY (IP, unixday, blockType)");
[692] Fix | Delete
}
[693] Fix | Delete
[694] Fix | Delete
//6.3.6
[695] Fix | Delete
if (!wfConfig::get('migration636_email_summary_excluded_directories')) {
[696] Fix | Delete
$excluded_directories = explode(',', (string) wfConfig::get('email_summary_excluded_directories'));
[697] Fix | Delete
$key = array_search('wp-content/plugins/wordfence/tmp', $excluded_directories); if ($key !== false) { unset($excluded_directories[$key]); }
[698] Fix | Delete
$key = array_search('wp-content/wflogs', $excluded_directories); if ($key === false) { $excluded_directories[] = 'wp-content/wflogs'; }
[699] Fix | Delete
wfConfig::set('email_summary_excluded_directories', implode(',', $excluded_directories));
[700] Fix | Delete
wfConfig::set('migration636_email_summary_excluded_directories', 1, wfConfig::DONT_AUTOLOAD);
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
$fileModsTable = wfDB::networkTable('wfFileMods');
[704] Fix | Delete
$hasSHAC = $wpdb->get_col($wpdb->prepare(<<<SQL
[705] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[706] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[707] Fix | Delete
AND COLUMN_NAME='SHAC'
[708] Fix | Delete
AND TABLE_NAME=%s
[709] Fix | Delete
SQL
[710] Fix | Delete
, $fileModsTable));
[711] Fix | Delete
if (!$hasSHAC) {
[712] Fix | Delete
$wpdb->query("ALTER TABLE {$fileModsTable} ADD COLUMN `SHAC` BINARY(32) NOT NULL DEFAULT '' AFTER `newMD5`");
[713] Fix | Delete
$wpdb->query("ALTER TABLE {$fileModsTable} ADD COLUMN `isSafeFile` VARCHAR(1) NOT NULL DEFAULT '?' AFTER `stoppedOnPosition`");
[714] Fix | Delete
}
[715] Fix | Delete
[716] Fix | Delete
//6.3.7
[717] Fix | Delete
$hooverTable = wfDB::networkTable('wfHoover');
[718] Fix | Delete
$hostKeySize = $wpdb->get_var($wpdb->prepare(<<<SQL
[719] Fix | Delete
SELECT CHARACTER_MAXIMUM_LENGTH FROM information_schema.COLUMNS
[720] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[721] Fix | Delete
AND COLUMN_NAME='hostKey'
[722] Fix | Delete
AND TABLE_NAME=%s
[723] Fix | Delete
SQL
[724] Fix | Delete
, $hooverTable));
[725] Fix | Delete
if ($hostKeySize < 124) {
[726] Fix | Delete
$wpdb->query("ALTER TABLE {$hooverTable} CHANGE `hostKey` `hostKey` VARBINARY(124) NULL DEFAULT NULL");
[727] Fix | Delete
}
[728] Fix | Delete
[729] Fix | Delete
//6.3.15
[730] Fix | Delete
$scanFileContents = wfConfig::get('scansEnabled_fileContents', false);
[731] Fix | Delete
if (!wfConfig::get('fileContentsGSB6315Migration', false)) {
[732] Fix | Delete
if (!$scanFileContents) {
[733] Fix | Delete
wfConfig::set('scansEnabled_fileContentsGSB', false);
[734] Fix | Delete
}
[735] Fix | Delete
wfConfig::set('fileContentsGSB6315Migration', 1);
[736] Fix | Delete
}
[737] Fix | Delete
[738] Fix | Delete
//6.3.20
[739] Fix | Delete
$lastBlockAggregation = wfConfig::get('lastBlockAggregation', 0);
[740] Fix | Delete
if ($lastBlockAggregation == 0) {
[741] Fix | Delete
wfConfig::set('lastBlockAggregation', time());
[742] Fix | Delete
}
[743] Fix | Delete
[744] Fix | Delete
//7.0.1
[745] Fix | Delete
//---- Config Migration
[746] Fix | Delete
if (!wfConfig::get('config701Migration', false)) {
[747] Fix | Delete
//loginSec_strongPasswds gains a toggle
[748] Fix | Delete
if (wfConfig::get('loginSec_strongPasswds') == '') {
[749] Fix | Delete
wfConfig::set('loginSec_strongPasswds', 'pubs');
[750] Fix | Delete
wfConfig::set('loginSec_strongPasswds_enabled', false);
[751] Fix | Delete
}
[752] Fix | Delete
[753] Fix | Delete
$limitedOptions = wfScanner::limitedScanTypeOptions();
[754] Fix | Delete
$standardOptions = wfScanner::standardScanTypeOptions();
[755] Fix | Delete
$highSensitivityOptions = wfScanner::highSensitivityScanTypeOptions();
[756] Fix | Delete
$settings = wfScanner::customScanTypeOptions();
[757] Fix | Delete
if ($settings == $limitedOptions) { wfConfig::set('scanType', wfScanner::SCAN_TYPE_LIMITED); }
[758] Fix | Delete
else if ($settings == $standardOptions) { wfConfig::set('scanType', wfScanner::SCAN_TYPE_STANDARD); }
[759] Fix | Delete
else if ($settings == $highSensitivityOptions) { wfConfig::set('scanType', wfScanner::SCAN_TYPE_HIGH_SENSITIVITY); }
[760] Fix | Delete
else { wfConfig::set('scanType', wfScanner::SCAN_TYPE_CUSTOM); }
[761] Fix | Delete
[762] Fix | Delete
if (wfConfig::get('isPaid')) {
[763] Fix | Delete
wfConfig::set('keyType', wfLicense::KEY_TYPE_PAID_CURRENT);
[764] Fix | Delete
}
[765] Fix | Delete
[766] Fix | Delete
wfConfig::remove('premiumAutoRenew');
[767] Fix | Delete
wfConfig::remove('premiumNextRenew');
[768] Fix | Delete
wfConfig::remove('premiumPaymentExpiring');
[769] Fix | Delete
wfConfig::remove('premiumPaymentExpired');
[770] Fix | Delete
wfConfig::remove('premiumPaymentMissing');
[771] Fix | Delete
wfConfig::remove('premiumPaymentHold');
[772] Fix | Delete
[773] Fix | Delete
wfConfig::set('config701Migration', 1);
[774] Fix | Delete
}
[775] Fix | Delete
[776] Fix | Delete
//---- wfBlocks migration
[777] Fix | Delete
$oldBlocksTable = wfDB::networkTable('wfBlocks');
[778] Fix | Delete
$blocksTable = wfBlock::blocksTable();
[779] Fix | Delete
$oldBlocksExist = $wpdb->get_col($wpdb->prepare(<<<SQL
[780] Fix | Delete
SELECT TABLE_NAME FROM information_schema.TABLES
[781] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[782] Fix | Delete
AND TABLE_NAME=%s
[783] Fix | Delete
SQL
[784] Fix | Delete
, $oldBlocksTable));
[785] Fix | Delete
if ($oldBlocksExist && !wfConfig::get('blocks701Migration', false)) {
[786] Fix | Delete
//wfBlocks migration
[787] Fix | Delete
$query = $wpdb->prepare("INSERT INTO `{$blocksTable}` (`type`, `IP`, `blockedTime`, `reason`, `lastAttempt`, `blockedHits`, `expiration`) SELECT CASE
[788] Fix | Delete
WHEN wfsn = 1 AND permanent = 0 THEN %d
[789] Fix | Delete
WHEN wfsn = 0 AND permanent = 0 THEN %d
[790] Fix | Delete
WHEN wfsn = 0 AND permanent = 1 THEN %d
[791] Fix | Delete
END AS `type`, `IP`, `blockedTime`, `reason`, `lastAttempt`, `blockedHits`, CASE
[792] Fix | Delete
WHEN wfsn = 1 AND permanent = 0 THEN (`blockedTime` + 600)
[793] Fix | Delete
WHEN wfsn = 0 AND permanent = 0 THEN (`blockedTime` + %d)
[794] Fix | Delete
WHEN wfsn = 0 AND permanent = 1 THEN 0
[795] Fix | Delete
END AS `expiration` FROM `{$oldBlocksTable}`", wfBlock::TYPE_WFSN_TEMPORARY, wfBlock::TYPE_RATE_BLOCK, wfBlock::TYPE_IP_AUTOMATIC_PERMANENT, wfConfig::get('blockedTime'));
[796] Fix | Delete
$wpdb->query($query);
[797] Fix | Delete
[798] Fix | Delete
//wfBlocksAdv migration
[799] Fix | Delete
$advancedBlocksTable = wfDB::networkTable('wfBlocksAdv');
[800] Fix | Delete
$advancedBlocks = $wpdb->get_results("SELECT * FROM {$advancedBlocksTable}", ARRAY_A);
[801] Fix | Delete
foreach ($advancedBlocks as $b) {
[802] Fix | Delete
$blockType = $b['blockType']; //unused
[803] Fix | Delete
$blockString = $b['blockString'];
[804] Fix | Delete
$ctime = (int) $b['ctime'];
[805] Fix | Delete
$reason = $b['reason'];
[806] Fix | Delete
$totalBlocked = (int) $b['totalBlocked'];
[807] Fix | Delete
$lastBlocked = (int) $b['lastBlocked'];
[808] Fix | Delete
[809] Fix | Delete
list($ipRange, $uaRange, $referrer, $hostname) = explode('|', $blockString);
[810] Fix | Delete
[811] Fix | Delete
wfBlock::createPattern($reason, $ipRange, $hostname, $uaRange, $referrer, wfBlock::DURATION_FOREVER, $ctime, $lastBlocked, $totalBlocked);
[812] Fix | Delete
}
[813] Fix | Delete
[814] Fix | Delete
//throttle migration
[815] Fix | Delete
$throttleTable = wfDB::networkTable('wfThrottleLog');
[816] Fix | Delete
$throttles = $wpdb->get_results("SELECT * FROM {$throttleTable}", ARRAY_A);
[817] Fix | Delete
foreach ($throttles as $t) {
[818] Fix | Delete
$ip = wfUtils::inet_ntop($t['IP']);
[819] Fix | Delete
$startTime = (int) $t['startTime'];
[820] Fix | Delete
$endTime = (int) $t['endTime'];
[821] Fix | Delete
$timesThrottled = (int) $t['timesThrottled'];
[822] Fix | Delete
$reason = $t['lastReason'];
[823] Fix | Delete
[824] Fix | Delete
wfBlock::createRateThrottle($reason, $ip, wfBlock::rateLimitThrottleDuration(), $startTime, $endTime, $timesThrottled);
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
//lockout migration
[828] Fix | Delete
$lockoutTable = wfDB::networkTable('wfLockedOut');
[829] Fix | Delete
$lockouts = $wpdb->get_results("SELECT * FROM {$lockoutTable}", ARRAY_A);
[830] Fix | Delete
foreach ($lockouts as $l) {
[831] Fix | Delete
$ip = wfUtils::inet_ntop($l['IP']);
[832] Fix | Delete
$blockedTime = (int) $l['blockedTime'];
[833] Fix | Delete
$reason = $l['reason'];
[834] Fix | Delete
$lastAttempt = (int) $l['lastAttempt'];
[835] Fix | Delete
$blockedHits = (int) $l['blockedHits'];
[836] Fix | Delete
[837] Fix | Delete
wfBlock::createLockout($reason, $ip, wfBlock::lockoutDuration(), $blockedTime, $lastAttempt, $blockedHits);
[838] Fix | Delete
}
[839] Fix | Delete
[840] Fix | Delete
//country blocking migration
[841] Fix | Delete
$countries = wfConfig::get('cbl_countries', false);
[842] Fix | Delete
if ($countries) {
[843] Fix | Delete
$countries = explode(',', $countries);
[844] Fix | Delete
wfBlock::createCountry(__('Automatically generated from previous country blocking settings', 'wordfence'), wfConfig::get('cbl_loginFormBlocked', false), wfConfig::get('cbl_restOfSiteBlocked', false), $countries);
[845] Fix | Delete
}
[846] Fix | Delete
[847] Fix | Delete
wfConfig::set('blocks701Migration', 1);
[848] Fix | Delete
}
[849] Fix | Delete
[850] Fix | Delete
//---- wfIssues/wfPendingIssues Schema Change
[851] Fix | Delete
$issuesTable = wfDB::networkTable('wfIssues');
[852] Fix | Delete
$pendingIssuesTable = wfDB::networkTable('wfPendingIssues');
[853] Fix | Delete
$hasLastUpdated = $wpdb->get_col($wpdb->prepare(<<<SQL
[854] Fix | Delete
SELECT * FROM information_schema.COLUMNS
[855] Fix | Delete
WHERE TABLE_SCHEMA=DATABASE()
[856] Fix | Delete
AND COLUMN_NAME='lastUpdated'
[857] Fix | Delete
AND TABLE_NAME=%s
[858] Fix | Delete
SQL
[859] Fix | Delete
, $issuesTable));
[860] Fix | Delete
if (!$hasLastUpdated) {
[861] Fix | Delete
$wpdb->query("ALTER TABLE `{$issuesTable}` ADD `lastUpdated` INT UNSIGNED NOT NULL AFTER `time`");
[862] Fix | Delete
$wpdb->query("ALTER TABLE `{$issuesTable}` ADD INDEX (`lastUpdated`)");
[863] Fix | Delete
$wpdb->query("ALTER TABLE `{$issuesTable}` ADD INDEX (`status`)");
[864] Fix | Delete
$wpdb->query("ALTER TABLE `{$issuesTable}` ADD INDEX (`ignoreP`)");
[865] Fix | Delete
$wpdb->query("ALTER TABLE `{$issuesTable}` ADD INDEX (`ignoreC`)");
[866] Fix | Delete
$wpdb->query("UPDATE `{$issuesTable}` SET `lastUpdated` = `time` WHERE `lastUpdated` = 0");
[867] Fix | Delete
[868] Fix | Delete
$wpdb->query("ALTER TABLE `{$pendingIssuesTable}` ADD `lastUpdated` INT UNSIGNED NOT NULL AFTER `time`");
[869] Fix | Delete
$wpdb->query("ALTER TABLE `{$pendingIssuesTable}` ADD INDEX (`lastUpdated`)");
[870] Fix | Delete
$wpdb->query("ALTER TABLE `{$pendingIssuesTable}` ADD INDEX (`status`)");
[871] Fix | Delete
$wpdb->query("ALTER TABLE `{$pendingIssuesTable}` ADD INDEX (`ignoreP`)");
[872] Fix | Delete
$wpdb->query("ALTER TABLE `{$pendingIssuesTable}` ADD INDEX (`ignoreC`)");
[873] Fix | Delete
}
[874] Fix | Delete
[875] Fix | Delete
//---- Scheduled scan start hour and manual type
[876] Fix | Delete
if (wfConfig::get('schedStartHour') < 0) {
[877] Fix | Delete
wfConfig::set('schedStartHour', wfWAFUtils::random_int(0, 23));
[878] Fix | Delete
[879] Fix | Delete
if (wfConfig::get('schedMode') == 'manual') {
[880] Fix | Delete
$sched = wfConfig::get_ser('scanSched', array());
[881] Fix | Delete
if (is_array($sched) && is_array($sched[0])) { //Try to determine the closest matching value for manualScanType
[882] Fix | Delete
$hours = array_fill(0, 24, 0);
[883] Fix | Delete
$distinctHours = array();
[884] Fix | Delete
$days = array_fill(0, 7, 0);
[885] Fix | Delete
$distinctDays = array();
[886] Fix | Delete
foreach ($sched as $dayIndex => $day) {
[887] Fix | Delete
foreach ($day as $h => $enabled) {
[888] Fix | Delete
if ($enabled) {
[889] Fix | Delete
if (in_array($h, $distinctHours)) {
[890] Fix | Delete
$distinctHours[] = $h;
[891] Fix | Delete
}
[892] Fix | Delete
$hours[$h]++;
[893] Fix | Delete
if (in_array($dayIndex, $distinctDays)) {
[894] Fix | Delete
$distinctDays[] = $dayIndex;
[895] Fix | Delete
}
[896] Fix | Delete
$days[$dayIndex]++;
[897] Fix | Delete
}
[898] Fix | Delete
}
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
sort($distinctHours, SORT_NUMERIC);
[902] Fix | Delete
sort($distinctDays, SORT_NUMERIC);
[903] Fix | Delete
if (count($distinctDays) == 7) {
[904] Fix | Delete
if (count($distinctHours) == 1) {
[905] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_ONCE_DAILY);
[906] Fix | Delete
wfConfig::set('schedStartHour', $distinctHours[0]);
[907] Fix | Delete
}
[908] Fix | Delete
else if (count($distinctHours) == 2) {
[909] Fix | Delete
$matchesTwiceDaily = false;
[910] Fix | Delete
if ($distinctHours[0] + 12 == $distinctHours[1]) {
[911] Fix | Delete
$matchesTwiceDaily = true;
[912] Fix | Delete
foreach ($sched as $dayIndex => $day) {
[913] Fix | Delete
if (!$day[$distinctHours[0]] || !$day[$distinctHours[1]]) {
[914] Fix | Delete
$matchesTwiceDaily = false;
[915] Fix | Delete
}
[916] Fix | Delete
}
[917] Fix | Delete
}
[918] Fix | Delete
[919] Fix | Delete
if ($matchesTwiceDaily) {
[920] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_TWICE_DAILY);
[921] Fix | Delete
wfConfig::set('schedStartHour', $distinctHours[0]);
[922] Fix | Delete
}
[923] Fix | Delete
else {
[924] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_CUSTOM);
[925] Fix | Delete
}
[926] Fix | Delete
}
[927] Fix | Delete
else {
[928] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_CUSTOM);
[929] Fix | Delete
}
[930] Fix | Delete
}
[931] Fix | Delete
else if (count($distinctDays) == 5 && count($distinctHours) == 1) {
[932] Fix | Delete
if ($days[2] == 0 && $days[4] == 0 && $hours[$distinctHours[0]] == 5) {
[933] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_ODD_DAYS_WEEKENDS);
[934] Fix | Delete
wfConfig::set('schedStartHour', $distinctHours[0]);
[935] Fix | Delete
}
[936] Fix | Delete
else if ($days[0] == 0 && $days[6] == 0 && $hours[$distinctHours[0]] == 5) {
[937] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_WEEKDAYS);
[938] Fix | Delete
wfConfig::set('schedStartHour', $distinctHours[0]);
[939] Fix | Delete
}
[940] Fix | Delete
else {
[941] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_CUSTOM);
[942] Fix | Delete
}
[943] Fix | Delete
}
[944] Fix | Delete
else if (count($distinctDays) == 2 && count($distinctHours) == 1) {
[945] Fix | Delete
if ($distinctDays[0] == 0 && $distinctDays[1] == 6 && $hours[$distinctHours[0]] == 2) {
[946] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_WEEKENDS);
[947] Fix | Delete
wfConfig::set('schedStartHour', $distinctHours[0]);
[948] Fix | Delete
}
[949] Fix | Delete
else {
[950] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_CUSTOM);
[951] Fix | Delete
}
[952] Fix | Delete
}
[953] Fix | Delete
else {
[954] Fix | Delete
wfConfig::set('manualScanType', wfScanner::MANUAL_SCHEDULING_CUSTOM);
[955] Fix | Delete
}
[956] Fix | Delete
}
[957] Fix | Delete
//manualScanType
[958] Fix | Delete
}
[959] Fix | Delete
}
[960] Fix | Delete
[961] Fix | Delete
//---- Onboarding
[962] Fix | Delete
if (!$freshAPIKey) {
[963] Fix | Delete
wfOnboardingController::migrateOnboarding();
[964] Fix | Delete
}
[965] Fix | Delete
[966] Fix | Delete
//7.0.2
[967] Fix | Delete
if (!wfConfig::get('blocks702Migration')) {
[968] Fix | Delete
$blocksTable = wfBlock::blocksTable();
[969] Fix | Delete
[970] Fix | Delete
$query = "UPDATE `{$blocksTable}` SET `type` = %d WHERE `type` = %d AND `parameters` IS NOT NULL AND `parameters` LIKE '%\"ipRange\"%'";
[971] Fix | Delete
$wpdb->query($wpdb->prepare($query, wfBlock::TYPE_PATTERN, wfBlock::TYPE_IP_AUTOMATIC_PERMANENT));
[972] Fix | Delete
[973] Fix | Delete
$countryBlock = wfBlock::countryBlocks();
[974] Fix | Delete
if (!count($countryBlock)) {
[975] Fix | Delete
$query = "UPDATE `{$blocksTable}` SET `type` = %d WHERE `type` = %d AND `parameters` IS NOT NULL AND `parameters` LIKE '%\"blockLogin\"%' LIMIT 1";
[976] Fix | Delete
$wpdb->query($wpdb->prepare($query, wfBlock::TYPE_COUNTRY, wfBlock::TYPE_IP_AUTOMATIC_PERMANENT));
[977] Fix | Delete
}
[978] Fix | Delete
[979] Fix | Delete
$query = "DELETE FROM `{$blocksTable}` WHERE `type` = %d AND `parameters` IS NOT NULL AND `parameters` LIKE '%\"blockLogin\"%'";
[980] Fix | Delete
$wpdb->query($wpdb->prepare($query, wfBlock::TYPE_IP_AUTOMATIC_PERMANENT));
[981] Fix | Delete
[982] Fix | Delete
wfConfig::set('blocks702Migration', 1);
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
//7.0.3
[986] Fix | Delete
/*if (!wfConfig::get('generateAllOptionsNotification')) {
[987] Fix | Delete
new wfNotification(null, wfNotification::PRIORITY_HIGH_WARNING, '<p>Developers: If you prefer to edit all Wordfence options on one page, you can enable the "All Options" page here:</p>
[988] Fix | Delete
<p><a href="javascript:WFAD.enableAllOptionsPage();" class="wf-btn wf-btn-primary wf-btn-callout-subtle">Enable "All Options" Page</a></p>', 'wfplugin_devalloptions');
[989] Fix | Delete
wfConfig::set('generateAllOptionsNotification', 1);
[990] Fix | Delete
}*/
[991] Fix | Delete
[992] Fix | Delete
//7.1.9
[993] Fix | Delete
if (wfConfig::get('loginSec_maxFailures') == 1) {
[994] Fix | Delete
wfConfig::set('loginSec_maxFailures', 2);
[995] Fix | Delete
}
[996] Fix | Delete
[997] Fix | Delete
$blocksTable = wfBlock::blocksTable();
[998] Fix | Delete
$patternBlocks = wfBlock::patternBlocks();
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function