Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / maintenance.php
blobaecd668f836cc89b6e571d97ef251e40a10d1c9d
1 <?php // $Id$
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');
11 //Check folder exists
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") {
21 unlink($filename);
22 redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
23 } else {
24 $file = fopen($filename, 'w');
25 fwrite($file, stripslashes($form->text));
26 fclose($file);
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>';
44 echo '</form>';
45 echo '</div>';
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">';
51 echo '<div>';
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>';
59 echo '</div>';
60 echo '</form>';
61 echo '</div>';
63 if ($usehtmleditor) {
64 use_html_editor();
68 admin_externalpage_print_footer();