From b1056a19a3bd807f212986c0ca5bf9861547d814 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sat, 17 Nov 2012 18:43:32 +0000 Subject: [PATCH] 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 --- lib/file-control.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/file-control.php b/lib/file-control.php index 4ca64ef..86ef062 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -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 ''; @@ -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 ''; @@ -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 ''; // 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']);