/// print header /// @param string $title Appears at the top of the window /// @param string $heading Appears at the top of the page print_header($CFG->sitename, $CFG->sitename); /// print page content header print_container_start(true, 'content-header', 'content-header'); corner_left_top(); corner_left_bottom(); corner_right_top(); corner_right_bottom(); echo "{$messagetext}"; echo '<div class="contenttoright">' . get_string('loginas', '', $USER->firstname) . ' (<a href="logout.php" title="' . get_string('logout') . '">' . get_string('logout') . '</a>)</div>'; print_container_end(); /// print content print_container_start(true, 'content-body', 'content-body'); corner_left_top(); corner_left_bottom(); corner_right_top(); corner_right_bottom(); echo "<br><form method=\"post\">"; /// sitename echo "<label for=\"sitename\">" . get_string("sitename") . ":</label><div class='formcontenttoright'><input type=\"text\" name=\"sitename\" size=\"55\" value=\"" . $CFG->sitename . "\" /><br>\r\n " . get_string('sitenameinfo') . "</div><br><br>"; ///lang echo "<label for=\"lang\">" . get_string("lang") . ":</label><div class='formcontenttoright'><select name=\"lang\" /><option value=\"en_utf8\""; if ($CFG->lang == "en_utf8") { echo " selected"; } echo ">" . get_string('en') . "</option><option value=\"ca_utf8\""; if ($CFG->lang == "ca_utf8") { echo " selected"; }
/** * Redirects the user to another page, after printing a notice * * @param string $url The url to take the user to * @param string $message The text message to display to the user about the redirect, if any * @param string $delay How long before refreshing to the new page at $url? * @todo '&' needs to be encoded into '&' for XHTML compliance, * however, this is not true for javascript. Therefore we * first decode all entities in $url (since we cannot rely on) * the correct input) and then encode for where it's needed * echo "<script type='text/javascript'>alert('Redirect $url');</script>"; */ function redirect($url, $message = '', $delay = -1) { global $CFG, $THEME; if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) { $url = sid_process_url($url); } $message = clean_text($message); $encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url); $encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />')); $url = str_replace('&', '&', $encodedurl); /// At developer debug level. Don't redirect if errors have been printed on screen. /// Currenly only works in PHP 5.2+; we do not want strict PHP5 errors $lasterror = error_get_last(); $error = defined('DEBUGGING_PRINTED') or !empty($lasterror) && $lasterror['type'] & DEBUG_DEVELOPER; $errorprinted = debugging('', DEBUG_ALL) && $CFG->debugdisplay && $error; if ($errorprinted) { $message = "<strong>Error output, so disabling automatic redirect.</strong></p><p>" . $message; } $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { $perf = get_performance_info(); error_log("PERF: " . $perf['txt']); } } /// when no message and header printed yet, try to redirect if (empty($message) and !defined('HEADER_PRINTED')) { // Technically, HTTP/1.1 requires Location: header to contain // the absolute path. (In practice browsers accept relative // paths - but still, might as well do it properly.) // This code turns relative into absolute. if (!preg_match('|^[a-z]+:|', $url)) { // Get host name http://www.wherever.com $hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot); if (preg_match('|^/|', $url)) { // URLs beginning with / are relative to web server root so we just add them in $url = $hostpart . $url; } else { // URLs not beginning with / are relative to path of current script, so add that on. $url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url; } // Replace all ..s while (true) { $newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url); if ($newurl == $url) { break; } $url = $newurl; } } $delay = 0; //try header redirection first @header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other'); //302 might not work for POST requests, 303 is ignored by obsolete clients @header('Location: ' . $url); //another way for older browsers and already sent headers (eg trailing whitespace in config.php) echo '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'; echo '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . "location.replace('" . addslashes_js($url) . "');" . "\n" . '//]]>' . "\n" . '</script>'; // To cope with Mozilla bug die; } if ($delay == -1) { $delay = 3; // if no delay specified wait 3 seconds } if (!defined('HEADER_PRINTED')) { // this type of redirect might not be working in some browsers - such as lynx :-( // IECISA *********** MODIFIED -> to put out sitename //print_header('', '', '', '', $errorprinted ? '' : ('<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />')); print_header($CFG->sitename, $CFG->sitename, '', '', $errorprinted ? '' : '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'); // ********* END $delay += 3; // double redirect prevention, it was sometimes breaking upgrades before 1.7 } else { print_container_end_all(false, $THEME->open_header_containers); } //IECISA ********** ADDED -> to have the save html aspect than the other pages /// print page content print_container_start(true, 'content-body', 'content-body'); corner_left_top(); corner_left_bottom(); corner_right_top(); corner_right_bottom(); // ********** END echo '<div id="redirect">'; echo '<div id="message">' . $message . '</div>'; echo '<div id="continue">( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>'; echo '</div>'; //IECISA ********** ADDED -> to have the save html aspect than the other pages print_container_end(); // *********** END if (!$errorprinted) { ?> <script type="text/javascript"> //<![CDATA[ function redirect() { document.location.replace('<?php echo addslashes_js($url); ?> '); } setTimeout("redirect()", <?php echo $delay * 1000; ?> ); //]]> </script> <?php } $CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page. print_footer('none'); die; }