本文整理汇总了PHP中Util_Environment::get_url_regexp方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::get_url_regexp方法的具体用法?PHP Util_Environment::get_url_regexp怎么用?PHP Util_Environment::get_url_regexp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::get_url_regexp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minify_filename_to_urls_for_minification
/**
* Decode a minify auto filename into an array of files.
*
* @param unknown $compressed
* @param unknown $type
* @return array
*/
public static function minify_filename_to_urls_for_minification($filename, $type)
{
$v = get_option('w3tc_minify');
$minify_filenames = @json_decode($v, true);
if (!is_array($minify_filenames)) {
$minify_filenames = array();
}
$minify_filename = $filename . '.' . $type;
if (!isset($minify_filenames[$minify_filename])) {
return array();
}
$urls_unverified = $minify_filenames[$minify_filename];
$urls = array();
foreach ($urls_unverified as $file) {
$verified = false;
if (Util_Environment::is_url($file)) {
$c = Dispatcher::config();
$external = $c->get_array('minify.cache.files');
foreach ($external as $ext) {
if (preg_match('#' . Util_Environment::get_url_regexp($ext) . '#', $file) && !$verified) {
$verified = true;
}
}
if (!$verified) {
Minify_Core::debug_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;
Minify_Core::debug_error(sprintf('File path invalid: "%s"', $file));
} else {
$verified = true;
}
if ($verified) {
$urls[] = $file;
}
}
return $urls;
}
示例2: is_file_for_minification
/**
* URL file filter
*
* @param string $file
* @return bool
*/
public function is_file_for_minification($file)
{
static $external;
if (!isset($external)) {
$external = $this->config->get_array('minify.cache.files');
}
foreach ($external as $ext) {
if (preg_match('#' . Util_Environment::get_url_regexp($ext) . '#', $file)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: whilelisted ' . $file);
}
return true;
}
}
$file_normalized = Util_Environment::remove_query_all($file);
$ext = strrchr($file_normalized, '.');
if ($ext != '.js' && $ext != '.css') {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: unknown extension ' . $ext . ' for ' . $file);
}
return false;
}
if (Util_Environment::is_url($file_normalized)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: its url ' . $file);
}
return false;
}
$path = Util_Environment::document_root() . '/' . $file;
if (!file_exists($path)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: file doesnt exists ' . $path);
}
return false;
}
if ($this->debug) {
Minify_Core::log('is_file_for_minification: true for file ' . $file . ' path ' . $path);
}
return true;
}
示例3: fill_regexps
private function fill_regexps()
{
$regexps = array();
$site_path = Util_Environment::site_url_uri();
$domain_url_regexp = Util_Environment::home_domain_root_url_regexp();
$site_domain_url_regexp = false;
if ($domain_url_regexp != Util_Environment::get_url_regexp(Util_Environment::url_to_host(site_url()))) {
$site_domain_url_regexp = Util_Environment::get_url_regexp(Util_Environment::url_to_host(site_url()));
}
if ($this->_config->get_boolean('cdn.uploads.enable')) {
$upload_info = Util_Http::upload_info();
if ($upload_info) {
$baseurl = $upload_info['baseurl'];
if (defined('DOMAIN_MAPPING') && DOMAIN_MAPPING) {
$parsed = @parse_url($upload_info['baseurl']);
$baseurl = home_url() . $parsed['path'];
}
$regexps = $this->make_uploads_regexes($domain_url_regexp, $baseurl, $upload_info, $regexps);
if ($site_domain_url_regexp) {
$regexps = $this->make_uploads_regexes($site_domain_url_regexp, $baseurl, $upload_info, $regexps);
}
}
}
if ($this->_config->get_boolean('cdn.includes.enable')) {
$mask = $this->_config->get_string('cdn.includes.files');
if ($mask != '') {
$regexps[] = '~(["\'(=])\\s*((' . $domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path . WPINC) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
if ($site_domain_url_regexp) {
$regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path . WPINC) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
}
}
}
if ($this->_config->get_boolean('cdn.theme.enable')) {
$theme_dir = preg_replace('~' . $domain_url_regexp . '~i', '', get_theme_root_uri());
$mask = $this->_config->get_string('cdn.theme.files');
if ($mask != '') {
$regexps[] = '~(["\'(=])\\s*((' . $domain_url_regexp . ')?(' . Util_Environment::preg_quote($theme_dir) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
if ($site_domain_url_regexp) {
$theme_dir2 = preg_replace('~' . $site_domain_url_regexp . '~i', '', get_theme_root_uri());
$regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($theme_dir) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
$regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($theme_dir2) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
}
}
}
if ($this->_config->get_boolean('cdn.custom.enable')) {
$masks = $this->_config->get_array('cdn.custom.files');
$masks = array_map(array('\\W3TC\\Cdn_Util', 'replace_folder_placeholders'), $masks);
$masks = array_map(array('\\W3TC\\Util_Environment', 'parse_path'), $masks);
if (count($masks)) {
$mask_regexps = array();
foreach ($masks as $mask) {
if ($mask != '') {
$mask = Util_Environment::normalize_file($mask);
$mask_regexps[] = Cdn_Util::get_regexp_by_mask($mask);
}
}
$regexps[] = '~(["\'(=])\\s*((' . $domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')([^"\'() >]*)))~i';
if ($site_domain_url_regexp) {
$regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')([^"\'() >]*)))~i';
}
}
}
$this->_regexps = $regexps;
}
示例4: home_url_regexp
/**
* Returns home url regexp
*
* @return string
*/
public static function home_url_regexp()
{
$home_url = get_home_url();
$regexp = Util_Environment::get_url_regexp($home_url);
return $regexp;
}