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


PHP files::touch方法代碼示例

本文整理匯總了PHP中files::touch方法的典型用法代碼示例。如果您正苦於以下問題:PHP files::touch方法的具體用法?PHP files::touch怎麽用?PHP files::touch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在files的用法示例。


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

示例1: withCache

 /**
  * Cache content
  *
  * Returns feedParser object from cache if present or write it to cache and
  * returns result.
  *
  * @param string	$url			Feed URL
  * @return feedParser
  */
 protected function withCache($url)
 {
     $url_md5 = md5($url);
     $cached_file = sprintf('%s/%s/%s/%s/%s.php', $this->cache_dir, $this->cache_file_prefix, substr($url_md5, 0, 2), substr($url_md5, 2, 2), $url_md5);
     $may_use_cached = false;
     if (@file_exists($cached_file)) {
         $may_use_cached = true;
         $ts = @filemtime($cached_file);
         if ($ts > strtotime($this->cache_ttl)) {
             # Direct cache
             return unserialize(file_get_contents($cached_file));
         }
         $this->setValidator('IfModifiedSince', $ts);
     }
     if (!$this->getFeed($url)) {
         if ($may_use_cached) {
             # connection failed - fetched from cache
             return unserialize(file_get_contents($cached_file));
         }
         return false;
     }
     switch ($this->getStatus()) {
         case '304':
             @files::touch($cached_file);
             return unserialize(file_get_contents($cached_file));
         case '200':
             if ($feed = new feedParser($this->getContent())) {
                 try {
                     files::makeDir(dirname($cached_file), true);
                 } catch (Exception $e) {
                     return $feed;
                 }
                 if ($fp = @fopen($cached_file, 'wb')) {
                     fwrite($fp, serialize($feed));
                     fclose($fp);
                     files::inheritChmod($cached_file);
                 }
                 return $feed;
             }
     }
     return false;
 }
開發者ID:HackerMajor,項目名稱:root,代碼行數:51,代碼來源:class.feed.reader.php

示例2: withCache

 /**
  * Get repository modules list using cache.
  *
  * @param	string	$url		XML feed URL
  * @return	array	Feed content or False on fail
  */
 protected function withCache($url)
 {
     $url_md5 = md5($url);
     $cached_file = sprintf('%s/%s/%s/%s/%s.ser', $this->cache_dir, $this->cache_file_prefix, substr($url_md5, 0, 2), substr($url_md5, 2, 2), $url_md5);
     $may_use_cached = false;
     # Use cache file ?
     if (@file_exists($cached_file) && !$this->force) {
         $may_use_cached = true;
         $ts = @filemtime($cached_file);
         if ($ts > strtotime($this->cache_ttl)) {
             # Direct cache
             return unserialize(file_get_contents($cached_file));
         }
         $this->setValidator('IfModifiedSince', $ts);
     }
     # Query repository
     if (!$this->getModulesXML($url)) {
         if ($may_use_cached) {
             # Touch cache TTL even if query failed ?
             if ($this->cache_touch_on_fail) {
                 @files::touch($cached_file);
             }
             # Connection failed - fetched from cache
             return unserialize(file_get_contents($cached_file));
         }
         return false;
     }
     # Parse response
     switch ($this->getStatus()) {
         # Not modified, use cache
         case '304':
             @files::touch($cached_file);
             return unserialize(file_get_contents($cached_file));
             # Ok, parse feed
         # Ok, parse feed
         case '200':
             if ($modules = new dcStoreParser($this->getContent())) {
                 try {
                     files::makeDir(dirname($cached_file), true);
                 } catch (Exception $e) {
                     return $modules;
                 }
                 if ($fp = @fopen($cached_file, 'wb')) {
                     fwrite($fp, serialize($modules));
                     fclose($fp);
                     files::inheritChmod($cached_file);
                 }
                 return $modules;
             }
     }
     return false;
 }
開發者ID:nikrou,項目名稱:dotclear,代碼行數:58,代碼來源:class.dc.store.reader.php


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