当前位置: 首页>>代码示例>>PHP>>正文


PHP wfConfig::set方法代码示例

本文整理汇总了PHP中wfConfig::set方法的典型用法代码示例。如果您正苦于以下问题:PHP wfConfig::set方法的具体用法?PHP wfConfig::set怎么用?PHP wfConfig::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wfConfig的用法示例。


在下文中一共展示了wfConfig::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: call

 public function call($action, $getParams = array(), $postParams = array(), $forceSSL = false)
 {
     $apiURL = $this->getAPIURL();
     //Sanity check. Developer should call wfAPI::SSLEnabled() to check if SSL is enabled before forcing SSL and return a user friendly msg if it's not.
     if ($forceSSL && !preg_match('/^https:/i', $apiURL)) {
         //User's should never see this message unless we aren't calling SSLEnabled() to check if SSL is enabled before using call() with forceSSL
         throw new Exception("SSL is not supported by your web server and is required to use this function. Please ask your hosting provider or site admin to install cURL with openSSL to use this feature.");
     }
     $json = $this->getURL($apiURL . '/v' . WORDFENCE_API_VERSION . '/?' . $this->makeAPIQueryString() . '&' . self::buildQuery(array_merge(array('action' => $action), $getParams)), $postParams);
     if (!$json) {
         throw new Exception("We received an empty data response from the Wordfence scanning servers when calling the '{$action}' function.");
     }
     $dat = json_decode($json, true);
     if (isset($dat['_isPaidKey'])) {
         wfConfig::set('keyExpDays', $dat['_keyExpDays']);
         if ($dat['_keyExpDays'] > -1) {
             wfConfig::set('isPaid', 1);
         } else {
             if ($dat['_keyExpDays'] < 0) {
                 wfConfig::set('isPaid', '');
             }
         }
     }
     if (!is_array($dat)) {
         throw new Exception("We received a data structure that is not the expected array when contacting the Wordfence scanning servers and calling the '{$action}' function.");
     }
     if (is_array($dat) && isset($dat['errorMsg'])) {
         throw new Exception($dat['errorMsg']);
     }
     return $dat;
 }
开发者ID:rootwork,项目名称:friendsoffifth,代码行数:31,代码来源:wfAPI.php

示例2: call

 public function call($action, $getParams = array(), $postParams = array())
 {
     $json = $this->getURL($this->getAPIURL() . '/v' . WORDFENCE_API_VERSION . '/?' . $this->makeAPIQueryString() . '&' . self::buildQuery(array_merge(array('action' => $action), $getParams)), $postParams);
     if (!$json) {
         throw new Exception("We received an empty data response from the Wordfence scanning servers when calling the '{$action}' function.");
     }
     $dat = json_decode($json, true);
     if (isset($dat['_isPaidKey'])) {
         wfConfig::set('keyExpDays', $dat['_keyExpDays']);
         if ($dat['_keyExpDays'] > -1) {
             wfConfig::set('isPaid', 1);
         } else {
             if ($dat['_keyExpDays'] < 0) {
                 wfConfig::set('isPaid', '');
             }
         }
     }
     if (!is_array($dat)) {
         throw new Exception("We received a data structure that is not the expected array when contacting the Wordfence scanning servers and calling the '{$action}' function.");
     }
     if (is_array($dat) && isset($dat['errorMsg'])) {
         throw new Exception($dat['errorMsg']);
     }
     return $dat;
 }
开发者ID:vegardvelle,项目名称:radikalportal,代码行数:25,代码来源:wfAPI.php

