Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 40 → Rev 59

/gestion/admin/services.php
File deleted
/gestion/admin/network.php
12,12 → 12,20
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
$l_eth1_legend = "Eth1 (Réseau de consultation)";
$l_internet_legend = "INTERNET";
$l_ip_adr = "Adresse IP";
$l_ip_mask = "Masque";
$l_ip_adr = "Adresse IP";
$l_ip_mask = "Masque";
$l_ip_router = "Passerelle";
$l_ip_public = "Adresse IP public";
$l_ip_dns1 = "DNS1";
$l_ip_dns2 = "DNS2";
$l_ip_dns1 = "DNS1";
$l_ip_dns2 = "DNS2";
$l_service_title = "Nom du services";
$l_service_start = "Démarrer";
$l_service_stop = "Arrêter";
$l_service_restart = "Redémarrer";
$l_service_status = "Status";
$l_service_action = "Actions";
$l_enable = "actif";
$l_disable = "inactif";
} else {
$l_network_title = "Network configuration";
$l_network_title1 = "Network configuration managment";
24,12 → 32,20
$l_eth0_legend = "Eth0 (Internet connected interface)";
$l_eth1_legend = "Eth1 (Private network)";
$l_internet_legend = "INTERNET";
$l_ip_adr = "IP Address";
$l_ip_mask = "Mask";
$l_ip_adr = "IP Address";
$l_ip_mask = "Mask";
$l_ip_router = "Router";
$l_ip_public = "Public IP address";
$l_ip_dns1 = "DNS1 :";
$l_ip_dns2 = "DNS2";
$l_ip_dns1 = "DNS1 :";
$l_ip_dns2 = "DNS2";
$l_service_title = "Name of service";
$l_service_start = "Start";
$l_service_stop = "Stop";
$l_service_restart = "Restart";
$l_service_status = "Status";
$l_service_action = "Actions";
$l_enable = "enable";
$l_disable = "disable";
}
 
