@@ -21,7 +21,6 @@ public function __construct($request, $response, $params = NULL)
21
21
22
22
}
23
23
24
-
25
24
26
25
public static function headlink ()
27
26
{
@@ -394,7 +393,6 @@ private function GetPostImg()
394
393
}
395
394
}
396
395
397
-
398
396
try {
399
397
list ($ width , $ height , $ type , $ attr ) = @getimagesize ($ img_url );
400
398
$ imgData =array (
@@ -524,7 +522,8 @@ private function substr_format($text, $length, $replace = '...', $encoding = 'UT
524
522
}
525
523
return $ text ;
526
524
}
527
-
525
+
526
+
528
527
private function getSlugRule ()
529
528
{
530
529
$ router = explode ('/ ' , Helper::options ()->routingTable ['post ' ]['url ' ]);
@@ -538,48 +537,58 @@ private function getSlugRule()
538
537
//For page_cacher
539
538
540
539
private function set ($ key , $ cache ){
541
- $ installDb = $ this ->db ;
542
- $ time =(int )Helper::options ()->plugin ('AMP ' )->cacheTime ;
543
- $ expire = $ time *60 *60 ;
544
- if (is_array ($ cache )) $ cache = json_encode ($ cache );
545
- $ table = $ this ->tablename ;
546
- $ time = time ();
547
-
548
- $ cache = addslashes ($ cache );
549
- $ sql = "REPLACE INTO $ table (`hash`,`cache`,`dateline`,`expire`) VALUES (' $ key',' $ cache',' $ time',' $ expire') " ;
550
- $ installDb ->query ($ sql );
551
-
540
+ if (Helper::options ()->plugin ('AMP ' )->cacheTime >0 ) {
541
+ $ installDb = $ this ->db ;
542
+ $ time = (int )Helper::options ()->plugin ('AMP ' )->cacheTime ;
543
+ $ expire = $ time * 60 * 60 ;
544
+ if (is_array ($ cache )) $ cache = json_encode ($ cache );
545
+ $ table = $ this ->tablename ;
546
+ $ time = time ();
547
+
548
+ $ cache = addslashes ($ cache );
549
+ $ sql = "REPLACE INTO $ table (`hash`,`cache`,`dateline`,`expire`) VALUES (' $ key',' $ cache',' $ time',' $ expire') " ;
550
+ $ installDb ->query ($ sql );
551
+ }else {
552
+ return null ;
553
+ }
552
554
}
553
555
554
556
private function del ($ key ){
555
- $ installDb = $ this ->db ;
556
- $ tablename =$ this ->tablename ;
557
- if (is_array ($ key )){
558
- foreach ($ key as $ k =>$ v ){
559
- $ this ->del ($ v );
557
+ if (Helper::options ()->plugin ('AMP ' )->cacheTime >0 ) {
558
+ $ installDb = $ this ->db ;
559
+ $ tablename = $ this ->tablename ;
560
+ if (is_array ($ key )) {
561
+ foreach ($ key as $ k => $ v ) {
562
+ $ this ->del ($ v );
563
+ }
564
+ } else {
565
+ if ($ key == '* ' ) {
566
+ $ installDb ->query ("DELETE FROM $ tablename WHERE 1=1 " );
567
+ } else {
568
+ $ delete = $ installDb ->delete ($ tablename )->where ('hash = ? ' , $ key )->limit (1 );
569
+ $ installDb ->query ($ delete );
570
+ }
560
571
}
561
572
}else {
562
- if ($ key =='* ' ){
563
- $ installDb ->query ("DELETE FROM $ tablename WHERE 1=1 " );
564
- }else {
565
- $ delete = $ installDb ->delete ($ tablename )->where ('hash = ? ' , $ key )->limit (1 );
566
- $ installDb ->query ($ delete );
567
- }
573
+ return null ;
568
574
}
569
575
}
570
576
571
577
private function get ($ key ){
572
- $ installDb = $ this ->db ;
573
- $ tablename =$ this ->tablename ;
574
-
575
- $ condition =$ installDb ->select ('cache ' ,'dateline ' ,'expire ' )->from ($ tablename )->where ('hash = ? ' , $ key );
576
-
577
- $ row = $ installDb ->fetchRow ($ condition );
578
- if (!$ row ) return ;
579
- if (time ()-$ row ['dateline ' ]>$ row ['expire ' ]) $ this ->del ($ key );
580
- $ cache = $ row ['cache ' ];
581
- $ arr = json_decode ($ cache ,true );
582
- return is_array ($ arr )?$ arr :$ cache ;
578
+ if (Helper::options ()->plugin ('AMP ' )->cacheTime >0 ) {
579
+ $ installDb = $ this ->db ;
580
+ $ tablename = $ this ->tablename ;
581
+
582
+ $ condition = $ installDb ->select ('cache ' , 'dateline ' , 'expire ' )->from ($ tablename )->where ('hash = ? ' , $ key );
583
+ $ row = $ installDb ->fetchRow ($ condition );
584
+ if (!$ row ) return ;
585
+ if (time () - $ row ['dateline ' ] > $ row ['expire ' ]) $ this ->del ($ key );
586
+ $ cache = $ row ['cache ' ];
587
+ $ arr = json_decode ($ cache , true );
588
+ return is_array ($ arr ) ? $ arr : $ cache ;
589
+ }else {
590
+ return null ;
591
+ }
583
592
}
584
593
585
594
0 commit comments