Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpfastcache/3.0.0/drivers/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
* because first-to-lock wins and the file will exist before the writer attempts
* to write.
*/
if($toWrite == true && !@file_exists($tmp_path && !@file_exists($file_path))) {
if($toWrite == true && !@file_exists($tmp_path) && !@file_exists($file_path)) {
try {
$f = @fopen($tmp_path, "c");
if ($f) {
Expand Down
11 changes: 9 additions & 2 deletions phpfastcache/3.0.0/phpfastcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ public static function getPath($skip_create_path = false, $config) {
if($securityKey == "" || $securityKey == "auto") {
$securityKey = self::$config['securityKey'];
if($securityKey == "auto" || $securityKey == "") {
$securityKey = isset($_SERVER['HTTP_HOST']) ? ltrim(strtolower($_SERVER['HTTP_HOST']),"www.") : "default";
$securityKey = preg_replace("/[^a-zA-Z0-9]+/","",$securityKey);
$securityKey = isset($_SERVER['HTTP_HOST']) ? preg_replace('/^www./','',strtolower($_SERVER['HTTP_HOST'])) : "default";
}
}
if($securityKey != "") {
$securityKey.= "/";
}

$securityKey = self::cleanFileName($securityKey);

$full_path = $path."/".$securityKey;
$full_pathx = md5($full_path);
Expand Down Expand Up @@ -199,6 +200,12 @@ public static function getPath($skip_create_path = false, $config) {
return realpath($full_path);

}

public static function cleanFileName($filename) {
$regex = ['/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/','/\.$/','/^\./'];
$replace = ['-','',''];
return preg_replace($regex,$replace,$filename);
}


public static function __setChmodAuto($config) {
Expand Down