2004-10-07 14:18:43 +00:00
|
|
|
<?php // $Id$
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
// Manage all uploaded files in a course file area
|
|
|
|
|
|
|
|
// All the Moodle-specific stuff is in this top section
|
|
|
|
// Configuration and access control occurs here.
|
|
|
|
// Must define: USER, basedir, baseweb, html_header and html_footer
|
|
|
|
// USER is a persistent variable using sessions
|
|
|
|
|
|
|
|
require("../config.php");
|
|
|
|
|
2004-10-07 14:18:43 +00:00
|
|
|
$id = required_param('id', PARAM_INT);
|
|
|
|
$file = optional_param('file', '');
|
|
|
|
$wdir = optional_param('wdir', '');
|
|
|
|
$action = optional_param('action', '');
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 14:16:07 +00:00
|
|
|
if (! $course = get_record("course", "id", $id) ) {
|
|
|
|
error("That's an invalid course id");
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 14:16:07 +00:00
|
|
|
require_login($course->id);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 14:16:07 +00:00
|
|
|
if (! isteacheredit($course->id) ) {
|
|
|
|
error("You need to be a teacher with editing privileges");
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function html_footer() {
|
|
|
|
global $course;
|
|
|
|
echo "</td></tr></table></body></html>";
|
|
|
|
print_footer($course);
|
|
|
|
}
|
|
|
|
|
2002-08-30 13:18:06 +00:00
|
|
|
function html_header($course, $wdir, $formfield=""){
|
2002-08-18 15:26:04 +00:00
|
|
|
|
2003-08-01 15:09:35 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($course->id == SITEID) {
|
2003-08-10 08:01:14 +00:00
|
|
|
$strfiles = get_string("sitefiles");
|
|
|
|
} else {
|
|
|
|
$strfiles = get_string("files");
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-30 13:18:06 +00:00
|
|
|
if ($wdir == "/") {
|
2003-08-01 15:09:35 +00:00
|
|
|
$fullnav = "$strfiles";
|
2002-08-30 13:18:06 +00:00
|
|
|
} else {
|
|
|
|
$dirs = explode("/", $wdir);
|
|
|
|
$numdirs = count($dirs);
|
|
|
|
$link = "";
|
|
|
|
$navigation = "";
|
2003-09-16 06:15:01 +00:00
|
|
|
for ($i=1; $i<$numdirs-1; $i++) {
|
2002-08-30 13:18:06 +00:00
|
|
|
$navigation .= " -> ";
|
|
|
|
$link .= "/".urlencode($dirs[$i]);
|
2004-09-16 17:13:57 +00:00
|
|
|
$navigation .= "<a href=\"index.php?id=$course->id&wdir=$link\">".$dirs[$i]."</a>";
|
2002-08-30 13:18:06 +00:00
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
$fullnav = "<a href=\"index.php?id=$course->id&wdir=/\">$strfiles</a> $navigation -> ".$dirs[$numdirs-1];
|
2003-08-01 15:09:35 +00:00
|
|
|
}
|
2002-08-30 13:18:06 +00:00
|
|
|
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($course->id == SITEID) {
|
2003-08-01 15:09:35 +00:00
|
|
|
print_header("$course->shortname: $strfiles", "$course->fullname",
|
|
|
|
"<a href=\"../$CFG->admin/index.php\">".get_string("administration").
|
|
|
|
"</a> -> $fullnav", $formfield);
|
2003-08-10 08:01:14 +00:00
|
|
|
|
|
|
|
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
|
|
|
|
2003-08-01 15:09:35 +00:00
|
|
|
} else {
|
2002-08-30 13:18:06 +00:00
|
|
|
print_header("$course->shortname: $strfiles", "$course->fullname",
|
2003-08-01 15:09:35 +00:00
|
|
|
"<a href=\"../course/view.php?id=$course->id\">$course->shortname".
|
|
|
|
"</a> -> $fullnav", $formfield);
|
2002-08-30 13:18:06 +00:00
|
|
|
}
|
2003-08-10 08:01:14 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<table border=\"0\" align=\"center\" cellspacing=\"3\" cellpadding=\"3\" width=\"640\">";
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\">";
|
|
|
|
}
|
2004-02-20 14:16:07 +00:00
|
|
|
|
|
|
|
if (! $basedir = make_upload_directory("$course->id")) {
|
2002-08-04 16:20:30 +00:00
|
|
|
error("The site administrator needs to fix the file permissions");
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$baseweb = $CFG->wwwroot;
|
|
|
|
|
|
|
|
// End of configuration and access control
|
|
|
|
|
|
|
|
require("mimetypes.php");
|
|
|
|
|
2004-10-07 14:18:43 +00:00
|
|
|
if (!$wdir) {
|
|
|
|
$wdir="/";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($wdir != '/' and detect_munged_arguments($wdir, 0))
|
|
|
|
or ($file != '' and detect_munged_arguments($file, 0))) {
|
2001-11-22 06:23:56 +00:00
|
|
|
$message = "Error: Directories can not contain \"..\"";
|
|
|
|
$wdir = "/";
|
|
|
|
$action = "";
|
|
|
|
}
|
|
|
|
|
2003-09-16 06:15:01 +00:00
|
|
|
if ($wdir == "/backupdata") {
|
|
|
|
if (! make_upload_directory("$course->id/backupdata")) { // Backup folder
|
|
|
|
error("Could not create backupdata folder. The site administrator needs to fix the file permissions");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
|
|
|
|
case "upload":
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2004-09-15 02:43:40 +00:00
|
|
|
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
|
|
|
|
2003-01-05 04:20:32 +00:00
|
|
|
if (!empty($save)) {
|
2004-09-15 02:43:40 +00:00
|
|
|
$um = new upload_manager('userfile',false,false,$course,false,0);
|
|
|
|
$dir = "$basedir$wdir";
|
|
|
|
if ($um->process_file_uploads($dir)) {
|
|
|
|
notify(get_string('uploadedfile'));
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-09-15 02:43:40 +00:00
|
|
|
// um will take care of error reporting.
|
2001-11-22 06:23:56 +00:00
|
|
|
displaydir($wdir);
|
|
|
|
} else {
|
2004-02-14 16:19:48 +00:00
|
|
|
$upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); // Restricted by site setting
|
2002-09-01 14:28:08 +00:00
|
|
|
$filesize = display_size($upload_max_filesize);
|
2002-08-07 08:24:38 +00:00
|
|
|
|
2003-01-05 04:20:32 +00:00
|
|
|
$struploadafile = get_string("uploadafile");
|
|
|
|
$struploadthisfile = get_string("uploadthisfile");
|
|
|
|
$strmaxsize = get_string("maxsize", "", $filesize);
|
|
|
|
$strcancel = get_string("cancel");
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p>$struploadafile ($strmaxsize) --> <b>$wdir</b>";
|
|
|
|
echo "<table><tr><td colspan=\"2\">";
|
|
|
|
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"index.php\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />";
|
2004-09-15 02:43:40 +00:00
|
|
|
upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false);
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td><tr><td width=\"10\">";
|
|
|
|
echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td><td width=\"100%\">";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strcancel\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr></table>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "delete":
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($confirm)) {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2001-11-22 06:23:56 +00:00
|
|
|
foreach ($USER->filelist as $file) {
|
|
|
|
$fullfile = $basedir.$file;
|
|
|
|
if (! fulldelete($fullfile)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<br />Error: Could not delete: $fullfile";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
clearfilelist();
|
|
|
|
displaydir($wdir);
|
|
|
|
html_footer();
|
|
|
|
|
|
|
|
} else {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2003-01-05 06:45:20 +00:00
|
|
|
if (setfilelist($_POST)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">".get_string("deletecheckwarning").":</p>";
|
2001-11-22 06:23:56 +00:00
|
|
|
print_simple_box_start("center");
|
|
|
|
printfilelist($USER->filelist);
|
|
|
|
print_simple_box_end();
|
2003-08-05 03:25:16 +00:00
|
|
|
echo "<br />";
|
|
|
|
notice_yesno (get_string("deletecheckfiles"),
|
2004-09-16 17:13:57 +00:00
|
|
|
"index.php?id=$id&wdir=$wdir&action=delete&confirm=1",
|
|
|
|
"index.php?id=$id&wdir=$wdir&action=cancel");
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
|
|
|
displaydir($wdir);
|
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "move":
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2003-01-05 06:45:20 +00:00
|
|
|
if ($count = setfilelist($_POST)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
$USER->fileop = $action;
|
|
|
|
$USER->filesource = $wdir;
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">";
|
2003-08-05 03:25:16 +00:00
|
|
|
print_string("selectednowmove", "moodle", $count);
|
|
|
|
echo "</p>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
displaydir($wdir);
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "paste":
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2003-01-02 13:08:20 +00:00
|
|
|
if (isset($USER->fileop) and $USER->fileop == "move") {
|
2001-11-22 06:23:56 +00:00
|
|
|
foreach ($USER->filelist as $file) {
|
|
|
|
$shortfile = basename($file);
|
|
|
|
$oldfile = $basedir.$file;
|
|
|
|
$newfile = $basedir.$wdir."/".$shortfile;
|
|
|
|
if (!rename($oldfile, $newfile)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p>Error: $shortfile not moved";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearfilelist();
|
|
|
|
displaydir($wdir);
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "rename":
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($name)) {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2004-09-28 08:05:18 +00:00
|
|
|
$name = clean_filename($name);
|
|
|
|
$oldname = clean_filename($oldname);
|
2001-11-22 06:23:56 +00:00
|
|
|
if (file_exists($basedir.$wdir."/".$name)) {
|
|
|
|
echo "Error: $name already exists!";
|
|
|
|
} else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) {
|
|
|
|
echo "Error: could not rename $oldname to $name";
|
|
|
|
}
|
|
|
|
displaydir($wdir);
|
|
|
|
|
|
|
|
} else {
|
2003-08-04 16:07:17 +00:00
|
|
|
$strrename = get_string("rename");
|
|
|
|
$strcancel = get_string("cancel");
|
|
|
|
$strrenamefileto = get_string("renamefileto", "moodle", $file);
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir, "form.name");
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p>$strrenamefileto:";
|
|
|
|
echo "<table><tr><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"post\" name=\"form\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />";
|
|
|
|
echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strrename\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strcancel\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr></table>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "mkdir":
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($name)) {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2001-11-22 06:23:56 +00:00
|
|
|
$name = clean_filename($name);
|
2003-04-25 08:39:11 +00:00
|
|
|
if (file_exists("$basedir$wdir/$name")) {
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "Error: $name already exists!";
|
2003-04-25 08:39:11 +00:00
|
|
|
} else if (! make_upload_directory("$course->id/$wdir/$name")) {
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "Error: could not create $name";
|
|
|
|
}
|
|
|
|
displaydir($wdir);
|
|
|
|
|
|
|
|
} else {
|
2003-08-04 16:07:17 +00:00
|
|
|
$strcreate = get_string("create");
|
|
|
|
$strcancel = get_string("cancel");
|
|
|
|
$strcreatefolder = get_string("createfolder", "moodle", $wdir);
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir, "form.name");
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p>$strcreatefolder:";
|
|
|
|
echo "<table><tr><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"post\" name=\"form\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />";
|
|
|
|
echo " <input type=\"text\" name=\"name\" size=\"35\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strcreate\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strcancel\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr></table>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "edit":
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2001-11-22 06:23:56 +00:00
|
|
|
if (isset($text)) {
|
|
|
|
$fileptr = fopen($basedir.$file,"w");
|
|
|
|
fputs($fileptr, stripslashes($text));
|
|
|
|
fclose($fileptr);
|
|
|
|
displaydir($wdir);
|
|
|
|
|
|
|
|
} else {
|
2004-09-12 21:43:59 +00:00
|
|
|
$streditfile = get_string("edit", "", "<b>$file</b>");
|
2001-11-22 06:23:56 +00:00
|
|
|
$fileptr = fopen($basedir.$file, "r");
|
|
|
|
$contents = fread($fileptr, filesize($basedir.$file));
|
|
|
|
fclose($fileptr);
|
|
|
|
|
2002-12-26 16:26:55 +00:00
|
|
|
if (mimeinfo("type", $file) == "text/html") {
|
2004-08-04 16:26:44 +00:00
|
|
|
$usehtmleditor = can_use_html_editor();
|
2002-12-26 16:26:55 +00:00
|
|
|
} else {
|
|
|
|
$usehtmleditor = false;
|
|
|
|
}
|
2004-08-30 08:44:00 +00:00
|
|
|
$usehtmleditor = false; // Always keep it off for now
|
2002-12-26 16:26:55 +00:00
|
|
|
|
|
|
|
print_heading("$streditfile");
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<table><tr><td colspan=\"2\">";
|
|
|
|
echo "<form action=\"index.php\" method=\"post\" name=\"form\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"file\" value=\"$file\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />";
|
2004-08-04 16:26:44 +00:00
|
|
|
print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents);
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td></tr><tr><td>";
|
|
|
|
echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr></table>";
|
2002-12-26 16:26:55 +00:00
|
|
|
|
|
|
|
if ($usehtmleditor) {
|
2004-08-04 16:26:44 +00:00
|
|
|
use_html_editor();
|
2002-12-26 16:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "zip":
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($name)) {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2001-11-22 06:23:56 +00:00
|
|
|
$name = clean_filename($name);
|
2003-04-06 05:53:47 +00:00
|
|
|
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
|
|
|
$files = array();
|
|
|
|
foreach ($USER->filelist as $file) {
|
2004-10-07 14:18:43 +00:00
|
|
|
$files[] = cleardoubleslashes("$basedir/$file"); // no doubleslashes!
|
2003-04-06 05:53:47 +00:00
|
|
|
}
|
2004-03-13 12:08:28 +00:00
|
|
|
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
|
2004-10-07 14:18:43 +00:00
|
|
|
$archive = new PclZip(cleardoubleslashes("$basedir/$wdir/$name"));
|
|
|
|
if (($list = $archive->create($files, PCLZIP_OPT_REMOVE_PATH,
|
|
|
|
rtrim(cleardoubleslashes("$basedir/$wdir"), "/"))) == 0) { // no double slashes and trailing slash!
|
2003-04-06 05:53:47 +00:00
|
|
|
error($archive->errorInfo(true));
|
|
|
|
}
|
|
|
|
} else { // Use external zip program
|
|
|
|
$files = "";
|
|
|
|
foreach ($USER->filelist as $file) {
|
|
|
|
$files .= basename($file);
|
|
|
|
$files .= " ";
|
|
|
|
}
|
|
|
|
$command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
|
|
|
|
Exec($command);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
clearfilelist();
|
|
|
|
displaydir($wdir);
|
|
|
|
|
|
|
|
} else {
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir, "form.name");
|
2003-08-04 16:07:17 +00:00
|
|
|
|
2003-01-05 06:45:20 +00:00
|
|
|
if (setfilelist($_POST)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>";
|
2001-11-22 06:23:56 +00:00
|
|
|
print_simple_box_start("center");
|
|
|
|
printfilelist($USER->filelist);
|
|
|
|
print_simple_box_end();
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<br />";
|
|
|
|
echo "<p align=\"center\">".get_string("whattocallzip");
|
|
|
|
echo "<table><tr><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"post\" name=\"form\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />";
|
|
|
|
echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td><td>";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr></table>";
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
|
|
|
displaydir($wdir);
|
|
|
|
clearfilelist();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "unzip":
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($file)) {
|
2003-04-06 05:53:47 +00:00
|
|
|
$strname = get_string("name");
|
|
|
|
$strsize = get_string("size");
|
|
|
|
$strmodified = get_string("modified");
|
|
|
|
$strstatus = get_string("status");
|
|
|
|
$strok = get_string("ok");
|
|
|
|
$strunpacking = get_string("unpacking", "", $file);
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">$strunpacking:</p>";
|
2003-04-06 05:53:47 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
$file = basename($file);
|
2003-04-06 05:53:47 +00:00
|
|
|
|
|
|
|
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
|
2004-03-13 12:08:28 +00:00
|
|
|
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
|
2004-10-07 14:18:43 +00:00
|
|
|
$archive = new PclZip(cleardoubleslashes("$basedir/$wdir/$file"));
|
|
|
|
if (!$list = $archive->extract(PCLZIP_OPT_PATH, cleardoubleslashes("$basedir/$wdir"),
|
|
|
|
PCLZIP_CB_PRE_EXTRACT, 'approvefile')) {
|
2003-04-06 05:53:47 +00:00
|
|
|
error($archive->errorInfo(true));
|
|
|
|
} else { // print some output
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\">";
|
|
|
|
echo "<tr><th align=\"left\">$strname</th>";
|
|
|
|
echo "<th align=\"right\">$strsize</th>";
|
|
|
|
echo "<th align=\"right\">$strmodified</th>";
|
|
|
|
echo "<th align=\"right\">$strstatus</th></tr>";
|
2003-04-06 05:53:47 +00:00
|
|
|
foreach ($list as $item) {
|
|
|
|
echo "<tr>";
|
2004-10-07 14:18:43 +00:00
|
|
|
$item['filename'] = str_replace(cleardoubleslashes("$basedir/$wdir/"), "", $item['filename']);
|
2003-04-06 05:53:47 +00:00
|
|
|
print_cell("left", $item['filename']);
|
|
|
|
if (! $item['folder']) {
|
|
|
|
print_cell("right", display_size($item['size']));
|
|
|
|
} else {
|
|
|
|
echo "<td> </td>";
|
|
|
|
}
|
|
|
|
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
|
|
|
|
print_cell("right", $filedate);
|
|
|
|
print_cell("right", $item['status']);
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else { // Use external unzip program
|
|
|
|
print_simple_box_start("center");
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<pre>";
|
2003-04-06 05:53:47 +00:00
|
|
|
$command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
|
|
|
|
passthru($command);
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</pre>";
|
2003-04-06 05:53:47 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center><form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strok\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</center>";
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
|
|
|
displaydir($wdir);
|
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
2003-04-06 05:53:47 +00:00
|
|
|
case "listzip":
|
|
|
|
html_header($course, $wdir);
|
|
|
|
if (!empty($file)) {
|
|
|
|
$strname = get_string("name");
|
|
|
|
$strsize = get_string("size");
|
|
|
|
$strmodified = get_string("modified");
|
|
|
|
$strok = get_string("ok");
|
|
|
|
$strlistfiles = get_string("listfiles", "", $file);
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">$strlistfiles:</p>";
|
2003-04-06 05:53:47 +00:00
|
|
|
$file = basename($file);
|
|
|
|
|
2004-03-13 12:08:28 +00:00
|
|
|
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
|
2004-10-07 14:18:43 +00:00
|
|
|
$archive = new PclZip(cleardoubleslashes("$basedir/$wdir/$file"));
|
|
|
|
if (!$list = $archive->listContent(cleardoubleslashes("$basedir/$wdir"))) {
|
2003-04-06 05:53:47 +00:00
|
|
|
notify($archive->errorInfo(true));
|
|
|
|
|
|
|
|
} else {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\">";
|
|
|
|
echo "<tr><th align=\"left\">$strname</th><th align=\"right\">$strsize</th><th align=\"right\">$strmodified</th></tr>";
|
2003-04-06 05:53:47 +00:00
|
|
|
foreach ($list as $item) {
|
|
|
|
echo "<tr>";
|
|
|
|
print_cell("left", $item['filename']);
|
|
|
|
if (! $item['folder']) {
|
|
|
|
print_cell("right", display_size($item['size']));
|
|
|
|
} else {
|
|
|
|
echo "<td> </td>";
|
|
|
|
}
|
|
|
|
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
|
|
|
|
print_cell("right", $filedate);
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<br /><center><form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strok\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</center>";
|
2003-04-06 05:53:47 +00:00
|
|
|
} else {
|
|
|
|
displaydir($wdir);
|
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
2003-05-14 23:09:34 +00:00
|
|
|
case "restore":
|
|
|
|
html_header($course, $wdir);
|
|
|
|
if (!empty($file)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p align=\"center\">".get_string("youaregoingtorestorefrom").":</p>";
|
2003-05-14 23:09:34 +00:00
|
|
|
print_simple_box_start("center");
|
|
|
|
echo $file;
|
|
|
|
print_simple_box_end();
|
2003-08-23 15:47:57 +00:00
|
|
|
echo "<br />";
|
2004-10-07 14:18:43 +00:00
|
|
|
echo "<p align=center>".get_string("areyousuretorestorethisinfo")."</p>";
|
|
|
|
$restore_path = "$CFG->wwwroot/backup/restore.php";
|
2003-05-14 23:09:34 +00:00
|
|
|
notice_yesno (get_string("areyousuretorestorethis"),
|
2004-10-07 14:18:43 +00:00
|
|
|
$restore_path."?id=".$id."&file=".cleardoubleslashes($id.$wdir."/".$file),
|
|
|
|
"index.php?id=$id&wdir=$wdir&action=cancel");
|
2003-05-14 23:09:34 +00:00
|
|
|
} else {
|
|
|
|
displaydir($wdir);
|
|
|
|
}
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
case "cancel";
|
|
|
|
clearfilelist();
|
|
|
|
|
|
|
|
default:
|
2002-08-30 13:18:06 +00:00
|
|
|
html_header($course, $wdir);
|
2001-11-22 06:23:56 +00:00
|
|
|
displaydir($wdir);
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// FILE FUNCTIONS ///////////////////////////////////////////////////////////
|
|
|
|
|
2004-10-07 14:18:43 +00:00
|
|
|
function approvefile($p_event, &$p_header){
|
|
|
|
if (detect_munged_arguments($p_header['filename'], 0)) {
|
|
|
|
return 0; // do not extract file!!
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
function fulldelete($location) {
|
|
|
|
if (is_dir($location)) {
|
|
|
|
$currdir = opendir($location);
|
|
|
|
while ($file = readdir($currdir)) {
|
|
|
|
if ($file <> ".." && $file <> ".") {
|
|
|
|
$fullfile = $location."/".$file;
|
|
|
|
if (is_dir($fullfile)) {
|
|
|
|
if (!fulldelete($fullfile)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!unlink($fullfile)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($currdir);
|
|
|
|
if (! rmdir($location)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (!unlink($location)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setfilelist($VARS) {
|
|
|
|
global $USER;
|
|
|
|
|
|
|
|
$USER->filelist = array ();
|
|
|
|
$USER->fileop = "";
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
foreach ($VARS as $key => $val) {
|
|
|
|
if (substr($key,0,4) == "file") {
|
|
|
|
$count++;
|
2004-10-07 14:18:43 +00:00
|
|
|
$val = rawurldecode($val);
|
|
|
|
if (!detect_munged_arguments($val, 0)) {
|
|
|
|
$USER->filelist[] = rawurldecode($val);
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearfilelist() {
|
|
|
|
global $USER;
|
|
|
|
|
|
|
|
$USER->filelist = array ();
|
|
|
|
$USER->fileop = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function printfilelist($filelist) {
|
2004-02-14 16:19:48 +00:00
|
|
|
global $CFG, $basedir;
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
foreach ($filelist as $file) {
|
|
|
|
if (is_dir($basedir.$file)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
|
2001-11-22 06:23:56 +00:00
|
|
|
$subfilelist = array();
|
|
|
|
$currdir = opendir($basedir.$file);
|
|
|
|
while ($subfile = readdir($currdir)) {
|
|
|
|
if ($subfile <> ".." && $subfile <> ".") {
|
|
|
|
$subfilelist[] = $file."/".$subfile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printfilelist($subfilelist);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$icon = mimeinfo("icon", $file);
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function print_cell($alignment="center", $text=" ") {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<td align=\"$alignment\" nowrap=\"nowrap\">";
|
|
|
|
echo "<font size=\"-1\" face=\"Arial, Helvetica\">";
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "$text";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</font>";
|
|
|
|
echo "</td>\n";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function displaydir ($wdir) {
|
|
|
|
// $wdir == / or /a or /a/b/c/d etc
|
|
|
|
|
|
|
|
global $basedir;
|
|
|
|
global $id;
|
2002-08-28 13:41:38 +00:00
|
|
|
global $USER, $CFG;
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
$fullpath = $basedir.$wdir;
|
|
|
|
|
|
|
|
$directory = opendir($fullpath); // Find all files
|
|
|
|
while ($file = readdir($directory)) {
|
2004-02-20 14:16:07 +00:00
|
|
|
if ($file == "." || $file == "..") {
|
2001-11-22 06:23:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_dir($fullpath."/".$file)) {
|
|
|
|
$dirlist[] = $file;
|
|
|
|
} else {
|
|
|
|
$filelist[] = $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($directory);
|
|
|
|
|
2002-08-30 13:18:06 +00:00
|
|
|
$strname = get_string("name");
|
|
|
|
$strsize = get_string("size");
|
|
|
|
$strmodified = get_string("modified");
|
|
|
|
$straction = get_string("action");
|
|
|
|
$strmakeafolder = get_string("makeafolder");
|
|
|
|
$struploadafile = get_string("uploadafile");
|
|
|
|
$strwithchosenfiles = get_string("withchosenfiles");
|
|
|
|
$strmovetoanotherfolder = get_string("movetoanotherfolder");
|
|
|
|
$strmovefilestohere = get_string("movefilestohere");
|
|
|
|
$strdeletecompletely = get_string("deletecompletely");
|
|
|
|
$strcreateziparchive = get_string("createziparchive");
|
|
|
|
$strrename = get_string("rename");
|
|
|
|
$stredit = get_string("edit");
|
|
|
|
$strunzip = get_string("unzip");
|
2003-04-06 05:53:47 +00:00
|
|
|
$strlist = get_string("list");
|
2003-05-14 23:09:34 +00:00
|
|
|
$strrestore= get_string("restore");
|
2002-08-30 13:18:06 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<form action=\"index.php\" method=\"post\" name=\"dirform\">";
|
|
|
|
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
|
|
|
|
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">";
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<th width=\"5\"></th>";
|
|
|
|
echo "<th align=\"left\">$strname</th>";
|
|
|
|
echo "<th align=\"right\">$strsize</th>";
|
|
|
|
echo "<th align=\"right\">$strmodified</th>";
|
|
|
|
echo "<th align=\"right\">$straction</th>";
|
|
|
|
echo "</tr>\n";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
if ($wdir == "/") {
|
|
|
|
$wdir = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($dirlist)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
asort($dirlist);
|
|
|
|
foreach ($dirlist as $dir) {
|
|
|
|
|
|
|
|
$count++;
|
|
|
|
|
|
|
|
$filename = $fullpath."/".$dir;
|
|
|
|
$fileurl = rawurlencode($wdir."/".$dir);
|
|
|
|
$filesafe = rawurlencode($dir);
|
2004-05-16 08:52:32 +00:00
|
|
|
$filesize = display_size(get_directory_size("$fullpath/$dir"));
|
2003-12-08 13:31:14 +00:00
|
|
|
$filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<tr>";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />");
|
2004-09-16 17:13:57 +00:00
|
|
|
print_cell("left", "<a href=\"index.php?id=$id&wdir=$fileurl\"><img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"Folder\" /></a> <a href=\"index.php?id=$id&wdir=$fileurl\">".htmlspecialchars($dir)."</a>");
|
2004-05-16 08:52:32 +00:00
|
|
|
print_cell("right", "<b>$filesize</b>");
|
2001-11-22 06:23:56 +00:00
|
|
|
print_cell("right", $filedate);
|
2004-09-16 17:13:57 +00:00
|
|
|
print_cell("right", "<a href=\"index.php?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</a>");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($filelist)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
asort($filelist);
|
|
|
|
foreach ($filelist as $file) {
|
|
|
|
|
|
|
|
$icon = mimeinfo("icon", $file);
|
|
|
|
|
|
|
|
$count++;
|
|
|
|
$filename = $fullpath."/".$file;
|
|
|
|
$fileurl = "$wdir/$file";
|
|
|
|
$filesafe = rawurlencode($file);
|
|
|
|
$fileurlsafe = rawurlencode($fileurl);
|
2003-12-08 13:31:14 +00:00
|
|
|
$filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-08-10 08:01:14 +00:00
|
|
|
echo "<tr>";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" />");
|
|
|
|
echo "<td align=\"left\" nowrap=\"nowrap\">";
|
2002-08-26 09:48:00 +00:00
|
|
|
if ($CFG->slasharguments) {
|
|
|
|
$ffurl = "/file.php/$id$fileurl";
|
|
|
|
} else {
|
|
|
|
$ffurl = "/file.php?file=/$id$fileurl";
|
|
|
|
}
|
|
|
|
link_to_popup_window ($ffurl, "display",
|
2004-09-16 17:13:57 +00:00
|
|
|
"<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" border=\"0\" alt=\"File\" />",
|
2001-11-22 06:23:56 +00:00
|
|
|
480, 640);
|
2003-08-10 08:01:14 +00:00
|
|
|
echo "<font size=\"-1\" face=\"Arial, Helvetica\">";
|
2002-08-26 09:48:00 +00:00
|
|
|
link_to_popup_window ($ffurl, "display",
|
2001-11-22 06:23:56 +00:00
|
|
|
htmlspecialchars($file),
|
|
|
|
480, 640);
|
2003-08-10 08:01:14 +00:00
|
|
|
echo "</font></td>";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-09-01 14:28:08 +00:00
|
|
|
$file_size = filesize($filename);
|
|
|
|
print_cell("right", display_size($file_size));
|
2001-11-22 06:23:56 +00:00
|
|
|
print_cell("right", $filedate);
|
|
|
|
if ($icon == "text.gif" || $icon == "html.gif") {
|
2004-09-16 17:13:57 +00:00
|
|
|
$edittext = "<a href=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=edit\">$stredit</a>";
|
2001-11-22 06:23:56 +00:00
|
|
|
} else if ($icon == "zip.gif") {
|
2004-09-16 17:13:57 +00:00
|
|
|
$edittext = "<a href=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</a> ";
|
|
|
|
$edittext .= "<a href=\"index.php?id=$id&wdir=$wdir&file=$fileurl&action=listzip\">$strlist</a> ";
|
2003-08-16 16:14:25 +00:00
|
|
|
if (!empty($CFG->backup_version) and isteacheredit($id)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$edittext .= "<a href=\"index.php?id=$id&wdir=$wdir&file=$filesafe&action=restore\">$strrestore</a> ";
|
2003-05-14 23:09:34 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
|
|
|
$edittext = "";
|
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
print_cell("right", "$edittext <a href=\"index.php?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</a>");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</table>";
|
|
|
|
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-01-02 13:08:20 +00:00
|
|
|
if (empty($wdir)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
$wdir = "/";
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"640\">";
|
|
|
|
echo "<tr><td>";
|
|
|
|
echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" /> ";
|
2001-11-22 06:23:56 +00:00
|
|
|
$options = array (
|
2002-08-30 13:18:06 +00:00
|
|
|
"move" => "$strmovetoanotherfolder",
|
|
|
|
"delete" => "$strdeletecompletely",
|
|
|
|
"zip" => "$strcreateziparchive"
|
2001-11-22 06:23:56 +00:00
|
|
|
);
|
2003-01-02 13:08:20 +00:00
|
|
|
if (!empty($count)) {
|
2002-08-30 13:18:06 +00:00
|
|
|
choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()");
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</form>";
|
|
|
|
echo "<td align=\"center\">";
|
2003-01-08 09:08:05 +00:00
|
|
|
if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strmovefilestohere\" />";
|
|
|
|
echo "</form>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<td align=\"right\">";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$strmakeafolder\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td>";
|
|
|
|
echo "<td align=\"right\">";
|
|
|
|
echo "<form action=\"index.php\" method=\"get\">";
|
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />";
|
|
|
|
echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />";
|
|
|
|
echo " <input type=\"submit\" value=\"$struploadafile\" />";
|
|
|
|
echo "</form>";
|
|
|
|
echo "</td></tr>";
|
|
|
|
echo "</table>";
|
|
|
|
echo "<hr width=\"640\" align=\"center\" noshade=\"noshade\" size=\"1\" />";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|