/home/vianto5/.trash/cititower.mx/wp-content/plugins/wordfence/lib
Edit: /home/vianto5/.trash/cititower.mx/wp-content/plugins/wordfence/lib/wfScanMonitor.php (4152B)
self::MAX_RESUME_ATTEMPTS) {
$valid = false;
return self::DEFAULT_RESUME_ATTEMPTS;
}
$valid = true;
return $attempts;
}
private static function setRemainingResumeAttempts($attempts) {
wfConfig::set(self::CONFIG_REMAINING_RESUME_ATTEMPTS, $attempts);
}
public static function getConfiguredResumeAttempts() {
$attempts = (int) wfConfig::get(self::CONFIG_MAX_RESUME_ATTEMPTS, self::DEFAULT_RESUME_ATTEMPTS);
return self::validateResumeAttempts($attempts);
}
private static function resetResumeAttemptCounter() {
$attempts = self::getConfiguredResumeAttempts();
self::setRemainingResumeAttempts($attempts);
return $attempts;
}
private static function getRemainingResumeAttempts() {
$attempts = (int) wfConfig::get(self::CONFIG_REMAINING_RESUME_ATTEMPTS, 0);
return self::validateResumeAttempts($attempts);
}
public static function handleScanStart($mode) {
wfConfig::set(self::CONFIG_LAST_ATTEMPT_MODE, $mode);
$maxAttempts = self::resetResumeAttemptCounter();
if ($maxAttempts > 0)
self::beginMonitoring();
}
public static function monitorScan() {
$remainingAttempts = self::getRemainingResumeAttempts();
if ($remainingAttempts > 0) {
$now = time();
$lastAttempt = wfConfig::get(self::CONFIG_LAST_ATTEMPT);
if ($lastAttempt === null || $now - $lastAttempt < self::SCAN_START_TIMEOUT)
return;
$lastSuccess = wfConfig::get(self::CONFIG_LAST_SUCCESS);
self::setRemainingResumeAttempts(--$remainingAttempts);
if ($lastSuccess === null || $lastAttempt > $lastSuccess) {
wordfence::status(2, 'info', sprintf(__('Attempting to resume scan stage (%d attempt(s) remaining)...', 'wordfence'), $remainingAttempts));
self::resumeScan();
}
}
else {
self::endMonitoring();
}
}
private static function resumeScan() {
$mode = wfConfig::get(self::CONFIG_LAST_ATTEMPT_MODE);
if (!wfScanner::isValidScanType($mode))
$mode = false;
wfScanEngine::startScan(wfConfig::get(self::CONFIG_LAST_ATTEMPT_WAS_FORK), $mode, true);
}
private static function logTimestamp($key) {
wfConfig::set($key, time());
}
public static function logLastAttempt($fork) {
self::logTimestamp(self::CONFIG_LAST_ATTEMPT);
wfConfig::set(self::CONFIG_LAST_ATTEMPT_WAS_FORK, $fork);
}
public static function logLastSuccess() {
self::logTimestamp(self::CONFIG_LAST_SUCCESS);
}
public static function handleStageStart($fork) {
if ($fork)
self::resetResumeAttemptCounter();
}
public static function registerCronInterval($schedules) {
if (!array_key_exists(self::CRON_INTERVAL_NAME, $schedules)) {
$schedules[self::CRON_INTERVAL_NAME] = array(
'interval' => self::CRON_INTERVAL_AMOUNT,
'display' => 'Wordfence Scan Monitor'
);
}
return $schedules;
}
public static function registerActions() {
add_filter('cron_schedules', array(self::class, 'registerCronInterval'));
add_action(self::CRON_HOOK, array(self::class, 'monitorScan'));
}
public static function handleDeactivation() {
self::endMonitoring();
}
}