Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 719 → Rev 720

/web/admin/network.php
137,9 → 137,11
*********************************************************************/
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
//define ("ALCASAR_CONF_FILE", "/usr/local/etc/alcasar.conf");
define ("ALCASAR_CONF_FILE", "includes/alcasar.conf");
define ("ALCASAR_ETHERS", "/usr/local/etc/alcasar-ethers");
define ("ALCASAR_DNS_NAME", "/usr/local/etc/alcasar-dns-name");
define ("ALCASAR_CONF_FILE", "includes/alcasar.conf"); // uniquement pour le développement
//define ("ALCASAR_ETHERS", "/usr/local/etc/alcasar-ethers");
define ("ALCASAR_ETHERS", "includes/alcasar-ethers"); // uniquement pour le développement
//define ("ALCASAR_DNS_NAME", "/usr/local/etc/alcasar-dns-name");
define ("ALCASAR_DNS_NAME", "includes/alcasar-dns-name"); // uniquement pour le développement
 
/********************************************************************
* TEST DES FICHIERS DE CONFIGURATION *
154,7 → 156,6
if (!file_exists(ALCASAR_CONF_FILE)){
exit("Fichier de configuration ".ALCASAR_CONF_FILE." non présent");
}
/*
if (!file_exists(ALCASAR_ETHERS)){
exit("Fichier de configuration ".ALCASAR_ETHERS." non présent");
}
170,7 → 171,6
if (!is_readable(ALCASAR_DNS_NAME)){
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_DNS_NAME);
}
*/
 
/********************************************************************
* PARSING DES FICHIERS DE CONFIGURATION *
189,6 → 189,16
$alcasar_conf[trim($tmp[0])] = trim($tmp[1]);
}
}
 
function CIDRToNetmask($test){
// FONCTION A CREER
return "255.255.255.0";
}
 
$PUBLIC_IP = explode("/",$alcasar_conf["PUBLIC_IP"]);
$PUBLIC_IP_NETMASK = CIDRToNetmask($PUBLIC_IP[1]);
$PRIVATE_IP = explode("/",$alcasar_conf["PRIVATE_IP"]);
$PRIVATE_IP_NETMASK = CIDRToNetmask($PRIVATE_IP[1]);
/*
chilli parser
*/
208,10 → 218,15
/*
dnsname parser
*/
/*
 
$lines = file(ALCASAR_DNS_NAME);
$dnsadresse = array();
$dnsadresse['address'] = array();
$dnsadresse['cname'] = array();
$dnsadresse['domain'] = array();
$n = 0;
$m = 0;
$o = 0;
foreach($lines as $line)
{
if (preg_match('/^[[:space:]]*#/',$line)) // on ignore les commentaires (ligne débutant par #)
220,25 → 235,55
if (strpos($line,"/")!==false){
$tmp = explode("/",$line);
if (count($tmp) == 3) {
$dnsadresse[$n]['DNSNAME'] = $tmp[1];
$dnsadresse[$n]['IPADDR'] = $tmp[2];
$dnsadresse['address'][$n]['DNSNAME'] = $tmp[1];
$dnsadresse['address'][$n]['IPADDR'] = $tmp[2];
$n++;
}
}
}
if (preg_match("/^(cname=)/", trim($line))){ // on parse toutes les lignes commencant par "cname="
if (strpos($line,"=")!==false){
$tmp = explode("=",$line);
if (count($tmp) == 2) {
if (strpos($tmp[1],",")!==false){
$tmp = explode(",",$tmp[1]);
if (count($tmp) == 2) {
$dnsadresse['cname'][$m]['ALIAS'] = $tmp[0];
$dnsadresse['cname'][$m]['HOST'] = $tmp[1];
$m++;
}
}
}
}
}
if (preg_match("/^(domain=\/)/", trim($line))){ // on parse toutes les lignes commencant par "domain="
if (strpos($line,"/")!==false){
$tmp = explode("/",$line);
if (count($tmp) == 3) {
$dnsadresse['domain'][$o]['DOMAIN'] = $tmp[1];
$dnsadresse['domain'][$o]['IPADDR'] = $tmp[2];
$o++;
}
}
}
}
*/
$n = 0;
$m = 0;
$o = 0;
/*
ethers parser
BUG COOVA PRESENT : LE CHAMP DESCRIPTION EST TOUJOURS VIDE
BUG COOVA PRESENT : LE CHAMP DESCRIPTION EST TOUJOURS VIDE (bug à vérifier)
 
refaire une expression régulaire pour ne matcher que les lignes avec des mac, ou laisser tel quel afin de voir les erreurs dans le fichier de conf?
 
*/
/*
 
$lines = file(ALCASAR_ETHERS);
$ethers = array();
$n = 0;
foreach($lines as $line)
{
if (preg_match('^[[:space:]]*#',$line)) // on ignore les commentaires (ligne débutant par #)
if (preg_match('/^[[:space:]]*#/',$line)) // on ignore les commentaires (ligne débutant par #)
continue;
$tmp = preg_split("/\s/",$line,2);
if (count($tmp) == 2) {
256,7 → 301,22
$n++;
}
}
*/
 
 
// Fonction de test de connectivité internet
function internetTest(){
$host = "www.google.fr"; # Google Test
$port = "80";
//var $num; //non utilisé
//var $error; //non utilisé
if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
return false;
} else {
fclose($sock);
return true;
}
}
/********************************************************************
* AFFICHAGE DE LA PAGE *
*********************************************************************/
271,7 → 331,9
<link type="text/css" rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/ui-lightness/jquery-ui-1.8.10.custom.css">
<!-- include custom page CSS -->
<style type="text/css">
 
.tablewidth {
width:550px;
}
</style>
<!-- include JQUERY -->
<script type="text/javascript" src="<?php echo ALCASAR_ADMIN_PATH_JS; ?>/jquery-1.5.min.js"></script>
284,7 → 346,157
// Tabs
$('#tabs').tabs();
$( "button, input:submit, input:button, input:reset").button();
// NetMask-CIDR for all network interfaces
$('#WAN-cidr').change(function () {
$('#WAN-mask').val(CIDRToNetmask($('#WAN-cidr').val()));
});
$('#WAN-mask').change(function () {
$('#WAN-cidr').val(netmaskToCIDR($('#WAN-mask').val()));
});
$('#LAN-cidr').change(function () {
$('#LAN-mask').val(CIDRToNetmask($('#LAN-cidr').val()));
});
$('#LAN-mask').change(function () {
$('#LAN-cidr').val(netmaskToCIDR($('#LAN-mask').val()));
});
 
});
 
function h_fillbitsfromleft(num)
{
/*
author : Guido Socher (script from tuxgraphics.org)
*/
if (num >= 8 ){
return(255);
}
bitpat=0xff00;
while (num > 0){
bitpat=bitpat >> 1;
num--;
}
return(bitpat & 0xff);
}
function h_countbitsfromleft(num)
{
/*
author : Guido Socher (script from tuxgraphics.org)
*/
if (num == 255 ){
return(8);
}
i = 0;
bitpat=0xff00;
while (i < 8){
if (num == (bitpat & 0xff)){
return(i);
}
bitpat=bitpat >> 1;
i++;
}
return(Number.NaN);
}
function netmaskToCIDR(mask){
//test netmask
if (!isNetMask(mask)) return false;
//calculate CIDR
var bits = mask.split('.');
sumofbits=0;
for(bit in bits){
tmpvar = parseInt(bits[bit],10);
if (isNaN(tmpvar)){
return false;
}
bitsfromleft=h_countbitsfromleft(tmpvar);
if (isNaN(bitsfromleft)){
return false;
}
sumofbits+=bitsfromleft;
}
//return CIDR
return sumofbits;
}
function isIpV4(ip){
var bits = ip.split('.');
var regEx = /[^0-9]/;
if (bits.length !=4){
return false;
}
for(bit in bits){
if ((bits[bit]=='')||(bits[bit].length>3)||(regEx.test(bits[bit]))){
return false;
}
}
if (parseInt(bits[0],10)==0){
return false;
}
return true;
}
function isNetMask(mask){
var bits = mask.split('.');
var regEx = /[^0-9]/;
if (bits.length !=4)
{
return false;
}
for(bit in bits){
if ((bits[bit]=='')||(bits[bit].length>3)||(regEx.test(bits[bit]))){
return false;
}
}
if (parseInt(bits[0],10) != 255){
if ((parseInt(bits[1],10) != 0)) return false;
if ((parseInt(bits[2],10) != 0)) return false;
if ((parseInt(bits[3],10) != 0)) return false;
}
if (parseInt(bits[1],10) != 255){
if ((parseInt(bits[2],10) != 0)) return false;
if ((parseInt(bits[3],10) != 0)) return false;
}
if (parseInt(bits[2],10) != 255){
if ((parseInt(bits[3],10) != 0)) return false;
}
return true;
}
 
