function load() { if ($this->_checkWordFence()) { if (wfUtils::isScanRunning()) { return array('scan' => 'yes'); } else { return wordfence::ajax_loadIssues_callback(); } } else { return array('warning' => "Word Fence plugin is not activated"); } }
private function start_scan() { $information = array(); if (!class_exists('wordfence') || !class_exists('wfScanEngine')) { $information['error'] = 'NO_WORDFENCE'; return $information; } if (wfUtils::isScanRunning()) { $information['error'] = 'SCAN_RUNNING'; return $information; } $err = wfScanEngine::startScan(); if ($err) { $information['error'] = htmlentities($err); } else { $information['result'] = 'SUCCESS'; } return $information; }
public static function startScan($isFork = false) { if (!$isFork) { //beginning of scan wfConfig::inc('totalScansRun'); wfConfig::set('wfKillRequested', 0); wordfence::status(4, 'info', "Entering start scan routine"); if (wfUtils::isScanRunning()) { return "A scan is already running. Use the kill link if you would like to terminate the current scan."; } } $timeout = self::getMaxExecutionTime() - 2; //2 seconds shorter than max execution time which ensures that only 2 HTTP processes are ever occupied $testURL = admin_url('admin-ajax.php?action=wordfence_testAjax'); if (!wfConfig::get('startScansRemotely', false)) { $testResult = wp_remote_post($testURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => array())); wordfence::status(4, 'info', "Test result of scan start URL fetch: " . var_export($testResult, true)); } $cronKey = wfUtils::bigRandomHex(); wfConfig::set('currentCronKey', time() . ',' . $cronKey); if (!wfConfig::get('startScansRemotely', false) && !is_wp_error($testResult) && is_array($testResult) && strstr($testResult['body'], 'WFSCANTESTOK') !== false) { //ajax requests can be sent by the server to itself $cronURL = 'admin-ajax.php?action=wordfence_doScan&isFork=' . ($isFork ? '1' : '0') . '&cronKey=' . $cronKey; $cronURL = admin_url($cronURL); $headers = array(); wordfence::status(4, 'info', "Starting cron with normal ajax at URL {$cronURL}"); wp_remote_get($cronURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => $headers)); wordfence::status(4, 'info', "Scan process ended after forking."); } else { $cronURL = admin_url('admin-ajax.php'); $cronURL = preg_replace('/^(https?:\\/\\/)/i', '$1noc1.wordfence.com/scanp/', $cronURL); $cronURL .= '?action=wordfence_doScan&isFork=' . ($isFork ? '1' : '0') . '&cronKey=' . $cronKey; $headers = array(); wordfence::status(4, 'info', "Starting cron via proxy at URL {$cronURL}"); wp_remote_get($cronURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => $headers)); wordfence::status(4, 'info', "Scan process ended after forking."); } return false; //No error }
public function getSummaryItems() { if (!$this->updateCalled) { $this->updateCalled = true; $this->updateSummaryItems(); } $arr = wfConfig::get_ser('wf_summaryItems', array()); //$arr['scanTimeAgo'] = wfUtils::makeTimeAgo(sprintf('%.0f', time() - $arr['scanTime'])); $arr['scanRunning'] = wfUtils::isScanRunning() ? '1' : '0'; $arr['scheduledScansEnabled'] = wfConfig::get('scheduledScansEnabled'); $secsToGo = wp_next_scheduled('wordfence_scheduled_scan') - time(); if ($secsToGo < 1) { $nextRun = 'now'; } else { $nextRun = wfUtils::makeTimeAgo($secsToGo) . ' from now'; } $arr['nextRun'] = $nextRun; $arr['totalCritical'] = $this->getDB()->querySingle("select count(*) as cnt from " . $this->issuesTable . " where status='new' and severity=1"); $arr['totalWarning'] = $this->getDB()->querySingle("select count(*) as cnt from " . $this->issuesTable . " where status='new' and severity=2"); return $arr; }