MDL-63403 filterlib: Fix lots of coding style
[moodle.git] / error / index.php
blob2e3280d70e42c282d9d629828704d24512b27741
1 <?php
3 require('../config.php');
4 require_once($CFG->libdir.'/eventslib.php');
6 // Form submitted, do not check referer (original page unknown).
7 if ($form = data_submitted()) {
8 // Only deal with real users.
9 if (!isloggedin()) {
10 redirect($CFG->wwwroot);
13 // Send the message and redirect.
14 $eventdata = new \core\message\message();
15 $eventdata->courseid = SITEID;
16 $eventdata->component = 'moodle';
17 $eventdata->name = 'errors';
18 $eventdata->userfrom = $USER;
19 $eventdata->userto = core_user::get_support_user();
20 $eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested;
21 $eventdata->fullmessage = $form->text;
22 $eventdata->fullmessageformat = FORMAT_PLAIN;
23 $eventdata->fullmessagehtml = '';
24 $eventdata->smallmessage = '';
25 message_send($eventdata);
27 redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
28 exit;
31 $site = get_site();
32 $redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL'];
33 $httpreferer = get_local_referer(false);
34 $requesturi = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
36 header("HTTP/1.0 404 Not Found");
37 header("Status: 404 Not Found");
39 $PAGE->set_url('/error/');
40 $PAGE->set_context(context_system::instance());
41 $PAGE->set_title($site->fullname .':Error');
42 $PAGE->set_heading($site->fullname .': Error 404');
43 $PAGE->navbar->add('Error 404 - File not Found');
44 echo $OUTPUT->header();
45 echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
47 if (isloggedin()) {
49 <p><?php echo get_string('pleasereport', 'error'); ?>
50 <p><form action="<?php echo $CFG->wwwroot ?>/error/index.php" method="post">
51 <textarea rows="3" cols="50" name="text" id="text" spellcheck="true"></textarea><br />
52 <input type="hidden" name="referer" value="<?php p($httpreferer) ?>">
53 <input type="hidden" name="requested" value="<?php p($requesturi) ?>">
54 <input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?>">
55 </form>
56 <?php
57 } else {
58 echo $OUTPUT->continue_button($CFG->wwwroot);
60 echo $OUTPUT->footer();