function CIDRToNetmask(cidr){
//test CIDR
//format : 0 < cidr < 33
cidr = parseInt(cidr,10);
if ((isNaN(cidr))||(cidr > 32)||(cidr < 0)) return false;
//calculate Netmask
bit1 = "";
bit2 = "";
bit3 = "";
bit4 = "";
if (cidr<=8){
bit1 = h_fillbitsfromleft(cidr);
bit2 = "0";
bit3 = "0";
bit4 = "0";
} else if (cidr<=16){
bit1 = "255";
bit2 = h_fillbitsfromleft(cidr-8);
bit3 = "0";
bit4 = "0";
} else if (cidr<=24){
bit1 = "255";
bit2 = "255";
bit3 = h_fillbitsfromleft(cidr-16);
bit4 = "0";
} else if (cidr<=32){
bit1 = "255";
bit2 = "255";
bit3 = "255";
bit4 = h_fillbitsfromleft(cidr-24);
} else {
return false;
}
//return Netmask
return bit1+"."+bit2+"."+bit3+"."+bit4
}
</script>
</head>
<body>
293,13 → 505,16
<li><a href="#tabs-wan"><?php echo $l_wan; ?></a></li>
<li><a href="#tabs-lan"><?php echo $l_lan; ?></a></li>
<li><a href="#tabs-dns-local"><?php echo $l_local_dns; ?></a></li>
<li><a href="#tabs-dhcp"><?php echo $l_dhcp; ?></a></li>
<li><a href="#tabs-dhcp"><?php echo $l_dhcp; ?> et réseravation IP</a></li>
<!--
<li><a href="#tabs-route"><?php echo $l_route; ?></a></li>
<li><a href="#tabs-filter">Filtrage MAC</a></li>
-->
</ul>
<!-- -->
<div id="tabs-wan">
<form method="post" name="form_wan" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table class="ui-widget ui-widget-content">
<table class="ui-widget ui-widget-content tablewidth">
<thead>
<tr class="ui-widget-header"><th colspan="2"><?php echo $l_internet_title; ?></th></tr>
</head>
306,14 → 521,13
<tbody>
<tr><td><?php echo $l_state; ?> :</td>
<td><?php
/*
if (InternetTest()){
echo " <img src='../images/state_ok.gif'> $l_enable";
$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";
$IP_PUB = "-.-.-.-";}
*/
echo " <img src='../images/state_ok.gif'> $l_enable";
$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";
$IP_PUB = "-.-.-.-";
}
?>
</td></tr>
<tr><td><?php echo $l_ip_public; ?> :</td><td><?php //echo $IP_PUB; ?></td></tr>
321,13 → 535,11
<tr class="ui-widget-header"><th colspan="2"><?php echo $l_eth0_title; ?></th></tr>
<tr><td><?php echo $l_ip; ?> :</td>
<td>
<input type="text" name="WAN-ip" id="WAN-ip" value="<?php echo $alcasar_conf["PUBLIC_IP"]; ?>" class="text">
<input type="text" name="WAN-ip" id="WAN-ip" value="<?php echo $PUBLIC_IP[0]; ?>" class="text"> /<input type="text" name="WAN-cidr" id="WAN-cidr" value="<?php echo $PUBLIC_IP[1]; ?>" class="text" size="2" maxlength="2">
</td>
</tr>
<tr><td><?php echo $l_mask;
$WAN_mask="en cour";
?> :</td><td>
<input type="text" name="WAN-mask" id="WAN-mask" value="<?php echo $WAN_mask; ?>" class="text">
<tr><td><?php echo $l_mask; ?> :</td><td>
<input type="text" name="WAN-mask" id="WAN-mask" value="<?php echo $PUBLIC_IP_NETMASK ; ?>" class="text">
</td></tr>
<tr><td><?php echo $l_gateway; ?> :</td><td>
<input type="text" name="WAN-gateway" id="WAN-gateway" value="<?php echo $alcasar_conf["GW"]; ?>" class="text">
346,13 → 558,13
</div>
<div id="tabs-lan">
<form method="post" name="form_lan" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table class="ui-widget ui-widget-content">
<table class="ui-widget ui-widget-content tablewidth">
<thead>
<tr class="ui-widget-header"><th colspan="2"><?php echo $l_eth1_title; ?></th></tr>
</thead>
<tbody>
<tr><td><?php echo $l_ip; ?> :</td><td><input type="text" name="eth0-ip" id="eth0-ip" value="<?php echo $alcasar_conf["PRIVATE_IP"]; ?>" class="text"></td></tr>
<tr><td><?php echo $l_mask; ?> :</td><td><input type="text" name="eth0-ip" id="eth0-ip" value="EN COUR" class="text"></td></tr>
<tr><td><?php echo $l_ip; ?> :</td><td><input type="text" name="eth0-ip" id="eth0-ip" value="<?php echo $PRIVATE_IP[0]; ?>" class="text"> /<input type="text" name="LAN-cidr" id="LAN-cidr" value="<?php echo $PRIVATE_IP[1]; ?>" class="text" size="2" maxlength="2"></td></tr>
<tr><td><?php echo $l_mask; ?> :</td><td><input type="text" name="eth0-ip" id="eth0-ip" value="<?php echo $PRIVATE_IP_NETMASK; ?>" class="text"></td></tr>
<tr><td colspan ="2"><br /></td></tr>
<tr><td><input type="submit" value="Modifier" class="text"></td><td><br /></td></tr>
</tbody>
360,22 → 572,25
</form>
</div>
<div id="tabs-dns-local">
<table border="0" id="dns-local" class="ui-widget ui-widget-content">
<font color='red' size="8">Une liste par type d'entrée DNS (exemple actuel), ou un seul tableau global avec tri et colonne indiquant le type?</font>
<br />
<h2>Liste des hôtes DNS</h2>
<table border="0" id="dns-local" class="ui-widget ui-widget-content tablewidth">
<thead>
<tr class="ui-widget-header"><th><?php echo $l_ip_row_title; ?></th><th></th><th><?php echo $l_host_row_title; ?></th><th class="col_action" scope="col" colspan="2"></th></tr>
</thead>
<tbody>
<?php
//foreach ($dnsadresse as $dns_entry){
foreach ($dnsadresse['address'] as $dns_adress){
?>
<tr>
<td><?php echo "IP"; ?></td>
<td><?php echo $dns_adress['IPADDR']; ?></td>
<td> </td>
<td><?php echo "DOMAINE"; ?></td>
<td><?php echo $dns_adress['DNSNAME']; ?></td>
<td class="col_action" colspan="2"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/delete.png"></td>
</tr>
<?php
//}
}
?>
<tr>
<td>
393,6 → 608,72
</tr>
</tbody>
</table>
<h2>Liste des alias DNS</h2>
<table border="0" id="dns-local" class="ui-widget ui-widget-content tablewidth">
<thead>
<tr class="ui-widget-header"><th><?php echo $l_host_row_title; ?></th><th></th><th>Alias</th><th class="col_action" scope="col" colspan="2"></th></tr>
</thead>
<tbody>
<?php
foreach ($dnsadresse['cname'] as $dns_adress){
?>
<tr>
<td><?php echo $dns_adress['HOST']; ?></td>
<td> </td>
<td><?php echo $dns_adress['ALIAS']; ?></td>
<td class="col_action" colspan="2"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/delete.png"></td>
</tr>
<?php
}
?>
<tr>
<td>
<input type="text" value="" maxlength="100" size="30" class="text" name="alias_host_name" id="alias_host_name">
</td>
<td> </td>
<td>
<input type="text" value="" maxlength="100" size="30" class="text" name="alias_alias_name" id="alias_alias_name">
</td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/add.png"></td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/chart_organisation.png"></td>
</tr>
</tbody>
</table>
<h2>Liste des domaines locaux</h2>
<table border="0" id="dns-local" class="ui-widget ui-widget-content tablewidth">
<thead>
<tr class="ui-widget-header"><th>Adresse IP serveur DNS</th><th></th><th>Domaine</th><th class="col_action" scope="col" colspan="2"></th></tr>
</thead>
<tbody>
<?php
foreach ($dnsadresse['domain'] as $dns_adress){
?>
<tr>
<td><?php echo $dns_adress['IPADDR']; ?></td>
<td> </td>
<td><?php echo $dns_adress['DOMAIN']; ?></td>
<td class="col_action" colspan="2"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/delete.png"></td>
</tr>
<?php
}
?>
<tr>
<td>
<input type="text" readonly="readonly" value="192" maxlength="3" size="3" class="readonly" name="dhcp_static_ipaddr_p0" id="dhcp_static_ipaddr_p0">.
<input type="text" readonly="readonly" value="168" maxlength="3" size="3" class="readonly" name="dhcp_static_ipaddr_p1" id="dhcp_static_ipaddr_p1">.
<input type="text" readonly="readonly" value="182" maxlength="3" size="3" class="readonly" name="dhcp_static_ipaddr_p2" id="dhcp_static_ipaddr_p2">.
<input type="text" value="" maxlength="3" size="3" class="text" name="dhcp_static_ipaddr_p3" id="dhcp_static_ipaddr_p3">
</td>
<td> </td>
<td>
<input type="text" value="" maxlength="100" size="50" class="text" name="dhcp_static_macaddr_p0" id="dhcp_static_macaddr_p0">
</td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/add.png"></td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/chart_organisation.png"></td>
</tr>
</tbody>
</table>
</div>
<div id="tabs-dhcp">
<div id="dhcp">
400,12 → 681,12
<h3 class="ui-widget-header"><?php echo $l_dhcp_server; ?></h3>
<form name="form_dhcp" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="dhcp_conf_form">
<table class="ui-widget ui-widget-content">
<table class="ui-widget ui-widget-content tablewidth">
<tr><td><?php echo $l_dhcp_activation; ?> :</td>
<td>
<select name="" class="text">
<option><?php echo $l_yes; ?></option>
<option<?php echo $l_no; ?>></option>
<option><?php echo $l_no; ?></option>
</select>
</td>
</tr>
425,9 → 706,9
<input type="text" value="" maxlength="3" size="3" class="text" name="dhcp_static_ipaddr_p3" id="dhcp_static_ipaddr_p3">
</td>
</tr>
<tr><td>MTU :</td><td><input type="text" value="1500" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td><?php echo $l_dhcp_bail; ?> :</td><td><input type="text" value="600" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td>Grâce :</td><td><input type="text" value="60" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td>MTU :</td><td><input type="text" value="1500 (conf)" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td><?php echo $l_dhcp_bail; ?> :</td><td><input type="text" value="600 (conf)" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td>Grâce :</td><td><input type="text" value="60 (conf)" maxlength="8" size="8" class="text" name="" id=""></td></tr>
<tr><td colspan ="2"><br /></td></tr>
<tr><td><input type="submit" value="Modifier" class="text"></td><td></td></tr>
</table>
446,18 → 727,18
</thead>
<tbody>
<?php
//foreach ($ethers as $ip_static){
foreach ($ethers as $ip_static){
?>
<tr>
<td><?php //echo $ip_static['IP']; ?></td>
<td><?php echo $ip_static['IPADDR']; ?></td>
<td> </td>
<td><?php //echo $ip_static['MAC']; ?></td>
<td><?php echo $ip_static['MAC']; ?></td>
<td> </td>
<td><?php //echo $ip_static['DESCRIPTION']; ?></td>
<td><?php echo $ip_static['DESCRIPTION']; ?></td>
<td class="col_action" colspan="2"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/delete.png"></td>
</tr>
<?php
//}
}
?>
<tr>
<td>
485,6 → 766,7
</div>
</div>
</div>
<!--
<div id="tabs-route">
Alcasar est la passerelle par défaut des postes du réseau de consulation.<br />
Si un réseau est accessible par une autre passerelle présente sur le réseau de consultation vous pouvez le préciser içi.<br />
534,6 → 816,49
</tbody>
</table>
</div>
<div id="tabs-filter">
<h1>Filtrage MAC</h1>
<form>
<table><tr><td>Activation du filtrage</td><td><input type="radio">activé <input type="radio">désactivé</td></tr></table>
</form>
<h1>Adresses MAC autorisées</h1>
<form>
<table border="0" id="dhcp_static" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header"><th>#</th><th><?php echo $l_mac_row_title; ?></th><th></th><th class="col_action" scope="col" colspan="2"></th></tr>
</thead>
<tbody>
<?php
//foreach ($ethers as $ip_static){
?>
<tr>
<td>1</td>
<td>08:00:55:DF:EE:00</td>
<td>station de toto</td>
<td class="col_action" colspan="2"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/delete.png"></td>
</tr>
<?php
//}
?>
<tr>
<td> </td>
<td>
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p0" id="dhcp_static_macaddr_p0">:
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p1" id="dhcp_static_macaddr_p1">:
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p2" id="dhcp_static_macaddr_p2">:
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p3" id="dhcp_static_macaddr_p3">:
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p4" id="dhcp_static_macaddr_p4">:
<input type="text" value="" maxlength="2" size="2" class="text" name="dhcp_static_macaddr_p5" id="dhcp_static_macaddr_p0">
</td>
<td><input type="text" value="" maxlength="20" size="20" class="text" name="dhcp_static_description" id="dhcp_static_description"></td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/add.png"></td>
<td class="col_action"><image src="<?php echo ALCASAR_ADMIN_PATH_IMG; ?>/chart_organisation.png"></td>
</tr>
</tbody>
</table>
</form>
</div>
-->
</div>
</body>
</html>