diff --git a/lib/file-control.php b/lib/file-control.php index d5d73a6..212f436 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -18,6 +18,11 @@ $file = str_replace("|","/",strClean( // Trim any +'s or spaces from the end of file and clear any ../'s $file = str_replace("../","",rtrim(rtrim($file,'+'),' ')); +// Make $file a full path and establish the $fileLoc and $fileName +if (strpos($file,$docRoot)===false && $_GET['action']!="getRemoteFile") {$file=str_replace("|","/",$docRoot.$iceRoot.$file);}; +$fileLoc = substr(str_replace($docRoot,"",$file),0,strrpos(str_replace($docRoot,"",$file),"/")); +$fileName = basename($file); + // Die if the file requested isn't something we expect if( ($_GET['action']!="getRemoteFile" && strpos(realpath($file),realpath($docRoot)) !== 0) || @@ -26,11 +31,6 @@ if( die("alert('Sorry - problem with file requested');"); }; -// Make $file a full path and establish the $fileLoc and $fileName -if (strpos($file,$docRoot)===false && $_GET['action']!="getRemoteFile") {$file=str_replace("|","/",$docRoot.$iceRoot.$file);}; -$fileLoc = substr(str_replace($docRoot,"",$file),0,strrpos(str_replace($docRoot,"",$file),"/")); -$fileName = basename($file); - // echo ";alert('".xssClean($_GET['action'],"html")." : ".$file."');console.log('".xssClean($_GET['action'],"html")." : ".$file."');"; // If we're due to open a file...