mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
替换 time() 为 $_SERVER['REQUEST_TIME']
This commit is contained in:
@@ -88,7 +88,7 @@ class Cookie
|
||||
array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
|
||||
$value = 'think:' . json_encode($value);
|
||||
}
|
||||
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
|
||||
$expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0;
|
||||
if ($config['setcookie']) {
|
||||
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class Cookie
|
||||
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
||||
$name = $prefix . $name;
|
||||
if ($config['setcookie']) {
|
||||
setcookie($name, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
setcookie($name, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
// 删除指定cookie
|
||||
unset($_COOKIE[$name]);
|
||||
@@ -169,7 +169,7 @@ class Cookie
|
||||
foreach ($_COOKIE as $key => $val) {
|
||||
if (0 === strpos($key, $prefix)) {
|
||||
if ($config['setcookie']) {
|
||||
setcookie($key, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
setcookie($key, '', $_SERVER['REQUEST_TIME'] - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
unset($_COOKIE[$key]);
|
||||
}
|
||||
|
||||
2
library/think/cache/driver/File.php
vendored
2
library/think/cache/driver/File.php
vendored
@@ -101,7 +101,7 @@ class File
|
||||
$content = file_get_contents($filename);
|
||||
if (false !== $content) {
|
||||
$expire = (int) substr($content, 8, 12);
|
||||
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
||||
if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire) {
|
||||
//缓存过期删除缓存文件
|
||||
$this->unlink($filename);
|
||||
return false;
|
||||
|
||||
4
library/think/cache/driver/Lite.php
vendored
4
library/think/cache/driver/Lite.php
vendored
@@ -65,7 +65,7 @@ class Lite
|
||||
if (is_file($filename)) {
|
||||
// 判断是否过期
|
||||
$mtime = filemtime($filename);
|
||||
if ($mtime < time()) {
|
||||
if ($mtime < $_SERVER['REQUEST_TIME']) {
|
||||
// 清除已经过期的文件
|
||||
unlink($filename);
|
||||
return false;
|
||||
@@ -97,7 +97,7 @@ class Lite
|
||||
$ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";"));
|
||||
// 通过设置修改时间实现有效期
|
||||
if ($ret) {
|
||||
touch($filename, time() + $expire);
|
||||
touch($filename, $_SERVER['REQUEST_TIME'] + $expire);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
2
library/think/cache/driver/Memcached.php
vendored
2
library/think/cache/driver/Memcached.php
vendored
@@ -88,7 +88,7 @@ class Memcached
|
||||
$expire = $this->options['expire'];
|
||||
}
|
||||
$name = $this->options['prefix'] . $name;
|
||||
$expire = 0 == $expire ? 0 : time() + $expire;
|
||||
$expire = 0 == $expire ? 0 : $_SERVER['REQUEST_TIME'] + $expire;
|
||||
if ($this->handler->set($name, $value, $expire)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
4
library/think/cache/driver/Sqlite.php
vendored
4
library/think/cache/driver/Sqlite.php
vendored
@@ -56,7 +56,7 @@ class Sqlite implements CacheInterface
|
||||
public function get($name)
|
||||
{
|
||||
$name = $this->options['prefix'] . sqlite_escape_string($name);
|
||||
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1';
|
||||
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . $_SERVER['REQUEST_TIME'] . ') LIMIT 1';
|
||||
$result = sqlite_query($this->handler, $sql);
|
||||
if (sqlite_num_rows($result)) {
|
||||
$content = sqlite_fetch_single($result);
|
||||
@@ -84,7 +84,7 @@ class Sqlite implements CacheInterface
|
||||
if (is_null($expire)) {
|
||||
$expire = $this->options['expire'];
|
||||
}
|
||||
$expire = (0 == $expire) ? 0 : (time() + $expire); //缓存有效期为0表示永久缓存
|
||||
$expire = (0 == $expire) ? 0 : ($_SERVER['REQUEST_TIME'] + $expire); //缓存有效期为0表示永久缓存
|
||||
if (function_exists('gzcompress')) {
|
||||
//数据压缩
|
||||
$value = gzcompress($value, 3);
|
||||
|
||||
@@ -45,7 +45,7 @@ class File
|
||||
|
||||
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
||||
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
||||
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
|
||||
rename($destination, dirname($destination) . DS . $_SERVER['REQUEST_TIME'] . '-' . basename($destination));
|
||||
}
|
||||
|
||||
// 获取基本信息
|
||||
|
||||
@@ -62,7 +62,7 @@ class File
|
||||
if (!file_exists($cacheFile)) {
|
||||
return false;
|
||||
}
|
||||
if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
|
||||
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) {
|
||||
// 缓存是否在有效期
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Sae
|
||||
public function write($cacheFile, $content)
|
||||
{
|
||||
// 添加写入时间
|
||||
$content = time() . $content;
|
||||
$content = $_SERVER['REQUEST_TIME'] . $content;
|
||||
if (!$this->mc->set($cacheFile, $content, MEMCACHE_COMPRESSED, 0)) {
|
||||
throw new Exception('sae mc write error:' . $cacheFile);
|
||||
} else {
|
||||
@@ -76,7 +76,7 @@ class Sae
|
||||
public function check($cacheFile, $cacheTime)
|
||||
{
|
||||
$mtime = $this->get($cacheFile, 'mtime');
|
||||
if (0 != $cacheTime && time() > $mtime + $cacheTime) {
|
||||
if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > $mtime + $cacheTime) {
|
||||
// 缓存是否在有效期
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user