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.../lib
File: wfScan.php
<?php
[0] Fix | Delete
class wfScan {
[1] Fix | Delete
public static $debugMode = false;
[2] Fix | Delete
public static $errorHandlingOn = true;
[3] Fix | Delete
public static $peakMemAtStart = 0;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Returns the stored cronkey or false if not set. If $expired is provided, will set to <timestamp>/false based
[7] Fix | Delete
* on whether or not the cronkey is expired.
[8] Fix | Delete
*
[9] Fix | Delete
* @param null $expired
[10] Fix | Delete
* @return bool|string
[11] Fix | Delete
*/
[12] Fix | Delete
private static function storedCronKey(&$expired = null) {
[13] Fix | Delete
$currentCronKey = wfConfig::get('currentCronKey', false);
[14] Fix | Delete
if (empty($currentCronKey))
[15] Fix | Delete
{
[16] Fix | Delete
if ($expired !== null) {
[17] Fix | Delete
$expired = false;
[18] Fix | Delete
}
[19] Fix | Delete
return false;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
$savedKey = explode(',',$currentCronKey);
[23] Fix | Delete
if (time() - $savedKey[0] > 86400) {
[24] Fix | Delete
if ($expired !== null) {
[25] Fix | Delete
$expired = $savedKey[0];
[26] Fix | Delete
}
[27] Fix | Delete
return $savedKey[1];
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
if ($expired !== null) {
[31] Fix | Delete
$expired = false;
[32] Fix | Delete
}
[33] Fix | Delete
return $savedKey[1];
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public static function wfScanMain(){
[37] Fix | Delete
self::$peakMemAtStart = memory_get_peak_usage(true);
[38] Fix | Delete
$db = new wfDB();
[39] Fix | Delete
if($db->errorMsg){
[40] Fix | Delete
self::errorExit(sprintf(/* translators: Error message. */ __("Could not connect to database to start scan: %s", 'wordfence'), $db->errorMsg));
[41] Fix | Delete
}
[42] Fix | Delete
if(! wordfence::wfSchemaExists()){
[43] Fix | Delete
self::errorExit(__("Looks like the Wordfence database tables have been deleted. You can fix this by de-activating and re-activating the Wordfence plugin from your Plugins menu.", 'wordfence'));
[44] Fix | Delete
}
[45] Fix | Delete
if( isset( $_GET['test'] ) && $_GET['test'] == '1'){
[46] Fix | Delete
echo "WFCRONTESTOK:" . wfConfig::get('cronTestID');
[47] Fix | Delete
self::status(4, 'info', __("Cron test received and message printed", 'wordfence'));
[48] Fix | Delete
exit();
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
self::status(4, 'info', __("Scan engine received request.", 'wordfence'));
[52] Fix | Delete
[53] Fix | Delete
/* ----------Starting signature check -------- */
[54] Fix | Delete
self::status(4, 'info', __("Verifying start request signature.", 'wordfence'));
[55] Fix | Delete
if (!isset($_GET['signature']) || !wfScanEngine::verifyStartSignature($_GET['signature'], isset($_GET['isFork']) ? wfUtils::truthyToBoolean($_GET['isFork']) : false, isset($_GET['scanMode']) ? $_GET['scanMode'] : '', isset($_GET['cronKey']) ? $_GET['cronKey'] : '', isset($_GET['remote']) ? wfUtils::truthyToBoolean($_GET['remote']) : false)) {
[56] Fix | Delete
self::errorExit(__('The signature on the request to start a scan is invalid. Please try again.', 'wordfence'));
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/* ----------Starting cronkey check -------- */
[60] Fix | Delete
self::status(4, 'info', __("Fetching stored cronkey for comparison.", 'wordfence'));
[61] Fix | Delete
$expired = false;
[62] Fix | Delete
$storedCronKey = self::storedCronKey($expired);
[63] Fix | Delete
$displayCronKey_received = (isset($_GET['cronKey']) ? (preg_match('/^[a-f0-9]+$/i', $_GET['cronKey']) && strlen($_GET['cronKey']) == 32 ? $_GET['cronKey'] : __('[invalid]', 'wordfence')) : __('[none]', 'wordfence'));
[64] Fix | Delete
$displayCronKey_stored = (!empty($storedCronKey) && !$expired ? $storedCronKey : __('[none]', 'wordfence'));
[65] Fix | Delete
self::status(4, 'info', sprintf(/* translators: 1. WordPress nonce. 2. WordPress nonce. */ __('Checking cronkey: %1$s (expecting %2$s)', 'wordfence'), $displayCronKey_received, $displayCronKey_stored));
[66] Fix | Delete
if (empty($_GET['cronKey'])) {
[67] Fix | Delete
self::status(4, 'error', __("Wordfence scan script accessed directly, or WF did not receive a cronkey.", 'wordfence'));
[68] Fix | Delete
echo "If you see this message it means Wordfence is working correctly. You should not access this URL directly. It is part of the Wordfence security plugin and is designed for internal use only.";
[69] Fix | Delete
exit();
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if ($expired) {
[73] Fix | Delete
self::errorExit(sprintf(
[74] Fix | Delete
/* translators: 1. Unix timestamp. 2. WordPress nonce. 3. Unix timestamp. */
[75] Fix | Delete
__('The key used to start a scan expired. The value is: %1$s and split is: %2$s and time is: %3$d', 'wordfence'), $expired, $storedCronKey, time()));
[76] Fix | Delete
} //keys only last 60 seconds and are used within milliseconds of creation
[77] Fix | Delete
[78] Fix | Delete
if (!$storedCronKey) {
[79] Fix | Delete
wordfence::status(4, 'error', __("Wordfence could not find a saved cron key to start the scan so assuming it started and exiting.", 'wordfence'));
[80] Fix | Delete
exit();
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
self::status(4, 'info', __("Checking saved cronkey against cronkey param", 'wordfence'));
[84] Fix | Delete
if (!hash_equals($storedCronKey, $_GET['cronKey'])) {
[85] Fix | Delete
self::errorExit(
[86] Fix | Delete
sprintf(
[87] Fix | Delete
/* translators: 1. WordPress nonce (used for debugging). 2. WordPress nonce (used for debugging). 3. WordPress nonce (used for debugging). */
[88] Fix | Delete
__('Wordfence could not start a scan because the cron key does not match the saved key. Saved: %1$s Sent: %2$s Current unexploded: %3$s', 'wordfence'),
[89] Fix | Delete
$storedCronKey,
[90] Fix | Delete
$_GET['cronKey'],
[91] Fix | Delete
wfConfig::get('currentCronKey', false)
[92] Fix | Delete
)
[93] Fix | Delete
);
[94] Fix | Delete
}
[95] Fix | Delete
wfConfig::set('currentCronKey', '');
[96] Fix | Delete
/* --------- end cronkey check ---------- */
[97] Fix | Delete
[98] Fix | Delete
wfScanMonitor::logLastSuccess();
[99] Fix | Delete
[100] Fix | Delete
$scanMode = wfScanner::SCAN_TYPE_STANDARD;
[101] Fix | Delete
if (isset($_GET['scanMode']) && wfScanner::isValidScanType($_GET['scanMode'])) {
[102] Fix | Delete
$scanMode = $_GET['scanMode'];
[103] Fix | Delete
}
[104] Fix | Delete
$scanController = new wfScanner($scanMode);
[105] Fix | Delete
[106] Fix | Delete
wfConfig::remove('scanStartAttempt');
[107] Fix | Delete
$isFork = ($_GET['isFork'] == '1' ? true : false);
[108] Fix | Delete
[109] Fix | Delete
wfScanMonitor::handleStageStart($isFork);
[110] Fix | Delete
[111] Fix | Delete
if(! $isFork){
[112] Fix | Delete
self::status(4, 'info', __("Checking if scan is already running", 'wordfence'));
[113] Fix | Delete
if(! wfUtils::getScanLock()){
[114] Fix | Delete
self::errorExit(__("There is already a scan running.", 'wordfence'));
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
wfIssues::updateScanStillRunning();
[118] Fix | Delete
wfConfig::set('wfPeakMemory', 0, wfConfig::DONT_AUTOLOAD);
[119] Fix | Delete
wfConfig::set('wfScanStartVersion', wfUtils::getWPVersion());
[120] Fix | Delete
wfConfig::set('lowResourceScanWaitStep', false);
[121] Fix | Delete
[122] Fix | Delete
if ($scanController->useLowResourceScanning()) {
[123] Fix | Delete
self::status(1, 'info', __("Using low resource scanning", 'wordfence'));
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
self::status(4, 'info', __("Requesting max memory", 'wordfence'));
[127] Fix | Delete
wfUtils::requestMaxMemory();
[128] Fix | Delete
self::status(4, 'info', __("Setting up error handling environment", 'wordfence'));
[129] Fix | Delete
set_error_handler('wfScan::error_handler', E_ALL);
[130] Fix | Delete
register_shutdown_function('wfScan::shutdown');
[131] Fix | Delete
if(! self::$debugMode){
[132] Fix | Delete
ob_start('wfScan::obHandler');
[133] Fix | Delete
}
[134] Fix | Delete
@error_reporting(E_ALL);
[135] Fix | Delete
wfUtils::iniSet('display_errors','On');
[136] Fix | Delete
self::status(4, 'info', __("Setting up scanRunning and starting scan", 'wordfence'));
[137] Fix | Delete
try {
[138] Fix | Delete
if ($isFork) {
[139] Fix | Delete
$scan = wfConfig::get_ser('wfsd_engine', false, false);
[140] Fix | Delete
if ($scan) {
[141] Fix | Delete
self::status(4, 'info', sprintf(/* translators: Error message (used for debugging). */ __("Got a true deserialized value back from 'wfsd_engine' with type: %s", 'wordfence'), gettype($scan)));
[142] Fix | Delete
wfConfig::set('wfsd_engine', '', wfConfig::DONT_AUTOLOAD);
[143] Fix | Delete
}
[144] Fix | Delete
else {
[145] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message (used for debugging). */ __("Scan can't continue - stored data not found after a fork. Got type: %s", 'wordfence'), gettype($scan)));
[146] Fix | Delete
wfConfig::set('wfsd_engine', '', wfConfig::DONT_AUTOLOAD);
[147] Fix | Delete
wfConfig::set('lastScanCompleted', __('Scan can\'t continue - stored data not found after a fork.', 'wordfence'));
[148] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_FORK_FAILED);
[149] Fix | Delete
wfUtils::clearScanLock();
[150] Fix | Delete
self::status(2, 'error', "Scan terminated with error: " . __('Scan can\'t continue - stored data not found after a fork.', 'wordfence'));
[151] Fix | Delete
self::status(10, 'info', "SUM_KILLED:" . __('Previous scan terminated with an error. See below.', 'wordfence'));
[152] Fix | Delete
exit();
[153] Fix | Delete
}
[154] Fix | Delete
}
[155] Fix | Delete
else {
[156] Fix | Delete
$delay = -1;
[157] Fix | Delete
$isScheduled = false;
[158] Fix | Delete
$originalScanStart = wfConfig::get('originalScheduledScanStart', 0);
[159] Fix | Delete
$lastScanStart = wfConfig::get('lastScheduledScanStart', 0);
[160] Fix | Delete
$minimumFrequency = ($scanController->schedulingMode() == wfScanner::SCAN_SCHEDULING_MODE_MANUAL ? 1800 : 43200);
[161] Fix | Delete
if ($lastScanStart && (time() - $lastScanStart) < $minimumFrequency) {
[162] Fix | Delete
$isScheduled = true;
[163] Fix | Delete
[164] Fix | Delete
if ($originalScanStart > 0) {
[165] Fix | Delete
$delay = max($lastScanStart - $originalScanStart, 0);
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
wfIssues::statusPrep(); //Re-initializes all status counters
[170] Fix | Delete
$scanController->resetStages();
[171] Fix | Delete
$scanController->resetSummaryItems();
[172] Fix | Delete
[173] Fix | Delete
if ($scanMode != wfScanner::SCAN_TYPE_QUICK) {
[174] Fix | Delete
wordfence::status(1, 'info', __("Contacting Wordfence to initiate scan", 'wordfence'));
[175] Fix | Delete
$wp_version = wfUtils::getWPVersion();
[176] Fix | Delete
$apiKey = wfConfig::get('apiKey');
[177] Fix | Delete
$api = new wfAPI($apiKey, $wp_version);
[178] Fix | Delete
$response = $api->call('log_scan', array(), array('delay' => $delay, 'scheduled' => (int) $isScheduled, 'mode' => wfConfig::get('schedMode')/*, 'forcedefer' => 1*/));
[179] Fix | Delete
[180] Fix | Delete
if ($scanController->schedulingMode() == wfScanner::SCAN_SCHEDULING_MODE_AUTOMATIC && $isScheduled) {
[181] Fix | Delete
if (isset($response['defer'])) {
[182] Fix | Delete
$defer = (int) $response['defer'];
[183] Fix | Delete
wordfence::status(2, 'info', sprintf(/* translators: Time until. */ __("Deferring scheduled scan by %s", 'wordfence'), wfUtils::makeDuration($defer)));
[184] Fix | Delete
wfConfig::set('lastScheduledScanStart', 0);
[185] Fix | Delete
wfConfig::set('lastScanCompleted', 'ok');
[186] Fix | Delete
wfConfig::set('lastScanFailureType', false);
[187] Fix | Delete
wfConfig::set_ser('wfStatusStartMsgs', array());
[188] Fix | Delete
$scanController->recordLastScanTime();
[189] Fix | Delete
$i = new wfIssues();
[190] Fix | Delete
wfScanEngine::refreshScanNotification($i);
[191] Fix | Delete
wfScanner::shared()->scheduleSingleScan(time() + $defer, $originalScanStart);
[192] Fix | Delete
wfUtils::clearScanLock();
[193] Fix | Delete
exit();
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
$malwarePrefixesHash = (isset($response['malwarePrefixes']) ? $response['malwarePrefixes'] : '');
[198] Fix | Delete
$coreHashesHash = (isset($response['coreHashes']) ? $response['coreHashes'] : '');
[199] Fix | Delete
[200] Fix | Delete
$scan = new wfScanEngine($malwarePrefixesHash, $coreHashesHash, $scanMode);
[201] Fix | Delete
$scan->deleteNewIssues();
[202] Fix | Delete
}
[203] Fix | Delete
else {
[204] Fix | Delete
wordfence::status(1, 'info', __("Initiating quick scan", 'wordfence'));
[205] Fix | Delete
$scan = new wfScanEngine('', '', $scanMode);
[206] Fix | Delete
}
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
$scan->go();
[210] Fix | Delete
}
[211] Fix | Delete
catch (wfScanEngineDurationLimitException $e) { //User error set in wfScanEngine
[212] Fix | Delete
wfUtils::clearScanLock();
[213] Fix | Delete
$peakMemory = self::logPeakMemory();
[214] Fix | Delete
self::status(2, 'info', sprintf(
[215] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[216] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[217] Fix | Delete
wfUtils::formatBytes($peakMemory)
[218] Fix | Delete
));
[219] Fix | Delete
self::status(2, 'error', sprintf(__("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[220] Fix | Delete
exit();
[221] Fix | Delete
}
[222] Fix | Delete
catch (wfScanEngineCoreVersionChangeException $e) { //User error set in wfScanEngine
[223] Fix | Delete
wfUtils::clearScanLock();
[224] Fix | Delete
$peakMemory = self::logPeakMemory();
[225] Fix | Delete
self::status(2, 'info', sprintf(
[226] Fix | Delete
/* translators: 1. Bytes of memory. 2. Bytes of memory. */
[227] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[228] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[229] Fix | Delete
wfUtils::formatBytes($peakMemory)
[230] Fix | Delete
));
[231] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */ __("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[232] Fix | Delete
[233] Fix | Delete
$nextScheduledScan = wfScanner::shared()->nextScheduledScanTime();
[234] Fix | Delete
if ($nextScheduledScan !== false && $nextScheduledScan - time() > 21600 /* 6 hours */) {
[235] Fix | Delete
$nextScheduledScan = time() + 3600;
[236] Fix | Delete
wfScanner::shared()->scheduleSingleScan($nextScheduledScan);
[237] Fix | Delete
}
[238] Fix | Delete
self::status(2, 'error', wordfence::getNextScanStartTime($nextScheduledScan));
[239] Fix | Delete
[240] Fix | Delete
exit();
[241] Fix | Delete
}
[242] Fix | Delete
catch (wfAPICallSSLUnavailableException $e) {
[243] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[244] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_API_SSL_UNAVAILABLE);
[245] Fix | Delete
[246] Fix | Delete
wfUtils::clearScanLock();
[247] Fix | Delete
$peakMemory = self::logPeakMemory();
[248] Fix | Delete
self::status(2, 'info', sprintf(
[249] Fix | Delete
/* translators: 1. Bytes of memory. 2. Bytes of memory. */
[250] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[251] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[252] Fix | Delete
wfUtils::formatBytes($peakMemory)
[253] Fix | Delete
));
[254] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */__("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[255] Fix | Delete
exit();
[256] Fix | Delete
}
[257] Fix | Delete
catch (wfAPICallFailedException $e) {
[258] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[259] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_API_CALL_FAILED);
[260] Fix | Delete
[261] Fix | Delete
wfUtils::clearScanLock();
[262] Fix | Delete
$peakMemory = self::logPeakMemory();
[263] Fix | Delete
self::status(2, 'info', sprintf(
[264] Fix | Delete
/* translators: 1. Bytes of memory. 2. Bytes of memory. */
[265] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[266] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[267] Fix | Delete
wfUtils::formatBytes($peakMemory)
[268] Fix | Delete
));
[269] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */ __("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[270] Fix | Delete
exit();
[271] Fix | Delete
}
[272] Fix | Delete
catch (wfAPICallInvalidResponseException $e) {
[273] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[274] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_API_INVALID_RESPONSE);
[275] Fix | Delete
[276] Fix | Delete
wfUtils::clearScanLock();
[277] Fix | Delete
$peakMemory = self::logPeakMemory();
[278] Fix | Delete
self::status(2, 'info', sprintf(
[279] Fix | Delete
/* translators: 1. Bytes of memory. 2. Bytes of memory. */
[280] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[281] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[282] Fix | Delete
wfUtils::formatBytes($peakMemory)
[283] Fix | Delete
));
[284] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */ __("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[285] Fix | Delete
exit();
[286] Fix | Delete
}
[287] Fix | Delete
catch (wfAPICallErrorResponseException $e) {
[288] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[289] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_API_ERROR_RESPONSE);
[290] Fix | Delete
[291] Fix | Delete
wfUtils::clearScanLock();
[292] Fix | Delete
$peakMemory = self::logPeakMemory();
[293] Fix | Delete
self::status(2, 'info', sprintf(
[294] Fix | Delete
/* translators: 1. Bytes of memory. 2. Bytes of memory. */
[295] Fix | Delete
__('Wordfence used %1$s of memory for scan. Server peak memory usage was: %2$s', 'wordfence'),
[296] Fix | Delete
wfUtils::formatBytes($peakMemory - self::$peakMemAtStart),
[297] Fix | Delete
wfUtils::formatBytes($peakMemory)
[298] Fix | Delete
));
[299] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */ __("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[300] Fix | Delete
[301] Fix | Delete
if (preg_match('/The Wordfence API key you\'re using is already being used by: (\S*?) /', $e->getMessage(), $matches)) {
[302] Fix | Delete
wordfence::alert(__('Wordfence scan failed because of license site URL conflict', 'wordfence'), sprintf(
[303] Fix | Delete
/* translators: Site URL. */
[304] Fix | Delete
__(<<<MSG
[305] Fix | Delete
The Wordfence scan has failed because the Wordfence API key you're using is already being used by: %s
[306] Fix | Delete
[307] Fix | Delete
If you have changed your blog URL, please sign-in to Wordfence, purchase a new key or reset an existing key, and then enter that key on this site's Wordfence Options page.
[308] Fix | Delete
MSG
[309] Fix | Delete
, 'wordfence'), $matches[1]), false);
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
exit();
[313] Fix | Delete
}
[314] Fix | Delete
catch (Exception $e) {
[315] Fix | Delete
wfUtils::clearScanLock();
[316] Fix | Delete
self::status(2, 'error', sprintf(/* translators: Error message. */ __("Scan terminated with error: %s", 'wordfence'), $e->getMessage()));
[317] Fix | Delete
self::status(10, 'info', "SUM_KILLED:" . __('Previous scan terminated with an error. See below.', 'wordfence'));
[318] Fix | Delete
exit();
[319] Fix | Delete
}
[320] Fix | Delete
wfUtils::clearScanLock();
[321] Fix | Delete
}
[322] Fix | Delete
public static function logPeakMemory(){
[323] Fix | Delete
$oldPeak = wfConfig::get('wfPeakMemory', 0, false);
[324] Fix | Delete
$peak = memory_get_peak_usage(true);
[325] Fix | Delete
if ($peak > $oldPeak) {
[326] Fix | Delete
wfConfig::set('wfPeakMemory', $peak, wfConfig::DONT_AUTOLOAD);
[327] Fix | Delete
return $peak;
[328] Fix | Delete
}
[329] Fix | Delete
return $oldPeak;
[330] Fix | Delete
}
[331] Fix | Delete
public static function obHandler($buf){
[332] Fix | Delete
if(strlen($buf) > 1000){
[333] Fix | Delete
$buf = substr($buf, 0, 255);
[334] Fix | Delete
}
[335] Fix | Delete
if(empty($buf) === false && preg_match('/[a-zA-Z0-9]+/', $buf)){
[336] Fix | Delete
self::status(1, 'error', $buf);
[337] Fix | Delete
}
[338] Fix | Delete
}
[339] Fix | Delete
public static function error_handler($errno, $errstr, $errfile, $errline){
[340] Fix | Delete
if(self::$errorHandlingOn && error_reporting() > 0){
[341] Fix | Delete
if(preg_match('/wordfence\//', $errfile)){
[342] Fix | Delete
$level = 1; //It's one of our files, so level 1
[343] Fix | Delete
} else {
[344] Fix | Delete
$level = 4; //It's someone elses plugin so only show if debug is enabled
[345] Fix | Delete
}
[346] Fix | Delete
self::status($level, 'error', "$errstr ($errno) File: $errfile Line: $errline");
[347] Fix | Delete
}
[348] Fix | Delete
return false;
[349] Fix | Delete
}
[350] Fix | Delete
public static function shutdown(){
[351] Fix | Delete
self::logPeakMemory();
[352] Fix | Delete
}
[353] Fix | Delete
private static function errorExit($msg){
[354] Fix | Delete
wordfence::status(1, 'error', sprintf(/* translators: Error message. */ __('Scan Engine Error: %s', 'wordfence'), $msg));
[355] Fix | Delete
exit();
[356] Fix | Delete
}
[357] Fix | Delete
private static function status($level, $type, $msg){
[358] Fix | Delete
wordfence::status($level, $type, $msg);
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function