Skip to content

Commit 4fbc2a8

Browse files
committed
Merge pull request #125 from bfintal/file_get_contents_warning
File get contents warning fix
2 parents cd63b09 + 939a46b commit 4fbc2a8

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

phpfastcache/3.0.0/abstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ protected function required_extension($name) {
272272

273273
protected function readfile($file) {
274274
if(function_exists("file_get_contents")) {
275-
return file_get_contents($file);
275+
return @file_get_contents($file);
276276
} else {
277277
$string = "";
278278

@@ -328,7 +328,7 @@ protected function decode($value) {
328328
protected function htaccessGen($path = "") {
329329
if($this->option("htaccess") == true) {
330330

331-
if(!file_exists($path."/.htaccess")) {
331+
if(!@file_exists($path."/.htaccess")) {
332332
// echo "write me";
333333
$html = "order deny, allow \r\n
334334
deny from all \r\n
@@ -408,7 +408,7 @@ public function systemInfo() {
408408

409409

410410
protected function isExistingDriver($class) {
411-
if(file_exists(dirname(__FILE__)."/drivers/".$class.".php")) {
411+
if(@file_exists(dirname(__FILE__)."/drivers/".$class.".php")) {
412412
require_once(dirname(__FILE__)."/drivers/".$class.".php");
413413
if(class_exists("phpfastcache_".$class)) {
414414
return true;

phpfastcache/3.0.0/drivers/files.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private function getFilePath($keyword, $skip = false) {
5252
* Skip Create Sub Folders;
5353
*/
5454
if($skip == false) {
55-
if(!file_exists($path)) {
55+
if(!@file_exists($path)) {
5656
if(!@mkdir($path,$this->__setChmodAuto())) {
5757
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
5858
}
@@ -78,7 +78,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
7878
/*
7979
* Skip if Existing Caching in Options
8080
*/
81-
if(isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) {
81+
if(isset($option['skipExisting']) && $option['skipExisting'] == true && @file_exists($file_path)) {
8282
$content = $this->readfile($file_path);
8383
$old = $this->decode($content);
8484
$toWrite = false;
@@ -89,7 +89,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
8989

9090
if($toWrite == true) {
9191
try {
92-
$f = fopen($file_path, "w+");
92+
$f = @fopen($file_path, "w+");
9393
fwrite($f, $data);
9494
fclose($f);
9595
} catch (Exception $e) {
@@ -105,7 +105,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
105105
function driver_get($keyword, $option = array()) {
106106

107107
$file_path = $this->getFilePath($keyword);
108-
if(!file_exists($file_path)) {
108+
if(!@file_exists($file_path)) {
109109
return null;
110110
}
111111

@@ -147,18 +147,18 @@ function driver_stats($option = array()) {
147147

148148
$total = 0;
149149
$removed = 0;
150-
while($file=readdir($dir)) {
150+
while($file=@readdir($dir)) {
151151
if($file!="." && $file!=".." && is_dir($path."/".$file)) {
152152
// read sub dir
153153
$subdir = @opendir($path."/".$file);
154154
if(!$subdir) {
155155
throw new Exception("Can't read path:".$path."/".$file,93);
156156
}
157157

158-
while($f = readdir($subdir)) {
158+
while($f = @readdir($subdir)) {
159159
if($f!="." && $f!="..") {
160160
$file_path = $path."/".$file."/".$f;
161-
$size = filesize($file_path);
161+
$size = @filesize($file_path);
162162
$object = $this->decode($this->readfile($file_path));
163163
if($this->isExpired($object)) {
164164
@unlink($file_path);
@@ -195,15 +195,15 @@ function driver_clean($option = array()) {
195195
throw new Exception("Can't read PATH:".$path,94);
196196
}
197197

198-
while($file=readdir($dir)) {
198+
while($file=@readdir($dir)) {
199199
if($file!="." && $file!=".." && is_dir($path."/".$file)) {
200200
// read sub dir
201201
$subdir = @opendir($path."/".$file);
202202
if(!$subdir) {
203203
throw new Exception("Can't read path:".$path."/".$file,93);
204204
}
205205

206-
while($f = readdir($subdir)) {
206+
while($f = @readdir($subdir)) {
207207
if($f!="." && $f!="..") {
208208
$file_path = $path."/".$file."/".$f;
209209
@unlink($file_path);
@@ -218,7 +218,7 @@ function driver_clean($option = array()) {
218218

219219
function driver_isExisting($keyword) {
220220
$file_path = $this->getFilePath($keyword,true);
221-
if(!file_exists($file_path)) {
221+
if(!@file_exists($file_path)) {
222222
return false;
223223
} else {
224224
// check expired or not

phpfastcache/3.0.0/drivers/sqlite.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ function initDB(PDO $db) {
3333
function initIndexing(PDO $db) {
3434

3535
// delete everything before reset indexing
36-
$dir = opendir($this->path);
37-
while($file = readdir($dir)) {
36+
$dir = @opendir($this->path);
37+
while($file = @readdir($dir)) {
3838
if($file != "." && $file!=".." && $file != "indexing" && $file!="dbfastcache") {
3939
@unlink($this->path."/".$file);
4040
}
@@ -54,7 +54,7 @@ function initIndexing(PDO $db) {
5454
function indexing($keyword) {
5555
if($this->indexing == NULL) {
5656
$createTable = false;
57-
if(!file_exists($this->path."/indexing")) {
57+
if(!@file_exists($this->path."/indexing")) {
5858
$createTable = true;
5959
}
6060

@@ -81,7 +81,7 @@ function indexing($keyword) {
8181

8282
// check file size
8383

84-
$size = file_exists($this->path."/db".$db) ? filesize($this->path."/db".$db) : 1;
84+
$size = @file_exists($this->path."/db".$db) ? @filesize($this->path."/db".$db) : 1;
8585
$size = round($size / 1024 / 1024,1);
8686

8787

@@ -129,7 +129,7 @@ function db($keyword, $reset = false) {
129129
if(!isset($this->instant[$instant])) {
130130
// check DB Files ready or not
131131
$createTable = false;
132-
if(!file_exists($this->path."/db".$instant) || $reset == true) {
132+
if(!@file_exists($this->path."/db".$instant) || $reset == true) {
133133
$createTable = true;
134134
}
135135
$PDO = new PDO("sqlite:".$this->path."/db".$instant);
@@ -171,7 +171,7 @@ function __construct($config = array()) {
171171
$this->fallback = true;
172172
}
173173

174-
if(!file_exists($this->getPath()."/sqlite")) {
174+
if(!@file_exists($this->getPath()."/sqlite")) {
175175
if(!@mkdir($this->getPath()."/sqlite",$this->__setChmodAuto())) {
176176
$this->fallback = true;
177177
}
@@ -310,11 +310,11 @@ function driver_stats($option = array()) {
310310
$total = 0;
311311
$optimized = 0;
312312

313-
$dir = opendir($this->path);
314-
while($file = readdir($dir)) {
313+
$dir = @opendir($this->path);
314+
while($file = @readdir($dir)) {
315315
if($file!="." && $file!="..") {
316316
$file_path = $this->path."/".$file;
317-
$size = filesize($file_path);
317+
$size = @filesize($file_path);
318318
$total = $total + $size;
319319

320320
try {
@@ -328,7 +328,7 @@ function driver_stats($option = array()) {
328328
));
329329

330330
$PDO->exec("VACUUM;");
331-
$size = filesize($file_path);
331+
$size = @filesize($file_path);
332332
$optimized = $optimized + $size;
333333
} catch (PDOException $e) {
334334
$size = 0;
@@ -355,8 +355,8 @@ function driver_clean($option = array()) {
355355
$this->indexing = NULL;
356356

357357
// delete everything before reset indexing
358-
$dir = opendir($this->path);
359-
while($file = readdir($dir)) {
358+
$dir = @opendir($this->path);
359+
while($file = @readdir($dir)) {
360360
if($file != "." && $file!="..") {
361361
@unlink($this->path."/".$file);
362362
}

phpfastcache/3.0.0/phpfastcache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected static function htaccessGen($path, $create = true) {
234234
die(" NEED WRITEABLE ".$path);
235235
}
236236
}
237-
if(!file_exists($path."/.htaccess")) {
237+
if(!@file_exists($path."/.htaccess")) {
238238
// echo "write me";
239239
$html = "order deny, allow \r\n
240240
deny from all \r\n

0 commit comments

Comments
 (0)