2005-02-10 05:11:34 +00:00
|
|
|
<?php // $Id$
|
|
|
|
// Enables/disables maintenance mode
|
|
|
|
|
|
|
|
require('../config.php');
|
2006-09-02 13:14:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2005-02-10 05:11:34 +00:00
|
|
|
|
|
|
|
$action = optional_param('action', '', PARAM_ALPHA);
|
|
|
|
|
2006-09-02 13:14:57 +00:00
|
|
|
$adminroot = admin_get_root();
|
2006-09-03 15:21:46 +00:00
|
|
|
admin_externalpage_setup('maintenancemode', $adminroot);
|
2005-02-10 05:11:34 +00:00
|
|
|
|
2005-02-24 00:01:52 +00:00
|
|
|
//Check folder exists
|
|
|
|
if (! make_upload_directory(SITEID)) { // Site folder
|
|
|
|
error("Could not create site folder. The site administrator needs to fix the file permissions");
|
|
|
|
}
|
|
|
|
|
2005-05-11 08:57:14 +00:00
|
|
|
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
|
2005-02-10 05:11:34 +00:00
|
|
|
|
|
|
|
if ($form = data_submitted()) {
|
|
|
|
if (confirm_sesskey()) {
|
|
|
|
if ($form->action == "disable") {
|
|
|
|
unlink($filename);
|
2006-08-18 07:25:17 +00:00
|
|
|
redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
|
2005-02-10 05:11:34 +00:00
|
|
|
} else {
|
|
|
|
$file = fopen($filename, 'w');
|
2005-04-23 07:49:29 +00:00
|
|
|
fwrite($file, stripslashes($form->text));
|
2005-02-10 05:11:34 +00:00
|
|
|
fclose($file);
|
2006-08-18 07:25:17 +00:00
|
|
|
redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
|
2005-02-10 05:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print the header stuff
|
|
|
|
|
2006-09-02 13:14:57 +00:00
|
|
|
admin_externalpage_print_header($adminroot);
|
2005-02-10 05:11:34 +00:00
|
|
|
|
|
|
|
/// Print the appropriate form
|
|
|
|
|
|
|
|
if (file_exists($filename)) { // We are in maintenance mode
|
|
|
|
echo '<center>';
|
|
|
|
echo '<form action="maintenance.php" method="post">';
|
|
|
|
echo '<input type="hidden" name="action" value="disable">';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
|
|
|
echo '<p><input type="submit" value="'.get_string('disable').'"></p>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</center>';
|
|
|
|
} else { // We are not in maintenance mode
|
|
|
|
$usehtmleditor = can_use_html_editor();
|
|
|
|
|
|
|
|
echo '<center>';
|
|
|
|
echo '<form action="maintenance.php" method="post">';
|
|
|
|
echo '<input type="hidden" name="action" value="enable">';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
|
|
|
|
echo '<p><input type="submit" value="'.get_string('enable').'"></p>';
|
|
|
|
echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
|
|
|
|
echo '<table><tr><td>';
|
|
|
|
print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
|
|
|
|
echo '</td></tr></table>';
|
|
|
|
echo '</form>';
|
|
|
|
echo '</center>';
|
|
|
|
|
|
|
|
if ($usehtmleditor) {
|
|
|
|
use_html_editor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-02 13:14:57 +00:00
|
|
|
admin_externalpage_print_footer($adminroot);
|
2005-02-10 05:11:34 +00:00
|
|
|
?>
|