示例3: processAttackData

 /**
  *
  */
 public static function processAttackData()
 {
     global $wpdb;
     $waf = wfWAF::getInstance();
     if ($waf->getStorageEngine()->getConfig('attackDataKey', false) === false) {
         $waf->getStorageEngine()->setConfig('attackDataKey', mt_rand(0, 0xfff));
     }
     $limit = 500;
     $lastSendTime = wfConfig::get('lastAttackDataSendTime');
     $attackData = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->base_prefix}wfHits\nWHERE action in ('blocked:waf', 'learned:waf')\nAND attackLogTime > %.6f\nLIMIT %d", $lastSendTime, $limit));
     $totalRows = $wpdb->get_var('SELECT FOUND_ROWS()');
     if ($attackData) {
         $response = wp_remote_get(sprintf(WFWAF_API_URL_SEC . "waf-rules/%d.txt", $waf->getStorageEngine()->getConfig('attackDataKey')));
         if (!is_wp_error($response)) {
             $okToSendBody = wp_remote_retrieve_body($response);
             if ($okToSendBody === 'ok') {
                 // Build JSON to send
                 $dataToSend = array();
                 $attackDataToUpdate = array();
                 foreach ($attackData as $attackDataRow) {
                     $actionData = (array) wfRequestModel::unserializeActionData($attackDataRow->actionData);
                     $dataToSend[] = array($attackDataRow->attackLogTime, $attackDataRow->ctime, wfUtils::inet_ntop($attackDataRow->IP), array_key_exists('learningMode', $actionData) ? $actionData['learningMode'] : 0, array_key_exists('paramKey', $actionData) ? base64_encode($actionData['paramKey']) : false, array_key_exists('paramValue', $actionData) ? base64_encode($actionData['paramValue']) : false, array_key_exists('failedRules', $actionData) ? $actionData['failedRules'] : '', strpos($attackDataRow->URL, 'https') === 0 ? 1 : 0, array_key_exists('fullRequest', $actionData) ? $actionData['fullRequest'] : '');
                     if (array_key_exists('fullRequest', $actionData)) {
                         unset($actionData['fullRequest']);
                         $attackDataToUpdate[$attackDataRow->id] = array('actionData' => wfRequestModel::serializeActionData($actionData));
                     }
                     if ($attackDataRow->attackLogTime > $lastSendTime) {
                         $lastSendTime = $attackDataRow->attackLogTime;
                     }
                 }
                 $response = wp_remote_post(WFWAF_API_URL_SEC . "?" . http_build_query(array('action' => 'send_waf_attack_data', 'k' => $waf->getStorageEngine()->getConfig('apiKey'), 's' => $waf->getStorageEngine()->getConfig('siteURL') ? $waf->getStorageEngine()->getConfig('siteURL') : sprintf('%s://%s/', $waf->getRequest()->getProtocol(), rawurlencode($waf->getRequest()->getHost())))), array('body' => json_encode($dataToSend), 'headers' => array('Content-Type' => 'application/json'), 'timeout' => 30));
                 if (!is_wp_error($response) && ($body = wp_remote_retrieve_body($response))) {
                     $jsonData = json_decode($body, true);
                     if (is_array($jsonData) && array_key_exists('success', $jsonData)) {
                         // Successfully sent data, remove the full request from the table to reduce storage size
                         foreach ($attackDataToUpdate as $hitID => $dataToUpdate) {
                             $wpdb->update($wpdb->base_prefix . 'wfHits', $dataToUpdate, array('id' => $hitID));
                         }
                         wfConfig::set('lastAttackDataSendTime', $lastSendTime);
                         if ($totalRows > $limit) {
                             self::scheduleSendAttackData();
                         }
                     }
                 }
             } else {
                 if (is_string($okToSendBody) && preg_match('/next check in: ([0-9]+)/', $okToSendBody, $matches)) {
                     self::scheduleSendAttackData(time() + $matches[1]);
                 }
             }
             // Could be that the server is down, so hold off on sending data for a little while.
         } else {
             self::scheduleSendAttackData(time() + 7200);
         }
     }
     self::trimWfHits();
 }
开发者ID:ashenkar,项目名称:sanga,代码行数:59,代码来源:wordfenceClass.php

示例4: getCBLCookieVal

 public function getCBLCookieVal()
 {
     $val = wfConfig::get('cbl_cookieVal', false);
     if (!$val) {
         $val = uniqid();
         wfConfig::set('cbl_cookieVal', $val);
     }
     return $val;
 }
开发者ID:TomFarrow,项目名称:wordpress-stackable,代码行数:9,代码来源:wfLog.php

示例5: clearScanLock

 public static function clearScanLock()
 {
     wfConfig::set('wf_scanRunning', '');
 }
开发者ID:mariuskarma,项目名称:wp,代码行数:4,代码来源:wfUtils.php

