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


PHP filemtime函数代码示例

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


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

示例1: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         $image = new Image(DIR_IMAGE . $old_image);
         $image->resize($width, $height);
         $image->save(DIR_IMAGE . $new_image);
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return HTTPS_CATALOG . 'image/' . $new_image;
     } else {
         return HTTP_CATALOG . 'image/' . $new_image;
     }
 }
开发者ID:gittrue,项目名称:VIF,代码行数:28,代码来源:image.php

示例2: template

function template($filename, $flag = TEMPLATE_DISPLAY)
{
    global $_W;
    $source = IA_ROOT . "/web/themes/{$_W['template']}/{$filename}.html";
    $compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/{$filename}.tpl.php";
    if (!is_file($source)) {
        $source = IA_ROOT . "/web/themes/default/{$filename}.html";
        $compile = IA_ROOT . "/data/tpl/web/default/{$filename}.tpl.php";
    }
    if (!is_file($source)) {
        exit("Error: template source '{$filename}' is not exist!");
    }
    if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
        template_compile($source, $compile);
    }
    switch ($flag) {
        case TEMPLATE_DISPLAY:
        default:
            extract($GLOBALS, EXTR_SKIP);
            include $compile;
            break;
        case TEMPLATE_FETCH:
            extract($GLOBALS, EXTR_SKIP);
            ob_clean();
            ob_start();
            include $compile;
            $contents = ob_get_contents();
            ob_clean();
            return $contents;
            break;
        case TEMPLATE_INCLUDEPATH:
            return $compile;
            break;
    }
}
开发者ID:legeng,项目名称:project-2,代码行数:35,代码来源:template.func.php

示例3: display

 function display($tmpl_file, $app_id = null)
 {
     array_unshift($this->_files, $tmpl_file);
     $this->_vars = $this->pagedata;
     if ($p = strpos($tmpl_file, ':')) {
         $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p));
         if ($object) {
             $tmpl_file_path = substr($tmpl_file, $p + 1);
             $last_modified = $object->last_modified($tmpl_file_path);
         }
     } else {
         $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
         $last_modified = filemtime($tmpl_file);
     }
     if (!$last_modified) {
         //无文件
     }
     $compile_id = $this->compile_id($tmpl_file);
     if ($object) {
         $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
     } else {
         $compile_code = $this->_compiler()->compile_file($tmpl_file);
     }
     eval('?>' . $compile_code);
     array_shift($this->_files);
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:26,代码来源:controller.php

示例4: _toHtml

 /**
  * Render home category list xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     /** @var $homeXmlObj Mage_XmlConnect_Model_Simplexml_Element */
     $homeXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<home></home>');
     $categoryCollection = array();
     $helper = Mage::helper('catalog/category');
     $categoryCount = 0;
     foreach ($helper->getStoreCategories() as $child) {
         if ($child->getIsActive()) {
             $categoryCollection[] = $child;
             $categoryCount++;
         }
         if ($categoryCount == self::HOME_PAGE_CATEGORIES_COUNT) {
             break;
         }
     }
     if (sizeof($categoryCollection)) {
         $itemsXmlObj = $homeXmlObj->addChild('categories');
     }
     foreach ($categoryCollection as $item) {
         /** @var $item Mage_Catalog_Model_Category */
         $item = Mage::getModel('catalog/category')->load($item->getId());
         $itemXmlObj = $itemsXmlObj->addChild('item');
         $itemXmlObj->addChild('label', $homeXmlObj->xmlentities($item->getName()));
         $itemXmlObj->addChild('entity_id', $item->getId());
         $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
         $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
         $iconXml = $itemXmlObj->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
     }
     $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png');
     return $homeXmlObj->asNiceXml();
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:39,代码来源:Home.php

示例5: data

 public function data()
 {
     $data = $this->toArray();
     $data["modified"] = filemtime($this->file);
     $data["foundry_version"] = "3.1.15";
     return $data;
 }
开发者ID:alexinteam,项目名称:joomla3,代码行数:7,代码来源:configuration.php

