diff --git a/.gitattributes b/.gitattributes
index efebe1ff..b982f2e8 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -70,6 +70,7 @@ bureau/admin/adm_dosu.php -text
bureau/admin/adm_edit.php -text
bureau/admin/adm_email.php -text
bureau/admin/adm_list.php -text
+bureau/admin/adm_lockpanel.php -text
bureau/admin/adm_login.php -text
bureau/admin/adm_mxaccount.php -text
bureau/admin/adm_panel.php -text
diff --git a/bureau/admin/adm_lockpanel.php b/bureau/admin/adm_lockpanel.php
new file mode 100644
index 00000000..8f0d0571
--- /dev/null
+++ b/bureau/admin/adm_lockpanel.php
@@ -0,0 +1,56 @@
+enabled || $cuid!=2000) {
+ __("This page is restricted to authorized staff");
+ die();
+}
+
+$fields = array (
+ "action" =>array ("get","string",""),
+);
+
+getFields($fields);
+
+switch ($action) {
+ case "lock":
+ panel_lock();
+ break;
+ case "unlock":
+ panel_unlock();
+ break;
+ default:
+ die('Wrong action');
+}
+
+Header('Location: /adm_panel.php');
+
+?>
diff --git a/bureau/admin/adm_panel.php b/bureau/admin/adm_panel.php
index 2f6c13d3..453da78f 100644
--- a/bureau/admin/adm_panel.php
+++ b/bureau/admin/adm_panel.php
@@ -89,4 +89,14 @@ closedir($d);
?>
+
+
+
+
+
+
+
+
+
+
diff --git a/bureau/admin/head.php b/bureau/admin/head.php
index c1ef7e03..a56cbae3 100644
--- a/bureau/admin/head.php
+++ b/bureau/admin/head.php
@@ -60,6 +60,11 @@ if ($isinvited && isset($oldid) && !empty($oldid) && $oldid!=$cuid ) {
if ($oldid == 2000) echo ' '._("You can also apply changes."); // Yes, hardcoded uid. We will rewrite permissions another day
echo "";
}
+if ( panel_islocked() ) {
+ echo "";
+ __("Panel is locked! No one can login!");
+ echo "
";
+}
?>
diff --git a/bureau/class/config.php b/bureau/class/config.php
index a5dd6b9a..7a0dcb70 100644
--- a/bureau/class/config.php
+++ b/bureau/class/config.php
@@ -103,6 +103,7 @@ define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
define('ALTERNC_PANEL', "/usr/share/alternc/panel");
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock');
+define('ALTERNC_LOCK_PANEL', '/var/lib/alternc/panel/nologin.lock');
/* PHPLIB inclusions : */
$root=ALTERNC_PANEL."/";
diff --git a/bureau/class/functions.php b/bureau/class/functions.php
index a9495f4f..59f95a3e 100644
--- a/bureau/class/functions.php
+++ b/bureau/class/functions.php
@@ -750,4 +750,21 @@ function PercentToColor($p=0) {
return $color;
}
+
+function panel_lock() {
+ global $err,$mem,$cuid;
+ if ($cuid!=2000) return false;
+ return touch(ALTERNC_LOCK_PANEL);
+}
+
+function panel_unlock() {
+ global $err,$mem,$cuid;
+ if ($cuid!=2000) return false;
+ return unlink(ALTERNC_LOCK_PANEL);
+}
+
+function panel_islocked() {
+ return file_exists(ALTERNC_LOCK_PANEL);
+}
+
?>
diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php
index 7bd0d283..aeb2b276 100644
--- a/bureau/class/m_admin.php
+++ b/bureau/class/m_admin.php
@@ -44,6 +44,8 @@ class m_admin {
*/
public $tldmode=array();
+ var $archive='';
+
/* ----------------------------------------------------------------- */
/** Constructor
@@ -62,7 +64,7 @@ class m_admin {
4 => _("Domain can be installed, no check at all"),
5 => _("Domain can be installed, force NO DNS hosting"),
);
- $archive=variable_get('archive_del_data','','If folder specified html folder of deleted user is archived, else it is deleted. ');
+ $this->archive=variable_get('archive_del_data','','If folder specified html folder of deleted user is archived, else it is deleted. ');
}
function hook_menu() {
@@ -361,7 +363,6 @@ class m_admin {
return $creators;
}
-
/* ----------------------------------------------------------------- */
/** Check if I am the creator of the member $uid
* @param integer $uid a unique integer identifying the account
diff --git a/bureau/class/m_mem.php b/bureau/class/m_mem.php
index 71adce52..32181367 100644
--- a/bureau/class/m_mem.php
+++ b/bureau/class/m_mem.php
@@ -86,7 +86,7 @@ class m_mem {
* @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured.
*/
function login($username,$password,$restrictip=0,$authip_token=false) {
- global $db,$err,$cuid, $authip;
+ global $db,$err,$cuid,$authip,$admin;
$err->log("mem","login",$username);
// $username=addslashes($username);
// $password=addslashes($password);
@@ -108,6 +108,11 @@ class m_mem {
$this->user=$db->Record;
$cuid=$db->f("uid");
+ if (panel_islocked() && $cuid != 2000) {
+ $err->raise("mem",_("This website is currently under maintenance, login is currently disabled."));
+ return false;
+ }
+
// AuthIP
$allowed_ip=false;
if ( $authip_token ) $allowed_ip = $this->authip_tokencheck($authip_token);
@@ -261,6 +266,12 @@ class m_mem {
}
}
$cuid=$db->f("uid");
+
+ if (panel_islocked() && $cuid != 2000) {
+ $err->raise("mem",_("This website is currently under maintenance, login is currently disabled."));
+ return false;
+ }
+
$db->query("select * from membres where uid='$cuid';");
$db->next_record();
$this->user=$db->Record;
diff --git a/debian/alternc.dirs b/debian/alternc.dirs
index 05c32bf4..41336d9e 100644
--- a/debian/alternc.dirs
+++ b/debian/alternc.dirs
@@ -24,4 +24,5 @@ var/lib/alternc/backups
var/lib/alternc/apache-vhost
var/lib/alternc/bind
var/lib/alternc/bind/zones
+var/lib/alternc/panel
var/log/alternc
diff --git a/debian/alternc.postinst b/debian/alternc.postinst
index a7a81f81..44990296 100644
--- a/debian/alternc.postinst
+++ b/debian/alternc.postinst
@@ -63,6 +63,8 @@ case "$1" in
chmod g+rxw "$VMAIL_HOME"
chmod g+rxw "$VMAIL_HOME"/* 2>/dev/null || true # It may be empty
+ chown alterncpanel.alterncpanel "/var/lib/alternc/panel"
+
# build local.sh if it does not exist
if [ ! -f $CONFIGFILE ]; then
cat > $CONFIGFILE <