本文整理汇总了PHP中w3_get_base_path函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_base_path函数的具体用法?PHP w3_get_base_path怎么用?PHP w3_get_base_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_base_path函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_imported_legacy_config_keys
/**
* Reads legacy config file
* @param int $blog_id
* @param bool $force_master
* @return array
*/
public function get_imported_legacy_config_keys($blog_id, $force_master = false)
{
$suffix = '';
if ($force_master) {
} else {
if ($blog_id > 0) {
if (w3_is_network()) {
if (w3_is_subdomain_install()) {
$suffix = '-' . w3_get_domain(w3_get_host());
} else {
// try subdir blog
$request_uri = rtrim($_SERVER['REQUEST_URI'], '/');
$site_home_uri = w3_get_base_path();
if (substr($request_uri, 0, strlen($site_home_uri)) == $site_home_uri) {
$request_path_in_wp = '/' . substr($request_uri, strlen($site_home_uri));
$n = strpos($request_path_in_wp, '/', 1);
if ($n === false) {
$blog_path_in_wp = substr($request_path_in_wp, 1);
} else {
$blog_path_in_wp = substr($request_path_in_wp, 1, $n - 1);
}
$suffix = '-' . ($blog_path_in_wp != 'wp-admin' ? $blog_path_in_wp . '.' : '') . w3_get_domain(w3_get_host());
}
}
}
}
}
$filename = WP_CONTENT_DIR . '/w3-total-cache-config' . $suffix . '.php';
$legacy_config = W3_ConfigData::get_array_from_file($filename);
if (is_array($legacy_config) && isset($legacy_config['pgcache.engine']) && $legacy_config['pgcache.engine'] == 'file_pgcache') {
$legacy_config['pgcache.engine'] = 'file_generic';
}
return $legacy_config;
}
示例2: get_http_referrer
/**
* Returns HTTP referrer value
*
* @return string
*/
function get_http_referrer()
{
$http_referrer = '';
if (isset($_COOKIE[W3TC_REFERRER_COOKIE_NAME])) {
$http_referrer = $_COOKIE[W3TC_REFERRER_COOKIE_NAME];
} elseif (isset($_SERVER['HTTP_REFERER'])) {
$http_referrer = $_SERVER['HTTP_REFERER'];
setcookie(W3TC_REFERRER_COOKIE_NAME, $http_referrer, 0, w3_get_base_path());
}
return $http_referrer;
}
示例3: get_http_referrer
/**
* Returns HTTP referrer value
*
* @return string
*/
function get_http_referrer()
{
$http_referrer = '';
if ($this->has_enabled_groups()) {
if (isset($_COOKIE[W3TC_REFERRER_COOKIE_NAME])) {
$http_referrer = $_COOKIE[W3TC_REFERRER_COOKIE_NAME];
} elseif (isset($_SERVER['HTTP_REFERER'])) {
$http_referrer = $_SERVER['HTTP_REFERER'];
setcookie(W3TC_REFERRER_COOKIE_NAME, $http_referrer, 0, w3_get_base_path());
}
} elseif (isset($_COOKIE[W3TC_REFERRER_COOKIE_NAME])) {
setcookie(W3TC_REFERRER_COOKIE_NAME, '', 1);
}
return $http_referrer;
}
示例4: _rewriteRelative
/**
* Rewrite a file relative URI as root relative
*
* <code>
* Minify_CSS_UriRewriter::rewriteRelative(
* '../img/hello.gif'
* , '/home/user/www/css' // path of CSS file
* , '/home/user/www' // doc root
* );
* // returns '/img/hello.gif'
*
* // example where static files are stored in a symlinked directory
* Minify_CSS_UriRewriter::rewriteRelative(
* 'hello.gif'
* , '/var/staticFiles/theme'
* , '/home/user/www'
* , array('/home/user/www/static' => '/var/staticFiles')
* );
* // returns '/static/theme/hello.gif'
* </code>
*
* @param string $uri file relative URI
*
* @param string $realCurrentDir realpath of the current file's directory.
*
* @param string $realDocRoot realpath of the site document root.
*
* @param array $symlinks (default = array()) If the file is stored in
* a symlink-ed directory, provide an array of link paths to
* real target paths, where the link paths "appear" to be within the document
* root. E.g.:
* <code>
* array('/home/foo/www/not/real/path' => '/real/target/path') // unix
* array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
* </code>
*
* @return string
*/
private static function _rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
{
if ('/' === $uri[0]) {
// root-relative
return $uri;
}
// prepend path with current dir separator (OS-independent)
$path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
self::$debugText .= "file-relative URI : {$uri}\n" . "path prepended : {$path}\n";
// "unresolve" a symlink back to doc root
foreach ($symlinks as $link => $target) {
if (0 === strpos($path, $target)) {
// replace $target with $link
$path = $link . substr($path, strlen($target));
self::$debugText .= "symlink unresolved : {$path}\n";
break;
}
}
// strip doc root
$path = substr($path, strlen($realDocRoot));
self::$debugText .= "docroot stripped : {$path}\n";
// fix to root-relative URI
$uri = strtr($path, '/\\', '//');
// remove /./ and /../ where possible
$uri = str_replace('/./', '/', $uri);
// inspired by patch from Oleg Cherniy
do {
$uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
} while ($changed);
self::$debugText .= "traversals removed : {$uri}\n\n";
$uri = preg_replace('~^' . w3_preg_quote(w3_get_base_path()) . '~', w3_get_site_path(), $uri);
return $uri;
}
示例5: w3_translate_file
/**
* Translates remote file to local file
*
* @param string $file
* @return string
*/
function w3_translate_file($file)
{
if (!w3_is_url($file)) {
$file = '/' . ltrim($file, '/');
$regexp = '~^' . w3_preg_quote(w3_get_site_path()) . '~';
$file = preg_replace($regexp, w3_get_base_path(), $file);
$file = ltrim($file, '/');
}
return $file;
}
示例6: rules_core_generate_nginx
/**
* Generates rules for WP dir
*
* @param W3_Config $config
* @return string
*/
private function rules_core_generate_nginx($config)
{
$is_network = w3_is_network();
$base_path = w3_get_base_path();
$cache_dir = w3_path(W3TC_CACHE_PAGE_ENHANCED_DIR);
$permalink_structure = get_option('permalink_structure');
/**
* Auto reject cookies
*/
$reject_cookies = array('comment_author', 'wp-postpass');
if ($config->get_string('pgcache.engine') == 'file_generic') {
$reject_cookies[] = 'w3tc_logged_out';
}
/**
* Reject cache for logged in users
* OR
* Reject cache for roles if any
*/
if ($config->get_boolean('pgcache.reject.logged')) {
$reject_cookies = array_merge($reject_cookies, array('wordpress_logged_in'));
} elseif ($config->get_boolean('pgcache.reject.logged_roles')) {
$new_cookies = array();
foreach ($config->get_array('pgcache.reject.roles') as $role) {
$new_cookies[] = 'w3tc_logged_' . md5(NONCE_KEY . $role);
}
$reject_cookies = array_merge($reject_cookies, $new_cookies);
}
/**
* Custom config
*/
$reject_cookies = array_merge($reject_cookies, $config->get_array('pgcache.reject.cookie'));
w3_array_trim($reject_cookies);
$reject_user_agents = $config->get_array('pgcache.reject.ua');
if ($config->get_boolean('pgcache.compatibility')) {
$reject_user_agents = array_merge(array(W3TC_POWERED_BY), $reject_user_agents);
}
w3_array_trim($reject_user_agents);
/**
* Generate rules
*/
$env_w3tc_ua = '';
$env_w3tc_ref = '';
$env_w3tc_ssl = '';
$env_w3tc_ext = '';
$env_w3tc_enc = '';
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
if ($config->get_boolean('pgcache.debug')) {
$rules .= "rewrite ^(.*\\/)?w3tc_rewrite_test/?\$ \$1?w3tc_rewrite_test=1 last;\n";
}
/**
* Check for mobile redirect
*/
if ($config->get_boolean('mobile.enabled')) {
$mobile_groups = $config->get_array('mobile.rgroups');
foreach ($mobile_groups as $mobile_group => $mobile_config) {
$mobile_enabled = isset($mobile_config['enabled']) ? (bool) $mobile_config['enabled'] : false;
$mobile_agents = isset($mobile_config['agents']) ? (array) $mobile_config['agents'] : '';
$mobile_redirect = isset($mobile_config['redirect']) ? $mobile_config['redirect'] : '';
if ($mobile_enabled && count($mobile_agents) && $mobile_redirect) {
$rules .= "if (\$http_user_agent ~* \"(" . implode('|', $mobile_agents) . ")\") {\n";
$rules .= " rewrite .* " . $mobile_redirect . " last;\n";
$rules .= "}\n";
}
}
}
/**
* Check for referrer redirect
*/
if ($config->get_boolean('referrer.enabled')) {
$referrer_groups = $config->get_array('referrer.rgroups');
foreach ($referrer_groups as $referrer_group => $referrer_config) {
$referrer_enabled = isset($referrer_config['enabled']) ? (bool) $referrer_config['enabled'] : false;
$referrer_referrers = isset($referrer_config['referrers']) ? (array) $referrer_config['referrers'] : '';
$referrer_redirect = isset($referrer_config['redirect']) ? $referrer_config['redirect'] : '';
if ($referrer_enabled && count($referrer_referrers) && $referrer_redirect) {
$rules .= "if (\$http_cookie ~* \"w3tc_referrer=.*(" . implode('|', $referrer_referrers) . ")\") {\n";
$rules .= " rewrite .* " . $referrer_redirect . " last;\n";
$rules .= "}\n";
}
}
}
/**
* Don't accept POSTs
*/
$rules .= "set \$w3tc_rewrite 1;\n";
$rules .= "if (\$request_method = POST) {\n";
$rules .= " set \$w3tc_rewrite 0;\n";
$rules .= "}\n";
/**
* Query string should be empty
*/
$rules .= "if (\$query_string != \"\") {\n";
$rules .= " set \$w3tc_rewrite 0;\n";
//.........这里部分代码省略.........
示例7: get_server_info
/**
* Returns server info
*
* @return array
*/
function get_server_info()
{
global $wp_version, $wp_db_version, $wpdb;
$wordpress_plugins = get_plugins();
$wordpress_plugins_active = array();
foreach ($wordpress_plugins as $wordpress_plugin_file => $wordpress_plugin) {
if (is_plugin_active($wordpress_plugin_file)) {
$wordpress_plugins_active[$wordpress_plugin_file] = $wordpress_plugin;
}
}
$mysql_version = $wpdb->get_var('SELECT VERSION()');
$mysql_variables_result = (array) $wpdb->get_results('SHOW VARIABLES', ARRAY_N);
$mysql_variables = array();
foreach ($mysql_variables_result as $mysql_variables_row) {
$mysql_variables[$mysql_variables_row[0]] = $mysql_variables_row[1];
}
$server_info = array('w3tc' => array('version' => W3TC_VERSION, 'server' => !empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown', 'dir' => W3TC_DIR, 'cache_dir' => W3TC_CACHE_DIR, 'blog_id' => w3_get_blog_id(), 'document_root' => w3_get_document_root(), 'home_root' => w3_get_home_root(), 'site_root' => w3_get_site_root(), 'base_path' => w3_get_base_path(), 'home_path' => w3_get_home_path(), 'site_path' => w3_get_site_path()), 'wp' => array('version' => $wp_version, 'db_version' => $wp_db_version, 'abspath' => ABSPATH, 'home' => get_option('home'), 'siteurl' => get_option('siteurl'), 'email' => get_option('admin_email'), 'upload_info' => (array) w3_upload_info(), 'theme' => w3tc_get_current_theme(), 'wp_cache' => defined('WP_CACHE') && WP_CACHE ? 'true' : 'false', 'plugins' => $wordpress_plugins_active), 'mysql' => array('version' => $mysql_version, 'variables' => $mysql_variables));
return $server_info;
}
示例8: generate_rules_core_nginx
/**
* Generates rules for WP dir
*
* @return string
*/
function generate_rules_core_nginx()
{
$is_network = w3_is_network();
$is_vhost = w3_is_subdomain_install();
$base_path = w3_get_base_path();
$cache_dir = w3_path(W3TC_CACHE_FILE_PGCACHE_DIR);
$permalink_structure = get_option('permalink_structure');
/**
* Auto reject cookies
*/
$reject_cookies = array('comment_author', 'wp-postpass');
/**
* Auto reject URIs
*/
$reject_uris = array('\\/wp-admin\\/', '\\/xmlrpc.php', '\\/wp-(app|cron|login|register|mail)\\.php');
/**
* Reject cache for logged in users
*/
if ($this->_config->get_boolean('pgcache.reject.logged')) {
$reject_cookies = array_merge($reject_cookies, array('wordpress_[a-f0-9]+', 'wordpress_logged_in'));
}
/**
* Reject cache for home page
*/
if (!$this->_config->get_boolean('pgcache.cache.home')) {
$reject_uris[] = '^(\\/|\\/index.php)$';
}
/**
* Reject cache for feeds
*/
if (!$this->_config->get_boolean('pgcache.cache.feed')) {
$reject_uris[] = '\\/feed\\/';
}
/**
* Custom config
*/
$reject_cookies = array_merge($reject_cookies, $this->_config->get_array('pgcache.reject.cookie'));
$reject_uris = array_merge($reject_uris, $this->_config->get_array('pgcache.reject.uri'));
$reject_uris = array_map('w3_parse_path', $reject_uris);
$reject_user_agents = array_merge(array(W3TC_POWERED_BY), $this->_config->get_array('pgcache.reject.ua'));
$accept_uris = $this->_config->get_array('pgcache.accept.uri');
$accept_files = $this->_config->get_array('pgcache.accept.files');
/**
* Generate rules
*/
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
$rules .= "rewrite ^(.*\\/)?w3tc_rewrite_test\$ \$1?w3tc_rewrite_test=1 last;\n";
/**
* Check for mobile redirect
*/
if ($this->_config->get_boolean('mobile.enabled')) {
$mobile_groups = $this->_config->get_array('mobile.rgroups');
foreach ($mobile_groups as $mobile_group => $mobile_config) {
$mobile_enabled = isset($mobile_config['enabled']) ? (bool) $mobile_config['enabled'] : false;
$mobile_agents = isset($mobile_config['agents']) ? (array) $mobile_config['agents'] : '';
$mobile_redirect = isset($mobile_config['redirect']) ? $mobile_config['redirect'] : '';
if ($mobile_enabled && count($mobile_agents) && $mobile_redirect) {
$rules .= "if (\$http_user_agent ~* \"(" . implode('|', $mobile_agents) . ")\") {\n";
$rules .= " rewrite .* " . $mobile_redirect . " last;\n";
$rules .= "}\n";
}
}
}
/**
* Check for referrer redirect
*/
if ($this->_config->get_boolean('referrer.enabled')) {
$referrer_groups = $this->_config->get_array('referrer.rgroups');
foreach ($referrer_groups as $referrer_group => $referrer_config) {
$referrer_enabled = isset($referrer_config['enabled']) ? (bool) $referrer_config['enabled'] : false;
$referrer_referrers = isset($referrer_config['referrers']) ? (array) $referrer_config['referrers'] : '';
$referrer_redirect = isset($referrer_config['redirect']) ? $referrer_config['redirect'] : '';
if ($referrer_enabled && count($referrer_referrers) && $referrer_redirect) {
$rules .= "if (\$http_cookie ~* \"w3tc_referrer=.*(" . implode('|', $referrer_referrers) . ")\") {\n";
$rules .= " rewrite .* " . $referrer_redirect . " last;\n";
$rules .= "}\n";
}
}
}
/**
* Don't accept POSTs
*/
$rules .= "set \$w3tc_rewrite 1;\n";
$rules .= "if (\$request_method = POST) {\n";
$rules .= " set \$w3tc_rewrite 0;\n";
$rules .= "}\n";
/**
* Query string should be empty
*/
$rules .= "if (\$query_string != \"\") {\n";
$rules .= " set \$w3tc_rewrite 0;\n";
$rules .= "}\n";
/**
* Check hostname
//.........这里部分代码省略.........
示例9: _import_legacy_config
/**
* Reads legacy config file
*
* @param object $compiled_config
* @return array
*/
private function _import_legacy_config($compiled_config)
{
$suffix = '';
if ($this->_blog_id > 0) {
if (w3_is_network()) {
if (w3_is_subdomain_install()) {
$suffix = '-' . w3_get_domain(w3_get_host());
} else {
// try subdir blog
$request_uri = rtrim($_SERVER['REQUEST_URI'], '/');
$site_home_uri = w3_get_base_path();
if (substr($request_uri, 0, strlen($site_home_uri)) == $site_home_uri) {
$request_path_in_wp = '/' . substr($request_uri, strlen($site_home_uri));
$n = strpos($request_path_in_wp, '/', 1);
if ($n === false) {
$blog_path_in_wp = substr($request_path_in_wp, 1);
} else {
$blog_path_in_wp = substr($request_path_in_wp, 1, $n - 1);
}
$suffix = '-' . ($blog_path_in_wp != 'wp-admin' ? $blog_path_in_wp . '.' : '') . w3_get_domain(w3_get_host());
}
}
}
}
$filename = WP_CONTENT_DIR . '/w3-total-cache-config' . $suffix . '.php';
return $compiled_config->get_array_from_file($filename);
}