| Line 4... |
Line 4... |
| 4 |
/********************
|
4 |
/********************
|
| 5 |
* READ CONF FILES *
|
5 |
* READ CONF FILES *
|
| 6 |
*********************/
|
6 |
*********************/
|
| 7 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
7 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
| 8 |
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
|
8 |
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
|
| - |
|
9 |
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
|
| 9 |
$conf_files=array(CONF_FILE,ETHERS_FILE);
|
10 |
$conf_files=array(CONF_FILE,ETHERS_FILE);
|
| 10 |
$reg_ip = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
|
11 |
$reg_ip = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
|
| 11 |
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
|
12 |
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
|
| 12 |
$network_modification=0;
|
13 |
$network_modification=0;
|
| 13 |
foreach ($conf_files as $file){
|
14 |
foreach ($conf_files as $file){
|
| Line 24... |
Line 25... |
| 24 |
if($Language == 'fr'){
|
25 |
if($Language == 'fr'){
|
| 25 |
$l_network_title = "Configuration réseau";
|
26 |
$l_network_title = "Configuration réseau";
|
| 26 |
$l_extif_legend = " (Interface connectée à Internet)";
|
27 |
$l_extif_legend = " (Interface connectée à Internet)";
|
| 27 |
$l_intif_legend = " (Réseau de consultation)";
|
28 |
$l_intif_legend = " (Réseau de consultation)";
|
| 28 |
$l_internet_legend = "INTERNET";
|
29 |
$l_internet_legend = "INTERNET";
|
| 29 |
$l_ip_adr = "Adresse IP";
|
- |
|
| 30 |
$l_ip_mask = "Masque";
|
30 |
$l_ip_mask = "Masque";
|
| 31 |
$l_ip_router = "Passerelle";
|
31 |
$l_ip_router = "Passerelle";
|
| 32 |
$l_ip_public = "Adresse IP publique";
|
32 |
$l_ip_public = "Adresse IP publique";
|
| 33 |
$l_ip_dns1 = "DNS1";
|
33 |
$l_ip_dns1 = "DNS1";
|
| 34 |
$l_ip_dns2 = "DNS2";
|
34 |
$l_ip_dns2 = "DNS2";
|
| Line 38... |
Line 38... |
| 38 |
$l_DHCP_off = "inactif";
|
38 |
$l_DHCP_off = "inactif";
|
| 39 |
$l_DHCP_off_explain = "! Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
|
39 |
$l_DHCP_off_explain = "! Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
|
| 40 |
$l_static_dhcp_title = "Réservation d'adresses IP statiques";
|
40 |
$l_static_dhcp_title = "Réservation d'adresses IP statiques";
|
| 41 |
$l_mac_address = "Adresse MAC";
|
41 |
$l_mac_address = "Adresse MAC";
|
| 42 |
$l_ip_address = "Adresse IP";
|
42 |
$l_ip_address = "Adresse IP";
|
| - |
|
43 |
$l_host_name = "Nom d'hôte";
|
| 43 |
$l_mac_del = "Supprimer de la liste";
|
44 |
$l_del = "Supprimer de la liste";
|
| 44 |
$l_add_to_list = "Ajouter";
|
45 |
$l_add_to_list = "Ajouter";
|
| 45 |
$l_apply = "Appliquer les changements";
|
46 |
$l_apply = "Appliquer les changements";
|
| - |
|
47 |
$l_local_dns = "Résolution local de nom";
|
| 46 |
$l_import_cert = "Import de certificat";
|
48 |
$l_import_cert = "Import de certificat";
|
| 47 |
$l_private_key = "Clé privée (.key) :";
|
49 |
$l_private_key = "Clé privée (.key) :";
|
| 48 |
$l_certificate = "Certificat (.crt) :";
|
50 |
$l_certificate = "Certificat (.crt) :";
|
| 49 |
$l_server_chain = "Chaîne de certification (si nécéssaire : .crt) :";
|
51 |
$l_server_chain = "Chaîne de certification (si nécéssaire : .crt) :";
|
| 50 |
$l_default_cert = "Revenir au certificat d'origine";
|
52 |
$l_default_cert = "Revenir au certificat d'origine";
|
| Line 55... |
Line 57... |
| 55 |
} else {
|
57 |
} else {
|
| 56 |
$l_network_title = "Network configuration";
|
58 |
$l_network_title = "Network configuration";
|
| 57 |
$l_extif_legend = " (Internet connected interface)";
|
59 |
$l_extif_legend = " (Internet connected interface)";
|
| 58 |
$l_intif_legend = " (Private network)";
|
60 |
$l_intif_legend = " (Private network)";
|
| 59 |
$l_internet_legend = "INTERNET";
|
61 |
$l_internet_legend = "INTERNET";
|
| 60 |
$l_ip_adr = "IP Address";
|
- |
|
| 61 |
$l_ip_mask = "Mask";
|
62 |
$l_ip_mask = "Mask";
|
| 62 |
$l_ip_router = "Gateway";
|
63 |
$l_ip_router = "Gateway";
|
| 63 |
$l_ip_public = "Public IP address";
|
64 |
$l_ip_public = "Public IP address";
|
| 64 |
$l_ip_dns1 = "DNS1";
|
65 |
$l_ip_dns1 = "DNS1";
|
| 65 |
$l_ip_dns2 = "DNS2";
|
66 |
$l_ip_dns2 = "DNS2";
|
| Line 69... |
Line 70... |
| 69 |
$l_DHCP_off = "disabled";
|
70 |
$l_DHCP_off = "disabled";
|
| 70 |
$l_DHCP_off_explain = "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
|
71 |
$l_DHCP_off_explain = "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
|
| 71 |
$l_static_dhcp_title = "Static IP addresses reservation";
|
72 |
$l_static_dhcp_title = "Static IP addresses reservation";
|
| 72 |
$l_mac_address = "MAC Address";
|
73 |
$l_mac_address = "MAC Address";
|
| 73 |
$l_ip_address = "IP Address";
|
74 |
$l_ip_address = "IP Address";
|
| - |
|
75 |
$l_host_name = "Host name";
|
| 74 |
$l_mac_del = "Delete from list";
|
76 |
$l_del = "Delete from list";
|
| 75 |
$l_add_to_list = "Add";
|
77 |
$l_add_to_list = "Add";
|
| 76 |
$l_apply = "Apply changes";
|
78 |
$l_apply = "Apply changes";
|
| - |
|
79 |
$l_local_dns = "Local name resolution";
|
| 77 |
$l_import_cert = "Certificate import";
|
80 |
$l_import_cert = "Certificate import";
|
| 78 |
$l_private_key = "Private key (.key) :";
|
81 |
$l_private_key = "Private key (.key) :";
|
| 79 |
$l_certificate = "Certificate (.crt) :";
|
82 |
$l_certificate = "Certificate (.crt) :";
|
| 80 |
$l_server_chain = "Server-chain (if necessary : .crt) :";
|
83 |
$l_server_chain = "Server-chain (if necessary : .crt) :";
|
| 81 |
$l_default_cert = "Back to default certificate";
|
84 |
$l_default_cert = "Back to default certificate";
|
| Line 95... |
Line 98... |
| 95 |
break;
|
98 |
break;
|
| 96 |
case 'new_mac' :
|
99 |
case 'new_mac' :
|
| 97 |
if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
|
100 |
if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
|
| 98 |
{
|
101 |
{
|
| 99 |
$tab=file(ETHERS_FILE);
|
102 |
$tab=file(ETHERS_FILE);
|
| 100 |
$insert="True";
|
- |
|
| 101 |
if ($tab) # the file isn't empty
|
103 |
if ($tab) # the file isn't empty
|
| 102 |
{
|
104 |
{
|
| - |
|
105 |
$insert="True";
|
| 103 |
foreach ($tab as $line) # verify that MAC or IP addresses doesn't exist
|
106 |
foreach ($tab as $line) # verify that MAC or IP address doesn't exist
|
| 104 |
{
|
107 |
{
|
| 105 |
$field=explode(" ", $line);
|
108 |
$field=explode(" ", $line);
|
| 106 |
$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
|
109 |
$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
|
| 107 |
if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
|
110 |
if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
|
| 108 |
{
|
111 |
{
|
| Line 113... |
Line 116... |
| 113 |
{
|
116 |
{
|
| 114 |
$insert="False";
|
117 |
$insert="False";
|
| 115 |
break;
|
118 |
break;
|
| 116 |
}
|
119 |
}
|
| 117 |
}
|
120 |
}
|
| - |
|
121 |
if ($insert == "True")
|
| - |
|
122 |
{
|
| - |
|
123 |
$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
|
| - |
|
124 |
$pointeur=fopen(ETHERS_FILE,"a");
|
| - |
|
125 |
fwrite ($pointeur, $line);
|
| - |
|
126 |
fclose ($pointeur);
|
| - |
|
127 |
exec ("sudo /usr/bin/systemctl reload chilli");
|
| - |
|
128 |
}
|
| 118 |
}
|
129 |
}
|
| - |
|
130 |
}
|
| - |
|
131 |
break;
|
| - |
|
132 |
case 'del_mac' :
|
| - |
|
133 |
foreach ($_POST as $key => $value)
|
| - |
|
134 |
{
|
| 119 |
if ($insert == "True")
|
135 |
if ($value == 'on')
|
| 120 |
{
|
136 |
{
|
| 121 |
$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
|
- |
|
| 122 |
$pointeur=fopen(ETHERS_FILE,"a");
|
137 |
$ether_file=ETHERS_FILE;
|
| 123 |
fwrite ($pointeur, $line);
|
138 |
exec("/bin/sed -i \"/^$key/d\" $ether_file");
|
| 124 |
fclose ($pointeur);
|
- |
|
| 125 |
exec ("sudo /usr/bin/systemctl reload chilli");
|
139 |
exec ("sudo /usr/bin/systemctl reload chilli");
|
| 126 |
}
|
140 |
}
|
| 127 |
}
|
141 |
}
|
| 128 |
break;
|
142 |
break;
|
| 129 |
case 'del_mac' :
|
143 |
case 'new_host' :
|
| 130 |
$tab=file(ETHERS_FILE);
|
144 |
if ((trim($_POST['add_host']) != "") and (trim($_POST['add_ip']) != ""))
|
| 131 |
if ($tab)
|
- |
|
| 132 |
{
|
145 |
{
|
| 133 |
$pointeur=fopen(ETHERS_FILE,"w+");
|
146 |
$tab=file(DNS_LOCAL_FILE);
|
| - |
|
147 |
$insert="True";
|
| 134 |
foreach ($tab as $line)
|
148 |
if ($tab) # the file isn't empty
|
| 135 |
{
|
149 |
{
|
| 136 |
$field=explode(" ", $line);
|
- |
|
| 137 |
$mac_addr=trim($field[0]);
|
- |
|
| 138 |
$remove_line = False;
|
- |
|
| 139 |
foreach ($_POST as $key => $value)
|
150 |
foreach ($tab as $line) # verify that host or IP address doesn't exist
|
| 140 |
{
|
151 |
{
|
| 141 |
if ($mac_addr == $key)
|
152 |
if (preg_match ('/^address/', $line))
|
| 142 |
{
|
153 |
{
|
| 143 |
$remove_line = True;
|
154 |
$field=explode("/", $line);
|
| - |
|
155 |
$host_name=trim($field[1]);$ip_addr=trim($field[2]);
|
| - |
|
156 |
if (strcasecmp(trim($_POST['add_host']),trim($host_name)) == 0)
|
| - |
|
157 |
{
|
| - |
|
158 |
$insert="False";
|
| 144 |
break;
|
159 |
break;
|
| - |
|
160 |
}
|
| - |
|
161 |
if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
|
| - |
|
162 |
{
|
| - |
|
163 |
$insert="False";
|
| - |
|
164 |
break;
|
| - |
|
165 |
}
|
| 145 |
}
|
166 |
}
|
| 146 |
}
|
167 |
}
|
| - |
|
168 |
if ($insert == "True")
|
| - |
|
169 |
{
|
| - |
|
170 |
$line1 = "address=/".trim($_POST['add_host'])."/".trim($_POST['add_ip'])."\n";
|
| - |
|
171 |
$explode_ip=explode('.',trim($_POST['add_ip']));
|
| - |
|
172 |
$reverse_ip=implode('.',array_reverse($explode_ip));
|
| - |
|
173 |
$line2 = "ptr-record=".$reverse_ip.".in-addr.arpa,".trim($_POST['add_host'])."\n";
|
| - |
|
174 |
$pointeur=fopen(DNS_LOCAL_FILE,"a");
|
| - |
|
175 |
fwrite ($pointeur, $line1);
|
| 147 |
if (! $remove_line) {fwrite($pointeur,$line);}
|
176 |
fwrite ($pointeur, $line2);
|
| - |
|
177 |
fclose ($pointeur);
|
| - |
|
178 |
exec ("sudo /usr/bin/systemctl restart dnsmasq");
|
| - |
|
179 |
exec ("sudo /usr/bin/systemctl restart dnsmasq-blacklist");
|
| - |
|
180 |
exec ("sudo /usr/bin/systemctl restart dnsmasq-whitelist");
|
| - |
|
181 |
}
|
| - |
|
182 |
}
|
| - |
|
183 |
}
|
| - |
|
184 |
break;
|
| - |
|
185 |
case 'del_mac' :
|
| - |
|
186 |
foreach ($_POST as $key => $value)
|
| - |
|
187 |
{
|
| - |
|
188 |
if ($value == 'on')
|
| - |
|
189 |
{
|
| - |
|
190 |
$ether_file=ETHERS_FILE;
|
| - |
|
191 |
exec("/bin/sed -i \"/^$key/d\" $ether_file");
|
| - |
|
192 |
exec ("sudo /usr/bin/systemctl reload chilli");
|
| 148 |
}
|
193 |
}
|
| 149 |
fclose($pointeur);
|
- |
|
| 150 |
exec ("sudo /usr/bin/systemctl reload chilli");
|
- |
|
| 151 |
}
|
194 |
}
|
| 152 |
break;
|
195 |
break;
|
| 153 |
}
|
196 |
}
|
| 154 |
|
197 |
|
| 155 |
// Fonction de test de connectivité internet
|
198 |
// Fonction de test de connectivité internet
|
| Line 283... |
Line 326... |
| 283 |
<fieldset>
|
326 |
<fieldset>
|
| 284 |
<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
|
327 |
<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
|
| 285 |
<table>
|
328 |
<table>
|
| 286 |
<?php
|
329 |
<?php
|
| 287 |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
|
330 |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
|
| 288 |
echo "<tr><td>".$l_ip_adr." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
|
331 |
echo "<tr><td>".$l_ip_address." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
|
| 289 |
echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
|
332 |
echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
|
| 290 |
?>
|
333 |
?>
|
| 291 |
</table>
|
334 |
</table>
|
| 292 |
</fieldset>
|
335 |
</fieldset>
|
| 293 |
</td><td>
|
336 |
</td><td>
|
| 294 |
<fieldset>
|
337 |
<fieldset>
|
| 295 |
<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
|
338 |
<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
|
| 296 |
<table>
|
339 |
<table>
|
| 297 |
<?php
|
340 |
<?php
|
| 298 |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
|
341 |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
|
| 299 |
echo "<tr><td>".$l_ip_adr."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
|
342 |
echo "<tr><td>".$l_ip_address."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
|
| 300 |
?>
|
343 |
?>
|
| 301 |
</table>
|
344 |
</table>
|
| 302 |
</fieldset>
|
345 |
</fieldset>
|
| 303 |
</td></tr>
|
346 |
</td></tr>
|
| 304 |
<?php
|
347 |
<?php
|
| Line 328... |
Line 371... |
| 328 |
else { echo "</TABLE>"; }
|
371 |
else { echo "</TABLE>"; }
|
| 329 |
$maxsize=100000;
|
372 |
$maxsize=100000;
|
| 330 |
?>
|
373 |
?>
|
| 331 |
|
374 |
|
| 332 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
375 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
| - |
|
376 |
<tr><th><?php echo $l_local_dns;?></th></tr>
|
| - |
|
377 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
| - |
|
378 |
</table>
|
| - |
|
379 |
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
| - |
|
380 |
<tr><td colspan=2 align="center">
|
| - |
|
381 |
<?
|
| - |
|
382 |
echo "<FORM action='network.php' method='POST'>";
|
| - |
|
383 |
echo "<table cellspacing=2 cellpadding=3 border=1>";
|
| - |
|
384 |
echo "<tr><th>$l_host_name<th>$l_ip_address<th>$l_del</tr>";
|
| - |
|
385 |
// Read the "dns_local" file
|
| - |
|
386 |
$line_exist=False;
|
| - |
|
387 |
$tab=file(DNS_LOCAL_FILE);
|
| - |
|
388 |
if ($tab) # not empty
|
| - |
|
389 |
{
|
| - |
|
390 |
$line_exist=True;
|
| - |
|
391 |
foreach ($tab as $line)
|
| - |
|
392 |
{
|
| - |
|
393 |
if (preg_match ('/^address/', $line))
|
| - |
|
394 |
{
|
| - |
|
395 |
$field=explode("/", $line);
|
| - |
|
396 |
$ip_addr=$field[1];
|
| - |
|
397 |
$host_name=$field[2];
|
| - |
|
398 |
echo "<tr><td>$ip_addr";
|
| - |
|
399 |
echo "<td>$host_name";
|
| - |
|
400 |
echo "<td><input type='checkbox' name='$host_name'>";
|
| - |
|
401 |
echo "</tr>";
|
| - |
|
402 |
}
|
| - |
|
403 |
}
|
| - |
|
404 |
}
|
| - |
|
405 |
echo "</table>";
|
| - |
|
406 |
if ($line_exist)
|
| - |
|
407 |
{
|
| - |
|
408 |
echo "<input type='hidden' name='choix' value='del_host'>";
|
| - |
|
409 |
echo "<input type='submit' value='$l_apply'>";
|
| - |
|
410 |
}
|
| - |
|
411 |
echo "</form></td><td valign='middle' align='center'>";
|
| - |
|
412 |
echo "<FORM name='new_host' action='network.php' method='POST'>";
|
| - |
|
413 |
echo "<table cellspacing=2 cellpadding=3 border=1>";
|
| - |
|
414 |
echo "<tr><th>$l_host_name<th>$l_ip_address";
|
| - |
|
415 |
?>
|
| - |
|
416 |
<td></td></tr>
|
| - |
|
417 |
<tr><td>exemple : my_nas</td><td>exemple : 192.168.182.10</td><td></td></tr>
|
| - |
|
418 |
<tr><td><input type='text' name='add_host' size='17'></td>
|
| - |
|
419 |
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td>
|
| - |
|
420 |
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td>
|
| - |
|
421 |
</tr></table>
|
| - |
|
422 |
</form>
|
| - |
|
423 |
</td></tr>
|
| - |
|
424 |
</table>
|
| - |
|
425 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
| 333 |
<tr><th><?php echo $l_import_cert;?></th></tr>
|
426 |
<tr><th><?php echo $l_import_cert;?></th></tr>
|
| 334 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
427 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
| 335 |
</table>
|
428 |
</table>
|
| 336 |
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
429 |
<table width="100%" border="1" cellspacing="0" cellpadding="0">
|
| 337 |
<tr><td>
|
430 |
<tr><td>
|