2 // Enables/disables maintenance mode
4 require('../config.php');
5 require_once($CFG->libdir
.'/adminlib.php');
7 $action = optional_param('action', '', PARAM_ALPHA
);
9 $adminroot = admin_get_root();
10 admin_externalpage_setup('maintenancemode', $adminroot);
13 if (! make_upload_directory(SITEID
)) { // Site folder
14 error("Could not create site folder. The site administrator needs to fix the file permissions");
17 $filename = $CFG->dataroot
.'/'.SITEID
.'/maintenance.html';
19 if ($form = data_submitted()) {
20 if (confirm_sesskey()) {
21 if ($form->action
== "disable") {
23 redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
25 $file = fopen($filename, 'w');
26 fwrite($file, stripslashes($form->text
));
28 redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
33 /// Print the header stuff
35 admin_externalpage_print_header($adminroot);
37 /// Print the appropriate form
39 if (file_exists($filename)) { // We are in maintenance mode
41 echo '<form action="maintenance.php" method="post">';
42 echo '<input type="hidden" name="action" value="disable">';
43 echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
44 echo '<p><input type="submit" value="'.get_string('disable').'"></p>';
47 } else { // We are not in maintenance mode
48 $usehtmleditor = can_use_html_editor();
51 echo '<form action="maintenance.php" method="post">';
52 echo '<input type="hidden" name="action" value="enable">';
53 echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
54 echo '<p><input type="submit" value="'.get_string('enable').'"></p>';
55 echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
56 echo '<table><tr><td>';
57 print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
58 echo '</td></tr></table>';
67 admin_externalpage_print_footer($adminroot);