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


PHP SplFileObject::getMTime方法代码示例

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


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

示例1: getPlanning

 public static function getPlanning($year, $group, $week, $h = false)
 {
     $groupModel = new GroupsModel();
     $ids = $groupModel->getIDs($year, $group);
     $ids = $ids[0];
     $identFile = new ConfigFileParser('app/config/ident.json');
     $ident = $identFile->getEntry('ident');
     $fileName = 'public/img/img_planning/' . $ids['ID'] . '_' . $week . ($h ? '_h' : '') . '.png';
     try {
         $file = new \SplFileObject($fileName, 'rw');
         if ($file->getMTime() < time() - 900) {
             throw new \RuntimeException();
         }
     } catch (\RuntimeException $e) {
         $fp = fopen($fileName, 'w+');
         $url = 'http://planning.univ-amu.fr/ade/imageEt?identifier=' . $ident . '&projectId=8&idPianoWeek=' . $week . '&idPianoDay=0,1,2,3,4,5&idTree=' . $ids['IDTREE'] . '&width=1000&height=700&lunchName=REPAS&displayMode=1057855&showLoad=false&ttl=1405063872880000&displayConfId=' . ($h ? '60' : '59');
         $ch = curl_init(str_replace(" ", "%20", $url));
         curl_setopt($ch, CURLOPT_TIMEOUT, 50);
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_exec($ch);
         curl_close($ch);
     }
     return '/' . $fileName;
 }
开发者ID:thomasmunoz13,项目名称:planning_iut,代码行数:25,代码来源:Planning.php

示例2: purgeAll

 public function purgeAll($check_expiry = false)
 {
     if (!$this->is_init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check_expiry) {
         if (is_numeric($check_expiry)) {
             $now = $check_expiry;
         } else {
             $now = time();
         }
         $threshold = $now - $this->settings['cache_duration'];
     }
     $prefixLength = strlen($this->settings['key_prefix']);
     while (($entry = $dir->read()) !== false) {
         if (substr($entry, 0, $prefixLength) !== $this->settings['key_prefix']) {
             continue;
         }
         if ($this->_openFile($entry) === false) {
             continue;
         }
         if ($check_expiry) {
             $mtime = $this->file->getMTime();
             if ($mtime > $threshold) {
                 continue;
             }
             $expires = (int) $this->file->current();
             if ($expires > $now) {
                 continue;
             }
         }
         $path = $this->file->getRealPath();
         $this->file = null;
         if (file_exists($path)) {
             unlink($path);
         }
     }
     $dir->close();
     return true;
 }
开发者ID:rossaffandy,项目名称:blockchains.io,代码行数:41,代码来源:cache.php

示例3: _getFile

 /**
  * 获取文件列表
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2012-07-17 12:46:02
  *
  * @param string $node 节点路径
  *
  * @return array 文件列表
  */
 private function _getFile($node)
 {
     $node = trim($node, '/');
     $this->_denyDirectory($node);
     $file_arr = array();
     $directory = PACKER_JS_PATH . $node . '/';
     $k = 0;
     if (is_dir($directory)) {
         $date_format = sys_config('sys_timezone_datetime_format');
         $d = dir($directory);
         while ($f = $d->read()) {
             if ($f == '.' || $f == '..' || substr($f, 0, 1) == '.') {
                 continue;
             }
             $filename = $directory . '/' . $f;
             if (is_dir($filename)) {
                 $file_arr[$k] = array('text' => $f, 'checked' => $f == 'pack' ? null : false, 'id' => $node . '/' . $f);
                 $file_arr[$k]['data'] = $this->_getFile($f);
                 $k++;
             } elseif (substr($f, -3) == '.js' && !in_array($f, array('app.js'))) {
                 $desc = '';
                 //js文件说明
                 $file = new SplFileObject($filename);
                 if (!strpos($filename, '.min.')) {
                     $file->fgets();
                     $desc = trim(str_replace('*', '', $file->fgets()));
                     //第二行为文件说明
                 }
                 $file_arr[] = array('text' => $f, 'id' => $node . '/' . $f, 'leaf' => true, 'checked' => $node == 'pack' ? null : false, 'filesize' => format_size($file->getSize()), 'filemtime' => new_date($date_format, $file->getMTime()), 'desc' => $desc);
             }
         }
         //end while
         $d->close();
     }
     //end if
     return $file_arr;
 }
