This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/contrib/downtime/main.php

43 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2009-08-20 22:37:17 +00:00
/*
* Name: Downtime
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Show a "down for maintenance" page
2009-08-20 22:37:17 +00:00
* Documentation:
* Once installed there will be some more options on the config page --
* Ticking "disable non-admin access" will mean that regular and anonymous
* users will be blocked from accessing the site, only able to view the
* message specified in the box.
*/
class Downtime extends Extension {
public function get_priority() {return 10;}
2012-01-30 02:24:17 +00:00
public function onSetupBuilding($event) {
$sb = new SetupBlock("Downtime");
$sb->add_bool_option("downtime", "Disable non-admin access: ");
$sb->add_longtext_option("downtime_message", "<br>");
$event->panel->add_block($sb);
}
2012-01-30 02:24:17 +00:00
public function onPageRequest($event) {
global $config, $page, $user;
2012-01-30 02:24:17 +00:00
if($config->get_bool("downtime")) {
if(!$user->is_admin() && !$this->is_safe_page($event)) {
$msg = $config->get_string("downtime_message");
$this->theme->display_message($msg);
exit;
}
2012-01-30 02:24:17 +00:00
$this->theme->display_notification($page);
}
}
2009-01-04 16:30:46 +00:00
private function is_safe_page(PageRequestEvent $event) {
if($event->page_matches("user_admin/login")) return true;
else return false;
}
}
?>