本文整理汇总了PHP中false::mtime方法的典型用法代码示例。如果您正苦于以下问题:PHP false::mtime方法的具体用法?PHP false::mtime怎么用?PHP false::mtime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类false
的用法示例。
在下文中一共展示了false::mtime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_data
/**
* Fetch the data via SimplePie_File
*
* If the data is already cached, attempt to fetch it from there instead
* @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache
* @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type
*/
protected function fetch_data(&$cache)
{
// If it's enabled, use the cache
if ($cache) {
// Load the Cache
$this->data = $cache->load();
if ($cache->mtime() + $this->cache_duration > time()) {
//FreshRSS
$this->raw_data = false;
return true;
// If the cache is still valid, just return true
} elseif (!empty($this->data)) {
// If the cache is for an outdated build of SimplePie
if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) {
$cache->unlink();
$this->data = array();
} elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) {
$cache = false;
$this->data = array();
} elseif (isset($this->data['feed_url'])) {
// If the autodiscovery cache is still valid use it.
if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) {
// Do not need to do feed autodiscovery yet.
if ($this->data['feed_url'] !== $this->data['url']) {
$this->set_feed_url($this->data['feed_url']);
return $this->init();
}
$cache->unlink();
$this->data = array();
}
} else {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
if (isset($this->data['headers']['last-modified'])) {
$headers['if-modified-since'] = $this->data['headers']['last-modified'];
}
if (isset($this->data['headers']['etag'])) {
$headers['if-none-match'] = $this->data['headers']['etag'];
}
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen));
//FreshRSS
if ($file->success) {
if ($file->status_code === 304) {
$cache->touch();
return true;
}
} else {
$cache->touch();
//FreshRSS
$this->error = $file->error;
//FreshRSS
return !empty($this->data);
//FreshRSS
//unset($file); //FreshRSS removed
}
//FreshRSS
$md5 = $this->cleanMd5($file->body);
if ($this->data['md5'] === $md5) {
// syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url);
$cache->touch();
return true;
//Content unchanged even though server did not send a 304
} else {
// syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url);
$this->data['md5'] = $md5;
}
}
//// If the cache is still valid, just return true
//else //FreshRSS removed
//{
// $this->raw_data = false;
// return true;
//}
} else {
//$cache->unlink(); //FreshRSS removed
$cache->touch();
//FreshRSS
$this->data = array();
}
}
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
if (!isset($file)) {
if ($this->file instanceof SimplePie_File && $this->file->url === $this->feed_url) {
$file =& $this->file;
} else {
$headers = array('Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1');
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen));
}
}
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) {
$this->error = $file->error;
return !empty($this->data);
}
//.........这里部分代码省略.........