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


PHP wfConfig::enableAutoUpdate方法代码示例

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


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

示例1: ajax_saveConfig_callback


//.........这里部分代码省略.........
         $opts['liveTraf_ignoreIPs'] = implode(',', $validIPs);
     }
     if (preg_match('/[a-zA-Z0-9\\d]+/', $opts['liveTraf_ignoreUA'])) {
         $opts['liveTraf_ignoreUA'] = trim($opts['liveTraf_ignoreUA']);
     } else {
         $opts['liveTraf_ignoreUA'] = '';
     }
     if (!$opts['other_WFNet']) {
         $wfdb = new wfDB();
         global $wpdb;
         $p = $wpdb->base_prefix;
         $wfdb->queryWrite("delete from {$p}" . "wfBlocks where wfsn=1 and permanent=0");
     }
     if ($opts['howGetIPs'] != wfConfig::get('howGetIPs', '')) {
         $reload = 'reload';
     }
     $regenerateHtaccess = false;
     if (wfConfig::get('bannedURLs', false) != $opts['bannedURLs']) {
         $regenerateHtaccess = true;
     }
     if (!is_numeric($opts['liveTraf_maxRows'])) {
         return array('errorMsg' => 'Please enter a number for the amount of Live Traffic data to store.');
     }
     foreach ($opts as $key => $val) {
         if ($key != 'apiKey') {
             //Don't save API key yet
             wfConfig::set($key, $val);
         }
     }
     if ($regenerateHtaccess && wfConfig::get('cacheType') == 'falcon') {
         wfCache::addHtaccessCode('add');
     }
     if ($opts['autoUpdate'] == '1') {
         wfConfig::enableAutoUpdate();
     } else {
         if ($opts['autoUpdate'] == '0') {
             wfConfig::disableAutoUpdate();
         }
     }
     try {
         if ($opts['disableCodeExecutionUploads']) {
             wfConfig::disableCodeExecutionForUploads();
         } else {
             wfConfig::removeCodeExecutionProtectionForUploads();
         }
     } catch (wfConfigException $e) {
         return array('errorMsg' => $e->getMessage());
     }
     if (!empty($opts['email_summary_enabled'])) {
         wfConfig::set('email_summary_enabled', 1);
         wfConfig::set('email_summary_interval', $opts['email_summary_interval']);
         wfConfig::set('email_summary_excluded_directories', $opts['email_summary_excluded_directories']);
         wfActivityReport::scheduleCronJob();
     } else {
         wfConfig::set('email_summary_enabled', 0);
         wfActivityReport::disableCronJob();
     }
     if (wfConfig::get('other_hideWPVersion')) {
         wfUtils::hideReadme();
     } else {
         wfUtils::showReadme();
     }
     $paidKeyMsg = false;
     if (!$opts['apiKey']) {
         //Empty API key (after trim above), then try to get one.
         $api = new wfAPI('', wfUtils::getWPVersion());
开发者ID:ashenkar,项目名称:sanga,代码行数:67,代码来源:wordfenceClass.php

示例2: save_setting

 function save_setting()
 {
     $settings = maybe_unserialize(base64_decode($_POST['settings']));
     if (is_array($settings) && count($settings) > 0) {
         $result = array();
         $reload = '';
         $opts = $settings;
         $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;
                 }
             }
         }
         if (count($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)) );
             $result['invalid_users'] = htmlentities(implode(', ', $invalidUsers));
         }
         if (count($validUsers) > 0) {
             $opts['liveTraf_ignoreUsers'] = implode(',', $validUsers);
         } else {
             $opts['liveTraf_ignoreUsers'] = '';
         }
         if (!$opts['other_WFNet']) {
             $wfdb = new wfDB();
             global $wpdb;
             $p = $wpdb->base_prefix;
             $wfdb->queryWrite("delete from {$p}" . 'wfBlocks where wfsn=1 and permanent=0');
         }
         $regenerateHtaccess = false;
         if (wfConfig::get('bannedURLs', false) !== $opts['bannedURLs']) {
             $regenerateHtaccess = true;
         }
         foreach ($opts as $key => $val) {
             if (in_array($key, self::$options_filter)) {
                 if ('apiKey' !== $key) {
                     //Don't save API key yet
                     wfConfig::set($key, $val);
                 }
             }
         }
         if ($regenerateHtaccess) {
             wfCache::addHtaccessCode('add');
         }
         if ('1' === $opts['autoUpdate']) {
             wfConfig::enableAutoUpdate();
         } else {
             if ('0' === $opts['autoUpdate']) {
                 wfConfig::disableAutoUpdate();
             }
         }
         if (isset($opts['disableCodeExecutionUploads'])) {
             try {
                 if ($opts['disableCodeExecutionUploads']) {
                     wfConfig::disableCodeExecutionForUploads();
                 } else {
                     wfConfig::removeCodeExecutionProtectionForUploads();
                 }
             } catch (wfConfigException $e) {
                 return array('error' => $e->getMessage());
             }
         }
         if (isset($opts['email_summary_enabled'])) {
             if (!empty($opts['email_summary_enabled'])) {
                 wfConfig::set('email_summary_enabled', 1);
                 wfConfig::set('email_summary_interval', $opts['email_summary_interval']);
                 wfConfig::set('email_summary_excluded_directories', $opts['email_summary_excluded_directories']);
                 wfActivityReport::scheduleCronJob();
             } else {
                 wfConfig::set('email_summary_enabled', 0);
                 wfActivityReport::disableCronJob();
             }
         }
         $sch = isset($opts['scheduleScan']) ? $opts['scheduleScan'] : '';
         if (get_option('mainwp_child_wordfence_cron_time') !== $sch) {
             update_option('mainwp_child_wordfence_cron_time', $sch);
             $sched = wp_next_scheduled('mainwp_child_wordfence_cron_scan');
             if (false !== $sched) {
                 wp_unschedule_event($sched, 'mainwp_child_wordfence_cron_scan');
             }
         }
         $result['cacheType'] = wfConfig::get('cacheType');
         $result['paidKeyMsg'] = false;
         $apiKey = trim($_POST['apiKey']);
         if (!$apiKey) {
             //Empty API key (after trim above), then try to get one.
             $api = new wfAPI('', wfUtils::getWPVersion());
             try {
                 $keyData = $api->call('get_anon_api_key');
                 if ($keyData['ok'] && $keyData['apiKey']) {
                     wfConfig::set('apiKey', $keyData['apiKey']);
                     wfConfig::set('isPaid', 0);
                     $result['apiKey'] = $keyData['apiKey'];
                     $result['isPaid'] = 0;
                     $reload = 'reload';
//.........这里部分代码省略.........
开发者ID:jexmex,项目名称:mainwp-child,代码行数:101,代码来源:class-mainwp-child-wordfence.php

示例3: ajax_saveConfig_callback


//.........这里部分代码省略.........
         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'])) {
         $opts['liveTraf_ignoreUA'] = trim($opts['liveTraf_ignoreUA']);
     } else {
         $opts['liveTraf_ignoreUA'] = '';
     }
     if (!$opts['other_WFNet']) {
         $wfdb = new wfDB();
         global $wpdb;
         $p = $wpdb->base_prefix;
         $wfdb->queryWrite("delete from {$p}" . "wfBlocks where wfsn=1 and permanent=0");
     }
     if ($opts['howGetIPs'] != wfConfig::get('howGetIPs', '')) {
         $reload = 'reload';
     }
     $regenerateHtaccess = false;
     if (wfConfig::get('bannedURLs', false) != $opts['bannedURLs']) {
         $regenerateHtaccess = true;
     }
     foreach ($opts as $key => $val) {
         if ($key != 'apiKey') {
             //Don't save API key yet
             wfConfig::set($key, $val);
         }
     }
     if ($regenerateHtaccess) {
         wfCache::addHtaccessCode('add');
     }
     if ($opts['autoUpdate'] == '1') {
         wfConfig::enableAutoUpdate();
     } else {
         if ($opts['autoUpdate'] == '0') {
             wfConfig::disableAutoUpdate();
         }
     }
     $paidKeyMsg = false;
     if (!$opts['apiKey']) {
         //Empty API key (after trim above), then try to get one.
         $api = new wfAPI('', wfUtils::getWPVersion());
         try {
             $keyData = $api->call('get_anon_api_key');
             if ($keyData['ok'] && $keyData['apiKey']) {
                 wfConfig::set('apiKey', $keyData['apiKey']);
                 wfConfig::set('isPaid', 0);
                 $reload = 'reload';
             } else {
                 throw new Exception("We could not understand the Wordfence server's response because it did not contain an 'ok' and 'apiKey' element.");
             }
         } catch (Exception $e) {
             return array('errorMsg' => "Your options have been saved, but we encountered a problem. You left your API key blank, so we tried to get you a free API key from the Wordfence servers. However we encountered a problem fetching the free key: " . htmlentities($e->getMessage()));
         }
     } else {
         if ($opts['apiKey'] != wfConfig::get('apiKey')) {
             $api = new wfAPI($opts['apiKey'], wfUtils::getWPVersion());
             try {
                 $res = $api->call('check_api_key', array(), array());
                 if ($res['ok'] && isset($res['isPaid'])) {
                     wfConfig::set('apiKey', $opts['apiKey']);
                     $reload = 'reload';
                     wfConfig::set('isPaid', $res['isPaid']);
                     //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
                     if ($res['isPaid']) {
                         $paidKeyMsg = true;
                     }
                 } else {
                     throw new Exception("We could not understand the Wordfence API server reply when updating your API key.");
                 }
             } catch (Exception $e) {
                 return array('errorMsg' => "Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: " . htmlentities($e->getMessage()));
             }
         } else {
             $api = new wfAPI($opts['apiKey'], wfUtils::getWPVersion());
             $res = $api->call('ping_api_key', array(), array());
         }
     }
     return array('ok' => 1, 'reload' => $reload, 'paidKeyMsg' => $paidKeyMsg);
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:101,代码来源:wordfenceClass.php


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