示例6: processAttackData

    /**
     *
     */
    public static function processAttackData()
    {
        global $wpdb;
        $waf = wfWAF::getInstance();
        if ($waf->getStorageEngine()->getConfig('attackDataKey', false) === false) {
            $waf->getStorageEngine()->setConfig('attackDataKey', mt_rand(0, 0xfff));
        }
        //Send alert email if needed
        if (wfConfig::get('wafAlertOnAttacks')) {
            $alertInterval = wfConfig::get('wafAlertInterval', 0);
            $cutoffTime = max(time() - $alertInterval, wfConfig::get('wafAlertLastSendTime'));
            $wafAlertWhitelist = wfConfig::get('wafAlertWhitelist', '');
            $wafAlertWhitelist = preg_split("/[,\r\n]+/", $wafAlertWhitelist);
            foreach ($wafAlertWhitelist as $index => &$entry) {
                $entry = trim($entry);
                if (!preg_match('/^(?:\\d{1,3}(?:\\.|$)){4}/', $entry) && !preg_match('/^((?:[\\da-f]{1,4}(?::|)){0,8})(::)?((?:[\\da-f]{1,4}(?::|)){0,8})$/i', $entry)) {
                    unset($wafAlertWhitelist[$index]);
                    continue;
                }
                $packed = @wfUtils::inet_pton($entry);
                if ($packed === false) {
                    unset($wafAlertWhitelist[$index]);
                    continue;
                }
                $entry = bin2hex($packed);
            }
            $wafAlertWhitelist = array_filter($wafAlertWhitelist);
            $attackData = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->base_prefix}wfHits\n\tWHERE action = 'blocked:waf' " . (count($wafAlertWhitelist) ? "AND HEX(IP) NOT IN (" . implode(", ", array_fill(0, count($wafAlertWhitelist), '%s')) . ")" : "") . "AND attackLogTime > %.6f\n\tORDER BY attackLogTime DESC\n\tLIMIT 10", array_merge($wafAlertWhitelist, array($cutoffTime))));
            $attackCount = $wpdb->get_var('SELECT FOUND_ROWS()');
            if ($attackCount >= wfConfig::get('wafAlertThreshold')) {
                $durationMessage = wfUtils::makeDuration($alertInterval);
                $message = <<<ALERTMSG
The Wordfence Web Application Firewall has blocked {$attackCount} attacks over the last {$durationMessage}. Below is a sample of these recent attacks:


ALERTMSG;
                $attackTable = array();
                $dateMax = $ipMax = $countryMax = 0;
                foreach ($attackData as $row) {
                    $row->longDescription = "Blocked for " . $row->actionDescription;
                    $actionData = json_decode($row->actionData, true);
                    if (!is_array($actionData) || !isset($actionData['paramKey']) || !isset($actionData['paramValue'])) {
                        continue;
                    }
                    $paramKey = base64_decode($actionData['paramKey']);
                    $paramValue = base64_decode($actionData['paramValue']);
                    if (strlen($paramValue) > 100) {
                        $paramValue = substr($paramValue, 0, 100) . chr(2026);
                    }
                    if (preg_match('/([a-z0-9_]+\\.[a-z0-9_]+)(?:\\[(.+?)\\](.*))?/i', $paramKey, $matches)) {
                        switch ($matches[1]) {
                            case 'request.queryString':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in query string: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.body':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in POST body: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.cookie':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in cookie: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.fileNames':
                                $row->longDescription = "Blocked for a " . $row->actionDescription . ' in file: ' . $matches[2] . '=' . $paramValue;
                                break;
                        }
                    }
                    $date = date_i18n('F j, Y g:ia', floor($row->attackLogTime));
                    $dateMax = max(strlen($date), $dateMax);
                    $ip = wfUtils::inet_ntop($row->IP);
                    $ipMax = max(strlen($ip), $ipMax);
                    $country = wfUtils::countryCode2Name(wfUtils::IP2Country($ip));
                    $country = empty($country) ? 'Unknown' : $country;
                    $countryMax = max(strlen($country), $countryMax);
                    $attackTable[] = array('date' => $date, 'IP' => $ip, 'country' => $country, 'message' => $row->longDescription);
                }
                foreach ($attackTable as $row) {
                    $date = str_pad($row['date'], $dateMax + 2);
                    $ip = str_pad($row['IP'] . " ({$row['country']})", $ipMax + $countryMax + 8);
                    $attackMessage = $row['message'];
                    $message .= $date . $ip . $attackMessage . "\n";
                }
                self::alert('Increased Attack Rate', $message, false);
                wfConfig::set('wafAlertLastSendTime', time());
            }
        }
        //Send attack data
        $limit = 500;
        $lastSendTime = wfConfig::get('lastAttackDataSendTime');
        $attackData = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->base_prefix}wfHits\nWHERE action in ('blocked:waf', 'learned:waf', 'logged:waf', 'blocked:waf-always')\nAND attackLogTime > %.6f\nLIMIT %d", $lastSendTime, $limit));
        $totalRows = $wpdb->get_var('SELECT FOUND_ROWS()');
        if ($attackData && wfConfig::get('other_WFNet', true)) {
            $response = wp_remote_get(sprintf(WFWAF_API_URL_SEC . "waf-rules/%d.txt", $waf->getStorageEngine()->getConfig('attackDataKey')));
            if (!is_wp_error($response)) {
                $okToSendBody = wp_remote_retrieve_body($response);
                if ($okToSendBody === 'ok') {
                    // Build JSON to send
                    $dataToSend = array();
                    $attackDataToUpdate = array();
//.........这里部分代码省略.........
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:101,代码来源:wordfenceClass.php

示例7: disableAutoUpdate

 public static function disableAutoUpdate()
 {
     wfConfig::set('autoUpdate', '0');
     wp_clear_scheduled_hook('wordfence_daily_autoUpdate');
 }
开发者ID:HandsomeDogStudio,项目名称:peanutbutterplan,代码行数:5,代码来源:wfConfig.php

示例8: menu_options

 public static function menu_options()
 {
     if (!wfConfig::get('alertEmails')) {
         foreach (array('alertOn_block', 'alertOn_loginLockout', 'alertOn_lostPasswdForm', 'alertOn_adminLogin') as $opt) {
             wfConfig::set($opt, '1');
         }
     }
     require 'menu_options.php';
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:9,代码来源:wordfenceClass.php

示例9: startScan

 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
 }
开发者ID:rinodung,项目名称:myfreetheme,代码行数:40,代码来源:wfScanEngine.php

示例10: processDetectProxyCallback

 /**
  * @return bool Returns false if the payload is invalid, true if it processed the callback (even if the IP wasn't found).
  */
 public static function processDetectProxyCallback()
 {
     $nonce = wfConfig::get('detectProxyNonce', '');
     $testNonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     if (empty($nonce) || empty($testNonce)) {
         return false;
     }
     if (!hash_equals($nonce, $testNonce)) {
         return false;
     }
     $ips = isset($_POST['ips']) ? $_POST['ips'] : array();
     if (empty($ips)) {
         return false;
     }
     $expandedIPs = array();
     foreach ($ips as $ip) {
         $expandedIPs[] = self::inet_pton($ip);
     }
     $checks = array('HTTP_CF_CONNECTING_IP', 'HTTP_X_REAL_IP', 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR');
     foreach ($checks as $key) {
         if (!isset($_SERVER[$key])) {
             continue;
         }
         $testIP = self::getCleanIPAndServerVar(array(array($_SERVER[$key], $key)));
         if ($testIP === false) {
             continue;
         }
         $testIP = self::inet_pton($testIP[0]);
         if (in_array($testIP, $expandedIPs)) {
             wfConfig::set('detectProxyRecommendation', $key, wfConfig::DONT_AUTOLOAD);
             wfConfig::set('detectProxyNonce', '', wfConfig::DONT_AUTOLOAD);
             return true;
         }
     }
     wfConfig::set('detectProxyRecommendation', 'UNKNOWN', wfConfig::DONT_AUTOLOAD);
     wfConfig::set('detectProxyNonce', '', wfConfig::DONT_AUTOLOAD);
     return true;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:41,代码来源:wfUtils.php

示例11: whitelistIP

 public static function whitelistIP($IP)
 {
     //IP as a string in dotted quad notation e.g. '10.11.12.13'
     $IP = trim($IP);
     $user_range = new wfUserIPRange($IP);
     if (!$user_range->isValidRange()) {
         throw new Exception("The IP you provided must be in dotted quad notation or use ranges with square brackets. e.g. 10.11.12.13 or 10.11.12.[1-50]");
     }
     $whites = wfConfig::get('whitelisted', '');
     $arr = explode(',', $whites);
     $arr2 = array();
     foreach ($arr as $e) {
         if ($e == $IP) {
             return false;
         }
         $arr2[] = trim($e);
     }
     $arr2[] = $IP;
     wfConfig::set('whitelisted', implode(',', $arr2));
     return true;
 }
开发者ID:rinodung,项目名称:myfreetheme,代码行数:21,代码来源:wordfenceClass.php

示例12: alert

 public static function alert($subject, $alertMsg, $IP)
 {
     wfConfig::inc('totalAlertsSent');
     $emails = wfConfig::getAlertEmails();
     if (sizeof($emails) < 1) {
         return;
     }
     $IPMsg = "";
     if ($IP) {
         $IPMsg = "User IP: {$IP}\n";
         $reverse = wfUtils::reverseLookup($IP);
         if ($reverse) {
             $IPMsg .= "User hostname: " . $reverse . "\n";
         }
         $userLoc = wfUtils::getIPGeo($IP);
         if ($userLoc) {
             $IPMsg .= "User location: ";
             if ($userLoc['city']) {
                 $IPMsg .= $userLoc['city'] . ', ';
             }
             $IPMsg .= $userLoc['countryName'] . "\n";
         }
     }
     $content = wfUtils::tmpl('email_genericAlert.php', array('isPaid' => wfConfig::get('isPaid'), 'subject' => $subject, 'blogName' => get_bloginfo('name', 'raw'), 'adminURL' => get_admin_url(), 'alertMsg' => $alertMsg, 'IPMsg' => $IPMsg, 'date' => wfUtils::localHumanDate(), 'myHomeURL' => self::getMyHomeURL(), 'myOptionsURL' => self::getMyOptionsURL()));
     $shortSiteURL = preg_replace('/^https?:\\/\\//i', '', site_url());
     $subject = "[Wordfence Alert] {$shortSiteURL} " . $subject;
     $sendMax = wfConfig::get('alert_maxHourly', 0);
     if ($sendMax > 0) {
         $sendArr = wfConfig::get_ser('alertFreqTrack', array());
         if (!is_array($sendArr)) {
             $sendArr = array();
         }
         $minuteTime = floor(time() / 60);
         $totalSent = 0;
         for ($i = $minuteTime; $i > $minuteTime - 60; $i--) {
             $totalSent += isset($sendArr[$i]) ? $sendArr[$i] : 0;
         }
         if ($totalSent >= $sendMax) {
             return;
         }
         $sendArr[$minuteTime] = isset($sendArr[$minuteTime]) ? $sendArr[$minuteTime] + 1 : 1;
         wfConfig::set_ser('alertFreqTrack', $sendArr);
     }
     //Prevent duplicate emails within 1 hour:
     $hash = md5(implode(',', $emails) . ':' . $subject . ':' . $alertMsg . ':' . $IP);
     //Hex
     $lastHash = wfConfig::get('lastEmailHash', false);
     if ($lastHash) {
         $lastHashDat = explode(':', $lastHash);
         //[time, hash]
         if (time() - $lastHashDat[0] < 3600) {
             if ($lastHashDat[1] == $hash) {
                 return;
                 //Don't send because this email is identical to the previous email which was sent within the last hour.
             }
         }
     }
     wfConfig::set('lastEmailHash', time() . ':' . $hash);
     wp_mail(implode(',', $emails), $subject, $content);
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:60,代码来源:wordfenceClass.php

示例13: logPeakMemory

 private static function logPeakMemory()
 {
     $oldPeak = wfConfig::get('wfPeakMemory', 0);
     $peak = memory_get_peak_usage();
     if ($peak > $oldPeak) {
         wfConfig::set('wfPeakMemory', $peak);
     }
 }
开发者ID:roycocup,项目名称:enclothed,代码行数:8,代码来源:wfScan.php

示例14: clearScanLock

 public static function clearScanLock()
 {
     global $wpdb;
     $wfdb = new wfDB();
     $wfdb->truncate($wpdb->base_prefix . 'wfHoover');
     wfConfig::set('wf_scanRunning', '');
 }
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:7,代码来源:wfUtils.php

示例15: setupSigs

 /**
  * Get scan regexes from noc1 and add any user defined regexes, including descriptions, ID's and time added.
  * @todo add caching to this.
  * @throws Exception
  */
 protected function setupSigs()
 {
     $this->api = new wfAPI($this->apiKey, $this->wordpressVersion);
     $sigData = $this->api->call('get_patterns', array(), array());
     if (!(is_array($sigData) && isset($sigData['rules']))) {
         throw new Exception("Wordfence could not get the attack signature patterns from the scanning server.");
     }
     if (is_array($sigData['rules'])) {
         foreach ($sigData['rules'] as $key => $signatureRow) {
             list(, , $pattern) = $signatureRow;
             if (@preg_match('/' . $pattern . '/i', null) === false) {
                 wordfence::status(1, 'error', "A regex Wordfence received from it's servers is invalid. The pattern is: " . esc_html($pattern));
                 unset($sigData['rules'][$key]);
             }
         }
     }
     $extra = wfConfig::get('scan_include_extra');
     if (!empty($extra)) {
         $regexs = explode("\n", $extra);
         $id = 1000001;
         foreach ($regexs as $r) {
             $r = rtrim($r, "\r");
             try {
                 preg_match('/' . $r . '/i', "");
             } catch (Exception $e) {
                 throw new Exception("The following user defined scan pattern has an error: {$r}");
             }
             $sigData['rules'][] = array($id++, time(), $r, "User defined scan pattern");
         }
     }
     $this->patterns = $sigData;
     if (isset($this->patterns['signatureUpdateTime'])) {
         wfConfig::set('signatureUpdateTime', $this->patterns['signatureUpdateTime']);
     }
 }
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:40,代码来源:wordfenceScanner.php


注:本文中的wfConfig::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。