當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wfConfig::parseOptions方法代碼示例

本文整理匯總了PHP中wfConfig::parseOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP wfConfig::parseOptions方法的具體用法?PHP wfConfig::parseOptions怎麽用?PHP wfConfig::parseOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wfConfig的用法示例。


在下文中一共展示了wfConfig::parseOptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ajax_saveConfig_callback

 public static function ajax_saveConfig_callback()
 {
     $reload = '';
     $opts = wfConfig::parseOptions();
     // These are now on the Diagnostics page, so they aren't sent across.
     foreach (self::$diagnosticParams as $param) {
         $opts[$param] = wfConfig::get($param);
     }
     $emails = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['alertEmails'])) as $email) {
         if (strlen($email) > 0) {
             $emails[] = $email;
         }
     }
     if (sizeof($emails) > 0) {
         $badEmails = array();
         foreach ($emails as $email) {
             if (!preg_match('/^[^@]+@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,11})$/i', $email)) {
                 $badEmails[] = $email;
             }
         }
         if (sizeof($badEmails) > 0) {
             return array('errorMsg' => "The following emails are invalid: " . wp_kses(implode(', ', $badEmails), array()));
         }
         $opts['alertEmails'] = implode(',', $emails);
     } else {
         $opts['alertEmails'] = '';
     }
     $opts['scan_exclude'] = wfUtils::cleanupOneEntryPerLine($opts['scan_exclude']);
     foreach (explode("\n", $opts['scan_include_extra']) as $regex) {
         if (@preg_match("/{$regex}/", "") === FALSE) {
             return array('errorMsg' => "\"" . esc_html($regex) . "\" is not a valid regular expression");
         }
     }
     $whiteIPs = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['whitelisted'])) as $whiteIP) {
         if (strlen($whiteIP) > 0) {
             $whiteIPs[] = $whiteIP;
         }
     }
     if (sizeof($whiteIPs) > 0) {
         $badWhiteIPs = array();
         $range = new wfUserIPRange();
         foreach ($whiteIPs as $whiteIP) {
             $range->setIPString($whiteIP);
             if (!$range->isValidRange()) {
                 $badWhiteIPs[] = $whiteIP;
             }
         }
         if (sizeof($badWhiteIPs) > 0) {
             return array('errorMsg' => "Please make sure you separate your IP addresses with commas. The following whitelisted IP addresses are invalid: " . wp_kses(implode(', ', $badWhiteIPs), array()));
         }
         $opts['whitelisted'] = implode(',', $whiteIPs);
     } else {
         $opts['whitelisted'] = '';
     }
     $validUsers = array();
     $invalidUsers = array();
     foreach (explode(',', $opts['liveTraf_ignoreUsers']) as $val) {
         $val = trim($val);
         if (strlen($val) > 0) {
             if (get_user_by('login', $val)) {
                 $validUsers[] = $val;
             } else {
                 $invalidUsers[] = $val;
             }
         }
     }
     $opts['loginSec_userBlacklist'] = wfUtils::cleanupOneEntryPerLine($opts['loginSec_userBlacklist']);
     $opts['apiKey'] = trim($opts['apiKey']);
     if ($opts['apiKey'] && !preg_match('/^[a-fA-F0-9]+$/', $opts['apiKey'])) {
         //User entered something but it's garbage.
         return array('errorMsg' => "You entered an API key but it is not in a valid format. It must consist only of characters A to F and 0 to 9.");
     }
     if (sizeof($invalidUsers) > 0) {
         return array('errorMsg' => "The following users you selected to ignore in live traffic reports are not valid on this system: " . wp_kses(implode(', ', $invalidUsers), array()));
     }
     if (sizeof($validUsers) > 0) {
         $opts['liveTraf_ignoreUsers'] = implode(',', $validUsers);
     } else {
         $opts['liveTraf_ignoreUsers'] = '';
     }
     $validIPs = array();
     $invalidIPs = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['liveTraf_ignoreIPs'])) as $val) {
         if (strlen($val) > 0) {
             if (wfUtils::isValidIP($val)) {
                 $validIPs[] = $val;
             } else {
                 $invalidIPs[] = $val;
             }
         }
     }
     if (sizeof($invalidIPs) > 0) {
         return array('errorMsg' => "The following IPs you selected to ignore in live traffic reports are not valid: " . wp_kses(implode(', ', $invalidIPs), array()));
     }
     if (sizeof($validIPs) > 0) {
         $opts['liveTraf_ignoreIPs'] = implode(',', $validIPs);
     }
     if (preg_match('/[a-zA-Z0-9\\d]+/', $opts['liveTraf_ignoreUA'])) {
//.........這裏部分代碼省略.........
開發者ID:ashenkar,項目名稱:sanga,代碼行數:101,代碼來源:wordfenceClass.php

示例2: ajax_saveConfig_callback

 public static function ajax_saveConfig_callback()
 {
     $reload = '';
     $opts = wfConfig::parseOptions();
     $emails = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['alertEmails'])) as $email) {
         if (strlen($email) > 0) {
             $emails[] = $email;
         }
     }
     if (sizeof($emails) > 0) {
         $badEmails = array();
         foreach ($emails as $email) {
             if (!preg_match('/^[^@]+@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,11})$/i', $email)) {
                 $badEmails[] = $email;
             }
         }
         if (sizeof($badEmails) > 0) {
             return array('errorMsg' => "The following emails are invalid: " . htmlentities(implode(', ', $badEmails)));
         }
         $opts['alertEmails'] = implode(',', $emails);
     } else {
         $opts['alertEmails'] = '';
     }
     $opts['scan_exclude'] = preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['scan_exclude']);
     $whiteIPs = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['whitelisted'])) as $whiteIP) {
         if (strlen($whiteIP) > 0) {
             $whiteIPs[] = $whiteIP;
         }
     }
     if (sizeof($whiteIPs) > 0) {
         $badWhiteIPs = array();
         foreach ($whiteIPs as $whiteIP) {
             if (!preg_match('/^[\\[\\]\\-\\d]+\\.[\\[\\]\\-\\d]+\\.[\\[\\]\\-\\d]+\\.[\\[\\]\\-\\d]+$/', $whiteIP)) {
                 $badWhiteIPs[] = $whiteIP;
             }
         }
         if (sizeof($badWhiteIPs) > 0) {
             return array('errorMsg' => "Please make sure you separate your IP addresses with commas. The following whitelisted IP addresses are invalid: " . htmlentities(implode(', ', $badWhiteIPs)));
         }
         $opts['whitelisted'] = implode(',', $whiteIPs);
     } else {
         $opts['whitelisted'] = '';
     }
     $validUsers = array();
     $invalidUsers = array();
     foreach (explode(',', $opts['liveTraf_ignoreUsers']) as $val) {
         $val = trim($val);
         if (strlen($val) > 0) {
             if (get_user_by('login', $val)) {
                 $validUsers[] = $val;
             } else {
                 $invalidUsers[] = $val;
             }
         }
     }
     $userBlacklist = array();
     foreach (explode(',', $opts['loginSec_userBlacklist']) as $user) {
         $user = trim($user);
         if (strlen($user) > 0) {
             $userBlacklist[] = $user;
         }
     }
     if (sizeof($userBlacklist) > 0) {
         $opts['loginSec_userBlacklist'] = implode(',', $userBlacklist);
     } else {
         $opts['loginSec_userBlacklist'] = '';
     }
     $opts['apiKey'] = trim($opts['apiKey']);
     if ($opts['apiKey'] && !preg_match('/^[a-fA-F0-9]+$/', $opts['apiKey'])) {
         //User entered something but it's garbage.
         return array('errorMsg' => "You entered an API key but it is not in a valid format. It must consist only of characters A to F and 0 to 9.");
     }
     if (sizeof($invalidUsers) > 0) {
         return array('errorMsg' => "The following users you selected to ignore in live traffic reports are not valid on this system: " . htmlentities(implode(', ', $invalidUsers)));
     }
     if (sizeof($validUsers) > 0) {
         $opts['liveTraf_ignoreUsers'] = implode(',', $validUsers);
     } else {
         $opts['liveTraf_ignoreUsers'] = '';
     }
     $validIPs = array();
     $invalidIPs = array();
     foreach (explode(',', preg_replace('/[\\r\\n\\s\\t]+/', '', $opts['liveTraf_ignoreIPs'])) as $val) {
         if (strlen($val) > 0) {
             if (preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', $val)) {
                 $validIPs[] = $val;
             } else {
                 $invalidIPs[] = $val;
             }
         }
     }
     if (sizeof($invalidIPs) > 0) {
         return array('errorMsg' => "The following IPs you selected to ignore in live traffic reports are not valid: " . htmlentities(implode(', ', $invalidIPs)));
     }
     if (sizeof($validIPs) > 0) {
         $opts['liveTraf_ignoreIPs'] = implode(',', $validIPs);
     }
     if (preg_match('/[a-zA-Z0-9\\d]+/', $opts['liveTraf_ignoreUA'])) {
//.........這裏部分代碼省略.........
開發者ID:christocmp,項目名稱:bingopaws,代碼行數:101,代碼來源:wordfenceClass.php


注:本文中的wfConfig::parseOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。