| 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 | ); |
|---|
| 14 | getFields($fields); |
|---|
| 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 ($error) { ?> |
|---|
| 36 | <p class="error"><?php echo $error ?></p> |
|---|
| 37 | <?php } ?> |
|---|
| 38 | |
|---|
| 39 | <p> |
|---|
| 40 | <fieldset> |
|---|
| 41 | <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> |
|---|
| 42 | <span id="form_add_ip"> |
|---|
| 43 | <form method="post" action="adm_authip_whitelist.php" name="main" id="main"> |
|---|
| 44 | <p id="reset_edit_ip" style="display:none;"><a href="javascript:reset_edit_ip();"><?php __("Cancel edit")?></a></p> |
|---|
| 45 | <input type="hidden" name="id" value="" id="edit_id" > |
|---|
| 46 | <p> |
|---|
| 47 | <?php __("Enter here the IP address you want. <br/> <i>IPv4, IPv6 and subnet allowed</i>"); ?> <br/> |
|---|
| 48 | <input type="text" size=20 maxlength=39 name="ipsub" id="edit_ip" /> |
|---|
| 49 | </p> |
|---|
| 50 | <p> |
|---|
| 51 | <?php __("Add a comment");?><br/> |
|---|
| 52 | <input type="text" size=25 maxlength=200 name="infos" id="edit_infos" /> |
|---|
| 53 | </p> |
|---|
| 54 | <input type="submit" class="inb" value="<?php __("Save")?>" /> |
|---|
| 55 | </form> |
|---|
| 56 | </span> |
|---|
| 57 | </fieldset> |
|---|
| 58 | |
|---|
| 59 | </p> |
|---|
| 60 | <table> |
|---|
| 61 | <tr><th><?php __("Type"); ?></th><th><?php __("IP"); ?></th><th><?php __("Informations"); ?></th><th colspan=2/></tr> |
|---|
| 62 | <?php foreach($list_ip as $i) { |
|---|
| 63 | if (checkip($i['ip'])) { |
|---|
| 64 | if ($i['subnet']==32) { |
|---|
| 65 | $txt="Address IPv4"; |
|---|
| 66 | } else { |
|---|
| 67 | $txt="Subnet IPv4"; |
|---|
| 68 | } |
|---|
| 69 | } elseif (checkipv6($i['ip'])) { |
|---|
| 70 | if ($i['subnet']==128) { |
|---|
| 71 | $txt="Address IPv6"; |
|---|
| 72 | } else { |
|---|
| 73 | $txt="Subnet IPv6"; |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | echo "<tr><td>$txt</td><td>{$i['ip_human']}</td><td>{$i['infos']}</td>"; |
|---|
| 77 | ?> |
|---|
| 78 | <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> |
|---|
| 79 | <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> |
|---|
| 80 | </tr> |
|---|
| 81 | |
|---|
| 82 | <?php } ?> |
|---|
| 83 | </table> |
|---|
| 84 | |
|---|
| 85 | <script type="text/javascript"> |
|---|
| 86 | function reset_edit_ip() { |
|---|
| 87 | $("#reset_edit_ip").hide(); |
|---|
| 88 | $("#edit_id").val(''); |
|---|
| 89 | $("#edit_ip").val(''); |
|---|
| 90 | $("#edit_infos").val(''); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | function edit_ip(id, iph, infos) { |
|---|
| 94 | if ( id != '' ) { |
|---|
| 95 | $("#reset_edit_ip").show(); |
|---|
| 96 | } |
|---|
| 97 | $("#edit_id").val(id); |
|---|
| 98 | $("#edit_infos").val(infos); |
|---|
| 99 | $("#edit_ip").val(iph); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | </script> |
|---|
| 103 | <?php include_once("foot.php"); ?> |
|---|