本文整理汇总了PHP中W3_Request::get_array方法的典型用法代码示例。如果您正苦于以下问题:PHP W3_Request::get_array方法的具体用法?PHP W3_Request::get_array怎么用?PHP W3_Request::get_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类W3_Request
的用法示例。
在下文中一共展示了W3_Request::get_array方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_extensions_status
/**
* Alters the active state of multiple extensions
*/
public function change_extensions_status()
{
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
$extensions = W3_Request::get_array('checked');
$action = W3_Request::get('action');
$all_extensions = w3_get_extensions($this->_config);
$message = '';
if ('activate-selected' == $action) {
foreach ($extensions as $extension) {
if ($this->activate($extension, $all_extensions)) {
$message .= '&activated=' . $extension;
}
}
wp_redirect(w3_admin_url(sprintf('admin.php?page=w3tc_extensions%s', $message)));
} elseif ('deactivate-selected' == $action) {
foreach ($extensions as $extension) {
if ($this->deactivate($extension, $this->_config)) {
$message .= '&deactivated=' . $extension;
}
}
wp_redirect(w3_admin_url(sprintf('admin.php?page=w3tc_extensions%s', $message)));
} else {
wp_redirect(w3_admin_url('admin.php?page=w3tc_extensions'));
}
}
示例2: action_test_memcached
/**
* Test memcached
*
* @return void
*/
function action_test_memcached()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$servers = W3_Request::get_array('servers');
if ($this->is_memcache_available($servers)) {
$result = true;
$error = __('Test passed.', 'w3-total-cache');
} else {
$result = false;
$error = __('Test failed.', 'w3-total-cache');
}
$response = array('result' => $result, 'error' => $error);
echo json_encode($response);
}
示例3: action_save_new_relic
function action_save_new_relic()
{
if ($this->_config->get_boolean('newrelic.enabled')) {
/**
* @var $nerser W3_NewRelicService
*/
$nerser = w3_instance('W3_NewRelicService');
$application = W3_Request::get_array('application');
$application['alerts_enabled'] = $application['alerts_enabled'] == 1 ? 'true' : 'false';
$application['rum_enabled'] = $application['rum_enabled'] == 1 ? 'true' : 'false';
$result = $nerser->update_application_settings($application);
w3_admin_redirect(array('w3tc_note' => 'new_relic_save'), true);
}
}
示例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: w3_instance
$command = W3_Request::get_string('command');
$nonce = W3_Request::get_string('nonce');
$uri = $_SERVER['REQUEST_URI'];
if (wp_hash($uri) == $nonce) {
/**
* @var $w3_cache W3_CacheFlush
*/
$w3_cache = w3_instance('W3_CacheFlush');
$result = false;
switch ($command) {
case 'delete_files':
$mask = W3_Request::get_string('mask');
$result = $w3_cache->apc_delete_files_based_on_regex($mask);
break;
case 'reload_files':
$files = W3_Request::get_array('files');
$w3_cache->apc_reload_files($files);
$result = true;
break;
}
if ($result) {
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
die('Success');
} else {
header($_SERVER["SERVER_PROTOCOL"] . " 500 OK");
die($command . ' could not be executed');
}
} else {
header($_SERVER["SERVER_PROTOCOL"] . " 401");
die("Unauthorized access. ");
}
示例7: action_cdn_create_container
/**
* Create container action
*
* @return void
*/
function action_cdn_create_container()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
w3_require_once(W3TC_LIB_W3_DIR . '/Cdn.php');
$engine = W3_Request::get_string('engine');
$config = W3_Request::get_array('config');
$config = array_merge($config, array('debug' => false));
$result = false;
$error = __('Incorrect type.', 'w3-total-cache');
$container_id = '';
switch ($engine) {
case 's3':
case 'cf':
case 'cf2':
case 'rscf':
case 'azure':
$result = true;
break;
}
if ($result) {
$w3_cdn = W3_Cdn::instance($engine, $config);
@set_time_limit($this->_config->get_integer('timelimit.cdn_container_create'));
if ($w3_cdn->create_container($container_id, $error)) {
$result = true;
$error = __('Created successfully.', 'w3-total-cache');
} else {
$result = false;
$error = sprintf(__('Error: %s', 'w3-total-cache'), $error);
}
}
$response = array('result' => $result, 'error' => $error, 'container_id' => $container_id);
echo json_encode($response);
}
示例8: action_save_options
//.........这里部分代码省略.........
}
} else {
if ($method == 'manual' && $config->get_string('newrelic.appname')) {
if ($newrelic_prefix != '' && strpos($config->get_string('newrelic.appname'), $newrelic_prefix) === false) {
$application_name = $newrelic_prefix . $config->get_string('newrelic.appname');
$config->set('newrelic.appname', $application_name);
} else {
$application_name = $config->get_string('newrelic.appname');
}
if ($config->get_string('newrelic.api_key') && $config->get_string('newrelic.account_id')) {
w3_require_once(W3TC_LIB_W3_DIR . '/NewRelicService.php');
$nerser = new W3_NewRelicService($config->get_string('newrelic.api_key'), $config->get_string('newrelic.account_id'));
$application_id = $nerser->get_application_id($application_name);
if ($application_id) {
$config->set('newrelic.application_id', $application_id);
}
}
}
}
}
if ($config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.enabled') || $config->get_boolean('minify.enabled') && $config->get_boolean('browsercache.enabled') && !$this->_config->get_boolean('browsercache.enabled') || $config->get_boolean('minify.enabled') && $config->get_boolean('minify.auto') && !$this->_config->get_boolean('minify.auto') || $config->get_boolean('minify.enabled') && $config->get_string('minify.engine') != $this->_config->get_string('minify.engine')) {
delete_transient('w3tc_minify_tested_filename_length');
}
if (!w3_is_pro($this->_config)) {
delete_transient('w3tc_license_status');
}
}
/**
* Minify tab
*/
if ($this->_page == 'w3tc_minify' && !$this->_config->get_boolean('minify.auto')) {
$js_groups = array();
$css_groups = array();
$js_files = W3_Request::get_array('js_files');
$css_files = W3_Request::get_array('css_files');
foreach ($js_files as $theme => $templates) {
foreach ($templates as $template => $locations) {
foreach ((array) $locations as $location => $types) {
foreach ((array) $types as $files) {
foreach ((array) $files as $file) {
if (!empty($file)) {
$js_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file);
}
}
}
}
}
}
foreach ($css_files as $theme => $templates) {
foreach ($templates as $template => $locations) {
foreach ((array) $locations as $location => $files) {
foreach ((array) $files as $file) {
if (!empty($file)) {
$css_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file);
}
}
}
}
}
$config->set('minify.js.groups', $js_groups);
$config->set('minify.css.groups', $css_groups);
$js_theme = W3_Request::get_string('js_theme');
$css_theme = W3_Request::get_string('css_theme');
$params = array_merge($params, array('js_theme' => $js_theme, 'css_theme' => $css_theme));
}
if ($this->_page == 'w3tc_minify') {
示例9: action_save_options
/**
* Options save action
*
* @return void
*/
function action_save_options()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
/**
* Redirect params
*/
$params = array();
/**
* Read config
* We should use new instance of nxt_Config object here
*/
@($config =& new W3_Config());
$config->read_request();
/**
* General tab
*/
if ($this->_page == 'w3tc_general') {
$file_nfs = W3_Request::get_boolean('file_nfs');
$file_locking = W3_Request::get_boolean('file_locking');
$config->set('pgcache.file.nfs', $file_nfs);
$config->set('minify.file.nfs', $file_nfs);
$config->set('dbcache.file.locking', $file_locking);
$config->set('objectcache.file.locking', $file_locking);
$config->set('pgcache.file.locking', $file_locking);
$config->set('minify.file.locking', $file_locking);
/**
* Check permalinks for page cache
*/
if ($config->get_boolean('pgcache.enabled') && $config->get_string('pgcache.engine') == 'file_generic' && !get_option('permalink_structure')) {
$this->redirect(array('w3tc_error' => 'fancy_permalinks_disabled_pgcache'));
}
}
/**
* Minify tab
*/
if ($this->_page == 'w3tc_minify' && !$this->_config->get_boolean('minify.auto')) {
$js_groups = array();
$css_groups = array();
$js_files = W3_Request::get_array('js_files');
$css_files = W3_Request::get_array('css_files');
foreach ($js_files as $theme => $templates) {
foreach ($templates as $template => $locations) {
foreach ((array) $locations as $location => $files) {
switch ($location) {
case 'include':
$js_groups[$theme][$template][$location]['blocking'] = true;
break;
case 'include-nb':
$js_groups[$theme][$template][$location]['blocking'] = false;
break;
case 'include-body':
$js_groups[$theme][$template][$location]['blocking'] = true;
break;
case 'include-body-nb':
$js_groups[$theme][$template][$location]['blocking'] = false;
break;
case 'include-footer':
$js_groups[$theme][$template][$location]['blocking'] = true;
break;
case 'include-footer-nb':
$js_groups[$theme][$template][$location]['blocking'] = false;
break;
}
foreach ((array) $files as $file) {
if (!empty($file)) {
$js_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file);
}
}
}
}
}
foreach ($css_files as $theme => $templates) {
foreach ($templates as $template => $locations) {
foreach ((array) $locations as $location => $files) {
foreach ((array) $files as $file) {
if (!empty($file)) {
$css_groups[$theme][$template][$location]['files'][] = w3_normalize_file_minify($file);
}
}
}
}
}
$config->set('minify.js.groups', $js_groups);
$config->set('minify.css.groups', $css_groups);
$js_theme = W3_Request::get_string('js_theme');
$css_theme = W3_Request::get_string('css_theme');
$params = array_merge($params, array('js_theme' => $js_theme, 'css_theme' => $css_theme));
}
/**
* Browser Cache tab
*/
if ($this->_page == 'w3tc_browsercache') {
if ($config->get_boolean('browsercache.enabled') && $config->get_boolean('browsercache.no404nxt') && !get_option('permalink_structure')) {
$this->redirect(array('w3tc_error' => 'fancy_permalinks_disabled_browsercache'));
}
//.........这里部分代码省略.........
示例10: test_memcached
/**
* Test memcached
*/
function test_memcached()
{
require_once W3TC_LIB_W3_DIR . '/Request.php';
$servers = W3_Request::get_array('servers');
if ($this->is_memcache_available($servers)) {
$result = true;
$error = 'Test passed';
} else {
$result = false;
$error = 'Test failed';
}
echo sprintf('{result: %d, error: "%s"}', $result, addslashes($error));
}