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_heading(get_string('sitemaintenancemode', 'admin'));
40 /// Print the appropriate form
42 if (file_exists($filename)) { // We are in maintenance mode
43 echo '<div class="buttons">';
44 echo '<p>'.get_string('sitemaintenanceon', 'admin').'</p>';
45 echo '<form action="maintenance.php" method="post">';
47 echo '<input type="hidden" name="action" value="disable" />';
48 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
49 echo '<p><input type="submit" value="'.get_string('disable').'" /></p>';
53 } else { // We are not in maintenance mode
54 $usehtmleditor = can_use_html_editor();
56 echo '<div class="buttons">';
57 echo '<form action="maintenance.php" method="post">';
59 echo '<input type="hidden" name="action" value="enable" />';
60 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
61 echo '<p><input type="submit" value="'.get_string('enable').'" /></p>';
62 echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
63 echo '<div class="editor" style="width:600px;">'; // contains the editor
64 print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
77 admin_externalpage_print_footer();