Fix a possible race condition in the PaintWeb DML code.
[moodle/mihaisucan.git] / admin / maintenance.php
blobe9ac09ef122fb263b4a822912c92a3fcb3064784
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_heading(get_string('sitemaintenancemode', 'admin'));
38 print_box_start();
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">';
46 echo '<div>';
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>';
50 echo '</div>';
51 echo '</form>';
52 echo '</div>';
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">';
58 echo '<div>';
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");
65 echo '</div>';
66 echo '</div>';
67 echo '</form>';
68 echo '</div>';
70 if ($usehtmleditor) {
71 use_html_editor();
75 print_box_end();
77 admin_externalpage_print_footer();