Fix #1254
This commit is contained in:
parent
12a18d98cb
commit
61b9efbb39
|
@ -13,6 +13,7 @@ aide/sommaire.sgml -text
|
|||
aide/stats.sgml -text
|
||||
aide/test.sgml -text
|
||||
bureau/admin/adm_add.php -text
|
||||
bureau/admin/adm_authip_whitelist.php -text
|
||||
bureau/admin/adm_cancel.php -text
|
||||
bureau/admin/adm_deactivate.php -text
|
||||
bureau/admin/adm_defquotas.php -text
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
require_once("../class/config.php");
|
||||
include_once("head.php");
|
||||
|
||||
|
||||
$fields = array (
|
||||
"delete_id" => array ("get", "integer", ""),
|
||||
"id" => array ("post", "integer", 0),
|
||||
"ipsub" => array ("post", "string", ""),
|
||||
"infos" => array ("post", "string" ,""),
|
||||
"s_ipsub" => array ("post", "integer", ""),
|
||||
"s_protocol" => array ("post", "string", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
if (!empty($delete_id)) {
|
||||
if (! $authip->ip_delete($delete_id)) {
|
||||
$error="Error during deletion";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ipsub)) {
|
||||
if (! $authip->ip_save_whitelist($id, $ipsub, $infos)) {
|
||||
$error="Error during recording";
|
||||
}
|
||||
}
|
||||
|
||||
$list_ip = $authip->list_ip_whitelist();
|
||||
?>
|
||||
|
||||
<h3><?php __("Access security"); ?></h3>
|
||||
<hr id="topbar"/>
|
||||
<br />
|
||||
|
||||
<?php if ($error) { ?>
|
||||
<p class="error"><?php echo $error ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<p>
|
||||
<fieldset>
|
||||
<legend><?php __("Add an IP");?> - <a href="javascript:edit_ip('','<?php echo htmlentities($_SERVER['REMOTE_ADDR'])."','Home IP'";?>);" ><?php echo __("Add my current IP"); ?></a></legend>
|
||||
<span id="form_add_ip">
|
||||
<form method="post" action="adm_authip_whitelist.php" name="main" id="main">
|
||||
<p id="reset_edit_ip" style="display:none;"><a href="javascript:reset_edit_ip();"><?php __("Cancel edit")?></a></p>
|
||||
<input type="hidden" name="id" value="" id="edit_id" >
|
||||
<p>
|
||||
<?php __("Enter here the IP address you want. <br/> <i>IPv4, IPv6 and subnet allowed</i>"); ?> <br/>
|
||||
<input type="text" size=20 maxlength=39 name="ipsub" id="edit_ip" />
|
||||
</p>
|
||||
<p>
|
||||
<?php __("Add a comment");?><br/>
|
||||
<input type="text" size=25 maxlength=200 name="infos" id="edit_infos" />
|
||||
</p>
|
||||
<input type="submit" class="inb" value="<?php __("Save")?>" />
|
||||
</form>
|
||||
</span>
|
||||
</fieldset>
|
||||
|
||||
</p>
|
||||
<table>
|
||||
<tr><th><?php __("Type"); ?></th><th><?php __("IP"); ?></th><th><?php __("Informations"); ?></th><th colspan=2/></tr>
|
||||
<?php foreach($list_ip as $i) {
|
||||
if (checkip($i['ip'])) {
|
||||
if ($i['subnet']==32) {
|
||||
$txt="Address IPv4";
|
||||
} else {
|
||||
$txt="Subnet IPv4";
|
||||
}
|
||||
} elseif (checkipv6($i['ip'])) {
|
||||
if ($i['subnet']==128) {
|
||||
$txt="Address IPv6";
|
||||
} else {
|
||||
$txt="Subnet IPv6";
|
||||
}
|
||||
}
|
||||
echo "<tr><td>$txt</td><td>{$i['ip_human']}</td><td>{$i['infos']}</td>";
|
||||
?>
|
||||
<td><div class="ina"><a href="javascript:edit_ip(<?php echo "'".htmlentities($i['id'])."','".htmlentities($i['ip_human'])."','".htmlentities($i['infos'])."'"; ?>);"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div></td>
|
||||
<td><div class="ina"><a href="adm_authip_whitelist.php?delete_id=<?php echo urlencode($i["id"]) ?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
function reset_edit_ip() {
|
||||
$("#reset_edit_ip").hide();
|
||||
$("#edit_id").val('');
|
||||
$("#edit_ip").val('');
|
||||
$("#edit_infos").val('');
|
||||
}
|
||||
|
||||
function edit_ip(id, iph, infos) {
|
||||
if ( id != '' ) {
|
||||
$("#reset_edit_ip").show();
|
||||
}
|
||||
$("#edit_id").val(id);
|
||||
$("#edit_infos").val(infos);
|
||||
$("#edit_ip").val(iph);
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php include_once("foot.php"); ?>
|
|
@ -52,6 +52,7 @@ include_once("head.php");
|
|||
<li class="lst2"><a href="adm_passpolicy.php"><?php __("Password Policies"); ?></a></li>
|
||||
<li class="lst1"><a href="adm_doms.php"><?php __("Manage installed domains"); ?></a></li>
|
||||
<li class="lst2"><a href="adm_defquotas.php"><?php __("Change the default quotas"); ?></a></li>
|
||||
<li class="lst1"><a href="adm_authip_whitelist.php"><?php __("Manage IP whitelist"); ?></a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
@ -24,13 +24,30 @@
|
|||
**/
|
||||
class m_authip {
|
||||
|
||||
/*
|
||||
* Retourne la liste des ip whitelist
|
||||
*
|
||||
* @return array retourne un tableau indexé des ip de l'utilisateur
|
||||
*/
|
||||
function list_ip_whitelist() {
|
||||
global $mem;
|
||||
if (!$mem->checkRight()) return false;
|
||||
return $this->list_ip(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retourne la liste des ip spécifiées par cet utilisateur
|
||||
*
|
||||
* @return array retourne un tableau indexé des ip de l'utilisateur
|
||||
*/
|
||||
function list_ip() {
|
||||
global $db, $cuid;
|
||||
function list_ip($whitelist=false) {
|
||||
global $db, $mem;
|
||||
|
||||
if ($whitelist && $mem->checkRight() ) {
|
||||
$cuid=0;
|
||||
} else {
|
||||
global $cuid;
|
||||
}
|
||||
|
||||
$r = array();
|
||||
$db->query("SELECT * FROM authorised_ip WHERE uid='$cuid';");
|
||||
|
@ -47,6 +64,8 @@ class m_authip {
|
|||
return $r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Supprime une IP des IP de l'utilisateur
|
||||
* et supprime les droits attaché en cascade
|
||||
|
@ -69,6 +88,23 @@ class m_authip {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sauvegarde une IP dans les IP TOUJOURS authorisée
|
||||
*
|
||||
* @param integer $id id de la ligne à modifier. Si vide ou
|
||||
* égal à 0, alors c'est une insertion
|
||||
* @param string $ipsub IP (v4 ou v6), potentiellement avec un subnet ( /24)
|
||||
* @param string $infos commentaire pour l'utilisateur
|
||||
* @param integer $uid Si $uid=0 et qu'on est super-admin, insertion avec uid=0
|
||||
* ce qui correspond a une ip toujours authorisée
|
||||
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
||||
*/
|
||||
function ip_save_whitelist($id, $ipsub, $infos) {
|
||||
global $mem;
|
||||
if (!$mem->checkRight()) return false;
|
||||
return $this->ip_save($id, $ipsub, $infos, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sauvegarde une IP dans les IP authorisée
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue