本文整理汇总了PHP中W3_Request::get_boolean方法的典型用法代码示例。如果您正苦于以下问题:PHP W3_Request::get_boolean方法的具体用法?PHP W3_Request::get_boolean怎么用?PHP W3_Request::get_boolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类W3_Request
的用法示例。
在下文中一共展示了W3_Request::get_boolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* New Relic tab
*/
function view()
{
$applications = array();
$dashboard = '';
/**
* @var $nerser W3_NewRelicService
*/
$nerser = w3_instance('W3_NewRelicService');
$new_relic_configured = $this->_config->get_string('newrelic.account_id') && $this->_config->get_string('newrelic.api_key') && $this->_config->get_string('newrelic.application_id');
$view_application = $this->_config->get_string('newrelic.application_id');
$new_relic_enabled = $this->_config->get_boolean('newrelic.enabled');
$verify_running = $nerser->verify_running();
$application_settings = array();
if (!is_array($verify_running)) {
try {
$application_settings = $nerser->get_application_settings();
} catch (Exception $ex) {
$application_settings = array();
}
}
if ($view_metric = W3_Request::get_boolean('view_metric', false)) {
$metric_names = $nerser->get_metric_names(W3_Request::get_string('regex', ''));
}
include W3TC_INC_DIR . '/options/new_relic.php';
}
示例2: view
/**
* Support tab
*
* @return void
*/
function view()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$request_type = W3_Request::get_string('request_type');
$payment = W3_Request::get_boolean('payment');
include W3TC_INC_DIR . '/options/support.php';
}
示例3: widget_pagespeed
/**
* PageSpeed widget
*
* @return void
*/
function widget_pagespeed()
{
w3_require_once(W3TC_LIB_W3_DIR . '/PageSpeed.php');
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$key = $this->_config->get_string('widget.pagespeed.key');
$force = W3_Request::get_boolean('w3tc_widget_pagespeed_force');
$results = null;
if ($key) {
$w3_pagespeed = new W3_PageSpeed();
$results = $w3_pagespeed->analyze(w3_get_home_url(), $force);
}
include W3TC_INC_DIR . '/widget/pagespeed.php';
}
示例4: read_request
/**
* Reads config from request
*/
function read_request()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
$request = W3_Request::get_request();
foreach ($this->_keys as $key => $type) {
$request_key = str_replace('.', '_', $key);
if (!isset($request[$request_key])) {
continue;
}
switch ($type) {
case 'string':
$this->set($key, W3_Request::get_string($request_key));
break;
case 'int':
case 'integer':
$this->set($key, W3_Request::get_integer($request_key));
break;
case 'float':
case 'double':
$this->set($key, W3_Request::get_double($request_key));
break;
case 'bool':
case 'boolean':
$this->set($key, W3_Request::get_boolean($request_key));
break;
case 'array':
$this->set($key, W3_Request::get_array($request_key));
break;
}
}
}
示例5: action_support_request
/**
* Send support request action
*
* @return void
*/
function action_support_request()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$request_type = W3_Request::get_string('request_type');
$payment = W3_Request::get_boolean('payment');
$request_id = W3_Request::get_string('request_id');
$url = W3_Request::get_string('url');
$name = W3_Request::get_string('name');
$email = W3_Request::get_string('email');
$twitter = W3_Request::get_string('twitter');
$phone = W3_Request::get_string('phone');
$subject = W3_Request::get_string('subject');
$description = W3_Request::get_string('description');
$templates = W3_Request::get_array('templates');
$forum_url = W3_Request::get_string('forum_url');
$wp_login = W3_Request::get_string('wp_login');
$wp_password = W3_Request::get_string('wp_password');
$ftp_host = W3_Request::get_string('ftp_host');
$ftp_login = W3_Request::get_string('ftp_login');
$ftp_password = W3_Request::get_string('ftp_password');
$subscribe_releases = W3_Request::get_string('subscribe_releases');
$subscribe_customer = W3_Request::get_string('subscribe_customer');
$params = array('request_type' => $request_type, 'payment' => $payment, 'url' => $url, 'name' => $name, 'email' => $email, 'twitter' => $twitter, 'phone' => $phone, 'subject' => $subject, 'description' => $description, 'forum_url' => $forum_url, 'wp_login' => $wp_login, 'wp_password' => $wp_password, 'ftp_host' => $ftp_host, 'ftp_login' => $ftp_login, 'ftp_password' => $ftp_password, 'subscribe_releases' => $subscribe_releases, 'subscribe_customer' => $subscribe_customer);
$post = $params;
foreach ($templates as $template_index => $template) {
$template_key = sprintf('templates[%d]', $template_index);
$params[$template_key] = $template;
}
if (!isset($this->_request_types[$request_type])) {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_type')), false);
}
$required = array('bug_report' => 'url,name,email,subject,description', 'new_feature' => 'url,name,email,subject,description', 'email_support' => 'url,name,email,subject,description', 'phone_support' => 'url,name,email,subject,description,phone', 'plugin_config' => 'url,name,email,subject,description,wp_login,wp_password', 'theme_config' => 'url,name,email,subject,description,wp_login,wp_password,ftp_host,ftp_login,ftp_password', 'linux_config' => 'url,name,email,subject,description,wp_login,wp_password,ftp_host,ftp_login,ftp_password');
if (strstr($required[$request_type], 'url') !== false && $url == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_url')), false);
}
if (strstr($required[$request_type], 'name') !== false && $name == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_name')), false);
}
if (strstr($required[$request_type], 'email') !== false && !preg_match('~^[a-z0-9_\\-\\.]+@[a-z0-9-\\.]+\\.[a-z]{2,5}$~', $email)) {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_email')), false);
}
if (strstr($required[$request_type], 'phone') !== false && !preg_match('~^[0-9\\-\\.\\ \\(\\)\\+]+$~', $phone)) {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_phone')), false);
}
if (strstr($required[$request_type], 'subject') !== false && $subject == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_subject')), false);
}
if (strstr($required[$request_type], 'description') !== false && $description == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_description')), false);
}
if (strstr($required[$request_type], 'wp_login') !== false && $wp_login == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_wp_login')), false);
}
if (strstr($required[$request_type], 'wp_password') !== false && $wp_password == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_wp_password')), false);
}
if (strstr($required[$request_type], 'ftp_host') !== false && $ftp_host == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_ftp_host')), false);
}
if (strstr($required[$request_type], 'ftp_login') !== false && $ftp_login == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_ftp_login')), false);
}
if (strstr($required[$request_type], 'ftp_password') !== false && $ftp_password == '') {
w3_admin_redirect(array_merge($params, array('w3tc_error' => 'support_request_ftp_password')), false);
}
/**
* Add attachments
*/
$attachments = array();
$attach_files = array(w3_get_wp_config_path(), w3_cache_blog_dir('log') . '/minify.log', w3_get_pgcache_rules_core_path(), w3_get_pgcache_rules_cache_path(), w3_get_browsercache_rules_cache_path(), w3_get_browsercache_rules_no404wp_path(), w3_get_minify_rules_core_path(), w3_get_minify_rules_cache_path());
/**
* Attach config files
*/
if ($handle = opendir(W3TC_CONFIG_DIR)) {
while (($entry = @readdir($handle)) !== false) {
if ($entry == '.' || $entry == '..' || $entry == 'index.html') {
continue;
}
$attachments[] = W3TC_CONFIG_DIR . '/' . $entry;
}
closedir($handle);
}
foreach ($attach_files as $attach_file) {
if ($attach_file && file_exists($attach_file) && !in_array($attach_file, $attachments)) {
$attachments[] = $attach_file;
}
}
/**
* Attach server info
*/
$server_info = print_r($this->get_server_info(), true);
$server_info = str_replace("\n", "\r\n", $server_info);
$server_info_path = W3TC_CACHE_TMP_DIR . '/server_info.txt';
if (@file_put_contents($server_info_path, $server_info)) {
$attachments[] = $server_info_path;
//.........这里部分代码省略.........
示例6: init
/**
* Init action
*
* @return void
*/
function init()
{
// Load plugin text domain
load_plugin_textdomain(W3TC_TEXT_DOMAIN, null, plugin_basename(W3TC_DIR) . '/languages/');
if (is_multisite()) {
global $w3_current_blog_id, $current_blog;
if ($w3_current_blog_id != $current_blog->blog_id && !isset($GLOBALS['w3tc_blogmap_register_new_item'])) {
$url = w3_get_host() . $_SERVER['REQUEST_URI'];
$pos = strpos($url, '?');
if ($pos !== false) {
$url = substr($url, 0, $pos);
}
$GLOBALS['w3tc_blogmap_register_new_item'] = $url;
}
}
if (isset($GLOBALS['w3tc_blogmap_register_new_item'])) {
$do_redirect = false;
// true value is a sign to just generate config cache
if ($GLOBALS['w3tc_blogmap_register_new_item'] != 'cache_options') {
if (w3_is_subdomain_install()) {
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
} else {
$home_url = rtrim(get_home_url(), '/');
if (substr($home_url, 0, 7) == 'http://') {
$home_url = substr($home_url, 7);
} else {
if (substr($home_url, 0, 8) == 'https://') {
$home_url = substr($home_url, 8);
}
}
if (substr($GLOBALS['w3tc_blogmap_register_new_item'], 0, strlen($home_url)) == $home_url) {
$blog_home_url = $home_url;
} else {
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
}
}
w3_require_once(W3TC_INC_DIR . '/functions/multisite.php');
$do_redirect = w3_blogmap_register_new_item($blog_home_url, $this->_config);
// reset cache of blog_id
global $w3_current_blog_id;
$w3_current_blog_id = null;
// change config to actual blog, it was master before
$this->_config = new W3_Config();
}
$do_redirect |= $this->_config->fill_missing_cache_options_and_save();
// need to repeat request processing, since we was not able to realize
// blog_id before so we are running with master config now.
// redirect to the same url causes "redirect loop" error in browser,
// so need to redirect to something a bit different
if ($do_redirect) {
if (strpos($_SERVER['REQUEST_URI'], '?') === false) {
w3_redirect_temp($_SERVER['REQUEST_URI'] . '?repeat=w3tc');
} else {
if (strpos($_SERVER['REQUEST_URI'], 'repeat=w3tc') === false) {
w3_redirect_temp($_SERVER['REQUEST_URI'] . '&repeat=w3tc');
}
}
}
}
/**
* Check request and handle w3tc_request_data requests
*/
$pos = strpos($_SERVER['REQUEST_URI'], '/w3tc_request_data/');
if ($pos !== false) {
$hash = substr($_SERVER['REQUEST_URI'], $pos + 19, 32);
if (strlen($hash) == 32) {
$request_data = (array) get_option('w3tc_request_data');
if (isset($request_data[$hash])) {
echo '<pre>';
foreach ($request_data[$hash] as $key => $value) {
printf("%s: %s\n", $key, $value);
}
echo '</pre>';
unset($request_data[$hash]);
update_option('w3tc_request_data', $request_data);
} else {
echo 'Requested hash expired or invalid';
}
exit;
}
}
/**
* Check for rewrite test request
*/
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$rewrite_test = W3_Request::get_boolean('w3tc_rewrite_test');
if ($rewrite_test) {
echo 'OK';
exit;
}
$admin_bar = false;
if (function_exists('is_admin_bar_showing')) {
$admin_bar = is_admin_bar_showing();
}
if (current_user_can('manage_options') && $admin_bar) {
//.........这里部分代码省略.........
示例7: action_test_pagespeed_results
/**
* Page Speed results action
*
* @return void
*/
function action_test_pagespeed_results()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
w3_require_once(W3TC_LIB_W3_DIR . '/PageSpeed.php');
$force = W3_Request::get_boolean('force');
$title = 'Google Page Speed';
$w3_pagespeed = new W3_PageSpeed();
$results = $w3_pagespeed->analyze(w3_get_home_url(), $force);
if ($force) {
w3_admin_redirect(array('w3tc_pagespeed_results' => 1, '_wpnonce' => wp_create_nonce('w3tc')));
}
include W3TC_INC_POPUP_DIR . '/pagespeed_results.php';
}
示例8: process
/**
* Runs minify
*
* @return void
*/
function process()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
/**
* Check for rewrite test request
*/
$rewrite_test = W3_Request::get_boolean('w3tc_rewrite_test');
if ($rewrite_test) {
echo 'OK';
exit;
}
$file = W3_Request::get_string('file');
if (!$file) {
$this->error('File param is missing', false);
return;
}
$hash = '';
$matches = null;
if (preg_match('~^([a-f0-9]+)\\.[a-f0-9]+\\.(css|js)$~', $file, $matches)) {
list(, $hash, $type) = $matches;
} elseif (preg_match('~^([a-f0-9]+)\\/(.+)\\.(include(\\-(footer|body))?(-nb)?)\\.[a-f0-9]+\\.(css|js)$~', $file, $matches)) {
list(, $theme, $template, $location, , , , $type) = $matches;
} else {
$this->error(sprintf('Bad file param format: "%s"', $file), false);
return;
}
require_once W3TC_LIB_MINIFY_DIR . '/Minify.php';
require_once W3TC_LIB_MINIFY_DIR . '/HTTP/Encoder.php';
/**
* Fix DOCUMENT_ROOT
*/
$_SERVER['DOCUMENT_ROOT'] = w3_get_document_root();
/**
* Set cache engine
*/
Minify::setCache($this->_get_cache());
/**
* Set cache ID
*/
$cache_id = $this->get_cache_id($file);
Minify::setCacheId($cache_id);
/**
* Set logger
*/
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Logger.php';
Minify_Logger::setLogger(array(&$this, 'error'));
/**
* Set options
*/
$browsercache = $this->_config->get_boolean('browsercache.enabled');
$serve_options = array_merge($this->_config->get_array('minify.options'), array('debug' => $this->_config->get_boolean('minify.debug'), 'maxAge' => $this->_config->get_integer('browsercache.cssjs.lifetime'), 'encodeOutput' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.compression'), 'bubbleCssImports' => $this->_config->get_string('minify.css.imports') == 'bubble', 'processCssImports' => $this->_config->get_string('minify.css.imports') == 'process', 'cacheHeaders' => array('use_etag' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.etag'), 'expires_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.expires'), 'cacheheaders_enabled' => $browsercache && $this->_config->get_boolean('browsercache.cssjs.cache.control'), 'cacheheaders' => $this->_config->get_string('browsercache.cssjs.cache.policy'))));
/**
* Set sources
*/
if ($hash) {
$_GET['f'] = $this->get_files($hash, $type);
} else {
$_GET['g'] = $location;
$serve_options['minApp']['groups'] = $this->get_groups($theme, $template, $type);
}
/**
* Set minifier
*/
$w3_minifier =& w3_instance('W3_Minifier');
if ($type == 'js') {
$minifier_type = 'application/x-javascript';
switch (true) {
case ($hash || $location == 'include' || $location == 'include-nb') && $this->_config->get_boolean('minify.js.combine.header'):
case ($location == 'include-body' || $location == 'include-body-nb') && $this->_config->get_boolean('minify.js.combine.body'):
case ($location == 'include-footer' || $location == 'include-footer-nb') && $this->_config->get_boolean('minify.js.combine.footer'):
$engine = 'combinejs';
break;
default:
$engine = $this->_config->get_string('minify.js.engine');
if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
$engine = 'js';
}
break;
}
} elseif ($type == 'css') {
$minifier_type = 'text/css';
if (($hash || $location == 'include') && $this->_config->get_boolean('minify.css.combine')) {
$engine = 'combinecss';
} else {
$engine = $this->_config->get_string('minify.css.engine');
if (!$w3_minifier->exists($engine) || !$w3_minifier->available($engine)) {
$engine = 'css';
}
}
}
/**
* Initialize minifier
*/
$w3_minifier->init($engine);
$serve_options['minifiers'][$minifier_type] = $w3_minifier->get_minifier($engine);
//.........这里部分代码省略.........
示例9: cdn_test_ftp
/**
* CDN Test FTP
*/
function cdn_test_ftp()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
require_once W3TC_LIB_W3_DIR . '/Cdn.php';
$host = W3_Request::get_string('host');
$user = W3_Request::get_string('user');
$pass = W3_Request::get_string('pass');
$path = W3_Request::get_string('path');
$pasv = W3_Request::get_boolean('pasv');
$w3_cdn_ftp =& W3_Cdn::instance('ftp', array('host' => $host, 'user' => $user, 'pass' => $pass, 'path' => $path, 'pasv' => $pasv));
$error = null;
if ($w3_cdn_ftp->test($error)) {
$result = true;
$error = 'Test passed';
} else {
$result = false;
$error = sprintf('Test failed. Error: %s', $error);
}
echo sprintf('{result: %d, error: "%s"}', $result, addslashes($error));
}
示例10: pagespeed_results
/**
* Page Speed results popup
*
* @return void
*/
function pagespeed_results()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
require_once W3TC_LIB_W3_DIR . '/PageSpeed.php';
$force = W3_Request::get_boolean('force');
$title = 'Google Page Speed';
$w3_pagespeed = new W3_PageSpeed();
$results = $w3_pagespeed->analyze(w3_get_home_url(), $force);
if ($force) {
$this->redirect(array('w3tc_action' => 'pagespeed_results'));
}
include W3TC_DIR . '/inc/popup/pagespeed_results.phtml';
}
示例11: init
/**
* Init action
*
* @return void
*/
function init()
{
/**
* Check request and handle w3tc_request_data requests
*/
$pos = strpos($_SERVER['REQUEST_URI'], '/w3tc_request_data/');
if ($pos !== false) {
$hash = substr($_SERVER['REQUEST_URI'], $pos + 19, 32);
if (strlen($hash) == 32) {
$request_data = (array) get_option('w3tc_request_data');
if (isset($request_data[$hash])) {
echo '<pre>';
foreach ($request_data[$hash] as $key => $value) {
printf("%s: %s\n", $key, $value);
}
echo '</pre>';
unset($request_data[$hash]);
update_option('w3tc_request_data', $request_data);
} else {
echo 'Requested hash expired or invalid';
}
exit;
}
}
/**
* Check for rewrite test request
*/
require_once W3TC_LIB_W3_DIR . '/Request.php';
$rewrite_test = W3_Request::get_boolean('w3tc_rewrite_test');
if ($rewrite_test) {
echo 'OK';
exit;
}
}
示例12:
<?php
if (!defined('W3TC')) {
die;
}
include W3TC_INC_DIR . '/options/common/header.php';
if (W3_Request::get_boolean('payment')) {
?>
<div class="error fade">
<p>To complete your support request fill out the form below!</p>
</div>
<?php
} else {
?>
<p>
<?php
_e('Request premium services, suggest a feature or submit a bug using the form below:', 'w3-total-cache');
?>
</p>
<?php
}
?>
<div id="support_container">
<?php
if (!$request_type || !isset($this->_request_types[$request_type])) {
$this->action_support_select();
} else {
if (isset($this->_request_prices[$request_type]) && !$payment) {
$this->action_support_payment();
} else {
$this->action_support_form();
示例13: action_config_save_support_us
/**
* Save support us action
*
* @return void
*/
function action_config_save_support_us()
{
$support = W3_Request::get_string('support');
$tweeted = W3_Request::get_boolean('tweeted');
$signmeup = W3_Request::get_boolean('signmeup');
$this->_config->set('common.support', $support);
$this->_config->set('common.tweeted', $tweeted);
if ($signmeup) {
if (w3_is_pro($this->_config)) {
$license = 'pro';
} elseif (w3_is_enterprise()) {
$license = 'enterprise';
} else {
$license = 'community';
}
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
wp_remote_post(W3TC_MAILLINGLIST_SIGNUP_URL, array('body' => array('email' => $email, 'license' => $license)));
}
$this->_config->save();
w3_instance('W3_AdminLinks')->link_update($this->_config);
w3_admin_redirect(array('w3tc_note' => 'config_save'));
}
示例14: _check_ua
/**
* Checks User Agent
*
* @return boolean
*/
function _check_ua()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
$uas = $this->_config->get_array('pgcache.reject.ua');
$preload = W3_Request::get_boolean('w3tc_preload');
if (!$preload) {
$uas = array_merge($uas, array(W3TC_POWERED_BY));
}
foreach ($uas as $ua) {
if (isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], $ua) !== false) {
return false;
}
}
return true;
}
示例15: action_config_save_support_us
/**
* Save support us action
*
* @return void
*/
function action_config_save_support_us()
{
$support = W3_Request::get_string('support');
$tweeted = W3_Request::get_boolean('tweeted');
$this->_config->set('common.support', $support);
$this->_config->set('common.tweeted', $tweeted);
$this->_config->save();
w3_instance('W3_AdminLinks')->link_update($this->_config);
w3_admin_redirect(array('w3tc_note' => 'config_save'));
}