Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 840 → Rev 841

/web/acc/admin/network.php
1,6 → 1,36
<?php
/* written by steweb57 & Rexy */
 
/****************************************************************
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
*****************************************************************/
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
 
/********************************************************************************
* TEST DES FICHIERS DE CONFIGURATION *
********************************************************************************/
//Test de présence et des droits en lecture des fichiers de configuration.
if (!file_exists(ALCASAR_CHILLI)){
exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
}
if (!is_readable(ALCASAR_CHILLI)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_CHILLI);
}
if (!file_exists(CONF_FILE)){
exit("Fichier de configuration ".CONF_FILE." non présent");
}
if (!is_readable(CONF_FILE)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
}
if (!file_exists(ETHERS_FILE)){
exit("Fichier de configuration ".ETHERS_FILE." non présent");
}
if (!is_readable(ETHERS_FILE)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".ETHERS_FILE);
}
 
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
17,6 → 47,18
$l_ip_public = "Adresse IP publique";
$l_ip_dns1 = "DNS1";
$l_ip_dns2 = "DNS2";
$l_dhcp_title = "Serveur DHCP";
$l_dhcp_on = "Le service DHCP est actuellement activé";
$l_dhcp_off = "Le service DHCP est actuellement arrêté";
$l_switch_on = "Démarrer le service DHCP";
$l_switch_off = "Arrêter le service DHCP";
$l_static_dhcp_title = "Réservation d'adresses IP statiques";
$l_mac_address = "Adresse MAC";
$l_ip_address = "Adresse IP";
$l_mac_del = "Supprimer de la liste";
$l_add_to_list = "Ajouter";
$l_submit = "Appliquer";
 
} else {
$l_network_title = "Network configuration";
$l_eth0_legend = "Eth0 (Internet connected interface)";
24,34 → 66,89
$l_internet_legend = "INTERNET";
$l_ip_adr = "IP Address";
$l_ip_mask = "Mask";
$l_ip_router = "Router";
$l_ip_router = "Gateway";
$l_ip_public = "Public IP address";
$l_ip_dns1 = "DNS1 :";
$l_ip_dns2 = "DNS2";
$l_dhcp_title = "DHCP server";
$l_dhcp_on = "The DHCP service is enabled";
$l_dhcp_off = "The DHCP service is disabled";
$l_switch_on = "Start the DHCP service";
$l_switch_off = "Stop the DHCP service";
$l_static_dhcp_title = "Static IP addresses reservation";
$l_mac_address = "MAC Address";
$l_ip_address = "IP Address";
$l_mac_del = "Delete from list";
$l_add_to_list = "Add";
$l_submit = "Apply";
}
 
/********************************************************************
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
*********************************************************************/
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
 
/********************************************************************
* TEST DES FICHIERS DE CONFIGURATION *
*********************************************************************/
//Test de présence et des droits en lecture des fichiers de configuration.
if (!file_exists(ALCASAR_CHILLI)){
exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
switch ($choix)
{
case 'DHCP_On' :
exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -on");
break;
case 'DHCP_Off' :
exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -off");
break;
case 'new_mac' :
if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
{
$tab=file(ETHERS_FILE);
$insert="True";
if ($tab) # le fichier n'est pas vide
{
foreach ($tab as $line) # on vérifie que les adresses mac et IP ne sont pas déjà présentes
{
$field=explode(" ", $line);
$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
if (trim($_POST['add_mac']) == trim ($mac_addr))
{
$insert="False";
break;
}
if (trim($_POST['add_iip']) == trim ($ip_addr))
{
$insert="False";
break;
}
}
}
if ($insert == "True")
{
$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
$pointeur=fopen(ETHERS_FILE,"a");
fwrite ($pointeur, $line);
fclose ($pointeur);
# exec ("sudo service chilli restart");
}
}
break;
case 'del_mac' :
$tab=file(ETHERS_FILE);
if ($tab)
{
$pointeur=fopen(ETHERS_FILE,"w+");
foreach ($tab as $line)
{
$field=explode(" ", $line);
$mac_addr=trim($field[0]);
$remove_line = False;
foreach ($_POST as $key => $value)
{
if ($mac_addr == $key)
{
$remove_line = True;
break;
}
}
if (! $remove_line) {fwrite($pointeur,$line);}
}
fclose($pointeur);
# exec ("sudo service chilli restart");
}
break;
}
if (!file_exists(CONF_FILE)){
exit("Fichier de configuration ".CONF_FILE." non présent");
}
if (!is_readable(ALCASAR_CHILLI)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_CHILLI);
}
if (!is_readable(CONF_FILE)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
}
 
// Fonction de test de connectivité internet
function internetTest(){
99,7 → 196,7
}
}
}else{
exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
exit("Erreur d'ouverture du fichier ".CONF_FILE);
}
fclose($ouvre);
 
107,10 → 204,9
* TO DO *
*************************/
//modification de la conf réseau --> V3.0
//gestion du dhcp (affichage,modification, ajout @static)
 
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><!-- written by steweb57 / rexy -->
<html><!-- written by steweb57 & rexy -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $l_network_title; ?></title>
126,10 → 222,10
<fieldset>
<legend><?php echo $l_internet_legend;
if (InternetTest()){
echo " <img src='/images/state_ok.gif'> $l_enable";
echo " <img src='/images/state_ok.gif'>";
$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
else {
echo " <img src='/images/state_error.gif'> $l_disable";
echo " <img src='/images/state_error.gif'>";
$IP_PUB = "-.-.-.-";}
?></legend>
<table>
156,8 → 252,31
</td></tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><?php echo $l_main_services; ?></th></tr>
<tr><th><?php echo $l_dhcp_title;?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<table width="100%" border=1 cellspacing=0 cellpadding=0>
<tr><td valign="middle" align="left">
<?
if (strncmp ($conf["DHCP"],"on",2) == 0)
{
echo "<CENTER><H3>$l_dhcp_on</H3></CENTER>";
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
echo "<input type=hidden name='choix' value=\"DHCP_Off\">";
echo "<input type=submit value=\"$l_switch_off\">";
}
else
{
echo "<CENTER><H3>$l_dhcp_off</H3></CENTER>";
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
echo "<input type=hidden name='choix' value=\"DHCP_On\">";
echo "<input type=submit value=\"$l_switch_on\">";
}
echo "</FORM>";
echo "</td></tr>";
echo "</TABLE>";
if (strncmp($conf["DHCP"],"on",2) == 0) require ('network2.php');
?>
</BODY>
</body>
</html>
/web/acc/admin/auth_exceptions.php
22,15 → 22,7
$l_trusted_sites_explain2 = "Entrez un nom de domaine ou une adresse IP par ligne";
$l_trusted_sites_list = "Liste de nom de domaine de confiance";
$l_trusted_urls_list = "Liste d'adresses IP ou d'adresses de réseau de confiance";
$l_trusted_mac = "&Eacute;quipements de confiance";
$l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
$l_trusted_mac_list = "Liste d'adresses MAC de confiance";
$l_trusted_mac_address = "Adresses MAC autorisées";
$l_trusted_mac_info = "Information équipement";
$l_trusted_mac_del = "Supprimer de la liste";
$l_submit = "Enregistrer";
$l_submit2 = "Appliquer";
$l_add_to_list = "Ajouter";
}
else {
$l_error_open_file = "File open error";
39,15 → 31,7
$l_trusted_sites_explain2 = "Enter one domain name ou one IP address per line";
$l_trusted_sites_list = "Trusted Internet domain list";
$l_trusted_urls_list = "Trusted IP addresses or networks addresses list";
$l_trusted_mac = "Trusted Equipments";
$l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication";
$l_trusted_mac_list = "Trusted MAC addresses list";
$l_trusted_mac_address = "Allowed MAC adress";
$l_trusted_mac_info = "Equipment information";
$l_trusted_mac_del = "Delete from list";
$l_submit = "Submit";
$l_submit2 = "Apply";
$l_add_to_list = "Add";
}
if (isset($_POST['choix'])){
switch ($_POST['choix'])
74,63 → 58,6
exec ("sudo service chilli restart");
unset ($_POST['choix']);
break;
case 'new_mac' :
if (trim($_POST['add_mac']) != "")
{
if (is_file ($mac_allowed_list)) # le fichier existe
{
$tab=file($mac_allowed_list);
$insert = true;
if ($tab) # le fichier n'est pas vide
{
foreach ($tab as $line) # on teste si l'adresse mac n'est pas déjà présente
{
$field=explode("#", $line);
$mac_addr=trim($field[0],"macallowed=");
if (trim($_POST['add_mac']) == trim ($mac_addr))
{
$insert = false;;
break;
}
}
}
if ($insert == true)
{
$line = "macallowed=" . trim($_POST['add_mac']) . " #" . trim($_POST['add_comment']) . "\n";
$pointeur=fopen($mac_allowed_list,"a");
fwrite ($pointeur, $line);
fclose ($pointeur);
exec ("sudo service chilli restart");
}
}
else {echo "$l_error_open_file $mac_allowed_list";}
}
break;
case 'del_mac' :
$tab=file($mac_allowed_list);
if ($tab)
{
$pointeur=fopen($mac_allowed_list,"w+");
foreach ($tab as $line)
{
$field=explode("#", $line);
$mac_addr=trim(trim($field[0],"macallowed="));
$remove_line = false;
foreach ($_POST as $key => $value)
{
if ($mac_addr == $key)
{
$remove_line = True;
break;
}
}
if (! $remove_line) {fwrite($pointeur,$line);}
}
fclose($pointeur);
exec ("sudo service chilli restart");
}
else {echo "$l_error_open_file $mac_allowed_list";}
break;
}
}
?>
208,63 → 135,5
</td></tr>
</TABLE>
</TABLE>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><?php echo $l_trusted_mac ;?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</TABLE>
 
<table width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td colspan=2 align="center">
<?
echo "$l_trusted_mac_explain</td></tr>";
echo "<tr><td align='center' valign='middle'>";
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
echo "<table cellspacing=2 cellpadding=3 border=1>";
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>";
// On lit et on affiche le fichier d'exception
$display_form = true;
if (is_file ($mac_allowed_list))
{
$tab=file($mac_allowed_list);
if ($tab) # le fichier n'est pas vide
{
foreach ($tab as $line)
{
$field=explode("#", $line);
$mac_addr=trim(trim($field[0],"macallowed="));
$mac_info=trim($field[1],"#");
echo "<tr><td>$mac_addr";
echo "<td>$mac_info";
echo "<td><input type='checkbox' name='$mac_addr'>";
echo "</tr>";
}
}
else { $display_form = false;}
}
else {
echo "$l_error_open_file $mac_allowed_list";
$display_form = false;
}
echo "</table>";
if ($display_form)
{
echo "<input type='hidden' name='choix' value='del_mac'>";
echo "<input type='submit' value='$l_submit2'>";
}
echo "</form></td><td valign='middle' align='center'>";
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
echo "<table cellspacing=2 cellpadding=3 border=1>";
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info";
?>
<td></td></tr>
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : PC of the boss</td><td></td></tr>
<tr><td><input type='text' name='add_mac' size='17'></td>
<td><input type='text' name='add_comment' size='10'></td>
<input type='hidden' name='choix' value='new_mac'>
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
</tr></table>
</form>
</td></tr>
</table>
</BODY>
</HTML>
/web/acc/admin/network2.php
0,0 → 1,48
<table width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td colspan=2 align="center">
<?
echo "$l_static_dhcp_title</td></tr>";
echo "<tr><td align='center' valign='middle'>";
echo "<FORM action='network.php' method='POST'>";
echo "<table cellspacing=2 cellpadding=3 border=1>";
echo "<tr><th>$l_mac_address<th>$l_ip_address<th>$l_mac_del</tr>";
// Read the "ether" file
$line_exist=False;
$tab=file(ETHERS_FILE);
if ($tab) # le fichier n'est pas vide
{
$line_exist=True;
foreach ($tab as $line)
{
$field=explode(" ", $line);
$mac_addr=$field[0];
$ip_addr=$field[1];
echo "<tr><td>$mac_addr";
echo "<td>$ip_addr";
echo "<td><input type='checkbox' name='$mac_addr'>";
echo "</tr>";
}
}
echo "</table>";
if ($line_exist)
{
echo "<input type='hidden' name='choix' value='del_mac'>";
echo "<input type='submit' value='$l_submit'>";
}
echo "</form></td><td valign='middle' align='center'>";
echo "<FORM action='network.php' method='POST'>";
echo "<table cellspacing=2 cellpadding=3 border=1>";
echo "<tr><th>$l_mac_address<th>$l_ip_address";
?>
<td></td></tr>
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : 192.168.182.10</td><td></td></tr>
<tr><td><input type='text' name='add_mac' size='17'></td>
<td><input type='text' name='add_ip' size='10'></td>
<input type='hidden' name='choix' value='new_mac'>
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
</tr></table>
</form>
</td></tr>
</table>
</BODY>
</HTML>
/web/acc/system.php
2,7 → 2,7
$select[0]=$l_activity;
$select[1]=$l_network;
$select[2]=$l_ldap;
$select[3]=Services;
$select[3]="Services";
$fich[0]="admin/activity.php";
$fich[1]="admin/network.php";
$fich[2]="admin/ldap.php";