2 // Enables/disables maintenance mode
4 require('../config.php');
5 require_once($CFG->libdir
.'/adminlib.php');
7 $action = optional_param('action', '', PARAM_ALPHA
);
9 admin_externalpage_setup('maintenancemode');
12 if (! make_upload_directory(SITEID
)) { // Site folder
13 error("Could not create site folder. The site administrator needs to fix the file permissions");
16 $filename = $CFG->dataroot
.'/'.SITEID
.'/maintenance.html';
18 if ($form = data_submitted()) {
19 if (confirm_sesskey()) {
20 if ($form->action
== "disable") {
22 redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
24 $file = fopen($filename, 'w');
25 fwrite($file, stripslashes($form->text
));
27 redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
32 /// Print the header stuff
34 admin_externalpage_print_header();
36 /// Print the appropriate form
38 if (file_exists($filename)) { // We are in maintenance mode
39 echo '<div style="margin-left:auto;margin-right:auto">';
40 echo '<form action="maintenance.php" method="post">';
41 echo '<input type="hidden" name="action" value="disable" />';
42 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
43 echo '<p><input type="submit" value="'.get_string('disable').'" /></p>';
46 } else { // We are not in maintenance mode
47 $usehtmleditor = can_use_html_editor();
49 echo '<div style="text-align:center;margin-left:auto;margin-right:auto">';
50 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>';
68 admin_externalpage_print_footer();