當前位置: 首頁>>代碼示例>>PHP>>正文


PHP w3_download函數代碼示例

本文整理匯總了PHP中w3_download函數的典型用法代碼示例。如果您正苦於以下問題:PHP w3_download函數的具體用法?PHP w3_download怎麽用?PHP w3_download使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了w3_download函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _precache_file

 /**
  * Pre-caches external file
  *
  * @param string $url
  * @param string $type
  * @return string
  */
 function _precache_file($url, $type)
 {
     $lifetime = $this->_config->get_integer('minify.lifetime');
     $cache_path = sprintf('%s/minify_%s.%s', w3_cache_blog_dir('minify'), md5($url), $type);
     if (!file_exists($cache_path) || @filemtime($cache_path) < time() - $lifetime) {
         w3_require_once(W3TC_INC_DIR . '/functions/http.php');
         if (!@is_dir(dirname($cache_path))) {
             w3_require_once(W3TC_INC_DIR . '/functions/file.php');
             w3_mkdir_from(dirname($cache_path), W3TC_CACHE_DIR);
         }
         w3_download($url, $cache_path);
     }
     return file_exists($cache_path) ? $this->_get_minify_source($cache_path, $url) : false;
 }
開發者ID:easinewe,項目名稱:Avec2016,代碼行數:21,代碼來源:Minify.php

示例2: import_library


//.........這裏部分代碼省略.........
                                         $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'];
                                     }
                                     $src_filename = pathinfo($src, PATHINFO_FILENAME);
                                     $src_extension = pathinfo($src, PATHINFO_EXTENSION);
                                     /**
                                      * Get available filename
                                      */
                                     for ($i = 0;; $i++) {
                                         $dst = sprintf('%s/%s%s%s', $upload_dir, $src_filename, $i ? $i : '', $src_extension ? '.' . $src_extension : '');
                                         if (!file_exists($dst)) {
                                             break;
                                         }
                                     }
                                     $dst_basename = basename($dst);
                                     $dst_url = sprintf('%s/%s', $upload_url, $dst_basename);
                                     $dst_path = ltrim(str_replace($document_root, '', w3_path($dst)), '/');
                                     if ($upload_subdir) {
                                         w3_mkdir($upload_subdir, 0777, $upload_info['basedir']);
                                     }
                                     $download_result = false;
                                     /**
                                      * Check if file is remote URL
                                      */
                                     if (w3_is_url($src)) {
                                         /**
                                          * Download file
                                          */
                                         if ($import_external) {
                                             $download_result = w3_download($src, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to download file';
                                             }
                                         } else {
                                             $error = 'External file import is disabled';
                                         }
                                     } else {
                                         /**
                                          * Otherwise copy file from local path
                                          */
                                         $src_path = $document_root . '/' . urldecode($src);
                                         if (file_exists($src_path)) {
                                             $download_result = @copy($src_path, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to copy file';
                                             }
                                         } else {
                                             $error = 'Source file doesn\'t exists';
                                         }
                                     }
                                     /**
                                      * Check if download or copy was successful
                                      */
                                     if ($download_result) {
                                         w3_require_once(W3TC_INC_DIR . '/functions/mime.php');
                                         $title = $dst_basename;
                                         $guid = ltrim($upload_info['baseurlpath'] . $title, ',');
                                         $mime_type = w3_get_mime_type($dst);
                                         $GLOBALS['wp_rewrite'] = new WP_Rewrite();
                                         /**
                                          * Insert attachment
                                          */
開發者ID:marqui678,項目名稱:finalchance.Panopta,代碼行數:67,代碼來源:CdnAdmin.php

示例3: _precache_file

 /**
  * Pre-caches external file
  *
  * @param string $url
  * @param string $type
  * @return string
  */
 function _precache_file($url, $type)
 {
     $lifetime = $this->_config->get_integer('minify.lifetime');
     $cache_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
     if (!file_exists($cache_path) || @filemtime($cache_path) < time() - $lifetime) {
         require_once W3TC_INC_DIR . '/functions/http.php';
         w3_download($url, $cache_path);
     }
     return file_exists($cache_path) ? $this->_get_minify_source($cache_path, $url) : false;
 }
開發者ID:nxtclass,項目名稱:NXTClass,代碼行數:17,代碼來源:Minify.php

示例4: 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

示例5: get_files_minify

 /**
  * Exports min files to CDN
  */
 function get_files_minify()
 {
     $files = array();
     if (W3TC_PHP5) {
         require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
         $minify =& W3_Plugin_Minify::instance();
         $urls = $minify->get_urls();
         foreach ($urls as $url) {
             $file = basename($url);
             if (w3_download($url, W3TC_CONTENT_MINIFY_DIR . '/' . $file) !== false) {
                 $files[] = W3TC_CONTENT_MINIFY_DIR_NAME . '/' . $file;
             }
         }
     }
     return $files;
 }
開發者ID:alx,項目名稱:SBek-Arak,代碼行數:19,代碼來源:Cdn.php

示例6: _precache_file

 /**
  * Precaches external file
  *
  * @param string $url
  * @param string $type
  * @return string
  */
 function _precache_file($url, $type)
 {
     $lifetime = $this->_config->get_integer('minify.lifetime');
     $file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
     $file_exists = file_exists($file_path);
     if ($file_exists && @filemtime($file_path) >= time() - $lifetime) {
         return $this->_get_minify_source($file_path, $url);
     }
     if (is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
         if (w3_download($url, $file_path) !== false) {
             return $this->_get_minify_source($file_path, $url);
         } else {
             $this->log(sprintf('Unable to download URL: %s', $url));
         }
     } else {
         $this->log(sprintf('The cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
     }
     return $file_exists ? $this->_get_minify_source($file_path, $url) : false;
 }
開發者ID:kennethreitz-archive,項目名稱:wordpress-skeleton,代碼行數:26,代碼來源:Minify.php


注:本文中的w3_download函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。