• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP w3_is_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中w3_is_url函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_is_url函数的具体用法?PHP w3_is_url怎么用?PHP w3_is_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了w3_is_url函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: _processUriCB

 private static function _processUriCB($m)
 {
     // $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
     $isImport = $m[0][0] === '@';
     // determine URI and the quote character (if any)
     if ($isImport) {
         $quoteChar = $m[1];
         $uri = $m[2];
     } else {
         // $m[1] is either quoted or not
         $quoteChar = $m[1][0] === "'" || $m[1][0] === '"' ? $m[1][0] : '';
         $uri = $quoteChar === '' ? $m[1] : substr($m[1], 1, strlen($m[1]) - 2);
     }
     // analyze URI
     if (false === strpos($uri, '//') && 0 !== strpos($uri, 'data:')) {
         // prepend
         if (self::$_prependRelativePath) {
             if (w3_is_url(self::$_prependRelativePath)) {
                 $parse_url = @parse_url(self::$_prependRelativePath);
                 if ($parse_url && isset($parse_url['host'])) {
                     $scheme = $parse_url['scheme'];
                     $host = $parse_url['host'];
                     $port = isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '';
                     $path = !empty($parse_url['path']) ? $parse_url['path'] : '/';
                     $dir_css = preg_replace('~[^/]+$~', '', $path);
                     $dir_obj = preg_replace('~[^/]+$~', '', $uri);
                     $dir = ltrim(strpos($dir_obj, '/') === 0 ? w3_realpath($dir_obj) : w3_realpath($dir_css . $dir_obj), '/');
                     $file = basename($uri);
                     $uri = sprintf('%s://%s%s/%s/%s', $scheme, $host, $port, $dir, $file);
                 }
             } else {
                 $uri = self::$_prependRelativePath . $uri;
             }
         } else {
             $uri = self::_rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
             if (self::$_prependAbsolutePath) {
                 $prependAbsolutePath = self::$_prependAbsolutePath;
             } elseif (self::$_prependAbsolutePathCallback) {
                 $prependAbsolutePath = call_user_func(self::$_prependAbsolutePathCallback, $uri);
             } else {
                 $prependAbsolutePath = '';
             }
             if ($prependAbsolutePath) {
                 $uri = rtrim($prependAbsolutePath, '/') . $uri;
             }
         }
         if (self::$_browserCacheId && count(self::$_browserCacheExtensions)) {
             $matches = null;
             if (preg_match('~\\.([a-z-_]+)(\\?.*)?$~', $uri, $matches)) {
                 $extension = $matches[1];
                 $query = isset($matches[2]) ? $matches[2] : '';
                 if ($extension && in_array($extension, self::$_browserCacheExtensions)) {
                     $uri = w3_remove_query($uri);
                     $uri .= ($query ? '&' : '?') . self::$_browserCacheId;
                 }
             }
         }
     }
     return $isImport ? "@import {$quoteChar}{$uri}{$quoteChar}" : "url({$quoteChar}{$uri}{$quoteChar})";
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:60,代码来源:UriRewriter.php


示例2: 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;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:16,代码来源:define.php


示例3: remove_scripts

 /**
  * Remove script tags from the source
  *
  * @param string $content
  * @param array $files
  * @return void
  */
 function remove_scripts(&$content, $files)
 {
     $regexps = array();
     $domain_url_regexp = w3_get_domain_url_regexp();
     foreach ($files as $file) {
         $this->replaced_scripts[] = $file;
         if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
             // external JS files
             $regexps[] = w3_preg_quote($file);
         } else {
             // local JS files
             $file = ltrim(preg_replace('~' . $domain_url_regexp . '~i', '', $file), '/\\');
             $regexps[] = '(' . $domain_url_regexp . ')?/?' . w3_preg_quote($file);
         }
     }
     foreach ($regexps as $regexp) {
         $content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~Uis', '', $content);
     }
 }
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:26,代码来源:Minify.php


示例4: w3_normalize_file_minify

 function w3_normalize_file_minify($file)
 {
     global $wp_rewrite;
     $hmwp = new HideMyWP();
     $hmwp->init();
     $hmwp->add_rewrite_rules($wp_rewrite);
     $file = $hmwp->reverse_partial_filter($file);
     if (w3_is_url($file)) {
         if (strstr($file, '?') === false) {
             $domain_url_regexp = '~' . w3_get_domain_url_regexp() . '~i';
             $file = preg_replace($domain_url_regexp, '', $file);
         }
     }
     if (!w3_is_url($file)) {
         $file = w3_path($file);
         $file = str_replace(w3_get_document_root(), '', $file);
         $file = ltrim($file, '/');
     }
     return $file;
 }
