Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
adm_authip_whitelist.php
Go to the documentation of this file.
1 <?php
2 require_once("../class/config.php");
3 include_once("head.php");
4 
5 
6 $fields = array (
7  "delete_id" => array ("get", "integer", ""),
8  "id" => array ("post", "integer", 0),
9  "ipsub" => array ("post", "string", ""),
10  "infos" => array ("post", "string" ,""),
11  "s_ipsub" => array ("post", "integer", ""),
12  "s_protocol" => array ("post", "string", ""),
13 );
15 
16 if (!empty($delete_id)) {
17  if (! $authip->ip_delete($delete_id)) {
18  $error="Error during deletion";
19  }
20 }
21 
22 if (!empty($ipsub)) {
23  if (! $authip->ip_save_whitelist($id, $ipsub, $infos)) {
24  $error="Error during recording";
25  }
26 }
27 
28 $list_ip = $authip->list_ip_whitelist();
29 ?>
30 
31 <h3><?php __("Access security"); ?></h3>
32 <hr id="topbar"/>
33 <br />
34 
35 <?php if (isset($error) && $error) { ?>
36  <p class="alert alert-danger"><?php echo $error ?></p>
37 <?php } ?>
38 <center>
39  <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>
40 </center>
41 
42 <br/>
43  <fieldset>
44  <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>
45  <span id="form_add_ip">
46  <form method="post" action="adm_authip_whitelist.php" name="main" id="main">
47  <p id="reset_edit_ip" style="display:none;"><a href="javascript:reset_edit_ip();"><?php __("Cancel edit")?></a></p>
48  <input type="hidden" name="id" value="" id="edit_id" />
49  <p>
50  <?php __("Enter here the IP address you want. <br/> <i>IPv4, IPv6 and subnet allowed</i>"); ?> <br/>
51  <input type="text" size='20' maxlength='39' name="ipsub" id="edit_ip" />
52  </p>
53  <p>
54  <?php __("Add a comment");?><br/>
55  <input type="text" size='25' maxlength='200' name="infos" id="edit_infos" />
56  </p>
57  <input type="submit" class="inb" value="<?php __("Save")?>" />
58  </form>
59  </span>
60  </fieldset>
61 
62 <br/>
63  <table class='tlist'>
64  <tr><th><?php __("Type"); ?></th><th><?php __("IP"); ?></th><th><?php __("Informations"); ?></th><th colspan='2' /></tr>
65  <?php
66  foreach($list_ip as $i) {
67  if (checkip($i['ip'])) {
68  if ($i['subnet']==32) {
69  $txt="Address IPv4";
70  } else {
71  $txt="Subnet IPv4";
72  }
73  } elseif (checkipv6($i['ip'])) {
74  if ($i['subnet']==128) {
75  $txt="Address IPv6";
76  } else {
77  $txt="Subnet IPv6";
78  }
79  }
80  echo "<tr class='lst'><td>$txt</td><td>{$i['ip_human']}</td><td>{$i['infos']}</td>";
81  ?>
82  <td><div class="ina edit"><a href="javascript:edit_ip(<?php echo "'".htmlentities($i['id'])."','".htmlentities($i['ip_human'])."','".htmlentities($i['infos'])."'"; ?>);"><?php __("Edit"); ?></a></div></td>
83  <td><div class="ina delete"><a href="adm_authip_whitelist.php?delete_id=<?php echo urlencode($i["id"]) ?>"><?php __("Delete"); ?></a></div></td>
84  </tr>
85 
86  <?php } ?>
87  </table>
88 
89 <script type="text/javascript">
90  function reset_edit_ip() {
91  $("#reset_edit_ip").hide();
92  $("#edit_id").val('');
93  $("#edit_ip").val('');
94  $("#edit_infos").val('');
95  }
96 
97  function edit_ip(id, iph, infos) {
98  if ( id != '' ) {
99  $("#reset_edit_ip").show();
100  }
101  $("#edit_id").val(id);
102  $("#edit_infos").val(infos);
103  $("#edit_ip").val(iph);
104  }
105 
106 </script>
107 <?php include_once("foot.php"); ?>