From: skodak Date: Sat, 27 Jan 2007 23:23:44 +0000 (+0000) Subject: Editor related fixes: X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1e94fe068cc22494d967402f0d8d3538c67c9033;p=moodle.git Editor related fixes: MDL-7545 HTML Editor does not send http headers for character encoding; MDL-8323 added proper require_course_login() + fixed javascript in coursefiles broken by XHTML strict + general cleanup and fixing in coursefiles (themes, javascript, obsoleted functions, etc.) --- diff --git a/lib/editor/htmlarea/coursefiles.php b/lib/editor/htmlarea/coursefiles.php index 843cfd432f..6f2206f439 100644 --- a/lib/editor/htmlarea/coursefiles.php +++ b/lib/editor/htmlarea/coursefiles.php @@ -30,8 +30,7 @@ error("That's an invalid course id"); } - require_login($course->id); - + require_login($course); require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)); function html_footer() { @@ -50,7 +49,9 @@ coursefiles @@ -190,18 +192,10 @@ // End of configuration and access control - if (!$wdir) { - $wdir="/"; + if ($wdir == '') { + $wdir='/'; } - if (($wdir != '/' and detect_munged_arguments($wdir, 0)) - or ($file != '' and detect_munged_arguments($file, 0))) { - $message = "Error: Directories can not contain \"..\""; - $wdir = "/"; - $action = ""; - } - - switch ($action) { case "upload": @@ -316,10 +310,9 @@ if (!empty($name) and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); - $oldname = clean_filename($oldname); if (file_exists($basedir.$wdir."/".$name)) { echo "Error: $name already exists!"; - } else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { + } else if (!@rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) { echo "Error: could not rename $oldname to $name"; } displaydir($wdir); @@ -336,7 +329,7 @@ echo " \n"; echo " \n"; echo " sesskey\" />\n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "\n"; @@ -718,14 +711,13 @@ function displaydir ($wdir) { $count++; $filename = $fullpath."/".$dir; - $fileurl = rawurlencode($wdir."/".$dir); - $filesafe = rawurlencode($dir); + $fileurl = $wdir."/".$dir; $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); echo ""; if ($usecheckboxes) { - print_cell("center", ""); + print_cell("center", ""); } print_cell("left", "pixpath/f/folder.gif\" class=\"icon\" alt=\"".get_string('folder')."\" /> ".htmlspecialchars($dir).""); print_cell("right", " "); @@ -746,8 +738,6 @@ function displaydir ($wdir) { $count++; $filename = $fullpath."/".$file; $fileurl = "$wdir/$file"; - $filesafe = rawurlencode($file); - $fileurlsafe = rawurlencode($fileurl); $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p"); $dimensions = get_image_size($filename); @@ -762,7 +752,7 @@ function displaydir ($wdir) { echo "\n"; if ($usecheckboxes) { - print_cell("center", ""); + print_cell("center", ""); } echo ""; if ($CFG->slasharguments) { diff --git a/lib/editor/htmlarea/htmlarea.php b/lib/editor/htmlarea/htmlarea.php index d0f2247798..1ec349e8f8 100644 --- a/lib/editor/htmlarea/htmlarea.php +++ b/lib/editor/htmlarea/htmlarea.php @@ -2,8 +2,10 @@ include("../../../config.php"); require_once($CFG->dirroot.'/lib/languages.php'); - $id = optional_param('id', 0, PARAM_INT); - $httpsrequired = optional_param('httpsrequired', 0, PARAM_BOOL);//flag indicating editor on page with required https + $id = optional_param('id', SITEID, PARAM_INT); + $httpsrequired = optional_param('httpsrequired', 0, PARAM_BOOL); //flag indicating editor on page with required https + + require_course_login($id); $lastmodified = filemtime("htmlarea.php"); $lifetime = 1800; @@ -1650,7 +1652,7 @@ HTMLArea.prototype._insertTable = function() { var sel = this._getSelection(); var range = this._createRange(sel); var editor = this; // for nested functions - this._popupDialog("insert_table.php", function(param) { + this._popupDialog("insert_table.php?id=", function(param) { if (!param) { // user must have pressed Cancel return false; } @@ -1709,7 +1711,7 @@ HTMLArea.prototype._insertSmile = function() { var sel = this._getSelection(); var range = this._createRange(sel); var editor = this; // for nested functions - this._popupDialog("dlg_ins_smile.php", function(imgString) { + this._popupDialog("dlg_ins_smile.php?id=", function(imgString) { if(!imgString) { return false; } @@ -1726,7 +1728,7 @@ HTMLArea.prototype._insertChar = function() { var sel = this._getSelection(); var range = this._createRange(sel); var editor = this; // for nested functions - this._popupDialog("dlg_ins_char.php", function(sChar) { + this._popupDialog("dlg_ins_char.php?id=", function(sChar) { if(!sChar) { return false; } @@ -1758,7 +1760,7 @@ HTMLArea.prototype._createanchor = function () { alert(""); return false; } - this._popupDialog("createanchor.php", function(objAn) { + this._popupDialog("createanchor.php?id=", function(objAn) { if(!objAn) { return false; } @@ -1816,7 +1818,7 @@ HTMLArea.prototype._searchReplace = function() { }; //Call Search And Replace popup window - editor._popupDialog( "searchandreplace.php", function( entity ) { + editor._popupDialog( "searchandreplace.php?id=", function( entity ) { if ( !entity ) { //user must have pressed Cancel return false; @@ -1997,7 +1999,7 @@ HTMLArea.prototype.execCommand = function(cmdID, UI, param) { case "hilitecolor": (HTMLArea.is_ie) && (cmdID = "backcolor"); case "forecolor": - this._popupDialog("select_color.php", function(color) { + this._popupDialog("select_color.php?id=", function(color) { if (color) { // selection not canceled editor._doc.execCommand(cmdID, false, "#" + color); } diff --git a/lib/editor/htmlarea/popups/createanchor.php b/lib/editor/htmlarea/popups/createanchor.php index 5220572029..0aa34ee0b1 100644 --- a/lib/editor/htmlarea/popups/createanchor.php +++ b/lib/editor/htmlarea/popups/createanchor.php @@ -1,5 +1,10 @@ diff --git a/lib/editor/htmlarea/popups/dlg_ins_char.php b/lib/editor/htmlarea/popups/dlg_ins_char.php index ea5b0bda3d..e59e57037c 100644 --- a/lib/editor/htmlarea/popups/dlg_ins_char.php +++ b/lib/editor/htmlarea/popups/dlg_ins_char.php @@ -45,7 +45,12 @@ ################################################################################ --> diff --git a/lib/editor/htmlarea/popups/dlg_ins_smile.php b/lib/editor/htmlarea/popups/dlg_ins_smile.php index 0ced0282ab..0f5657dc25 100644 --- a/lib/editor/htmlarea/popups/dlg_ins_smile.php +++ b/lib/editor/htmlarea/popups/dlg_ins_smile.php @@ -6,7 +6,13 @@ ## ################################################################################# - include('../../../../config.php'); + require("../../../../config.php"); + + $id = optional_param('id', SITEID, PARAM_INT); + + require_course_login($id); + @header('Content-Type: text/html; charset=utf-8'); + $pixpath = "$CFG->pixpath/s"; $fullnames = get_list_of_pixnames(); diff --git a/lib/editor/htmlarea/popups/fullscreen.php b/lib/editor/htmlarea/popups/fullscreen.php index 2f5a39d6cb..a85fb9bfc5 100644 --- a/lib/editor/htmlarea/popups/fullscreen.php +++ b/lib/editor/htmlarea/popups/fullscreen.php @@ -1,11 +1,10 @@ <?php print_string("fullscreen","editor");?> diff --git a/lib/editor/htmlarea/popups/insert_image.php b/lib/editor/htmlarea/popups/insert_image.php index 89d478734c..3a3c4c3476 100644 --- a/lib/editor/htmlarea/popups/insert_image.php +++ b/lib/editor/htmlarea/popups/insert_image.php @@ -1,12 +1,13 @@ fullname = ""; // Just to keep display happy, though browsing may fail - } + require_login($id); + require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)); + + @header('Content-Type: text/html; charset=utf-8'); $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); @@ -35,7 +36,7 @@ function Init() { document.getElementById("f_horiz").value = param["f_horiz"] != -1 ? param["f_horiz"] : 0; document.getElementById("f_width").value = param["f_width"]; document.getElementById("f_height").value = param["f_height"]; - window.ipreview.location.replace('preview.php?id='+ id);?> +'&imageurl='+ param.f_url); + window.ipreview.location.replace('preview.php?id='+ +'&imageurl='+ param.f_url); } document.getElementById("f_url").focus(); }; @@ -262,13 +263,10 @@ form { margin-bottom: 0px; margin-top: 0px; } - @@ -313,10 +311,9 @@ form { margin-bottom: 0px; margin-top: 0px; } - +
"; - echo ""; - } else { - print "
"; - }?> + echo ""; + ?>
:
@@ -287,10 +285,10 @@ form { margin-bottom: 0px; margin-top: 0px; } " onclick="return submit_form('move');" />
" onclick="return submit_form('zip');" />
- +
+ - + " />
+
- + @@ -324,20 +321,16 @@ form { margin-bottom: 0px; margin-top: 0px; } " onclick="return checkvalue('foldername','cfolder');" />
-
+ - + " />
- -

 

diff --git a/lib/editor/htmlarea/popups/insert_image_std.php b/lib/editor/htmlarea/popups/insert_image_std.php index cbdb26359f..6f12d9cc63 100644 --- a/lib/editor/htmlarea/popups/insert_image_std.php +++ b/lib/editor/htmlarea/popups/insert_image_std.php @@ -1,13 +1,10 @@ fullname = ""; // Just to keep display happy, though browsing may fail - } + $id = optional_param('id', SITEID, PARAM_INT); + require_course_login($id); + @header('Content-Type: text/html; charset=utf-8'); ?> diff --git a/lib/editor/htmlarea/popups/insert_table.php b/lib/editor/htmlarea/popups/insert_table.php index 1dfa446c47..1055855476 100644 --- a/lib/editor/htmlarea/popups/insert_table.php +++ b/lib/editor/htmlarea/popups/insert_table.php @@ -1,5 +1,10 @@ diff --git a/lib/editor/htmlarea/popups/link.php b/lib/editor/htmlarea/popups/link.php index 38e245b668..fd9b451520 100644 --- a/lib/editor/htmlarea/popups/link.php +++ b/lib/editor/htmlarea/popups/link.php @@ -1,11 +1,10 @@ fullname = ""; // Just to keep display happy, though browsing may fail - } + require_course_login($id); + @header('Content-Type: text/html; charset=utf-8'); ?> @@ -89,7 +88,7 @@ form { margin-bottom: 1px; margin-top: 1px; }
id."\" width=\"420\" height=\"180\">": + "": ""; ?>

@@ -109,7 +108,7 @@ form { margin-bottom: 1px; margin-top: 1px; }
" onclick="return submit_form('zip');" />
- + @@ -128,16 +127,16 @@ form { margin-bottom: 1px; margin-top: 1px; } - + " onclick="return checkvalue('foldername','cfolder');" />
-
+ - + diff --git a/lib/editor/htmlarea/popups/link_std.php b/lib/editor/htmlarea/popups/link_std.php index 310d5d7f9e..f3f354ad7e 100644 --- a/lib/editor/htmlarea/popups/link_std.php +++ b/lib/editor/htmlarea/popups/link_std.php @@ -1,12 +1,10 @@ diff --git a/lib/editor/htmlarea/popups/preview.php b/lib/editor/htmlarea/popups/preview.php index f4e02e1521..204302ed10 100644 --- a/lib/editor/htmlarea/popups/preview.php +++ b/lib/editor/htmlarea/popups/preview.php @@ -1,16 +1,15 @@ id); - require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $course->id)); $imagetag = clean_text(''); @@ -19,7 +18,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -Preview +<?php echo get_string('preview') ?> diff --git a/lib/editor/htmlarea/popups/searchandreplace.php b/lib/editor/htmlarea/popups/searchandreplace.php index 05492b515e..0b3e817786 100644 --- a/lib/editor/htmlarea/popups/searchandreplace.php +++ b/lib/editor/htmlarea/popups/searchandreplace.php @@ -1,5 +1,10 @@ diff --git a/lib/editor/htmlarea/popups/select_color.php b/lib/editor/htmlarea/popups/select_color.php index a364f263b9..8ec7f7c12a 100644 --- a/lib/editor/htmlarea/popups/select_color.php +++ b/lib/editor/htmlarea/popups/select_color.php @@ -1,5 +1,10 @@