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: wfScanEngine.php
[2500] Fix | Delete
public function addPendingIssue($type, $severity, $ignoreP, $ignoreC, $shortMsg, $longMsg, $templateData) {
[2501] Fix | Delete
wfIssues::updateScanStillRunning();
[2502] Fix | Delete
return $this->i->addPendingIssue($type, $severity, $ignoreP, $ignoreC, $shortMsg, $longMsg, $templateData);
[2503] Fix | Delete
}
[2504] Fix | Delete
[2505] Fix | Delete
public function getPendingIssueCount() {
[2506] Fix | Delete
return $this->i->getPendingIssueCount();
[2507] Fix | Delete
}
[2508] Fix | Delete
[2509] Fix | Delete
public function getPendingIssues($offset = 0, $limit = 100) {
[2510] Fix | Delete
return $this->i->getPendingIssues($offset, $limit);
[2511] Fix | Delete
}
[2512] Fix | Delete
[2513] Fix | Delete
public static function requestKill() {
[2514] Fix | Delete
wfScanMonitor::endMonitoring();
[2515] Fix | Delete
wfConfig::set('wfKillRequested', time(), wfConfig::DONT_AUTOLOAD);
[2516] Fix | Delete
}
[2517] Fix | Delete
[2518] Fix | Delete
public static function checkForKill() {
[2519] Fix | Delete
$kill = wfConfig::get('wfKillRequested', 0);
[2520] Fix | Delete
if ($kill && time() - $kill < 600) { //Kill lasts for 10 minutes
[2521] Fix | Delete
wordfence::status(10, 'info', "SUM_KILLED:" . __('Previous scan was stopped successfully.', 'wordfence'));
[2522] Fix | Delete
throw new Exception(__("Scan was stopped on administrator request.", 'wordfence'), wfScanEngine::SCAN_MANUALLY_KILLED);
[2523] Fix | Delete
}
[2524] Fix | Delete
}
[2525] Fix | Delete
[2526] Fix | Delete
public static function startScan($isFork = false, $scanMode = false, $isResume = false) {
[2527] Fix | Delete
if (!defined('DONOTCACHEDB')) {
[2528] Fix | Delete
define('DONOTCACHEDB', true);
[2529] Fix | Delete
}
[2530] Fix | Delete
[2531] Fix | Delete
if ($scanMode === false) {
[2532] Fix | Delete
$scanMode = wfScanner::shared()->scanType();
[2533] Fix | Delete
}
[2534] Fix | Delete
[2535] Fix | Delete
if (!$isFork) { //beginning of scan
[2536] Fix | Delete
wfConfig::inc('totalScansRun');
[2537] Fix | Delete
wfConfig::set('wfKillRequested', 0, wfConfig::DONT_AUTOLOAD);
[2538] Fix | Delete
wordfence::status(4, 'info', __("Entering start scan routine", 'wordfence'));
[2539] Fix | Delete
if (wfScanner::shared()->isRunning()) {
[2540] Fix | Delete
return __("A scan is already running. Use the stop scan button if you would like to terminate the current scan.", 'wordfence');
[2541] Fix | Delete
}
[2542] Fix | Delete
wfConfig::set('currentCronKey', ''); //Ensure the cron key is cleared
[2543] Fix | Delete
if (!$isResume)
[2544] Fix | Delete
wfScanMonitor::handleScanStart($scanMode);
[2545] Fix | Delete
}
[2546] Fix | Delete
wfScanMonitor::logLastAttempt($isFork);
[2547] Fix | Delete
$timeout = self::getMaxExecutionTime() - 2; //2 seconds shorter than max execution time which ensures that only 2 HTTP processes are ever occupied
[2548] Fix | Delete
$testURL = admin_url('admin-ajax.php?action=wordfence_testAjax');
[2549] Fix | Delete
$forceIpv4 = wfConfig::get('scan_force_ipv4_start');
[2550] Fix | Delete
$interceptor = new wfCurlInterceptor($forceIpv4);
[2551] Fix | Delete
if ($forceIpv4)
[2552] Fix | Delete
$interceptor->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
[2553] Fix | Delete
if (!wfConfig::get('startScansRemotely', false)) {
[2554] Fix | Delete
if ($isFork) {
[2555] Fix | Delete
$testSuccessful = (bool) wfConfig::get('scanAjaxTestSuccessful');
[2556] Fix | Delete
wordfence::status(4, 'info', sprintf(__("Cached result for scan start test: %s", 'wordfence'), var_export($testSuccessful, true)));
[2557] Fix | Delete
}
[2558] Fix | Delete
else {
[2559] Fix | Delete
try {
[2560] Fix | Delete
$testResult = $interceptor->intercept(function () use ($testURL, $timeout) {
[2561] Fix | Delete
return wp_remote_post($testURL, array(
[2562] Fix | Delete
'timeout' => $timeout,
[2563] Fix | Delete
'blocking' => true,
[2564] Fix | Delete
'sslverify' => false,
[2565] Fix | Delete
'headers' => array()
[2566] Fix | Delete
));
[2567] Fix | Delete
});
[2568] Fix | Delete
} catch (Exception $e) {
[2569] Fix | Delete
//Fall through to the remote start test below
[2570] Fix | Delete
}
[2571] Fix | Delete
[2572] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: Scan start test result data. */ __("Test result of scan start URL fetch: %s", 'wordfence'), var_export($testResult, true)));
[2573] Fix | Delete
[2574] Fix | Delete
$testSuccessful = !is_wp_error($testResult) && (is_array($testResult) || $testResult instanceof ArrayAccess) && strstr($testResult['body'], 'WFSCANTESTOK') !== false;
[2575] Fix | Delete
wfConfig::set('scanAjaxTestSuccessful', $testSuccessful);
[2576] Fix | Delete
}
[2577] Fix | Delete
}
[2578] Fix | Delete
[2579] Fix | Delete
$cronKey = wfUtils::bigRandomHex();
[2580] Fix | Delete
wfConfig::set('currentCronKey', time() . ',' . $cronKey);
[2581] Fix | Delete
if ((!wfConfig::get('startScansRemotely', false)) && $testSuccessful) {
[2582] Fix | Delete
//ajax requests can be sent by the server to itself
[2583] Fix | Delete
$cronURL = self::_localStartURL($isFork, $scanMode, $cronKey);
[2584] Fix | Delete
$headers = array('Referer' => false/*, 'Cookie' => 'XDEBUG_SESSION=1'*/);
[2585] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: WordPress admin panel URL. */ __("Starting cron with normal ajax at URL %s", 'wordfence'), $cronURL));
[2586] Fix | Delete
[2587] Fix | Delete
try {
[2588] Fix | Delete
wfConfig::set('scanStartAttempt', time());
[2589] Fix | Delete
$response = $interceptor->intercept(function () use ($cronURL, $headers) {
[2590] Fix | Delete
return wp_remote_get($cronURL, array(
[2591] Fix | Delete
'timeout' => 0.01,
[2592] Fix | Delete
'blocking' => false,
[2593] Fix | Delete
'sslverify' => false,
[2594] Fix | Delete
'headers' => $headers
[2595] Fix | Delete
));
[2596] Fix | Delete
});
[2597] Fix | Delete
if (wfCentral::isConnected()) {
[2598] Fix | Delete
wfCentral::updateScanStatus();
[2599] Fix | Delete
}
[2600] Fix | Delete
} catch (Exception $e) {
[2601] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[2602] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_CALLBACK_TEST_FAILED);
[2603] Fix | Delete
return false;
[2604] Fix | Delete
}
[2605] Fix | Delete
[2606] Fix | Delete
if (is_wp_error($response)) {
[2607] Fix | Delete
$error_message = $response->get_error_message();
[2608] Fix | Delete
if ($error_message) {
[2609] Fix | Delete
$lastScanCompletedMessage = sprintf(/* translators: Error message. */ __("There was an error starting the scan: %s.", 'wordfence'), $error_message);
[2610] Fix | Delete
} else {
[2611] Fix | Delete
$lastScanCompletedMessage = __("There was an unknown error starting the scan.", 'wordfence');
[2612] Fix | Delete
}
[2613] Fix | Delete
[2614] Fix | Delete
wfConfig::set('lastScanCompleted', $lastScanCompletedMessage);
[2615] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_CALLBACK_TEST_FAILED);
[2616] Fix | Delete
}
[2617] Fix | Delete
[2618] Fix | Delete
wordfence::status(4, 'info', __("Scan process ended after forking.", 'wordfence'));
[2619] Fix | Delete
} else {
[2620] Fix | Delete
$cronURL = self::_remoteStartURL($isFork, $scanMode, $cronKey);
[2621] Fix | Delete
$headers = array();
[2622] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: WordPress admin panel URL. */ __("Starting cron via proxy at URL %s", 'wordfence'), $cronURL));
[2623] Fix | Delete
[2624] Fix | Delete
try {
[2625] Fix | Delete
wfConfig::set('scanStartAttempt', time());
[2626] Fix | Delete
$response = wp_remote_get($cronURL, array(
[2627] Fix | Delete
'timeout' => 0.01,
[2628] Fix | Delete
'blocking' => false,
[2629] Fix | Delete
'sslverify' => false,
[2630] Fix | Delete
'headers' => $headers
[2631] Fix | Delete
));
[2632] Fix | Delete
if (wfCentral::isConnected()) {
[2633] Fix | Delete
wfCentral::updateScanStatus();
[2634] Fix | Delete
}
[2635] Fix | Delete
} catch (Exception $e) {
[2636] Fix | Delete
wfConfig::set('lastScanCompleted', $e->getMessage());
[2637] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_CALLBACK_TEST_FAILED);
[2638] Fix | Delete
return false;
[2639] Fix | Delete
}
[2640] Fix | Delete
[2641] Fix | Delete
if (is_wp_error($response)) {
[2642] Fix | Delete
$error_message = $response->get_error_message();
[2643] Fix | Delete
if ($error_message) {
[2644] Fix | Delete
$lastScanCompletedMessage = sprintf(/* translators: WordPress admin panel URL. */ __("There was an error starting the scan: %s.", 'wordfence'), $error_message);
[2645] Fix | Delete
} else {
[2646] Fix | Delete
$lastScanCompletedMessage = __("There was an unknown error starting the scan.", 'wordfence');
[2647] Fix | Delete
}
[2648] Fix | Delete
wfConfig::set('lastScanCompleted', $lastScanCompletedMessage);
[2649] Fix | Delete
wfConfig::set('lastScanFailureType', wfIssues::SCAN_FAILED_CALLBACK_TEST_FAILED);
[2650] Fix | Delete
}
[2651] Fix | Delete
[2652] Fix | Delete
wordfence::status(4, 'info', __("Scan process ended after forking.", 'wordfence'));
[2653] Fix | Delete
}
[2654] Fix | Delete
return false; //No error
[2655] Fix | Delete
}
[2656] Fix | Delete
[2657] Fix | Delete
public static function verifyStartSignature($signature, $isFork, $scanMode, $cronKey, $remote) {
[2658] Fix | Delete
$url = self::_baseStartURL($isFork, $scanMode, $cronKey);
[2659] Fix | Delete
if ($remote) {
[2660] Fix | Delete
$url = self::_remoteStartURL($isFork, $scanMode, $cronKey);
[2661] Fix | Delete
$url = remove_query_arg('signature', $url);
[2662] Fix | Delete
}
[2663] Fix | Delete
$test = self::_signStartURL($url);
[2664] Fix | Delete
return hash_equals($signature, $test);
[2665] Fix | Delete
}
[2666] Fix | Delete
[2667] Fix | Delete
protected static function _baseStartURL($isFork, $scanMode, $cronKey) {
[2668] Fix | Delete
$url = admin_url('admin-ajax.php');
[2669] Fix | Delete
$url .= '?action=wordfence_doScan&isFork=' . ($isFork ? '1' : '0') . '&scanMode=' . urlencode($scanMode) . '&cronKey=' . urlencode($cronKey);
[2670] Fix | Delete
return $url;
[2671] Fix | Delete
}
[2672] Fix | Delete
[2673] Fix | Delete
protected static function _localStartURL($isFork, $scanMode, $cronKey) {
[2674] Fix | Delete
$url = self::_baseStartURL($isFork, $scanMode, $cronKey);
[2675] Fix | Delete
return add_query_arg('signature', self::_signStartURL($url), $url);
[2676] Fix | Delete
}
[2677] Fix | Delete
[2678] Fix | Delete
protected static function _remoteStartURL($isFork, $scanMode, $cronKey) {
[2679] Fix | Delete
$url = self::_baseStartURL($isFork, $scanMode, $cronKey);
[2680] Fix | Delete
$url = preg_replace('/^https?:\/\//i', (wfAPI::SSLEnabled() ? WORDFENCE_API_URL_SEC : WORDFENCE_API_URL_NONSEC) . 'scanp/', $url);
[2681] Fix | Delete
$url = add_query_arg('k', wfConfig::get('apiKey'), $url);
[2682] Fix | Delete
$url = add_query_arg('ssl', wfUtils::isFullSSL() ? '1' : '0', $url);
[2683] Fix | Delete
return add_query_arg('signature', self::_signStartURL($url), $url);
[2684] Fix | Delete
}
[2685] Fix | Delete
[2686] Fix | Delete
protected static function _signStartURL($url) {
[2687] Fix | Delete
$payload = preg_replace('~^https?://[^/]+~i', '', $url);
[2688] Fix | Delete
return wfCrypt::local_sign($payload);
[2689] Fix | Delete
}
[2690] Fix | Delete
[2691] Fix | Delete
public function processResponse($result) {
[2692] Fix | Delete
return false;
[2693] Fix | Delete
}
[2694] Fix | Delete
[2695] Fix | Delete
public static function getMaxExecutionTime($staySilent = false) {
[2696] Fix | Delete
$config = wfConfig::get('maxExecutionTime');
[2697] Fix | Delete
if (!$staySilent) {
[2698] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: Time in seconds. */ __("Got value from wf config maxExecutionTime: %s", 'wordfence'), $config));
[2699] Fix | Delete
}
[2700] Fix | Delete
if (is_numeric($config) && $config >= WORDFENCE_SCAN_MIN_EXECUTION_TIME) {
[2701] Fix | Delete
if (!$staySilent) {
[2702] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: Time in seconds. */ __("getMaxExecutionTime() returning config value: %s", 'wordfence'), $config));
[2703] Fix | Delete
}
[2704] Fix | Delete
return $config;
[2705] Fix | Delete
}
[2706] Fix | Delete
[2707] Fix | Delete
$ini = @ini_get('max_execution_time');
[2708] Fix | Delete
if (!$staySilent) {
[2709] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: PHP ini value. */ __("Got max_execution_time value from ini: %s", 'wordfence'), $ini));
[2710] Fix | Delete
}
[2711] Fix | Delete
if (is_numeric($ini) && $ini >= WORDFENCE_SCAN_MIN_EXECUTION_TIME) {
[2712] Fix | Delete
if ($ini > WORDFENCE_SCAN_MAX_INI_EXECUTION_TIME) {
[2713] Fix | Delete
if (!$staySilent) {
[2714] Fix | Delete
wordfence::status(4, 'info', sprintf(
[2715] Fix | Delete
/* translators: 1. PHP ini setting. 2. Time in seconds. */
[2716] Fix | Delete
__('ini value of %1$d is higher than value for WORDFENCE_SCAN_MAX_INI_EXECUTION_TIME (%2$d), reducing', 'wordfence'),
[2717] Fix | Delete
$ini,
[2718] Fix | Delete
WORDFENCE_SCAN_MAX_INI_EXECUTION_TIME
[2719] Fix | Delete
));
[2720] Fix | Delete
}
[2721] Fix | Delete
$ini = WORDFENCE_SCAN_MAX_INI_EXECUTION_TIME;
[2722] Fix | Delete
}
[2723] Fix | Delete
[2724] Fix | Delete
$ini = floor($ini / 2);
[2725] Fix | Delete
if (!$staySilent) {
[2726] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: PHP ini setting. */ __("getMaxExecutionTime() returning half ini value: %d", 'wordfence'), $ini));
[2727] Fix | Delete
}
[2728] Fix | Delete
return $ini;
[2729] Fix | Delete
}
[2730] Fix | Delete
[2731] Fix | Delete
if (!$staySilent) {
[2732] Fix | Delete
wordfence::status(4, 'info', __("getMaxExecutionTime() returning default of: 15", 'wordfence'));
[2733] Fix | Delete
}
[2734] Fix | Delete
return 15;
[2735] Fix | Delete
}
[2736] Fix | Delete
[2737] Fix | Delete
/**
[2738] Fix | Delete
* @return wfScanKnownFilesLoader
[2739] Fix | Delete
*/
[2740] Fix | Delete
public function getKnownFilesLoader() {
[2741] Fix | Delete
if ($this->knownFilesLoader === null) {
[2742] Fix | Delete
$this->knownFilesLoader = new wfScanKnownFilesLoader($this->api, $this->getPlugins(), $this->getThemes());
[2743] Fix | Delete
}
[2744] Fix | Delete
return $this->knownFilesLoader;
[2745] Fix | Delete
}
[2746] Fix | Delete
[2747] Fix | Delete
/**
[2748] Fix | Delete
* @return array
[2749] Fix | Delete
*/
[2750] Fix | Delete
public function getPlugins() {
[2751] Fix | Delete
static $plugins = null;
[2752] Fix | Delete
if ($plugins !== null) {
[2753] Fix | Delete
return $plugins;
[2754] Fix | Delete
}
[2755] Fix | Delete
[2756] Fix | Delete
if (!function_exists('get_plugins')) {
[2757] Fix | Delete
require_once(ABSPATH . '/wp-admin/includes/plugin.php');
[2758] Fix | Delete
}
[2759] Fix | Delete
$pluginData = get_plugins();
[2760] Fix | Delete
$plugins = array();
[2761] Fix | Delete
foreach ($pluginData as $key => $data) {
[2762] Fix | Delete
if (preg_match('/^([^\/]+)\//', $key, $matches)) {
[2763] Fix | Delete
$pluginDir = $matches[1];
[2764] Fix | Delete
$pluginFullDir = "wp-content/plugins/" . $pluginDir;
[2765] Fix | Delete
$plugins[$key] = array(
[2766] Fix | Delete
'Name' => $data['Name'],
[2767] Fix | Delete
'Version' => $data['Version'],
[2768] Fix | Delete
'ShortDir' => $pluginDir,
[2769] Fix | Delete
'FullDir' => $pluginFullDir
[2770] Fix | Delete
);
[2771] Fix | Delete
}
[2772] Fix | Delete
if (!$this->pluginsCounted) {
[2773] Fix | Delete
$this->scanController->incrementSummaryItem(wfScanner::SUMMARY_SCANNED_PLUGINS);
[2774] Fix | Delete
}
[2775] Fix | Delete
}
[2776] Fix | Delete
[2777] Fix | Delete
$this->pluginsCounted = true;
[2778] Fix | Delete
return $plugins;
[2779] Fix | Delete
}
[2780] Fix | Delete
[2781] Fix | Delete
/**
[2782] Fix | Delete
* @return array
[2783] Fix | Delete
*/
[2784] Fix | Delete
public function getThemes() {
[2785] Fix | Delete
static $themes = null;
[2786] Fix | Delete
if ($themes !== null) {
[2787] Fix | Delete
return $themes;
[2788] Fix | Delete
}
[2789] Fix | Delete
[2790] Fix | Delete
if (!function_exists('wp_get_themes')) {
[2791] Fix | Delete
require_once(ABSPATH . '/wp-includes/theme.php');
[2792] Fix | Delete
}
[2793] Fix | Delete
$themeData = wp_get_themes();
[2794] Fix | Delete
$themes = array();
[2795] Fix | Delete
foreach ($themeData as $themeName => $themeVal) {
[2796] Fix | Delete
if (preg_match('/\/([^\/]+)$/', $themeVal['Stylesheet Dir'], $matches)) {
[2797] Fix | Delete
$shortDir = $matches[1]; //e.g. evo4cms
[2798] Fix | Delete
$fullDir = "wp-content/themes/{$shortDir}"; //e.g. wp-content/themes/evo4cms
[2799] Fix | Delete
$themes[$themeName] = array(
[2800] Fix | Delete
'Name' => $themeVal['Name'],
[2801] Fix | Delete
'Version' => $themeVal['Version'],
[2802] Fix | Delete
'ShortDir' => $shortDir,
[2803] Fix | Delete
'FullDir' => $fullDir
[2804] Fix | Delete
);
[2805] Fix | Delete
}
[2806] Fix | Delete
if (!$this->themesCounted) {
[2807] Fix | Delete
$this->scanController->incrementSummaryItem(wfScanner::SUMMARY_SCANNED_THEMES);
[2808] Fix | Delete
}
[2809] Fix | Delete
}
[2810] Fix | Delete
[2811] Fix | Delete
$this->themesCounted = true;
[2812] Fix | Delete
return $themes;
[2813] Fix | Delete
}
[2814] Fix | Delete
[2815] Fix | Delete
public function recordMetric($type, $key, $value, $singular = true) {
[2816] Fix | Delete
if (!isset($this->metrics[$type])) {
[2817] Fix | Delete
$this->metrics[$type] = array();
[2818] Fix | Delete
}
[2819] Fix | Delete
[2820] Fix | Delete
if (!isset($this->metrics[$type][$key])) {
[2821] Fix | Delete
$this->metrics[$type][$key] = array();
[2822] Fix | Delete
}
[2823] Fix | Delete
[2824] Fix | Delete
if ($singular) {
[2825] Fix | Delete
$this->metrics[$type][$key] = $value;
[2826] Fix | Delete
} else {
[2827] Fix | Delete
$this->metrics[$type][$key][] = $value;
[2828] Fix | Delete
}
[2829] Fix | Delete
}
[2830] Fix | Delete
[2831] Fix | Delete
/**
[2832] Fix | Delete
* Queries the is_safe_file endpoint. If provided an array, it does a bulk check and returns an array containing the
[2833] Fix | Delete
* hashes that were marked as safe. If provided a string, it returns a boolean to indicate the safeness of the file.
[2834] Fix | Delete
*
[2835] Fix | Delete
* @param string|array $shac
[2836] Fix | Delete
* @return array|bool
[2837] Fix | Delete
*/
[2838] Fix | Delete
public function isSafeFile($shac) {
[2839] Fix | Delete
if (is_array($shac)) {
[2840] Fix | Delete
$result = $this->api->call('is_safe_file', array(), array('multipleSHAC' => json_encode($shac)));
[2841] Fix | Delete
if (isset($result['isSafe'])) {
[2842] Fix | Delete
return $result['isSafe'];
[2843] Fix | Delete
}
[2844] Fix | Delete
return array();
[2845] Fix | Delete
}
[2846] Fix | Delete
$result = $this->api->call('is_safe_file', array(), array('shac' => strtoupper($shac)));
[2847] Fix | Delete
return isset($result['isSafe']) && $result['isSafe'] == 1;
[2848] Fix | Delete
}
[2849] Fix | Delete
}
[2850] Fix | Delete
[2851] Fix | Delete
class wfScanKnownFilesLoader {
[2852] Fix | Delete
/**
[2853] Fix | Delete
* @var array
[2854] Fix | Delete
*/
[2855] Fix | Delete
private $plugins;
[2856] Fix | Delete
[2857] Fix | Delete
/**
[2858] Fix | Delete
* @var array
[2859] Fix | Delete
*/
[2860] Fix | Delete
private $themes;
[2861] Fix | Delete
[2862] Fix | Delete
/**
[2863] Fix | Delete
* @var array
[2864] Fix | Delete
*/
[2865] Fix | Delete
private $knownFiles = array();
[2866] Fix | Delete
[2867] Fix | Delete
/**
[2868] Fix | Delete
* @var wfAPI
[2869] Fix | Delete
*/
[2870] Fix | Delete
private $api;
[2871] Fix | Delete
[2872] Fix | Delete
[2873] Fix | Delete
/**
[2874] Fix | Delete
* @param wfAPI $api
[2875] Fix | Delete
* @param array $plugins
[2876] Fix | Delete
* @param array $themes
[2877] Fix | Delete
*/
[2878] Fix | Delete
public function __construct($api, $plugins = null, $themes = null) {
[2879] Fix | Delete
$this->api = $api;
[2880] Fix | Delete
$this->plugins = $plugins;
[2881] Fix | Delete
$this->themes = $themes;
[2882] Fix | Delete
}
[2883] Fix | Delete
[2884] Fix | Delete
/**
[2885] Fix | Delete
* @return bool
[2886] Fix | Delete
*/
[2887] Fix | Delete
public function isLoaded() {
[2888] Fix | Delete
return is_array($this->knownFiles) && count($this->knownFiles) > 0;
[2889] Fix | Delete
}
[2890] Fix | Delete
[2891] Fix | Delete
/**
[2892] Fix | Delete
* @param $file
[2893] Fix | Delete
* @return bool
[2894] Fix | Delete
* @throws wfScanKnownFilesException
[2895] Fix | Delete
*/
[2896] Fix | Delete
public function isKnownFile($file) {
[2897] Fix | Delete
if (!$this->isLoaded()) {
[2898] Fix | Delete
$this->fetchKnownFiles();
[2899] Fix | Delete
}
[2900] Fix | Delete
[2901] Fix | Delete
return isset($this->knownFiles['core'][$file]) ||
[2902] Fix | Delete
isset($this->knownFiles['plugins'][$file]) ||
[2903] Fix | Delete
isset($this->knownFiles['themes'][$file]);
[2904] Fix | Delete
}
[2905] Fix | Delete
[2906] Fix | Delete
/**
[2907] Fix | Delete
* @param $file
[2908] Fix | Delete
* @return bool
[2909] Fix | Delete
* @throws wfScanKnownFilesException
[2910] Fix | Delete
*/
[2911] Fix | Delete
public function isKnownCoreFile($file) {
[2912] Fix | Delete
if (!$this->isLoaded()) {
[2913] Fix | Delete
$this->fetchKnownFiles();
[2914] Fix | Delete
}
[2915] Fix | Delete
return isset($this->knownFiles['core'][$file]);
[2916] Fix | Delete
}
[2917] Fix | Delete
[2918] Fix | Delete
/**
[2919] Fix | Delete
* @param $file
[2920] Fix | Delete
* @return bool
[2921] Fix | Delete
* @throws wfScanKnownFilesException
[2922] Fix | Delete
*/
[2923] Fix | Delete
public function isKnownPluginFile($file) {
[2924] Fix | Delete
if (!$this->isLoaded()) {
[2925] Fix | Delete
$this->fetchKnownFiles();
[2926] Fix | Delete
}
[2927] Fix | Delete
return isset($this->knownFiles['plugins'][$file]);
[2928] Fix | Delete
}
[2929] Fix | Delete
[2930] Fix | Delete
/**
[2931] Fix | Delete
* @param $file
[2932] Fix | Delete
* @return bool
[2933] Fix | Delete
* @throws wfScanKnownFilesException
[2934] Fix | Delete
*/
[2935] Fix | Delete
public function isKnownThemeFile($file) {
[2936] Fix | Delete
if (!$this->isLoaded()) {
[2937] Fix | Delete
$this->fetchKnownFiles();
[2938] Fix | Delete
}
[2939] Fix | Delete
return isset($this->knownFiles['themes'][$file]);
[2940] Fix | Delete
}
[2941] Fix | Delete
[2942] Fix | Delete
/**
[2943] Fix | Delete
* @throws wfScanKnownFilesException
[2944] Fix | Delete
*/
[2945] Fix | Delete
public function fetchKnownFiles() {
[2946] Fix | Delete
try {
[2947] Fix | Delete
$dataArr = $this->api->binCall('get_known_files', json_encode(array(
[2948] Fix | Delete
'plugins' => $this->plugins,
[2949] Fix | Delete
'themes' => $this->themes
[2950] Fix | Delete
)));
[2951] Fix | Delete
[2952] Fix | Delete
if ($dataArr['code'] != 200) {
[2953] Fix | Delete
throw new wfScanKnownFilesException(sprintf(/* translators: 1. HTTP status code. */ __("Got error response from Wordfence servers: %s", 'wordfence'), $dataArr['code']), $dataArr['code']);
[2954] Fix | Delete
}
[2955] Fix | Delete
$this->knownFiles = @json_decode($dataArr['data'], true);
[2956] Fix | Delete
if (!is_array($this->knownFiles)) {
[2957] Fix | Delete
throw new wfScanKnownFilesException(__("Invalid response from Wordfence servers.", 'wordfence'));
[2958] Fix | Delete
}
[2959] Fix | Delete
} catch (Exception $e) {
[2960] Fix | Delete
throw new wfScanKnownFilesException($e->getMessage(), $e->getCode(), $e);
[2961] Fix | Delete
}
[2962] Fix | Delete
}
[2963] Fix | Delete
[2964] Fix | Delete
public function getKnownPluginData($file) {
[2965] Fix | Delete
if ($this->isKnownPluginFile($file)) {
[2966] Fix | Delete
return $this->knownFiles['plugins'][$file];
[2967] Fix | Delete
}
[2968] Fix | Delete
return null;
[2969] Fix | Delete
}
[2970] Fix | Delete
[2971] Fix | Delete
public function getKnownThemeData($file) {
[2972] Fix | Delete
if ($this->isKnownThemeFile($file)) {
[2973] Fix | Delete
return $this->knownFiles['themes'][$file];
[2974] Fix | Delete
}
[2975] Fix | Delete
return null;
[2976] Fix | Delete
}
[2977] Fix | Delete
[2978] Fix | Delete
/**
[2979] Fix | Delete
* @return array
[2980] Fix | Delete
*/
[2981] Fix | Delete
public function getPlugins() {
[2982] Fix | Delete
return $this->plugins;
[2983] Fix | Delete
}
[2984] Fix | Delete
[2985] Fix | Delete
/**
[2986] Fix | Delete
* @param array $plugins
[2987] Fix | Delete
*/
[2988] Fix | Delete
public function setPlugins($plugins) {
[2989] Fix | Delete
$this->plugins = $plugins;
[2990] Fix | Delete
}
[2991] Fix | Delete
[2992] Fix | Delete
/**
[2993] Fix | Delete
* @return array
[2994] Fix | Delete
*/
[2995] Fix | Delete
public function getThemes() {
[2996] Fix | Delete
return $this->themes;
[2997] Fix | Delete
}
[2998] Fix | Delete
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function