开发者ID:yunsite,项目名称:yablog,代码行数:47,代码来源:PackerController.class.php

示例4: _clearDirectory

 /**
  * Used to clear a directory of matching files.
  *
  * @param string $path The path to search.
  * @param integer $now The current timestamp
  * @param integer $threshold Any file not modified after this value will be deleted.
  * @return void
  */
 protected function _clearDirectory($path, $now, $threshold)
 {
     $prefixLength = strlen($this->settings['prefix']);
     if (!is_dir($path)) {
         return;
     }
     $dir = dir($path);
     while (($entry = $dir->read()) !== false) {
         if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
             continue;
         }
         $filePath = $path . $entry;
         if (!file_exists($filePath) || is_dir($filePath)) {
             continue;
         }
         $file = new SplFileObject($path . $entry, 'r');
         if ($threshold) {
             $mtime = $file->getMTime();
             if ($mtime > $threshold) {
                 continue;
             }
             $expires = (int) $file->current();
             if ($expires > $now) {
                 continue;
             }
         }
         if ($file->isFile()) {
             $filePath = $file->getRealPath();
             $file = null;
             //@codingStandardsIgnoreStart
             @unlink($filePath);
             //@codingStandardsIgnoreEnd
         }
     }
 }
开发者ID:jrbasso,项目名称:cakephp,代码行数:43,代码来源:FileEngine.php

示例5: _getFile

 private function _getFile($download = false)
 {
     if (!$this->authed && !$this->config->readonly) {
         echo json_encode(array('status' => false, 'message' => 'not authenticated'));
         exit;
     }
     if (!$this->requestDir || !is_file($this->requestDir)) {
         header('Status: 404 Not Found');
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     $file = new SplFileObject($this->requestDir);
     // not really sure if this range shit works. stole it from an old script i wrote
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2);
         if ($size_unit == 'bytes') {
             list($range, $extra_ranges) = explode(',', $range_orig, 2);
         } else {
             $range = '';
         }
         if ($range) {
             list($seek_start, $seek_end) = explode('-', $range, 2);
         }
         $seek_end = empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1);
         $seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);
         if ($seek_start > 0 || $seek_end < $size - 1) {
             header('HTTP/1.1 206 Partial Content');
         } else {
             header('HTTP/1.1 200 OK');
         }
         header('Accept-Ranges: bytes');
         header('Content-Range: bytes ' . $seek_start . '-' . $seek_end . '/' . $size);
         $contentLength = $seek_end - $seek_start + 1;
     } else {
         header('HTTP/1.1 200 OK');
         header('Accept-Ranges: bytes');
         $contentLength = $file->getSize();
     }
     header('Pragma: public');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Date: ' . date('r'));
     header('Last-Modified: ' . date('r', $file->getMTime()));
     header('Content-Length: ' . $contentLength);
     header('Content-Transfer-Encoding: binary');
     if ($download) {
         header('Content-Disposition: attachment; filename="' . $file->getFilename() . '"');
         header('Content-Type: application/force-download');
     } else {
         header('Content-Type: ' . mime_content_type($file->getPathname()));
     }
     // i wrote this freading a really long time ago but it seems to be more robust than SPL. someone correct me if im wrong
     $fp = fopen($file->getPathname(), 'rb');
     fseek($fp, $seek_start);
     while (!feof($fp)) {
         set_time_limit(0);
         print fread($fp, 1024 * 8);
         flush();
         ob_flush();
     }
     fclose($fp);
     exit;
 }
开发者ID:pinoaffe,项目名称:cheryl,代码行数:62,代码来源:Cheryl.php


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