示例6: test_recache

 /**
  * @group internet
  * @group slow
  */
 public function test_recache()
 {
     global $conf;
     $conf['fetchsize'] = 500 * 1024;
     //500kb
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     // remember time stamp
     $time = filemtime($local);
     clearstatcache(false, $local);
     sleep(1);
     // fetch again and make sure we got a cache file
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     clearstatcache(false, $local);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     $this->assertEquals($time, filemtime($local));
     clearstatcache(false, $local);
     sleep(6);
     // fetch again and make sure we got a new file
     $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png', 'png', 5);
     clearstatcache(false, $local);
     $this->assertTrue($local !== false);
     $this->assertFileExists($local);
     $this->assertNotEquals($time, filemtime($local));
     unlink($local);
 }
开发者ID:richmahn,项目名称:Door43,代码行数:32,代码来源:media_get_from_url.test.php

示例7: thumbnailFile

 /**
  * Creates and caches the image thumbnail and returns full path from thumbnail file.
  *
  * @param string $filename
  * @param integer $width
  * @param integer $height
  * @param string $mode
  * @return string
  * @throws FileNotFoundException
  */
 public static function thumbnailFile($filename, $width, $height, $mode = self::THUMBNAIL_OUTBOUND)
 {
     $filename = FileHelper::normalizePath(Yii::getAlias($filename));
     if (!is_file($filename)) {
         throw new FileNotFoundException("File {$filename} doesn't exist");
     }
     $cachePath = Yii::getAlias('@webroot/' . self::$cacheAlias);
     $thumbnailFileExt = strrchr($filename, '.');
     $thumbnailFileName = md5($filename . $width . $height . $mode . filemtime($filename));
     $thumbnailFilePath = $cachePath . DIRECTORY_SEPARATOR . substr($thumbnailFileName, 0, 2);
     $thumbnailFile = $thumbnailFilePath . DIRECTORY_SEPARATOR . $thumbnailFileName . $thumbnailFileExt;
     if (file_exists($thumbnailFile)) {
         if (self::$cacheExpire !== 0 && time() - filemtime($thumbnailFile) > self::$cacheExpire) {
             unlink($thumbnailFile);
         } else {
             return $thumbnailFile;
         }
     }
     if (!is_dir($thumbnailFilePath)) {
         mkdir($thumbnailFilePath, 0755, true);
     }
     $box = new Box($width, $height);
     $image = Image::getImagine()->open($filename);
     $image = $image->thumbnail($box, $mode);
     $image->save($thumbnailFile);
     return $thumbnailFile;
 }
开发者ID:keltstr,项目名称:basic,代码行数:37,代码来源:EasyThumbnailImage.php

示例8: tplsadmin_copy_templates_f2db

function tplsadmin_copy_templates_f2db($tplset_to, $whr_append = '1')
{
    global $db;
    // get tplsource
    $result = $db->query("SELECT * FROM " . $db->prefix("tplfile") . "  WHERE tpl_tplset='default' AND ({$whr_append})");
    while ($row = $db->fetchArray($result)) {
        $basefilepath = tplsadmin_get_basefilepath($row['tpl_module'], $row['tpl_type'], $row['tpl_file']);
        $tpl_source = rtrim(implode("", file($basefilepath)));
        $lastmodified = filemtime($basefilepath);
        $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_to) . "' AND ({$whr_append}) AND tpl_file='" . addslashes($row['tpl_file']) . "' AND tpl_refid='" . addslashes($row['tpl_refid']) . "'");
        if (!$db->getRowsNum($drs)) {
            // INSERT mode
            $sql = "INSERT INTO " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_lastmodified='" . addslashes($lastmodified) . "',tpl_type='" . addslashes($row['tpl_type']) . "',tpl_tplset='" . addslashes($tplset_to) . "',tpl_file='" . addslashes($row['tpl_file']) . "',tpl_module='" . addslashes($row['tpl_module']) . "'";
            $db->query($sql);
            $tpl_id = $db->getInsertId();
            $db->query("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source='" . addslashes($tpl_source) . "'");
            altsys_template_touch($tpl_id);
        } else {
            while (list($tpl_id) = $db->fetchRow($drs)) {
                // UPDATE mode
                $db->query("UPDATE " . $db->prefix("tplfile") . " SET tpl_lastmodified='" . addslashes($lastmodified) . "' WHERE tpl_id='{$tpl_id}'");
                $db->query("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'");
                altsys_template_touch($tpl_id);
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:27,代码来源:tpls_functions.php

示例9: style

 /**
  * Creates a stylesheet link with LESS support
  *
  * @param   string  $style       file name
  * @param   array   $attributes  default attributes
  * @param   bool    $index       include the index page
  * @param   array   $imports     compare file date for these too, CSS and LESS in style @import
  * @return  string
  */
 public static function style($file, array $attributes = null, $index = false, $imports = null)
 {
     $imports = (array) $imports;
     // Compile only .less files
     if (substr_compare($file, '.less', -5, 5, false) === 0) {
         $css = substr_replace($file, 'css', -4);
         $compiled = is_file($css) ? filemtime($css) : 0;
         try {
             // Check if imported files have changed
             $compile = filemtime($file) > $compiled;
             if (!$compile && !empty($imports)) {
                 foreach ($imports as $import) {
                     if (filemtime($import) > $compiled) {
                         $compile = true;
                         break;
                     }
                 }
             }
             // Compile LESS
             if ($compile) {
                 $compiler = new self($file);
                 file_put_contents($css, $compiler->parse());
             }
             $file = $css;
         } catch (Exception $e) {
             Kohana::$log->add(Kohana::ERROR, __METHOD__ . ': Error compiling LESS file ' . $file . ', ' . $e->getMessage());
         }
     }
     return HTML::style($file . '?' . filemtime($file), $attributes, $index);
 }
开发者ID:netbiel,项目名称:core,代码行数:39,代码来源:less.php

示例10: load

 public function load($locale, $locale_path, $domain, $textdomain = true)
 {
     $file = $locale_path . '/' . $locale . '/LC_MESSAGES/' . $domain . '.po';
     $cache_file = waSystem::getInstance()->getConfig()->getPath('cache') . '/apps/' . $domain . '/locale/' . $locale . '.php';
     if (isset(self::$cache[$locale][$domain])) {
     } elseif (!file_exists($file)) {
         self::$cache[$locale][$domain] = array();
     } elseif (file_exists($cache_file) && filemtime($cache_file) > filemtime($file)) {
         self::$cache[$locale][$domain] = (include $cache_file);
     } else {
         if (file_exists($file)) {
             $gettext = new waGettext($file);
             self::$cache[$locale][$domain] = $gettext->read();
         } else {
             self::$cache[$locale][$domain] = array();
         }
         waFiles::create($cache_file);
         waUtils::varExportToFile(self::$cache[$locale][$domain], $cache_file);
     }
     if (isset(self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']) && self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']) {
         self::$cache[$locale][$domain]['meta']['f'] = create_function('$n', self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']);
     }
     if ($textdomain) {
         self::$domain = $domain;
         self::$locale = $locale;
     }
     if (!self::$locale) {
         self::$locale = $locale;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:30,代码来源:waLocalePHPAdapter.class.php

示例11: retrieveFile

 /**
  * Retrieves data from cache, if it's there.  If it is, but it's expired,
  * it performs a conditional GET to see if the data is updated.  If it
  * isn't, it down updates the modification time of the cache file and
  * returns the data.  If the cache is not there, or the remote file has been
  * modified, it is downloaded and cached.
  *
  * @param string URL of remote file to retrieve
  * @param int Length of time to cache file locally before asking the server
  *            if it changed.
  * @return string File contents
  */
 function retrieveFile($url, $cacheLength, $cacheDir)
 {
     $cacheID = md5($url);
     $cache = new Cache_Lite(array("cacheDir" => $cacheDir, "lifeTime" => $cacheLength));
     if ($data = $cache->get($cacheID)) {
         return $data;
     } else {
         // we need to perform a request, so include HTTP_Request
         include_once 'HTTP/Request.php';
         // HTTP_Request has moronic redirect "handling", turn that off (Alexey Borzov)
         $req = new HTTP_Request($url, array('allowRedirects' => false));
         // if $cache->get($cacheID) found the file, but it was expired,
         // $cache->_file will exist
         if (isset($cache->_file) && file_exists($cache->_file)) {
             $req->addHeader('If-Modified-Since', gmdate("D, d M Y H:i:s", filemtime($cache->_file)) . " GMT");
         }
         $req->sendRequest();
         if (!($req->getResponseCode() == 304)) {
             // data is changed, so save it to cache
             $data = $req->getResponseBody();
             $cache->save($data, $cacheID);
             return $data;
         } else {
             // retrieve the data, since the first time we did this failed
             if ($data = $cache->get($cacheID, 'default', true)) {
                 return $data;
             }
         }
     }
     Services_ExchangeRates::raiseError("Unable to retrieve file {$url} (unknown reason)", SERVICES_EXCHANGERATES_ERROR_RETRIEVAL_FAILED);
     return false;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:44,代码来源:Common.php

示例12: minifyTemplateFile

 public static function minifyTemplateFile($mTimeFile, $fileToMinify, $targetMinifiedFile, $ext)
 {
     file_put_contents($targetMinifiedFile, $ext == 'js' ? static::minifyJs($fileToMinify) : static::minifyCss($fileToMinify));
     chmod($targetMinifiedFile, 0775);
     file_put_contents($mTimeFile, filemtime($fileToMinify));
     chmod($mTimeFile, 0775);
 }
开发者ID:RoxasShadow,项目名称:nerdz.eu,代码行数:7,代码来源:minification.class.php

示例13: wirte

 /**
  * 写入缓存
  * @param string $name 缓存文件名字
  * @param function $callback 回调函数,必须要有返回值
  * @param Array or string or Object $params 要传进去的参数
  * @param int $time 写入的缓存时间
  * @return array
  * @author wave
  */
 public static function wirte($name, $callback, $params = null, $time = TIME)
 {
     self::init();
     $file = ROOT . DS . APP_PATH . DS . self::$cache_dir;
     $content = '';
     if (!file_exists($file . self::CACHE_PREFIX . $name)) {
         $content = $callback($params);
         if (!empty($content)) {
             file_put_contents($file . self::CACHE_PREFIX . $name, gzcompress(serialize($content)));
             return;
         }
     }
     if (empty($time)) {
         return;
     }
     if (file_exists($file . self::CACHE_PREFIX . $name)) {
         $cache_time = strtotime(date('Y-m-d H:i:s')) - strtotime(date('Y-m-d H:i:s', filemtime($file . self::CACHE_PREFIX . $name)));
         if ($cache_time / 1000 >= $time || $time == 1) {
             $content = $callback($params);
             if (!empty($content)) {
                 file_put_contents($file . self::CACHE_PREFIX . $name, gzcompress(serialize($content)));
                 return;
             }
         }
     }
 }
开发者ID:DenonHuang,项目名称:xbphp,代码行数:35,代码来源:Cache.php

示例14: sortByModified

 function sortByModified($files)
 {
     $hasComplexKeys = false;
     $tmpFiles = array();
     foreach ($files as $file) {
         $key = @filemtime(JPATH_ROOT . DS . $file);
         if (isset($tmpFiles[$key])) {
             $hasComplexKeys = true;
             if (!is_array($tmpFiles[$key])) {
                 $tmpFiles[$key] = array($tmpFiles[$key]);
             }
             $tmpFiles[$key][] = $file;
         } else {
             $tmpFiles[$key] = $file;
         }
         ksort($tmpFiles, SORT_NUMERIC);
     }
     if (!$hasComplexKeys) {
         $files = array_values($tmpFiles);
     } else {
         $files = array();
         $tmpFiles = array_values($tmpFiles);
         foreach ($tmpFiles as $file) {
             if (is_array($file)) {
                 $files = array_merge($files, $file);
             } else {
                 $files[] = $file;
             }
         }
     }
     return $files;
 }
开发者ID:sansandeep143,项目名称:av,代码行数:32,代码来源:class.Folder.php

示例15: initialize

 /**
  * @param string $type The type of init to load, possible values are: frontend, frontend_ajax, frontend_js.
  */
 public function initialize($type)
 {
     $type = (string) $type;
     // check if this is a valid type
     if (!in_array($type, $this->allowedTypes)) {
         exit('Invalid init-type');
     }
     $this->type = $type;
     // set a default timezone if no one was set by PHP.ini
     if (ini_get('date.timezone') == '') {
         date_default_timezone_set('Europe/Brussels');
     }
     // get last modified time for globals
     $lastModifiedTime = @filemtime(PATH_WWW . '/app/config/parameters.yml');
     // reset last modified time if needed when invalid or debug is active
     if ($lastModifiedTime === false || $this->getContainer()->getParameter('kernel.debug')) {
         $lastModifiedTime = time();
     }
     // define as a constant
     defined('LAST_MODIFIED_TIME') || define('LAST_MODIFIED_TIME', $lastModifiedTime);
     $this->definePaths();
     $this->defineURLs();
     $this->setDebugging();
     // require spoon
     require_once 'spoon/spoon.php';
 }
开发者ID:arashrasoulzadeh,项目名称:forkcms,代码行数:29,代码来源:Init.php


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