/********************************************************************
61,10 → 77,71
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH1);
}
 
//fonction pour faire une action (start,stop,restart) sur un service
function serviceExec($service, $action){
if (($action == "start")||($action == "stop")||($action == "restart")){
exec("sudo /sbin/service $service $action",$retval, $retstatus);
return $retstatus;
} else {
return false;
}
}
//fonction définissant le status d'un service
//(en fonction de la présence d'un mot clé dans la valeur de status)
function checkServiceStatus($service, $strMatch){
$response = false;
exec("sudo /sbin/service $service status",$retval);
foreach( $retval as $val ) {
if (strpos($val,$strMatch)){
$response = true;
break;
}
}
return $response;
}
 
//-------------------------------
// Les actions sur un service
//-------------------------------
//sécurité sur les actions à réaliser
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","squid","named","sshd");
$autorizeAction = array("start","stop","restart");
 
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
$execStatus = serviceExec($_GET['service'], $_GET['action']);
// execStatus non exploité
}
}
//-------------------------------
//recherche du status des services
//-------------------------------
$serviceStatus = array();
$serviceStatus['radiusd'] = checkServiceStatus("radiusd","pid");
$serviceStatus['chilli'] = checkServiceStatus("chilli","pid");
$serviceStatus['dansguardian'] = checkServiceStatus("dansguardian","pid");
$serviceStatus['mysqld'] = checkServiceStatus("mysqld","OK");
$serviceStatus['squid'] = checkServiceStatus("squid","pid");
$serviceStatus['named'] = checkServiceStatus("named","up");
$serviceStatus['sshd'] = checkServiceStatus("sshd","pid");
 
// Fonction de test de connectivité internet
function internetTest(){
$host = "www.google.fr";
$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;
}
}
/********************************************************************
* Lecture du fichier ALCASAR_CHILLI *
*********************************************************************/
//Lecture du fichier ALCASAR_ETH0
$ouvre=fopen(ALCASAR_CHILLI,"r");
if ($ouvre){
while (!feof ($ouvre))
83,8 → 160,6
/********************************************************************
* Lecture du fichier ALCASAR_ETH0 *
*********************************************************************/
 
//Lecture du fichier ALCASAR_ETH0
$ouvre=fopen(ALCASAR_ETH0,"r");
if ($ouvre){
while (!feof ($ouvre))
103,8 → 178,6
/********************************************************************
* Lecture du fichier ALCASAR_ETH1 *
*********************************************************************/
 
//Lecture du fichier ALCASAR_ETH1
$ouvre=fopen(ALCASAR_ETH1,"r");
if ($ouvre){
while (!feof ($ouvre))
120,14 → 193,6
}
fclose($ouvre);
 
 
/********************************************************************
* Recherche IP public *
*********************************************************************/
$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");
 
 
 
/************************
* TO DO *
*************************/
136,9 → 201,9
//gestion du dhcp (affichage,modification, ajout @static)
 
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><!-- written by steweb57 -->
<html><!-- written by steweb57 / rexy -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $l_network_title; ?></title>
<link rel="stylesheet" href="../css/style.css" type="text/css">
</head>
150,6 → 215,22
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td valign="middle" align="left">
<fieldset>
<legend><?php echo $l_internet_legend;
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 = "-.-.-.-";}
?></legend>
<table>
<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
<tr><td><?php echo $l_ip_dns1." : </td><td>".$eth0["DNS1"];?></td></tr>
<tr><td><?php echo $l_ip_dns2." : </td><td>".$eth0["DNS2"];?></td></tr>
</table>
</fieldset>
</td><td>
<fieldset>
<legend><?php echo $l_eth0_legend; ?></legend>
<table>
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth0["IPADDR"];?></td></tr>
157,7 → 238,7
<tr><td><?php echo $l_ip_router." : </td><td>".$eth0["GATEWAY"];?></td></tr>
</table>
</fieldset>
<br />
</td><td>
<fieldset>
<legend><?php echo $l_eth1_legend; ?></legend>
<table>
165,17 → 246,32
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth1["NETMASK"];?></td></tr>
</table>
</fieldset>
<br />
<fieldset>
<legend><?php echo $l_internet_legend; ?></legend>
<table>
<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
<tr><td><?php echo $l_ip_dns1." : </td><td>".$eth0["DNS1"];?></td></tr>
<tr><td><?php echo $l_ip_dns2." : </td><td>".$eth0["DNS2"];?></td></tr>
</table>
</fieldset>
<br />
</td></tr>
</table>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><th><?php echo $l_service_status;?></th><th><?php echo $l_service_title;?></th><th colspan="3"><?php echo $l_service_action;?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td><td><img src="/images/pix.gif" width="1" height="2"></td><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
<TR align="center">
<?php foreach( $serviceStatus as $serviceName => $statusOK ) { ?>
<tr>
<?php if ($statusOK) { ?>
<td><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
<td><?php echo $serviceName ;?></td>
<td width="30" align="center">---</td>
<td width="30" align="center"><a href="services.php?action=stop&service=<?php echo $serviceName;?>"><?php echo $l_service_stop;?></a></td>
<td width="30" align="center"><a href="services.php?action=restart&service=<?php echo $serviceName;?>"><?php echo $l_service_restart;?></a></td>
<?php } else { ?>
<td><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
<td><?php echo $serviceName ;?></td>
<td width="30" align="center"><a href="services.php?action=start&service=<?php echo $serviceName;?>"><?php echo $l_service_start;?></a></td>
<td width="30" align="center">---</td>
<td width="30" align="center">---</td>
<?php } ?>
</tr>
<?php } ?>
</td></tr></table>
</table>
</body>
</html>
/gestion/admin/activity.php
73,39 → 73,41
exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output);
while (list(,$ligne) = each($output)){
$detail = explode (" ", $ligne);
$nb_ligne ++;
echo "<FORM action='activity.php' method=POST>";
echo "<TR>";
echo "<TD>"; echo $nb_ligne; echo "</TD>";
echo "<TD>"; echo $detail[1]; echo "</TD>";
echo "<TD>"; echo $detail[0]; echo "</TD>";
echo "<TD>";
# station authorisée
if ($detail[4] == "1"){
if ($detail[1] != "0.0.0.0"){
$nb_ligne ++;
echo "<FORM action='activity.php' method=POST>";
echo "<TR>";
echo "<TD>"; echo $nb_ligne; echo "</TD>";
echo "<TD>"; echo $detail[1]; echo "</TD>";
echo "<TD>"; echo $detail[0]; echo "</TD>";
echo "<TD>";
# station authorisée
if ($detail[4] == "1"){
# par @MAC
if ($detail[5] == "-"){
echo "$l_mac_allowed</TD><TD>&nbsp;";}
if ($detail[5] == "-"){
echo "$l_mac_allowed</TD><TD>&nbsp;";}
# par usager authentifié
else {
echo "<a href=\"/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"Editer l'utilisateur $detail[5]\">$detail[5]</a>";
else {
echo "<a href=\"/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"Editer l'utilisateur $detail[5]\">$detail[5]</a>";
echo "</TD>";
echo "<TD>";
echo "<INPUT type='hidden' name='action' value='mac_unconnect'>";
echo "<INPUT type='hidden' name='user' value='$detail[5]'>";
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
echo "<INPUT type=submit value='$l_disconnect'>";
}
}
# station sans usager connecté
else {
echo "&nbsp;";
echo "</TD>";
echo "<TD>";
echo "<INPUT type='hidden' name='action' value='mac_unconnect'>";
echo "<INPUT type='hidden' name='user' value='$detail[5]'>";
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
echo "<INPUT type=submit value='$l_disconnect'>";
}
}
# station sans usager connecté
else {
echo "&nbsp;";
echo "</TD>";
echo "<TD>";
echo "<INPUT type='hidden' name='action' value='mac_unconnect'>";
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
echo "<INPUT type='submit' value='$l_dissociate'>";
echo "<INPUT type='submit' value='$l_dissociate'>";
}
echo "</TD></TR></FORM>";
}
echo "</TD></TR></FORM>";
}
?>
</td></tr>