parentHasWordfence() ? self::LV_HARD_WARNING : self::LV_GOOD; } public function getTitle() { return 'Wordfence'; } protected function swarnContent() { return dupxTplRender('parts/validation/tests/wordfence/wordfence-detected', array( 'wordFencePath' => $this->wordFencePath ), false); } protected function hwarnContent() { return dupxTplRender('parts/validation/tests/wordfence/wordfence-detected', array( 'wordFencePath' => $this->wordFencePath ), false); } protected function goodContent() { return dupxTplRender('parts/validation/tests/wordfence/wordfence-not-detected', array(), false); } protected function parentHasWordfence() { $scanPath = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_NEW); $rootPath = SnapIO::getMaxAllowedRootOfPath($scanPath); $result = false; if ($rootPath === false) { //$scanPath is not contained in open_basedir paths skip return false; } LogHandler::setMode(LogHandler::MODE_OFF); $continueScan = true; while ($continueScan) { if ($this->wordFenceFirewallEnabled($scanPath)) { $this->wordFencePath = $scanPath; $result = true; break; } $continueScan = $scanPath !== $rootPath && $scanPath != dirname($scanPath); $scanPath = dirname($scanPath); } LogHandler::setMode(); return $result; } protected function wordFenceFirewallEnabled($path) { $configFiles = array( 'php.ini', '.user.ini', '.htaccess' ); foreach ($configFiles as $configFile) { $file = $path . '/' . $configFile; if (!@is_readable($file)) { continue; } if (($content = @file_get_contents($file)) === false) { continue; } if (strpos($content, 'wordfence-waf.php') !== false) { return true; } } return false; } }