@@ -28,14 +28,14 @@ function __construct($config = array()) {
28
28
}
29
29
30
30
}
31
-
31
+
32
32
private function encodeFilename ($ keyword ) {
33
- return trim (trim (preg_replace ("/[^a-zA-Z0-9]+/ " ,"_ " ,$ keyword ),"_ " ));
33
+ return trim (trim (preg_replace ("/[^a-zA-Z0-9]+/ " ,"_ " ,$ keyword ),"_ " ));
34
34
// return rtrim(base64_encode($keyword), '=');
35
35
}
36
-
36
+
37
37
private function decodeFilename ($ filename ) {
38
- return $ filename ;
38
+ return $ filename ;
39
39
// return base64_decode($filename);
40
40
}
41
41
@@ -44,8 +44,8 @@ private function decodeFilename($filename) {
44
44
*/
45
45
private function getFilePath ($ keyword , $ skip = false ) {
46
46
$ path = $ this ->getPath ();
47
-
48
- $ filename = $ this ->encodeFilename ($ keyword );
47
+
48
+ $ filename = $ this ->encodeFilename ($ keyword );
49
49
$ folder = substr ($ filename ,0 ,2 );
50
50
$ path = rtrim ($ path ,"/ " )."/ " .$ folder ;
51
51
/*
@@ -59,7 +59,7 @@ private function getFilePath($keyword, $skip = false) {
59
59
60
60
} elseif (!is_writeable ($ path )) {
61
61
if (!chmod ($ path ,$ this ->__setChmodAuto ())) {
62
- throw new Exception ("PLEASE CHMOD " .$ this ->getPath ()." - 0777 OR ANY WRITABLE PERMISSION! " ,92 );
62
+ throw new Exception ("PLEASE CHMOD " .$ this ->getPath ()." - 0777 OR ANY WRITABLE PERMISSION! " ,92 );
63
63
}
64
64
}
65
65
}
@@ -68,7 +68,6 @@ private function getFilePath($keyword, $skip = false) {
68
68
return $ file_path ;
69
69
}
70
70
71
-
72
71
function driver_set ($ keyword , $ value = "" , $ time = 300 , $ option = array () ) {
73
72
$ file_path = $ this ->getFilePath ($ keyword );
74
73
// echo "<br>DEBUG SET: ".$keyword." - ".$value." - ".$time."<br>";
@@ -99,9 +98,6 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
99
98
}
100
99
}
101
100
102
-
103
-
104
-
105
101
function driver_get ($ keyword , $ option = array ()) {
106
102
107
103
$ file_path = $ this ->getFilePath ($ keyword );
@@ -162,19 +158,19 @@ function driver_stats($option = array()) {
162
158
$ object = $ this ->decode ($ this ->readfile ($ file_path ));
163
159
if ($ this ->isExpired ($ object )) {
164
160
@unlink ($ file_path );
165
- $ removed = $ removed + $ size ;
161
+ $ removed += $ size ;
166
162
}
167
- $ total = $ total + $ size ;
163
+ $ total += $ size ;
168
164
}
169
165
} // end read subdir
170
166
} // end if
171
167
} // end while
172
168
173
- $ res ['size ' ] = $ total - $ removed ;
169
+ $ res ['size ' ] = $ total - $ removed ;
174
170
$ res ['info ' ] = array (
175
- "Total " => $ total ,
176
- "Removed " => $ removed ,
177
- "Current " => $ res ['size ' ],
171
+ "Total [bytes] " => $ total ,
172
+ "Expired and removed [bytes] " => $ removed ,
173
+ "Current [bytes] " => $ res ['size ' ],
178
174
);
179
175
return $ res ;
180
176
}
@@ -212,10 +208,8 @@ function driver_clean($option = array()) {
212
208
} // end if
213
209
} // end while
214
210
215
-
216
211
}
217
212
218
-
219
213
function driver_isExisting ($ keyword ) {
220
214
$ file_path = $ this ->getFilePath ($ keyword ,true );
221
215
if (!@file_exists ($ file_path )) {
@@ -232,15 +226,11 @@ function driver_isExisting($keyword) {
232
226
}
233
227
234
228
function isExpired ($ object ) {
235
-
236
229
if (isset ($ object ['expired_time ' ]) && time () >= $ object ['expired_time ' ]) {
237
230
return true ;
238
231
} else {
239
232
return false ;
240
233
}
241
234
}
242
235
243
-
244
-
245
-
246
236
}
0 commit comments