diff --git a/library/think/Cookie.php b/library/think/Cookie.php index 0ad2ff56..eb31c769 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -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]); } diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index 1edda249..53a5ded6 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -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; diff --git a/library/think/cache/driver/Lite.php b/library/think/cache/driver/Lite.php index fb9cfa75..551359f7 100644 --- a/library/think/cache/driver/Lite.php +++ b/library/think/cache/driver/Lite.php @@ -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, ("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; } diff --git a/library/think/cache/driver/Sqlite.php b/library/think/cache/driver/Sqlite.php index 681ace18..8a7c19aa 100644 --- a/library/think/cache/driver/Sqlite.php +++ b/library/think/cache/driver/Sqlite.php @@ -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); diff --git a/library/think/log/driver/File.php b/library/think/log/driver/File.php index b3a077b2..a540aac0 100644 --- a/library/think/log/driver/File.php +++ b/library/think/log/driver/File.php @@ -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)); } // 获取基本信息 diff --git a/library/think/template/driver/File.php b/library/think/template/driver/File.php index 8206571c..1cf98a27 100644 --- a/library/think/template/driver/File.php +++ b/library/think/template/driver/File.php @@ -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; } diff --git a/library/think/template/driver/Sae.php b/library/think/template/driver/Sae.php index 4c6e98a2..9e5230a5 100644 --- a/library/think/template/driver/Sae.php +++ b/library/think/template/driver/Sae.php @@ -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; }