coursefiles.php
来自「很棒的在线教学系统」· PHP 代码 · 共 814 行 · 第 1/3 页
PHP
814 行
displaydir($wdir); } html_footer(); } break; case "move": html_header($course, $wdir); if ($count = setfilelist($_POST) and confirm_sesskey()) { $USER->fileop = $action; $USER->filesource = $wdir; echo "<p align=\"center\">"; print_string("selectednowmove", "moodle", $count); echo "</p>"; } displaydir($wdir); html_footer(); break; case "paste": html_header($course, $wdir); if (isset($USER->fileop) and $USER->fileop == "move" and confirm_sesskey()) { foreach ($USER->filelist as $file) { $shortfile = basename($file); $oldfile = $basedir.$file; $newfile = $basedir.$wdir."/".$shortfile; if (!rename($oldfile, $newfile)) { echo "<p>Error: $shortfile not moved"; } } } clearfilelist(); displaydir($wdir); html_footer(); break; case "rename": if (!empty($name) and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); 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 { $strrename = get_string("rename"); $strcancel = get_string("cancel"); $strrenamefileto = get_string("renamefileto", "moodle", $file); html_header($course, $wdir, "form.name"); echo "<p>$strrenamefileto:"; echo "<table border=\"0\">\n<tr>\n<td>\n"; echo "<form action=\"coursefiles.php\" method=\"post\" id=\"form\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />\n"; echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n"; echo " <input type=\"hidden\" name=\"oldname\" value=\"$file\" />\n"; echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />\n"; echo " <input type=\"submit\" value=\"$strrename\" />\n"; echo "</form>\n"; echo "</td><td>\n"; echo "<form action=\"coursefiles.php\" method=\"get\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n"; echo " <input type=\"submit\" value=\"$strcancel\" />\n"; echo "</form>"; echo "</td></tr>\n</table>\n"; } html_footer(); break; case "mkdir": if (!empty($name) and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); if (file_exists("$basedir$wdir/$name")) { echo "Error: $name already exists!"; } else if (! make_upload_directory("$course->id/$wdir/$name")) { echo "Error: could not create $name"; } displaydir($wdir); } else { $strcreate = get_string("create"); $strcancel = get_string("cancel"); $strcreatefolder = get_string("createfolder", "moodle", $wdir); html_header($course, $wdir, "form.name"); echo "<p>$strcreatefolder:"; echo "<table border=\"0\">\n<tr><td>\n"; echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />\n"; echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n"; echo " <input type=\"text\" name=\"name\" size=\"35\" />\n"; echo " <input type=\"submit\" value=\"$strcreate\" />\n"; echo "</form>\n"; echo "</td><td>\n"; echo "<form action=\"coursefiles.php\" method=\"get\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n"; echo " <input type=\"submit\" value=\"$strcancel\" />\n"; echo "</form>\n"; echo "</td>\n</tr>\n</table>\n"; } html_footer(); break; case "edit": html_header($course, $wdir); if (($text != '') and confirm_sesskey()) { $fileptr = fopen($basedir.$file,"w"); fputs($fileptr, stripslashes($text)); fclose($fileptr); displaydir($wdir); } else { $streditfile = get_string("edit", "", "<strong>$file</strong>"); $fileptr = fopen($basedir.$file, "r"); $contents = fread($fileptr, filesize($basedir.$file)); fclose($fileptr); print_heading("$streditfile"); echo "<table><tr><td colspan=\"2\">\n"; echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\" $onsubmit>\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=file value=\"$file\" />"; echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />\n"; echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n"; print_textarea(false, 25, 80, 680, 400, "text", $contents); echo "</td>\n</tr>\n<tr>\n<td>\n"; echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />\n"; echo "</form>\n"; echo "</td>\n<td>\n"; echo "<form action=\"coursefiles.php\" method=\"get\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n"; echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n"; echo "</form>\n"; echo "</td></tr></table>\n"; if ($usehtmleditor) { use_html_editor("text"); } } html_footer(); break; case "zip": if (!empty($name) and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); $files = array(); foreach ($USER->filelist as $file) { $files[] = "$basedir/$file"; } if (!zip_files($files,"$basedir/$wdir/$name")) { print_error("zipfileserror","error"); } clearfilelist(); displaydir($wdir); } else { html_header($course, $wdir, "form.name"); if (setfilelist($_POST)) { echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>"; print_simple_box_start("center"); printfilelist($USER->filelist); print_simple_box_end(); echo "<br />"; echo "<p align=\"center\">".get_string("whattocallzip"); echo "<table border=\"0\">\n<tr>\n<td>\n"; echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />\n"; echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n"; echo " <INPUT type=\"text\" name=\"name\" size=\"35\" value=\"new.zip\" />\n"; echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />"; echo "</form>\n"; echo "</td>\n<td>\n"; echo "<form action=\"coursefiles.php\" method=\"get\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n"; echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n"; echo "</form>\n"; echo "</td>\n</tr>\n</table>\n"; } else { displaydir($wdir); clearfilelist(); } } html_footer(); break; case "unzip": html_header($course, $wdir); if (!empty($file) and confirm_sesskey()) { $strok = get_string("ok"); $strunpacking = get_string("unpacking", "", $file); echo "<p align=\"center\">$strunpacking:</p>"; $file = basename($file); if (!unzip_file("$basedir/$wdir/$file")) { print_error("unzipfileserror","error"); } echo "<center><form action=\"coursefiles.php\" method=\"get\">\n"; echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n"; echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n"; echo " <input type=\"submit\" value=\"$strok\" />\n"; echo "</form>\n"; echo "</center>\n"; } else { displaydir($wdir); } html_footer(); break; case "listzip": html_header($course, $wdir); if (!empty($file) and confirm_sesskey()) { $strname = get_string("name"); $strsize = get_string("size"); $strmodified = get_string("modified"); $strok = get_string("ok"); $strlistfiles = get_string("listfiles", "", $file); echo "<p align=\"center\">$strlistfiles:</p>"; $file = basename($file); require_once($CFG->libdir.'/pclzip/pclzip.lib.php'); $archive = new PclZip("$basedir/$wdir/$file"); if (!$list = $archive->listContent("$basedir/$wdir")) { notify($archive->errorInfo(true)); } else { echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\">\n"; echo "<tr>\n<th align=\"left\" scope=\"col\">$strname</th><th align=\"right\" scope=\"col\">$strsize</th><th align=\"right\" scope=\"col\">$strmodified</th></tr>"; 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>\n"; } $filedate = userdate($item['mtime'], get_string("strftimedatetime")); print_cell("right", $filedate); echo "</tr>\n"; } echo "</table>\n"; } echo "<br /><center><form action=\"coursefiles.php\" method=\"get\">\n";
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?