Maintenant on peux désactiver le login pour tout le monde SAUF l'admin.

Pratique lors des mise à jour.
This commit is contained in:
Alan Garcia 2013-09-12 13:17:04 +00:00
parent 0e8aab8e35
commit ed34d3bc3c
10 changed files with 108 additions and 3 deletions

1
.gitattributes vendored
View File

@ -70,6 +70,7 @@ bureau/admin/adm_dosu.php -text
bureau/admin/adm_edit.php -text bureau/admin/adm_edit.php -text
bureau/admin/adm_email.php -text bureau/admin/adm_email.php -text
bureau/admin/adm_list.php -text bureau/admin/adm_list.php -text
bureau/admin/adm_lockpanel.php -text
bureau/admin/adm_login.php -text bureau/admin/adm_login.php -text
bureau/admin/adm_mxaccount.php -text bureau/admin/adm_mxaccount.php -text
bureau/admin/adm_panel.php -text bureau/admin/adm_panel.php -text

View File

@ -0,0 +1,56 @@
<?php
/*
$Id: adm_tld.php,v 1.4 2004/11/29 17:27:04 anonymous Exp $
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2002 by the AlternC Development Team.
http://alternc.org/
----------------------------------------------------------------------
Based on:
Valentin Lacambre's web hosting softwares: http://altern.org/
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file: Alan Garcia
Purpose of file: Manage domain types on the server
----------------------------------------------------------------------
*/
require_once("../class/config.php");
if (!$admin->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');
?>

View File

@ -89,4 +89,14 @@ closedir($d);
?> ?>
</ul> </ul>
<?php if ($cuid == 2000) { ?>
<p class="error">
<?php if (panel_islocked()) { ?>
<a href="adm_lockpanel.php?action=unlock"><?php __("Click here to unlock the panel and allow user to login.");?></a>
<?php } else { ?>
<a href="adm_lockpanel.php?action=lock" onClick='return confirm("<?php echo addslashes(_("Are you sure you want to kick everyone?"));?>");' ><?php __("Click here to lock the panel and force logout of all the user.");?></a>
<?php } ?>
</p>
<?php } //cuid 2000 ?>
<?php include_once("foot.php"); ?> <?php include_once("foot.php"); ?>

View File

@ -60,6 +60,11 @@ if ($isinvited && isset($oldid) && !empty($oldid) && $oldid!=$cuid ) {
if ($oldid == 2000) echo ' '._("You can also <a href='adm_update_domains.php'>apply changes</a>."); // Yes, hardcoded uid. We will rewrite permissions another day if ($oldid == 2000) echo ' '._("You can also <a href='adm_update_domains.php'>apply changes</a>."); // Yes, hardcoded uid. We will rewrite permissions another day
echo "</p></div>"; echo "</p></div>";
} }
if ( panel_islocked() ) {
echo "<div align=center><p class='error'>";
__("Panel is locked! No one can login!");
echo "</p></div>";
}
?> ?>
<div id="global" class="clearfix"> <div id="global" class="clearfix">
<div id="menu"><?php include_once("menu.php"); ?></div> <div id="menu"><?php include_once("menu.php"); ?></div>

View File

@ -103,6 +103,7 @@ define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
define('ALTERNC_PANEL', "/usr/share/alternc/panel"); define('ALTERNC_PANEL', "/usr/share/alternc/panel");
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales"); define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock'); define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock');
define('ALTERNC_LOCK_PANEL', '/var/lib/alternc/panel/nologin.lock');
/* PHPLIB inclusions : */ /* PHPLIB inclusions : */
$root=ALTERNC_PANEL."/"; $root=ALTERNC_PANEL."/";

View File

@ -750,4 +750,21 @@ function PercentToColor($p=0) {
return $color; 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);
}
?> ?>

View File

@ -44,6 +44,8 @@ class m_admin {
*/ */
public $tldmode=array(); public $tldmode=array();
var $archive='';
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Constructor /** Constructor
@ -62,7 +64,7 @@ class m_admin {
4 => _("Domain can be installed, no check at all"), 4 => _("Domain can be installed, no check at all"),
5 => _("Domain can be installed, force NO DNS hosting"), 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() { function hook_menu() {
@ -361,7 +363,6 @@ class m_admin {
return $creators; return $creators;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Check if I am the creator of the member $uid /** Check if I am the creator of the member $uid
* @param integer $uid a unique integer identifying the account * @param integer $uid a unique integer identifying the account

View File

@ -86,7 +86,7 @@ class m_mem {
* @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured. * @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) { 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); $err->log("mem","login",$username);
// $username=addslashes($username); // $username=addslashes($username);
// $password=addslashes($password); // $password=addslashes($password);
@ -108,6 +108,11 @@ class m_mem {
$this->user=$db->Record; $this->user=$db->Record;
$cuid=$db->f("uid"); $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 // AuthIP
$allowed_ip=false; $allowed_ip=false;
if ( $authip_token ) $allowed_ip = $this->authip_tokencheck($authip_token); if ( $authip_token ) $allowed_ip = $this->authip_tokencheck($authip_token);
@ -261,6 +266,12 @@ class m_mem {
} }
} }
$cuid=$db->f("uid"); $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->query("select * from membres where uid='$cuid';");
$db->next_record(); $db->next_record();
$this->user=$db->Record; $this->user=$db->Record;

1
debian/alternc.dirs vendored
View File

@ -24,4 +24,5 @@ var/lib/alternc/backups
var/lib/alternc/apache-vhost var/lib/alternc/apache-vhost
var/lib/alternc/bind var/lib/alternc/bind
var/lib/alternc/bind/zones var/lib/alternc/bind/zones
var/lib/alternc/panel
var/log/alternc var/log/alternc

View File

@ -63,6 +63,8 @@ case "$1" in
chmod g+rxw "$VMAIL_HOME" chmod g+rxw "$VMAIL_HOME"
chmod g+rxw "$VMAIL_HOME"/* 2>/dev/null || true # It may be empty 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 # build local.sh if it does not exist
if [ ! -f $CONFIGFILE ]; then if [ ! -f $CONFIGFILE ]; then
cat > $CONFIGFILE <<EOF cat > $CONFIGFILE <<EOF