From 173f32e62a359d56f9e6cd22c67bb8f41445d56c Mon Sep 17 00:00:00 2001 From: owen0o0 <32561126+owen0o0@users.noreply.github.com> Date: Wed, 27 Nov 2019 20:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=A9=BA=E7=99=BD=E5=9B=BE=E5=83=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/get.php b/get.php index 8330f61..4e39dd5 100644 --- a/get.php +++ b/get.php @@ -2,9 +2,9 @@ /** * getFavicon * @author 一为 - * @date 2019-05-18 + * @date 2019-11-27 * @link https://www.iowen.cn - * @version 1.0.0 + * @version 1.1.0 */ if( !isset($_GET['url'])){ @@ -46,11 +46,13 @@ if($expire == 0){ } else{ $defaultMD5 = md5(file_get_contents($defaultIco)); - if (Cache::get($formatUrl,$defaultMD5,$expire) !== NULL) { + + $data = Cache::get($formatUrl,$defaultMD5,$expire); + if ($data !== NULL) { foreach ($favicon->getHeader() as $header) { @header($header); } - echo Cache::get($formatUrl,$defaultMD5,$expire); + echo $data; exit; } @@ -96,17 +98,21 @@ class Cache $a = $dir . '/' . $f . '.txt'; - $data = file_get_contents($a); - if( md5($data) == $default ){ - $expire = 43200; //如果返回默认图标,过期时间为12小时。 - } - if ( !is_file($a) || (time() - filemtime($a)) > $expire ) { + if(is_file($a)){ + $data = file_get_contents($a); + if( md5($data) == $default ){ + $expire = 43200; //如果返回默认图标,过期时间为12小时。 + } + if( (time() - filemtime($a)) > $expire ){ + return null; + } + else{ + return $data; + } + } + else{ return null; } - else { - return $data; - } - } /** @@ -133,7 +139,5 @@ class Cache fwrite($imgdata, $value); fclose($imgdata); } - } - -} \ No newline at end of file +}