소스 검색

fix Signature ticket expire

stanley-king 7 년 전
부모
커밋
656f87d1db
1개의 변경된 파일14개의 추가작업 그리고 5개의 파일을 삭제
  1. 14 5
      helper/third_author/signaturer.php

+ 14 - 5
helper/third_author/signaturer.php

@@ -66,10 +66,11 @@ class signaturer
 
     private function rjsapi_ticket()
     {
-        if(empty($this->mData) || empty($this->mData['jsapi_ticket']))
-        {
+        if(empty($this->mData) || empty($this->mData['jsapi_ticket'])) {
             $fReadCache = true;
-        } else {
+        }
+        else
+        {
             $expires = $this->mData['jsapi_ticket']['expires'];
             if(time() >= $expires) {
                 $fReadCache = true;
@@ -77,13 +78,21 @@ class signaturer
                 $fReadCache = false;
             }
         }
+
         if($fReadCache)
         {
             $items = rcache('jsapi_ticket',self::prefix);
             if(empty($items)) {
                 $this->mData['jsapi_ticket'] = $this->request();
-            } else {
-                $this->mData['jsapi_ticket'] = $items;
+            }
+            else
+            {
+                $expires = intval($items['expires']);
+                if($expires <= time()) {
+                    $this->mData['jsapi_ticket'] = $this->request();
+                } else {
+                    $this->mData['jsapi_ticket'] = $items;
+                }
             }
         }