2 require_once(
"../class/config.php");
3 include_once(
"head.php");
7 "delete_id" => array (
"get",
"integer",
""),
8 "delete_affected_id" => array (
"get",
"integer",
""),
9 "id" => array (
"post",
"integer", 0),
10 "ipsub" => array (
"post",
"string",
""),
11 "infos" => array (
"post",
"string" ,
""),
12 "s_ipsub" => array (
"post",
"integer",
""),
13 "s_protocol" => array (
"post",
"string",
""),
17 if (!empty($s_protocol)) {
18 $val=
"s_affect_".$s_protocol;
19 $fields = array(
$val => Array(
'post',
'string',
'') );
22 if (!
$authip->ip_affected_save($s_ipsub, $s_protocol, $
$val) ) {
23 $error=
"Error during ip_affected_save";
27 if (!empty($delete_affected_id)) {
28 if (!
$authip->ip_affected_delete($delete_affected_id)) {
29 $error=
"Error during deletion";
33 if (!empty($delete_id)) {
34 if (!
$authip->ip_delete($delete_id)) {
35 $error=
"Error during deletion";
41 $error=
"Error during recording";
50 <h3><?php
__(
"Access security"); ?></h3>
55 <p
class=
"alert alert-danger"><?php echo
$error ; $error=
''; ?></p>
58 <p><?php
__(
"Here you can add rules to restrict access to AlternC's services, filtered by IP. First, add trusted IPs in the 'Known IP and networks' list. Then, add rules to grant access on services to the chosen IPs from this list.") ?></p>
60 <h3><?php
__(
"Enabled rules"); ?></h3>
64 <th><?php
__(
"Authorised IP address or network");?></th>
65 <th><?php
__(
"Access type");?></th>
69 foreach (
$lac as $ll) {
70 echo
"<tr class='lst' >";
71 echo
"<td><span title=\"{$list_ip[$ll['authorised_ip_id']]['ip_human']}\">".$list_ip[$ll[
'authorised_ip_id']][
'infos'];
74 echo
"<td>".@
$ac[$ll[
'protocol']][
'name'];
75 if (
isset(
$ac[$ll[
'protocol']][
'values'][$ll[
'parameters']]) &&
$ac[$ll[
'protocol']][
'values'][$ll[
'parameters']]) {
76 echo
" "._(
"for").
" ".
$ac[$ll[
'protocol']][
'values'][$ll[
'parameters']];
79 echo
'<td><div class="ina delete"><a href="ip_main.php?delete_affected_id='.urlencode($ll[
"id"]).
'">'._(
"Delete").
'</a></div></td>';
86 <h3><?php
__(
"Add a new rule"); ?></h3>
89 <p><?php
__(
"You need to have some 'Known IP and networks' defined below to define a new rule.") ?></p>
91 <form method=
"post" action=
"ip_main.php" name=
"main" id=
"main">
92 <table
class=
"tlistb">
95 <th><?php
__(
"Access type"); ?></th>
97 <?php
foreach (
$ac as $a) { ?>
99 <input type=
"radio" name=
"s_protocol" id=
"s_protocol_<?php echo htmlentities($a['protocol']);?>" value=
"<?php echo htmlentities($a['protocol']);?>" />
100 <label
for=
"s_protocol_<?php echo htmlentities($a['protocol']);?>"><?php echo htmlentities($a[
'name']); ?></label>
102 <?php
if (
sizeof($a[
'values']) > 1 ) { ?>
103 <select name=
"s_affect_<?php echo htmlentities($a['protocol']);?>" id=
"s_affect_<?php echo htmlentities($a['protocol']);?>">
104 <?php
foreach ($a[
'values'] as $k => $v) { ?>
105 <option value=
"<?php echo htmlentities($k); ?>"><?php echo htmlentities($v); ?></option>
109 <?php
foreach ($a[
'values'] as $k => $v) { ?>
110 <label><b><?php echo htmlentities($v); ?></b></label>
111 <input type=hidden name=
"s_affect_<?php echo htmlentities($a['protocol']);?>" id=
"s_affect_<?php echo htmlentities($a['protocol']);?>" value=
"<?php echo htmlentities($k); ?>" readonly />
119 <th><?php
__(
"Authorized IP address or network"); ?></th>
120 <td valign=
"middle" class=
"lst2">
122 <select name=
"s_ipsub">
123 <?php
foreach (
$list_ip as $li) { ?>
124 <option value=
"<?php echo $li['id']; ?>"><?php echo htmlentities($li[
'infos']);
134 <td valign=
'middle' class=
"lst2">
135 <input type=
"submit" class=
"inb ok" value=
"<?php __("Save
")?>" onclick=
'return check_accesstype_selected();' />
144 <h3><?php
__(
"Known IP and networks");?></h3>
145 <table
class=
"tlist">
146 <tr><th><?php
__(
"Name"); ?></th><th><?php
__(
"IP or network"); ?></th><th><?php
__(
"Type"); ?></th><th colspan=
'2'></th></tr>
150 if ($i[
'subnet']==32) {
151 $txt=_(
"Address IPv4");
153 $txt=_(
"Subnet IPv4");
156 if ($i[
'subnet']==128) {
157 $txt=_(
"Address IPv6");
159 $txt=_(
"Subnet IPv6");
162 $txt=_(
"Error with this IP");
164 echo
"<tr class='lst' ><td>{$i['infos']}</td><td>{$i['ip_human']}</td><td>$txt</td>";
166 <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>
167 <td><div
class=
"ina delete"><a href=
"ip_main.php?delete_id=<?php echo urlencode($i["id"]) ?>"><?php
__(
"Delete"); ?></a></div></td>
174 <h3><?php
__(
"Add an IP or a networks");?></h3>
176 <p><a href=
"javascript:edit_ip('','<?php echo htmlentities(get_remote_ip())."','Home IP
'";?>);" ><?php echo __("Add my current IP"); ?></a></p>
177 <span id="form_add_ip">
178 <form method="post" action="ip_main.php" name="main" >
179 <p id="reset_edit_ip" style="display:none;"><a href="javascript:reset_edit_ip();"><?php __("Cancel edit")?></a></p>
181 <input type="hidden" name="id" value="" id="edit_id" />
182 <table class="tlistb">
183 <tr><th><?php __("Name"); ?></th><th><?php __("IP or network. <i>IPv4, IPv6 and subnet allowed</i>"); ?></th><th></th></tr>
186 <td><input type="text" size='20
' maxlength='39
' name="ipsub" id="edit_ip" /></td>
187 <td><input type="text" size='25
' maxlength='200
' name="infos" id="edit_infos" /></td>
188 <td><input type="submit" class="inb ok" value="<?php __("Save")?>" /></td>
194 <script type="text/javascript">
195 function reset_edit_ip() {
196 $("#reset_edit_ip").hide();
197 $("#edit_id").val('');
198 $("#edit_ip").val('');
199 $("#edit_infos").val('');
202 function edit_ip(id, iph, infos) {
204 $("#reset_edit_ip").show();
206 $("#edit_id").val(id);
207 $("#edit_infos").val(infos);
208 $("#edit_ip").val(iph);
211 function check_accesstype_selected() {
212 if ( $('input[name=s_protocol]:radio:checked
').val() ) {
216 alert("<?php __("Please select an access type"); ?>");
221 <?php include_once("foot.php"); ?>