当前位置: 首页>>代码示例>>PHP>>正文


PHP files::inheritChmod方法代码示例

本文整理汇总了PHP中files::inheritChmod方法的典型用法代码示例。如果您正苦于以下问题:PHP files::inheritChmod方法的具体用法?PHP files::inheritChmod怎么用?PHP files::inheritChmod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在files的用法示例。


在下文中一共展示了files::inheritChmod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: putContent

 protected function putContent($content, $target = false)
 {
     if ($target) {
         $r = @file_put_contents($target, $content);
         if ($r === false) {
             throw new Exception(__('Unable to write destination file.'));
         }
         files::inheritChmod($target);
         return true;
     }
     return $content;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:12,代码来源:class.unzip.php

示例3: uploadBits

 /**
  * Upload file by bits
  *
  * Creates a new file <var>$dest</var> with contents of <var>$bits</var> and
  * return the destination file path.
  * <var>$dest</var> should be in jail. This method will throw exception
  * if file cannot be written.
  *
  * @param string	$bits		Destination file content
  * @param string	$dest		Destination file
  * @return string				Destination real path
  */
 public function uploadBits($name, $bits)
 {
     $dest = $this->pwd . '/' . path::clean($name);
     if ($this->isFileExclude($dest)) {
         throw new Exception(__('Uploading this file is not allowed.'));
     }
     if (!$this->inJail(dirname($dest))) {
         throw new Exception(__('Destination directory is not in jail.'));
     }
     if (!is_writable(dirname($dest))) {
         throw new Exception(__('Cannot write in this directory.'));
     }
     $fp = @fopen($dest, 'wb');
     if ($fp === false) {
         throw new Exception(__('An error occurred while writing the file.'));
     }
     fwrite($fp, $bits);
     fclose($fp);
     files::inheritChmod($dest);
     return path::real($dest);
 }
开发者ID:HackerMajor,项目名称:root,代码行数:33,代码来源:class.filemanager.php

示例4: getFile

 public function getFile($file)
 {
     $tpl_file = $this->getFilePath($file);
     if (!$tpl_file) {
         throw new Exception('No template found for ' . $file);
         return false;
     }
     $file_md5 = md5($tpl_file);
     $dest_file = sprintf('%s/%s/%s/%s/%s.php', $this->cache_dir, 'cbtpl', substr($file_md5, 0, 2), substr($file_md5, 2, 2), $file_md5);
     clearstatcache();
     $stat_f = $stat_d = false;
     if (file_exists($dest_file)) {
         $stat_f = stat($tpl_file);
         $stat_d = stat($dest_file);
     }
     # We create template if:
     # - dest_file doest not exists
     # - we don't want cache
     # - dest_file size == 0
     # - tpl_file is more recent thant dest_file
     if (!$stat_d || !$this->use_cache || $stat_d['size'] == 0 || $stat_f['mtime'] > $stat_d['mtime']) {
         files::makeDir(dirname($dest_file), true);
         if (($fp = @fopen($dest_file, 'wb')) === false) {
             throw new Exception('Unable to create cache file');
         }
         $fc = $this->compileFile($tpl_file);
         fwrite($fp, $fc);
         fclose($fp);
         files::inheritChmod($dest_file);
     }
     return $dest_file;
 }
开发者ID:archcidburnziso,项目名称:Bilboplanet,代码行数:32,代码来源:class.template.php

示例5: 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::inheritChmod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。