开发者ID:roycocup,项目名称:enclothed,代码行数:20,代码来源:hide-my-wp.php


示例5: import_library

 /**
  * Imports library
  *
  * @param integer $limit
  * @param integer $offset
  * @param integer $count
  * @param integer $total
  * @param array $results
  * @return boolean
  */
 function import_library($limit, $offset, &$count, &$total, &$results)
 {
     global $wpdb;
     $count = 0;
     $total = 0;
     $results = array();
     $upload_info = w3_upload_info();
     $uploads_use_yearmonth_folders = get_option('uploads_use_yearmonth_folders');
     $document_root = w3_get_document_root();
     @set_time_limit($this->_config->get_integer('timelimit.cdn_import'));
     if ($upload_info) {
         /**
          * Search for posts with links or images
          */
         $sql = sprintf('SELECT
     		ID,
     		post_content,
     		post_date
         FROM
             %sposts
         WHERE
             post_status = "publish"
             AND (post_type = "post" OR post_type = "page")
             AND (post_content LIKE "%%src=%%"
             	OR post_content LIKE "%%href=%%")
    		', $wpdb->prefix);
         if ($limit) {
             $sql .= sprintf(' LIMIT %d', $limit);
             if ($offset) {
                 $sql .= sprintf(' OFFSET %d', $offset);
             }
         }
         $posts = $wpdb->get_results($sql);
         if ($posts) {
             $count = count($posts);
             $total = $this->get_import_posts_count();
             $regexp = '~(' . $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files')) . ')$~';
             $import_external = $this->_config->get_boolean('cdn.import.external');
             foreach ($posts as $post) {
                 $matches = null;
                 $replaced = array();
                 $attachments = array();
                 $post_content = $post->post_content;
                 /**
                  * Search for all link and image sources
                  */
                 if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
                     foreach ($matches as $match) {
                         list($search, $attribute, $origin) = $match;
                         /**
                          * Check if $search is already replaced
                          */
                         if (isset($replaced[$search])) {
                             continue;
                         }
                         $error = '';
                         $result = false;
                         $src = w3_normalize_file_minify($origin);
                         $dst = '';
                         /**
                          * Check if file exists in the library
                          */
                         if (stristr($origin, $upload_info['baseurl']) === false) {
                             /**
                              * Check file extension
                              */
                             $check_src = $src;
                             if (w3_is_url($check_src)) {
                                 $qpos = strpos($check_src, '?');
                                 if ($qpos !== false) {
                                     $check_src = substr($check_src, 0, $qpos);
                                 }
                             }
                             if (preg_match($regexp, $check_src)) {
                                 /**
                                  * Check for already uploaded attachment
                                  */
                                 if (isset($attachments[$src])) {
                                     list($dst, $dst_url) = $attachments[$src];
                                     $result = true;
                                 } else {
                                     if ($uploads_use_yearmonth_folders) {
                                         $upload_subdir = date('Y/m', strtotime($post->post_date));
                                         $upload_dir = sprintf('%s/%s', $upload_info['basedir'], $upload_subdir);
                                         $upload_url = sprintf('%s/%s', $upload_info['baseurl'], $upload_subdir);
                                     } else {
                                         $upload_subdir = '';
                                         $upload_dir = $upload_info['basedir'];
                                         $upload_url = $upload_info['baseurl'];
                                     }
//.........这里部分代码省略.........
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:101,代码来源:CdnAdmin.php


示例6: get_groups

 /**
  * Returns minify groups
  * @param string $group
  * @param string $type
  * @return array
  */
 function get_groups($group, $type)
 {
     $result = array();
     switch ($type) {
         case 'css':
             $groups = $this->_config->get_array('minify.css.groups');
             break;
         case 'js':
             $groups = $this->_config->get_array('minify.js.groups');
             break;
         default:
             return $result;
     }
     if (isset($groups['default'])) {
         $locations = (array) $groups['default'];
     } else {
         $locations = array();
     }
     if ($group != 'default' && isset($groups[$group])) {
         $locations = array_merge_recursive($locations, (array) $groups[$group]);
     }
     foreach ($locations as $location => $config) {
         if (!empty($config['files'])) {
             foreach ((array) $config['files'] as $file) {
                 if (w3_is_url($file)) {
                     if ($precached_file = $this->_precache_file($file, $type)) {
                         $result[$location][$file] = $precached_file;
                     }
                 } else {
                     if (w3_get_blog_id()) {
                         // for WPMU we have to remove blog path
                         $file = str_replace(w3_get_site_path(), '', $file);
                     }
                     $result[$location][$file] = '//' . $file;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:46,代码来源:Minify.php


示例7: get_groups

 /**
  * Returns minify groups
  *
  * @param string $theme
  * @param string $template
  * @param string $type
  * @return array
  */
 function get_groups($theme, $template, $type)
 {
     $result = array();
     switch ($type) {
         case 'css':
             $groups = $this->_config->get_array('minify.css.groups');
             break;
         case 'js':
             $groups = $this->_config->get_array('minify.js.groups');
             break;
         default:
             return $result;
     }
     if (isset($groups[$theme]['default'])) {
         $locations = (array) $groups[$theme]['default'];
     } else {
         $locations = array();
     }
     if ($template != 'default' && isset($groups[$theme][$template])) {
         $locations = array_merge_recursive($locations, (array) $groups[$theme][$template]);
     }
     foreach ($locations as $location => $config) {
         if (!empty($config['files'])) {
             foreach ((array) $config['files'] as $file) {
                 $file = w3_normalize_file_minify2($file);
                 if (w3_is_url($file)) {
                     $precached_file = $this->_precache_file($file, $type);
                     if ($precached_file) {
                         $result[$location][$file] = $precached_file;
                     } else {
                         $this->error(sprintf('Unable to cache remote file: "%s"', $file));
                     }
                 } else {
                     $path = w3_get_document_root() . '/' . $file;
                     if (file_exists($path)) {
                         $result[$location][$file] = '//' . $file;
                     } else {
                         $this->error(sprintf('File "%s" doesn\'t exist', $path));
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:53,代码来源:Minify.php


示例8: clean_scripts

 /**
  * Cleans scripts
  *
  * @param string $content
  * @return string
  */
 function clean_scripts($content)
 {
     $regexps = array();
     $groups = $this->_config->get_array('minify.js.groups');
     $domain_url_regexp = w3_get_domain_url_regexp();
     foreach ($groups as $group => $locations) {
         foreach ((array) $locations as $location => $config) {
             if (!empty($config['files'])) {
                 foreach ((array) $config['files'] as $file) {
                     if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
                         // external JS files
                         $regexps[] = w3_preg_quote($file);
                     } else {
                         // local JS files
                         $file = ltrim(preg_replace('~' . $domain_url_regexp . '~i', '', $file), '/\\');
                         $regexps[] = '(' . $domain_url_regexp . ')?/?' . w3_preg_quote($file);
                     }
                 }
             }
         }
     }
     foreach ($regexps as $regexp) {
         $content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~is', '', $content);
     }
     return $content;
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:32,代码来源:Minify.php


示例9: get_files_minify

 /**
  * Exports min files to CDN
  *
  * @return array
  */
 function get_files_minify()
 {
     $files = array();
     if (W3TC_PHP5 && $this->_config->get_boolean('minify.rewrite') && (!$this->_config->get_boolean('minify.auto') || w3_is_cdn_mirror($this->_config->get_string('cdn.engine')))) {
         require_once W3TC_INC_DIR . '/functions/http.php';
         $minify =& w3_instance('W3_Plugin_Minify');
         $document_root = w3_get_document_root();
         $site_root = w3_get_site_root();
         $minify_root = w3_path(W3TC_CACHE_FILE_MINIFY_DIR);
         $minify_path = ltrim(str_replace($site_root, rtrim(w3_get_site_path(), '/'), $minify_root), '/');
         $urls = $minify->get_urls();
         if ($this->_config->get_string('minify.engine') == 'file') {
             foreach ($urls as $url) {
                 w3_http_get($url);
             }
             $files = $this->search_files($minify_root, $minify_path, '*.css;*.js');
         } else {
             foreach ($urls as $url) {
                 $file = w3_normalize_file_minify($url);
                 $file = w3_translate_file($file);
                 if (!w3_is_url($file)) {
                     $file = $document_root . '/' . $file;
                     $file = ltrim(str_replace($minify_root, '', $file), '/');
                     $dir = dirname($file);
                     if ($dir) {
                         w3_mkdir($dir, 0777, $minify_root);
                     }
                     if (w3_download($url, $minify_root . '/' . $file) !== false) {
                         $files[] = $minify_path . '/' . $file;
                     }
                 }
             }
         }
     }
     return $files;
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:41,代码来源:Cdn.php


示例10: import_library

 /**
  * Imports library
  *
  * @param integer $limit
  * @param integer $offset
  * @param integer $count
  * @param integer $total
  * @param array $results
  * @return boolean
  */
 function import_library($limit, $offset, &$count, &$total, &$results)
 {
     global $wpdb;
     $count = 0;
     $total = 0;
     $results = array();
     $site_url = w3_get_site_url();
     $upload_info = w3_upload_info();
     if ($upload_info) {
         $sql = sprintf('SELECT
     		ID,
     		post_content,
     		post_date
         FROM
             %sposts
         WHERE
             post_status = "publish"
             AND (post_type = "post" OR post_type = "page") 
             AND (post_content LIKE "%%src=%%"
             	OR post_content LIKE "%%href=%%")
    		', $wpdb->prefix);
         if ($limit) {
             $sql .= sprintf(' LIMIT %d', $limit);
             if ($offset) {
                 $sql .= sprintf(' OFFSET %d', $offset);
             }
         }
         $posts = $wpdb->get_results($sql);
         if ($posts) {
             $count = count($posts);
             $total = $this->get_import_posts_count();
             $regexp = $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files'));
             $import_external = $this->_config->get_boolean('cdn.import.external');
             foreach ($posts as $post) {
                 $matches = null;
                 $post_content = $post->post_content;
                 if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
                     foreach ($matches as $match) {
                         $src = w3_normalize_file($match[2]);
                         if (preg_match('~(' . $regexp . ')$~', $src)) {
                             $src_dir = date('Y/m', strtotime($post->post_date));
                             $src_base = basename($src);
                             $dst = sprintf('%s/%s/%s', $upload_info['upload_dir'], $src_dir, $src_base);
                             $dst_dir = dirname($dst);
                             $dst_path = ABSPATH . $dst;
                             $dst_url = sprintf('%s%s/%s/%s', $site_url, $upload_info['upload_url'], $src_dir, $src_base);
                             $result = false;
                             $error = '';
                             $download_result = null;
                             w3_mkdir($dst_dir, 0755, ABSPATH);
                             // file already exists
                             if (!file_exists($dst_path)) {
                                 // source is external URL
                                 if (w3_is_url($src)) {
                                     if ($import_external) {
                                         $download_result = $this->download($src, $dst_path);
                                     } else {
                                         $error = 'External file import is disabled';
                                     }
                                     // source is local file not in wp-content/uploads dir
                                 } elseif (strstr($src, $upload_info['upload_dir']) === false) {
                                     $src_path = ABSPATH . $src;
                                     $download_result = @copy($src_path, $dst_path);
                                     // file is already in wp-content/uploads dir
                                 } else {
                                     $error = 'Source file already exists';
                                 }
                                 if ($download_result !== null) {
                                     if ($download_result) {
                                         $title = $src_base;
                                         $guid = $upload_info['upload_url'] . '/' . $title;
                                         $mime_type = w3_get_mime_type($src_base);
                                         $GLOBALS['wp_rewrite'] =& new WP_Rewrite();
                                         $id = wp_insert_attachment(array('post_mime_type' => $mime_type, 'guid' => $guid, 'post_title' => $title, 'post_content' => ''), $dst_path);
                                         if (!is_wp_error($id)) {
                                             require_once ABSPATH . 'wp-admin/includes/image.php';
                                             wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $dst_path));
                                             $post_content = str_replace($src, $dst_url, $post_content);
                                             $result = true;
                                             $error = 'OK';
                                         } else {
                                             $error = 'Unable to insert attachment';
                                         }
                                     } else {
                                         $error = 'Unable to download file';
                                     }
                                 }
                             } else {
                                 $error = 'Destination file already exists';
                             }
//.........这里部分代码省略.........
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:101,代码来源:Cdn.php


示例11: w3_translate_file

/**
 * Translates URL to local path
 * @param string $url
 * @return string
 */
function w3_translate_file($url)
{
    if (!w3_is_url($url)) {
        $url = w3_get_domain_url() . '/' . ltrim($url, '/\\');
    }
    $site_url_regexp = '~' . w3_get_site_url_regexp() . '~i';
    if (preg_match($site_url_regexp, $url) && strstr($url, '?') === false) {
        $url = preg_replace($site_url_regexp, '', $url);
        $url = w3_get_site_path() . ltrim($url, '/\\');
    }
    $url = ltrim($url, '/');
    return $url;
}
开发者ID:alx,项目名称:SBek-Arak,代码行数:18,代码来源:define.php


示例12: get_groups

 /**
  * Returns minify groups
  * @param string $group
  * @param string $type
  * @return array
  */
 function get_groups($group, $type)
 {
     $result = array();
     switch ($type) {
         case 'css':
             $groups = $this->_config->get_array('minify.css.groups');
             break;
         case 'js':
             $groups = $this->_config->get_array('minify.js.groups');
             break;
         default:
             return $result;
     }
     if (isset($groups['default'])) {
         $locations = (array) $groups['default'];
     } else {
         $locations = array();
     }
     if ($group != 'default' && isset($groups[$group])) {
         $locations = array_merge_recursive($locations, (array) $groups[$group]);
     }
     $site_url = w3_get_site_url();
     foreach ($locations as $location => $config) {
         if (!empty($config['files'])) {
             foreach ((array) $config['files'] as $file) {
                 $file = $this->_normalize_file($file);
                 if (w3_is_url($file)) {
                     $precached_file = $this->_precache_file($file, $type);
                     if ($precached_file) {
                         $result[$location][$file] = $precached_file;
                     }
                 } else {
                     $result[$location][$file] = '//' . $file;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:kennethreitz-archive,项目名称:wordpress-skeleton,代码行数:45,代码来源:Minify.php


示例13: is_file_for_minification

 /**
  * URL file filter
  *
  * @param string $file
  * @return bool
  */
 public function is_file_for_minification($file)
 {
     static $external;
     $ext = strrchr($file, '.');
     if ($ext != '.js' && $ext != '.css') {
         return false;
     }
     if (!isset($external)) {
         $external = $this->config->get_array('minify.cache.files');
     }
     foreach ($external as $ext) {
         if (preg_match('#' . w3_get_url_regexp($ext) . '#', $file)) {
             return true;
         }
     }
     if (w3_is_url($file)) {
         return false;
     }
     /** @var W3_MinifyFileTool $file_tool */
     $file_tool = w3_instance('W3_MinifyFileTool');
     $file_tool->setDocumentRoot(w3_get_document_root());
     if (!$file_tool->fileExists($file)) {
         return false;
     }
     return true;
 }
开发者ID:jcastilloa,项目名称:w3tc-transparentcdn,代码行数:32,代码来源:Minify.php


示例14: parse_sitemap

 /**
  * Parses sitemap
  *
  * @param string $url
  * @return array
  */
 function parse_sitemap($url)
 {
     w3_require_once(W3TC_INC_DIR . '/functions/http.php');
     if (!w3_is_url($url)) {
         $url = home_url($url);
     }
     $urls = array();
     $response = w3_http_get($url);
     if (!is_wp_error($response) && $response['response']['code'] == 200) {
         $url_matches = null;
         $sitemap_matches = null;
         if (preg_match_all('~<sitemap>(.*?)</sitemap>~is', $response['body'], $sitemap_matches)) {
             $loc_matches = null;
             foreach ($sitemap_matches[1] as $sitemap_match) {
                 if (preg_match('~<loc>(.*?)</loc>~is', $sitemap_match, $loc_matches)) {
                     $loc = trim($loc_matches[1]);
                     if ($loc) {
                         $urls = array_merge($urls, $this->parse_sitemap($loc));
                     }
                 }
             }
         } elseif (preg_match_all('~<url>(.*?)</url>~is', $response['body'], $url_matches)) {
             $locs = array();
             $loc_matches = null;
             $priority_matches = null;
             foreach ($url_matches[1] as $url_match) {
                 $loc = '';
                 $priority = 0;
                 if (preg_match('~<loc>(.*?)</loc>~is', $url_match, $loc_matches)) {
                     $loc = trim($loc_matches[1]);
                 }
                 if (preg_match('~<priority>(.*?)</priority>~is', $url_match, $priority_matches)) {
                     $priority = (double) trim($priority_matches[1]);
                 }
                 if ($loc && $priority) {
                     $locs[$loc] = $priority;
                 }
             }
             arsort($locs);
             $urls = array_keys($locs);
         }
     }
     return $urls;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:50,代码来源:PgCacheAdmin.php


示例15: uncompress_minify_files

 /**
  * 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;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:53,代码来源:Minify.php


示例16: _processUriCB

 private static function _processUriCB($m)
 {
     // $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
     $isImport = $m[0][0] === '@';
     // determine URI and the quote character (if any)
     if ($isImport) {
         $quoteChar = $m[1];
         $uri = $m[2];
     } else {
         // $m[1] is either quoted or not
         $quoteChar = $m[1][0] === "'" || $m[1][0] === '"' ? $m[1][0] : '';
         $uri = $quoteChar === '' ? $m[1] : substr($m[1], 1, strlen($m[1]) - 2);
     }
     // analyze URI
     if (false === strpos($uri, '//') && 0 !== strpos($uri, 'data:')) {
         if (self::$_prependPath !== null) {
             if (w3_is_url(self::$_prependPath)) {
                 $parse_url = @parse_url(self::$_prependPath);
                 if ($parse_url && isset($parse_url['host'])) {
                     $scheme = $parse_url['scheme'];
                     $host = $parse_url['host'];
                     $port = isset($parse_url['port']) && $parse_url['port'] != 80 ? ':' . (int) $parse_url['port'] : '';
                     $path = !empty($parse_url['path']) ? $parse_url['path'] : '/';
                     $dir_css = preg_replace('~[^/]+$~', '', $path);
                     $dir_obj = preg_replace('~[^/]+$~', '', $uri);
                     $dir = ltrim(strpos($dir_obj, '/') === 0 ? w3_realpath($dir_obj) : w3_realpath($dir_css . $dir_obj), '/');
                     $file = basename($uri);
                     $uri = sprintf('%s://%s%s/%s%s', $scheme, $host, $port, $dir, $file);
                 }
             } else {
                 $uri = self::$_prependPath . $uri;
             }
         } else {
             $uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
         }
     }
     return $isImport ? "@import {$quoteChar}{$uri}{$quoteChar}" : "url({$quoteChar}{$uri}{$quoteChar})";
 }
开发者ID:alx,项目名称:SBek-Arak,代码行数:38,代码来源:UriRewriter.php


示例17: remove_scripts

 /**
  * Remove script tags from the source
  *
  * @param string $content
  * @param array $files
  * @return void
  */
 function remove_scripts(&$content, $files)
 {
     $regexps = array();
     $home_url_regexp = w3_get_home_url_regexp();
     $path = '';
     if (w3_is_network() && !w3_is_subdomain_install()) {
         $path = ltrim(w3_get_home_path(), '/');
     }
     foreach ($files as $file) {
         if ($path && strpos($file, $path) === 0) {
             $file = substr($file, strlen($path));
         }
         $this->replaced_scripts[] = $file;
         if (w3_is_url($file) && !preg_match('~' . $home_url_regexp . '~i', $file)) {
             // external JS files
             $regexps[] = w3_preg_quote($file);
         } else {
             // local JS files
             $file = ltrim($file, '/');
             if (ltrim(w3_get_site_path(), '/') && strpos($file, ltrim(w3_get_site_path(), '/')) === 0) {
                 $file = str_replace(ltrim(w3_get_site_path(), '/'), '', $file);
             }
             $file = ltrim(preg_replace('~' . $home_url_regexp . '~i', '', $file), '/\\');
             $regexps[] = '(' . $home_url_regexp . ')?/?' . w3_preg_quote($file);
         }
     }
     foreach ($regexps as $regexp) {
         $content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~Uis', '', $content);
     }
 }
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:37,代码来源:Minify.php


示例18: is_file_for_minification

 /**
  * URL file filter
  *
  * @param string $file
  * @return bool
  */
 public function is_file_for_minification($file)
 {
     static $external;
     $ext = strrchr($file, '.');
     if ($ext != '.js' && $ext != '.css') {
         return false;
     }
     if (!isset($external)) {
         $external = $this->config->get_array('minify.cache.files');
     }
     foreach ($external as $ext) {
         if (preg_match('#' . w3_get_url_regexp($ext) . '#', $file)) {
             return true;
         }
     }
     if (w3_is_url($file)) {
         return false;
     }
     $path = w3_get_document_root() . '/' . $file;
     if (!file_exists($path)) {
         return false;
     }
     return true;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:30,代码来源:Minify.php



注:本文中的w3_is_url函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP w3_is_xml函数代码示例发布时间:2022-05-23
下一篇:
PHP w3_is_subdomain_install函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap