Skip to content

Commit

Permalink
Merge pull request #125 from bfintal/file_get_contents_warning
Browse files Browse the repository at this point in the history
File get contents warning fix
  • Loading branch information
khoaofgod committed Aug 25, 2015
2 parents cd63b09 + 939a46b commit 4fbc2a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions phpfastcache/3.0.0/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected function required_extension($name) {

protected function readfile($file) {
if(function_exists("file_get_contents")) {
return file_get_contents($file);
return @file_get_contents($file);
} else {
$string = "";

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

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


protected function isExistingDriver($class) {
if(file_exists(dirname(__FILE__)."/drivers/".$class.".php")) {
if(@file_exists(dirname(__FILE__)."/drivers/".$class.".php")) {
require_once(dirname(__FILE__)."/drivers/".$class.".php");
if(class_exists("phpfastcache_".$class)) {
return true;
Expand Down
20 changes: 10 additions & 10 deletions phpfastcache/3.0.0/drivers/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function getFilePath($keyword, $skip = false) {
* Skip Create Sub Folders;
*/
if($skip == false) {
if(!file_exists($path)) {
if(!@file_exists($path)) {
if(!@mkdir($path,$this->__setChmodAuto())) {
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
}
Expand All @@ -78,7 +78,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
/*
* Skip if Existing Caching in Options
*/
if(isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) {
if(isset($option['skipExisting']) && $option['skipExisting'] == true && @file_exists($file_path)) {
$content = $this->readfile($file_path);
$old = $this->decode($content);
$toWrite = false;
Expand All @@ -89,7 +89,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {

if($toWrite == true) {
try {
$f = fopen($file_path, "w+");
$f = @fopen($file_path, "w+");
fwrite($f, $data);
fclose($f);
} catch (Exception $e) {
Expand All @@ -105,7 +105,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
function driver_get($keyword, $option = array()) {

$file_path = $this->getFilePath($keyword);
if(!file_exists($file_path)) {
if(!@file_exists($file_path)) {
return null;
}

Expand Down Expand Up @@ -147,18 +147,18 @@ function driver_stats($option = array()) {

$total = 0;
$removed = 0;
while($file=readdir($dir)) {
while($file=@readdir($dir)) {
if($file!="." && $file!=".." && is_dir($path."/".$file)) {
// read sub dir
$subdir = @opendir($path."/".$file);
if(!$subdir) {
throw new Exception("Can't read path:".$path."/".$file,93);
}

while($f = readdir($subdir)) {
while($f = @readdir($subdir)) {
if($f!="." && $f!="..") {
$file_path = $path."/".$file."/".$f;
$size = filesize($file_path);
$size = @filesize($file_path);
$object = $this->decode($this->readfile($file_path));
if($this->isExpired($object)) {
@unlink($file_path);
Expand Down Expand Up @@ -195,15 +195,15 @@ function driver_clean($option = array()) {
throw new Exception("Can't read PATH:".$path,94);
}

while($file=readdir($dir)) {
while($file=@readdir($dir)) {
if($file!="." && $file!=".." && is_dir($path."/".$file)) {
// read sub dir
$subdir = @opendir($path."/".$file);
if(!$subdir) {
throw new Exception("Can't read path:".$path."/".$file,93);
}

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

function driver_isExisting($keyword) {
$file_path = $this->getFilePath($keyword,true);
if(!file_exists($file_path)) {
if(!@file_exists($file_path)) {
return false;
} else {
// check expired or not
Expand Down
24 changes: 12 additions & 12 deletions phpfastcache/3.0.0/drivers/sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function initDB(PDO $db) {
function initIndexing(PDO $db) {

// delete everything before reset indexing
$dir = opendir($this->path);
while($file = readdir($dir)) {
$dir = @opendir($this->path);
while($file = @readdir($dir)) {
if($file != "." && $file!=".." && $file != "indexing" && $file!="dbfastcache") {
@unlink($this->path."/".$file);
}
Expand All @@ -54,7 +54,7 @@ function initIndexing(PDO $db) {
function indexing($keyword) {
if($this->indexing == NULL) {
$createTable = false;
if(!file_exists($this->path."/indexing")) {
if(!@file_exists($this->path."/indexing")) {
$createTable = true;
}

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

// check file size

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


Expand Down Expand Up @@ -129,7 +129,7 @@ function db($keyword, $reset = false) {
if(!isset($this->instant[$instant])) {
// check DB Files ready or not
$createTable = false;
if(!file_exists($this->path."/db".$instant) || $reset == true) {
if(!@file_exists($this->path."/db".$instant) || $reset == true) {
$createTable = true;
}
$PDO = new PDO("sqlite:".$this->path."/db".$instant);
Expand Down Expand Up @@ -171,7 +171,7 @@ function __construct($config = array()) {
$this->fallback = true;
}

if(!file_exists($this->getPath()."/sqlite")) {
if(!@file_exists($this->getPath()."/sqlite")) {
if(!@mkdir($this->getPath()."/sqlite",$this->__setChmodAuto())) {
$this->fallback = true;
}
Expand Down Expand Up @@ -310,11 +310,11 @@ function driver_stats($option = array()) {
$total = 0;
$optimized = 0;

$dir = opendir($this->path);
while($file = readdir($dir)) {
$dir = @opendir($this->path);
while($file = @readdir($dir)) {
if($file!="." && $file!="..") {
$file_path = $this->path."/".$file;
$size = filesize($file_path);
$size = @filesize($file_path);
$total = $total + $size;

try {
Expand All @@ -328,7 +328,7 @@ function driver_stats($option = array()) {
));

$PDO->exec("VACUUM;");
$size = filesize($file_path);
$size = @filesize($file_path);
$optimized = $optimized + $size;
} catch (PDOException $e) {
$size = 0;
Expand All @@ -355,8 +355,8 @@ function driver_clean($option = array()) {
$this->indexing = NULL;

// delete everything before reset indexing
$dir = opendir($this->path);
while($file = readdir($dir)) {
$dir = @opendir($this->path);
while($file = @readdir($dir)) {
if($file != "." && $file!="..") {
@unlink($this->path."/".$file);
}
Expand Down
2 changes: 1 addition & 1 deletion phpfastcache/3.0.0/phpfastcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected static function htaccessGen($path, $create = true) {
die(" NEED WRITEABLE ".$path);
}
}
if(!file_exists($path."/.htaccess")) {
if(!@file_exists($path."/.htaccess")) {
// echo "write me";
$html = "order deny, allow \r\n
deny from all \r\n
Expand Down

0 comments on commit 4fbc2a8

Please sign in to comment.