From fb964e0c78199e16629f9dff9fc807087385dd46 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 2 Jan 2003 13:08:20 +0000 Subject: [PATCH] Some robustness fixes. --- files/index.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/files/index.php b/files/index.php index c167750104..3bcb2aa279 100644 --- a/files/index.php +++ b/files/index.php @@ -10,6 +10,9 @@ require("../config.php"); require_variable($id); + optional_variable($file, ""); + optional_variable($wdir, ""); + optional_variable($action, ""); if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); @@ -71,7 +74,6 @@ // End of configuration and access control - require("mimetypes.php"); $regexp="\\.\\."; @@ -142,7 +144,7 @@ break; case "delete": - if ($confirm) { + if (!empty($confirm)) { html_header($course, $wdir); foreach ($USER->filelist as $file) { $fullfile = $basedir.$file; @@ -186,7 +188,7 @@ case "paste": html_header($course, $wdir); - if ($USER->fileop == "move") { + if (isset($USER->fileop) and $USER->fileop == "move") { foreach ($USER->filelist as $file) { $shortfile = basename($file); $oldfile = $basedir.$file; @@ -202,7 +204,7 @@ break; case "rename": - if ($name) { + if (!empty($name)) { html_header($course, $wdir); $name = clean_filename($name); if (file_exists($basedir.$wdir."/".$name)) { @@ -237,7 +239,7 @@ break; case "mkdir": - if ($name) { + if (!empty($name)) { html_header($course, $wdir); $name = clean_filename($name); if (file_exists($basedir.$wdir."/".$name)) { @@ -326,7 +328,7 @@ break; case "zip": - if ($name) { + if (!empty($name)) { html_header($course, $wdir); $name = clean_filename($name); $files = ""; @@ -374,7 +376,7 @@ case "unzip": html_header($course, $wdir); - if ($file) { + if (!empty($file)) { echo "

Unzipping $file:

"; print_simple_box_start("center"); echo "
";
@@ -555,7 +557,7 @@ function displaydir ($wdir) {
 
     $count = 0;
 
-    if ($dirlist) {
+    if (!empty($dirlist)) {
         asort($dirlist);
         foreach ($dirlist as $dir) {
 
@@ -579,7 +581,7 @@ function displaydir ($wdir) {
     }
 
 
-    if ($filelist) {
+    if (!empty($filelist)) {
         asort($filelist);
         foreach ($filelist as $file) {
 
@@ -628,7 +630,7 @@ function displaydir ($wdir) {
     echo "";
     echo "
"; - if (!$wdir) { + if (empty($wdir)) { $wdir = "/"; } @@ -641,7 +643,7 @@ function displaydir ($wdir) { "delete" => "$strdeletecompletely", "zip" => "$strcreateziparchive" ); - if ($count) { + if (!empty($count)) { choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()"); } -- 2.39.5