Alternc  latest
Alternc logiel libre pour l'hébergement
adm_authip_whitelist.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Manages Whitelists in IP auth module
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 
30 $fields = array (
31  "delete_id" => array ("get", "integer", ""),
32  "id" => array ("post", "integer", 0),
33  "ipsub" => array ("post", "string", ""),
34  "infos" => array ("post", "string" ,""),
35  "s_ipsub" => array ("post", "integer", ""),
36  "s_protocol" => array ("post", "string", ""),
37 );
39 
40 if (!empty($delete_id)) {
41  if (! $authip->ip_delete($delete_id)) {
42  $msg->raise("ERROR", "admin", _("Error during deletion"));
43  }
44 }
45 
46 if (!empty($ipsub)) {
47  if (! $authip->ip_save_whitelist($id, $ipsub, $infos)) {
48  $msg->raise("ERROR", "admin", _("Error during recording"));
49  }
50 }
51 
52 $list_ip = $authip->list_ip_whitelist();
53 ?>
54 
55 <h3><?php __("Access security"); ?></h3>
56 <hr id="topbar"/>
57 <br />
58 
59 <?php echo $msg->msg_html_all(); ?>
60 
61 <center>
62  <p class="alert alert-warning"><?php __("Warning"); echo "<br/>"; __("The IP and subnet you have here are allowed for ALL users and ALL usages"); ?></p>
63 </center>
64 
65 <br/>
66  <fieldset>
67  <legend><?php __("Add an IP");?> - <a href="javascript:edit_ip('','<?php echo htmlentities(get_remote_ip())."','Home IP'";?>);" ><?php echo __("Add my current IP"); ?></a></legend>
68  <span id="form_add_ip">
69  <form method="post" action="adm_authip_whitelist.php" name="main" id="main">
70  <?php csrf_get(); ?>
71  <p id="reset_edit_ip" style="display:none;"><a href="javascript:reset_edit_ip();"><?php __("Cancel edit")?></a></p>
72  <input type="hidden" name="id" value="" id="edit_id" />
73  <p>
74  <?php __("Enter here the IP address you want. <br/> <i>IPv4, IPv6 and subnet allowed</i>"); ?> <br/>
75  <input type="text" size="20" maxlength="39" name="ipsub" id="edit_ip" />
76  </p>
77  <p>
78  <?php __("Add a comment");?><br/>
79  <input type="text" size="25" maxlength="200" name="infos" id="edit_infos" />
80  </p>
81  <input type="submit" class="inb" value="<?php __("Save")?>" />
82  </form>
83  </span>
84  </fieldset>
85 
86 <br/>
87  <table class="tlist">
88  <tr><th><?php __("Type"); ?></th><th><?php __("IP"); ?></th><th><?php __("Informations"); ?></th><th colspan="2" /></tr>
89  <?php
90  foreach($list_ip as $i) {
91  if (checkip($i['ip'])) {
92  if ($i['subnet']==32) {
93  $txt="Address IPv4";
94  } else {
95  $txt="Subnet IPv4";
96  }
97  } elseif (checkipv6($i['ip'])) {
98  if ($i['subnet']==128) {
99  $txt="Address IPv6";
100  } else {
101  $txt="Subnet IPv6";
102  }
103  } else {
104  $txt = "Unknow IP";
105  }
106  echo "<tr class=\"lst\"><td>$txt</td><td>{$i['ip_human']}</td><td>{$i['infos']}</td>";
107  ?>
108  <td><div class="ina edit"><a href="javascript:edit_ip(<?php echo "'".urlencode($i['id'])."','".urlencode($i['ip_human'])."','".urlencode($i['infos'])."'"; ?>);"><?php __("Edit"); ?></a></div></td>
109  <td><div class="ina delete"><a href="adm_authip_whitelist.php?delete_id=<?php eue($i["id"]); ?>"><?php __("Delete"); ?></a></div></td>
110  </tr>
111 
112  <?php } ?>
113  </table>
114 
115 <script type="text/javascript">
116  function reset_edit_ip() {
117  $("#reset_edit_ip").hide();
118  $("#edit_id").val('');
119  $("#edit_ip").val('');
120  $("#edit_infos").val('');
121  }
122 
123  function edit_ip(id, iph, infos) {
124  if ( id != '' ) {
125  $("#reset_edit_ip").show();
126  }
127  $("#edit_id").val(id);
128  $("#edit_infos").val(infos);
129  $("#edit_ip").val(iph);
130  }
131 
132 </script>
133 <?php include_once("foot.php"); ?>
if(!empty($delete_id)) if(!empty($ipsub)) $list_ip
$fields
Manages Whitelists in IP auth module.
$msg
Definition: bootstrap.php:75
$authip
Definition: bootstrap.php:73
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
if(!isset($is_include)) if(! $key &&! $crt) $id
if(in_array($action, array('start', 'stop', 'monit'))) switch($action) if($lxc->error &&! $script) $infos
Definition: vm.php:32