本文整理汇总了PHP中W3_Config::get_array方法的典型用法代码示例。如果您正苦于以下问题:PHP W3_Config::get_array方法的具体用法?PHP W3_Config::get_array怎么用?PHP W3_Config::get_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类W3_Config
的用法示例。
在下文中一共展示了W3_Config::get_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* PHP5-style constructor
*/
function __construct()
{
$this->_config = w3_instance('W3_Config');
$this->_debug = $this->_config->get_boolean('varnish.debug');
$this->_servers = $this->_config->get_array('varnish.servers');
$this->_timeout = $this->_config->get_integer('timelimit.varnish_purge');
}
示例2: foreach
/**
* Loads extensions stored in config
*/
function load_extensions()
{
$extensions = $this->_config->get_array('extensions.active');
foreach ($extensions as $extension => $path) {
include W3TC_EXTENSION_DIR . '/' . trim($path, '/');
}
}
示例3: array
/**
* Returns minify cache object
*
* @return object
*/
function &_get_cache()
{
static $cache = array();
if (!isset($cache[0])) {
switch ($this->_config->get_string('minify.engine')) {
case 'memcached':
require_once W3TC_LIB_W3_DIR . '/Cache/Memcached.php';
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Memcache.php';
$this->_memcached =& new W3_Cache_Memcached(array('servers' => $this->_config->get_array('minify.memcached.servers'), 'persistant' => $this->_config->get_boolean('minify.memcached.persistant')));
$cache[0] =& new Minify_Cache_Memcache($this->_memcached);
break;
case 'apc':
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/APC.php';
$cache[0] =& new Minify_Cache_APC();
break;
case 'eaccelerator':
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/Eaccelerator.php';
$cache[0] =& new Minify_Cache_Eaccelerator();
break;
case 'xcache':
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/XCache.php';
$cache[0] =& new Minify_Cache_XCache();
break;
case 'file':
default:
require_once W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php';
if (!is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
$this->log(sprintf('Cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
}
$cache[0] =& new Minify_Cache_File(W3TC_CACHE_FILE_MINIFY_DIR, $this->_config->get_boolean('minify.file.locking'));
break;
}
}
return $cache[0];
}
示例4: array
/**
* Returns cache object
*
* @param null $blog_id
* @param string $group
* @return W3_Cache_Base
*/
function _get_cache($blog_id = null, $group = 'transient')
{
static $cache = array();
if (is_null($blog_id) && $group != 'site-transient') {
$blog_id = $this->_blog_id;
} else {
$blog_id = 0;
}
if (!isset($cache[$blog_id])) {
$engine = $this->_config->get_string('fragmentcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('fragmentcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('fragmentcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('section' => 'fragment', 'locking' => $this->_config->get_boolean('fragmentcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
default:
$engineConfig = array();
}
$engineConfig['blog_id'] = $blog_id;
$engineConfig['module'] = 'fragmentcache';
$engineConfig['host'] = w3_get_host();
$engineConfig['instance_id'] = w3_get_instance_id();
w3_require_once(W3TC_LIB_W3_DIR . '/Cache.php');
$cache[$blog_id] = W3_Cache::instance($engine, $engineConfig);
}
return $cache[$blog_id];
}
示例5: update_ip_ranges
/**
* Check
* @throws FilesystemOperationException
* @throws FileOperationException
*/
public function update_ip_ranges()
{
w3_require_once(W3TC_INC_DIR . '/functions/http.php');
$ip4_diff = $ip6_diff = false;
$response = w3_http_get(W3TC_CLOUDFLARE_IP4_URL);
$extensions_settings = $this->_config->get_array('extensions.settings', array());
if (!is_wp_error($response)) {
$ip4_data = $response['body'];
$ip4_data = explode("\n", $ip4_data);
$ip4_data_old = w3tc_get_extension_config('cloudflare', 'ips.ip4', $this->_config, array());
if ($ip4_diff = array_diff($ip4_data, $ip4_data_old)) {
$extensions_settings['cloudflare']['ips.ip4'] = $ip4_data;
$this->_config->set('extensions.settings', $extensions_settings);
}
}
$response = w3_http_get(W3TC_CLOUDFLARE_IP6_URL);
if (!is_wp_error($response)) {
$ip6_data = $response['body'];
$ip6_data = explode("\n", $ip6_data);
$ip6_data_old = w3tc_get_extension_config('cloudflare', 'ips.ip6', $this->_config, array());
if ($ip6_diff = array_diff($ip6_data, $ip6_data_old)) {
$extensions_settings['cloudflare']['ips.ip6'] = $ip6_data;
$this->_config->set('extensions.settings', $extensions_settings);
}
}
if ($ip4_diff || $ip6_diff) {
try {
$this->_config->save();
$this->_config->refresh_cache();
} catch (Exception $ex) {
}
}
}
示例6: update_ip_ranges
/**
* Check
* @throws FilesystemOperationException
* @throws FileOperationException
*/
public function update_ip_ranges()
{
w3_require_once(W3TC_INC_DIR . '/functions/http.php');
$ip4_diff = $ip6_diff = false;
$config_master = new W3_Config(true);
$response = w3_http_get(W3TC_CLOUDFLARE_IP4_URL);
if (!is_wp_error($response)) {
$ip4_data = $response['body'];
$ip4_data = explode("\n", $ip4_data);
$ip4_data_old = $this->_config->get_array('cloudflare.ips.ip4');
if ($ip4_diff = array_diff($ip4_data, $ip4_data_old)) {
$config_master->set('cloudflare.ips.ip4', $ip4_data);
}
}
$response = w3_http_get(W3TC_CLOUDFLARE_IP6_URL);
if (!is_wp_error($response)) {
$ip6_data = $response['body'];
$ip6_data = explode("\n", $ip6_data);
$ip6_data_old = $this->_config->get_array('cloudflare.ips.ip6');
if ($ip6_diff = array_diff($ip6_data, $ip6_data_old)) {
$config_master->set('cloudflare.ips.ip6', $ip6_data);
}
}
if ($ip4_diff || $ip6_diff) {
$config_master->save();
}
}
示例7: _check_query_string
private function _check_query_string()
{
$accept_qs = $this->_config->get_array('pgcache.accept.qs');
foreach ($_GET as $key => $value) {
if (!in_array(strtolower($key), $accept_qs)) {
return false;
}
}
return true;
}
示例8: foreach
/**
* Checks if User Agent is mobile
*
* @return boolean
*/
function _is_mobile()
{
$mobile_agents = $this->_config->get_array('pgcache.mobile.agents');
foreach ($mobile_agents as $mobile_agent) {
if (stristr($_SERVER['HTTP_USER_AGENT'], $mobile_agent) !== false) {
return true;
}
}
return false;
}
示例9: array
/**
* Returns array of data headers
*
* @return array
*/
function _get_cached_headers()
{
$data_headers = array();
$cache_headers = $this->_config->get_array('pgcache.cache.headers');
$response_headers = $this->_get_response_headers();
foreach ($response_headers as $header_name => $header_value) {
foreach ($cache_headers as $cache_header_name) {
if (strcasecmp($header_name, $cache_header_name) == 0) {
$data_headers[$header_name] = $header_value;
}
}
}
return $data_headers;
}
示例10: array
/**
* Returns minifier options
*
* @param string $engine
* @return array
*/
function get_options($engine)
{
$options = array();
switch ($engine) {
case 'js':
$options = array('preserveComments' => !$this->_config->get_boolean('minify.js.strip.comments'), 'stripCrlf' => $this->_config->get_boolean('minify.js.strip.crlf'));
break;
case 'css':
$options = array('preserveComments' => !$this->_config->get_boolean('minify.css.strip.comments'), 'stripCrlf' => $this->_config->get_boolean('minify.css.strip.crlf'));
$symlinks = $this->_config->get_array('minify.symlinks');
foreach ($symlinks as $link => $target) {
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$options['symlinks'][$link] = realpath($target);
}
break;
case 'yuijs':
$options = array('line-break' => $this->_config->get_integer('minify.yuijs.options.line-break'), 'nomunge' => $this->_config->get_boolean('minify.yuijs.options.nomunge'), 'preserve-semi' => $this->_config->get_boolean('minify.yuijs.options.preserve-semi'), 'disable-optimizations' => $this->_config->get_boolean('minify.yuijs.options.disable-optimizations'));
break;
case 'yuicss':
$options = array('line-break' => $this->_config->get_integer('minify.yuicss.options.line-break'));
break;
case 'ccjs':
$options = array('compilation_level' => $this->_config->get_string('minify.ccjs.options.compilation_level'), 'formatting' => $this->_config->get_string('minify.ccjs.options.formatting'));
break;
case 'csstidy':
$options = array('remove_bslash' => $this->_config->get_boolean('minify.csstidy.options.remove_bslash'), 'compress_colors' => $this->_config->get_boolean('minify.csstidy.options.compress_colors'), 'compress_font-weight' => $this->_config->get_boolean('minify.csstidy.options.compress_font-weight'), 'lowercase_s' => $this->_config->get_boolean('minify.csstidy.options.lowercase_s'), 'optimise_shorthands' => $this->_config->get_integer('minify.csstidy.options.optimise_shorthands'), 'remove_last_;' => $this->_config->get_boolean('minify.csstidy.options.remove_last_;'), 'case_properties' => $this->_config->get_integer('minify.csstidy.options.case_properties'), 'sort_properties' => $this->_config->get_boolean('minify.csstidy.options.sort_properties'), 'sort_selectors' => $this->_config->get_boolean('minify.csstidy.options.sort_selectors'), 'merge_selectors' => $this->_config->get_integer('minify.csstidy.options.merge_selectors'), 'discard_invalid_properties' => $this->_config->get_boolean('minify.csstidy.options.discard_invalid_properties'), 'css_level' => $this->_config->get_string('minify.csstidy.options.css_level'), 'preserve_css' => $this->_config->get_boolean('minify.csstidy.options.preserve_css'), 'timestamp' => $this->_config->get_boolean('minify.csstidy.options.timestamp'), 'template' => $this->_config->get_string('minify.csstidy.options.template'));
break;
case 'html':
case 'htmlxml':
$options = array('xhtml' => true, 'stripCrlf' => $this->_config->get_boolean('minify.html.strip.crlf'), 'ignoredComments' => $this->_config->get_array('minify.html.comments.ignore'));
break;
case 'htmltidy':
case 'htmltidyxml':
$options = array('clean' => $this->_config->get_boolean('minify.htmltidy.options.clean'), 'hide-comments' => $this->_config->get_boolean('minify.htmltidy.options.hide-comments'), 'wrap' => $this->_config->get_integer('minify.htmltidy.options.wrap'));
break;
}
if ($this->_config->get_boolean('browsercache.enabled') && ($this->_config->get_boolean('browsercache.cssjs.replace') || $this->_config->get_boolean('browsercache.html.replace') || $this->_config->get_boolean('browsercache.other.replace'))) {
$w3_plugin_browsercache = w3_instance('W3_Plugin_BrowserCache');
$options = array_merge($options, array('browserCacheId' => $w3_plugin_browsercache->get_replace_id(), 'browserCacheExtensions' => $w3_plugin_browsercache->get_replace_extensions()));
}
if ($this->_config->get_boolean('cdn.enabled') && $this->_config->get_boolean('cdn.minify.enable')) {
$w3_plugin_cdn = w3_instance('W3_Plugin_CdnCommon');
$cdn = $w3_plugin_cdn->get_cdn();
$options = array_merge($options, array('prependAbsolutePathCallback' => array(&$cdn, 'get_prepend_path')));
}
return $options;
}
示例11: array
/**
* Uncompresses a minify auto filename into an array of files.
* @param $compressed
* @param $type
* @return array
*/
function uncompress_minify_files($compressed, $type)
{
$no_type_files = array();
$compressed = basename($compressed, '.' . $type);
$uncompressed = $this->_uncompress(base64_decode(strtr($compressed, '-_', '+/')));
$exploded = explode(',', $uncompressed);
$replacements = $this->_minify_path_replacements();
foreach ($exploded as $file) {
if (!w3_is_url($file)) {
$prefix = substr($file, 0, 1);
$after_pre = substr($file, 1, 1);
if (isset($replacements[$prefix]) && $after_pre == '/') {
$file = $replacements[$prefix] . substr($file, 1);
$no_type_files[] = $file;
} else {
$no_type_files[] = $file;
}
} else {
$no_type_files[] = $file;
}
}
$files = array();
foreach ($no_type_files as $no_type_file) {
$file = !w3_is_url($no_type_file) ? $no_type_file . '.' . $type : $no_type_file;
$verified = false;
if (w3_is_url($file)) {
$external = $this->_config->get_array('minify.cache.files');
foreach ($external as $ext) {
if (preg_match('#' . w3_get_url_regexp($ext) . '#', $file) && !$verified) {
$verified = true;
}
}
if (!$verified) {
$this->error(sprintf('Remote file not in external files/libraries list: "%s"', $file));
}
} elseif (strpos($file, '..') != false || strpos($file, '//') !== false || strpos($file, '\\') !== false && strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' || preg_match('/(?:^|[^\\.])\\.\\//', $file) || !preg_match('/^[a-zA-Z0-9_.\\/-]|[\\\\]+$/', $file)) {
$verified = false;
$this->error(sprintf('File path invalid: "%s"', $file));
} else {
$verified = true;
}
if ($verified) {
$files[] = $file;
}
}
return $files;
}
示例12: array
/**
* Check request URI
*
* @return boolean
*/
function _check_request_uri()
{
$auto_reject_uri = array('wp-login', 'wp-register');
foreach ($auto_reject_uri as $uri) {
if (strstr($_SERVER['REQUEST_URI'], $uri) !== false) {
return false;
}
}
$reject_uri = $this->_config->get_array('objectcache.reject.uri');
$reject_uri = array_map('w3_parse_path', $reject_uri);
foreach ($reject_uri as $expr) {
$expr = trim($expr);
if ($expr != '' && preg_match('~' . $expr . '~i', $_SERVER['REQUEST_URI'])) {
return false;
}
}
return true;
}
示例13: foreach
/**
* Checks for WordPress cookies
*
* @return boolean
*/
function _check_cookies()
{
foreach (array_keys($_COOKIE) as $cookie_name) {
if ($cookie_name == 'wordpress_test_cookie') {
continue;
}
if (preg_match('/^wp-postpass|^comment_author/', $cookie_name)) {
return false;
}
}
foreach ($this->_config->get_array('dbcache.reject.cookie') as $reject_cookie) {
foreach (array_keys($_COOKIE) as $cookie_name) {
if (strstr($cookie_name, $reject_cookie) !== false) {
return false;
}
}
}
return true;
}
示例14: array
/**
* Returns cache object
*
* @return W3_Cache_Base
*/
function &_get_cache()
{
static $cache = array();
if (!isset($cache[0])) {
$engine = $this->_config->get_string('objectcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('objectcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('objectcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('cache_dir' => W3TC_CACHE_FILE_OBJECTCACHE_DIR, 'locking' => $this->_config->get_boolean('objectcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
default:
$engineConfig = array();
}
require_once W3TC_LIB_W3_DIR . '/Cache.php';
@($cache[0] =& W3_Cache::instance($engine, $engineConfig));
}
return $cache[0];
}
示例15: explode
/**
* Create a NetDNA or MaxCDN pull zone automatically
*/
function action_cdn_auto_create_netdna_maxcdn_pull_zone()
{
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin.php');
$cdn_engine = W3_Request::get_string('type');
$this->validate_cdnengine_is_netdna_maxcdn($cdn_engine);
$authorization_key = W3_Request::get_string('authorization_key');
$this->validate_authorization_key($authorization_key);
$keys = explode('+', $authorization_key);
list($alias, $consumerkey, $consumersecret) = $keys;
$url = w3_get_home_url();
try {
$api = new NetDNA($alias, $consumerkey, $consumersecret);
$disable_cooker_header = $this->_config->get_boolean('browsercache.other.nocookies') || $this->_config->get_boolean('browsercache.cssjs.nocookies');
$zone = $api->create_default_pull_zone($url, null, null, array('ignore_setcookie_header' => $disable_cooker_header));
$name = $zone['name'];
$temporary_url = "{$name}.{$alias}.netdna-cdn.com";
$test_result = -1;
if (!$this->_config->get_array("cdn.{$cdn_engine}.domain")) {
$test_result = $this->test_cdn_url($temporary_url) ? 1 : 0;
$this->_config->set("cdn.{$cdn_engine}.zone_id", $zone['id']);
if ($test_result) {
$this->_config->set("cdn.enabled", true);
}
$this->_config->set("cdn.{$cdn_engine}.domain", array($temporary_url));
}
$this->_config->save();
$config_admin = w3_instance('W3_ConfigAdmin');
$zones = $api->get_pull_zones();
$zone_count = sizeof($zones);
w3tc_make_track_call(array('type' => 'cdn', 'data' => array('cdn' => $cdn_engine, 'action' => 'zonecreation', 'creation' => 'manual', 'creationtime' => time(), 'signupclick' => $config_admin->get_integer('track.maxcdn_signup'), 'authorizeclick' => $config_admin->get_integer('track.maxcdn_authorize'), 'validationclick' => $config_admin->get_integer('track.maxcdn_validation'), 'total_zones' => $zone_count, 'test' => $test_result)));
$result = array('result' => 'single', 'cnames' => array($temporary_url));
} catch (Exception $ex) {
$result = array('result' => 'error', 'message' => sprintf(__('Could not create default zone.' . $ex->getMessage(), 'w3-total-cache')));
}
echo json_encode($result);
exit;
}