Restrict demo mode to load only

Cannot only make new folder, paste, rename, replace text in file, change
perms, delete or save if demoMode is false
This commit is contained in:
Matt Pass
2012-11-17 18:43:32 +00:00
parent 048c47f7f3
commit b1056a19a3

View File

@@ -42,7 +42,7 @@ if ($_GET['action']=="load") {
// If we're due to add a new folder...
if ($_GET['action']=="newFolder") {
if (is_writable($docRoot.$fileLoc)) {
if (!$demoMode && is_writable($docRoot.$fileLoc)) {
mkdir($file, 0705);
// Reload file manager
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\');action="newFolder";</script>';
@@ -55,7 +55,7 @@ if ($_GET['action']=="newFolder") {
// If we're due to paste a new file...
if ($_GET['action']=="paste") {
$location = $docRoot.strClean(str_replace("|","/",$_GET['location']));
if (is_writable($location)) {
if (!$demoMode && is_writable($location)) {
copy($file, $location."/".basename($file));
// Reload file manager
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.str_replace($docRoot,"",$location).'\',\''.$fileName.'\');action="pasteFile";</script>';
@@ -67,7 +67,7 @@ if ($_GET['action']=="paste") {
// If we're due to rename a file/folder...
if ($_GET['action']=="rename") {
if (is_writable($docRoot.$iceRoot.str_replace("|","/",strClean($_GET['oldFileName'])))) {
if (!$demoMode && is_writable($docRoot.$iceRoot.str_replace("|","/",strClean($_GET['oldFileName'])))) {
rename($docRoot.$iceRoot.str_replace("|","/",strClean($_GET['oldFileName'])),$docRoot.$fileLoc."/".$fileName);
// Reload file manager
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'rename\',\''.$fileLoc.'\',\''.$fileName.'\',\'\',\''.str_replace($iceRoot,"",strClean($_GET['oldFileName'])).'\');';
@@ -80,7 +80,7 @@ if ($_GET['action']=="rename") {
// If we're due to replace text in a file...
if ($_GET['action']=="replaceText") {
if (is_writable(str_replace("|","/",strClean($_GET['fileRef'])))) {
if (!$demoMode && is_writable(str_replace("|","/",strClean($_GET['fileRef'])))) {
$file = str_replace("|","/",strClean($_GET['fileRef']));
$loadedFile = file_get_contents($file);
$newContent = str_replace(strClean($_GET['find']),strClean($_GET['replace']),$loadedFile);
@@ -96,7 +96,7 @@ if ($_GET['action']=="replaceText") {
// If we're due to change permissions on a file/folder...
if ($_GET['action']=="perms") {
if (is_writable($file)) {
if (!$demoMode && is_writable($file)) {
chmod($file,octdec(numClean($_GET['perms'])));
// Reload file manager
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'chmod\',\''.$fileLoc.'\',\''.$fileName.'\',\''.numClean($_GET['perms']).'\');';
@@ -111,7 +111,7 @@ if ($_GET['action']=="perms") {
if ($_GET['action']=="delete") {
$filesArray = explode(";",$file); // May contain more than one file here
for ($i=0;$i<=count($filesArray)-1;$i++) {
if (is_writable($iceRoot.$filesArray[$i])) {
if (!$demoMode && is_writable($iceRoot.$filesArray[$i])) {
is_dir($iceRoot.$filesArray[$i])
? rrmdir($iceRoot.$filesArray[$i])
: unlink($iceRoot.$filesArray[$i]);
@@ -146,7 +146,7 @@ if ($_GET['action']=="save") {
echo '<script>action="save";</script>';
// on the form posting via a reload, save the file
if (isset($_POST['contents'])) {
if ((file_exists($file) && is_writable($file)) || isset($_POST['newFileName']) && $_POST['newFileName']!="") {
if (!$demoMode && ((file_exists($file) && is_writable($file)) || isset($_POST['newFileName']) && $_POST['newFileName']!="")) {
if (filemtime($file)==$_GET['fileMDT']||!(isset($_GET['fileMDT']))) {
$fh = fopen($file, 'w') or die("Sorry, cannot save");
fwrite($fh, $_POST['contents']);