1 |
root |
1 |
<?php
|
|
|
2 |
/* written by steweb57 */
|
|
|
3 |
|
|
|
4 |
# Choice of language
|
|
|
5 |
$Language = 'en';
|
|
|
6 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
7 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
8 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
9 |
if($Language == 'fr'){
|
|
|
10 |
$l_network_title = "Configuration réseau";
|
|
|
11 |
$l_network_title1 = "Gestion de la configuration réseau";
|
|
|
12 |
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
|
|
|
13 |
$l_eth1_legend = "Eth1 (Réseau de consultation)";
|
|
|
14 |
$l_internet_legend = "INTERNET";
|
59 |
richard |
15 |
$l_ip_adr = "Adresse IP";
|
|
|
16 |
$l_ip_mask = "Masque";
|
1 |
root |
17 |
$l_ip_router = "Passerelle";
|
30 |
richard |
18 |
$l_ip_public = "Adresse IP public";
|
59 |
richard |
19 |
$l_ip_dns1 = "DNS1";
|
|
|
20 |
$l_ip_dns2 = "DNS2";
|
|
|
21 |
$l_service_title = "Nom du services";
|
|
|
22 |
$l_service_start = "Démarrer";
|
|
|
23 |
$l_service_stop = "Arrêter";
|
|
|
24 |
$l_service_restart = "Redémarrer";
|
|
|
25 |
$l_service_status = "Status";
|
|
|
26 |
$l_service_action = "Actions";
|
|
|
27 |
$l_enable = "actif";
|
|
|
28 |
$l_disable = "inactif";
|
1 |
root |
29 |
} else {
|
|
|
30 |
$l_network_title = "Network configuration";
|
37 |
richard |
31 |
$l_network_title1 = "Network configuration managment";
|
1 |
root |
32 |
$l_eth0_legend = "Eth0 (Internet connected interface)";
|
|
|
33 |
$l_eth1_legend = "Eth1 (Private network)";
|
|
|
34 |
$l_internet_legend = "INTERNET";
|
59 |
richard |
35 |
$l_ip_adr = "IP Address";
|
|
|
36 |
$l_ip_mask = "Mask";
|
1 |
root |
37 |
$l_ip_router = "Router";
|
30 |
richard |
38 |
$l_ip_public = "Public IP address";
|
59 |
richard |
39 |
$l_ip_dns1 = "DNS1 :";
|
|
|
40 |
$l_ip_dns2 = "DNS2";
|
|
|
41 |
$l_service_title = "Name of service";
|
|
|
42 |
$l_service_start = "Start";
|
|
|
43 |
$l_service_stop = "Stop";
|
|
|
44 |
$l_service_restart = "Restart";
|
|
|
45 |
$l_service_status = "Status";
|
|
|
46 |
$l_service_action = "Actions";
|
|
|
47 |
$l_enable = "enable";
|
|
|
48 |
$l_disable = "disable";
|
1 |
root |
49 |
}
|
|
|
50 |
|
|
|
51 |
/********************************************************************
|
|
|
52 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
|
|
53 |
*********************************************************************/
|
|
|
54 |
|
|
|
55 |
define ("ALCASAR_CHILLI", "/etc/chilli/config");
|
30 |
richard |
56 |
define ("ALCASAR_ETH0", "/etc/sysconfig/network-scripts/default-ifcfg-eth0");
|
1 |
root |
57 |
define ("ALCASAR_ETH1", "/etc/sysconfig/network-scripts/ifcfg-eth1");
|
|
|
58 |
|
|
|
59 |
/********************************************************************
|
|
|
60 |
* TEST DES FICHIERS DE CONFIGURATION *
|
|
|
61 |
*********************************************************************/
|
|
|
62 |
|
|
|
63 |
//Test de présence et des droits en lecture des fichiers de configuration.
|
|
|
64 |
if (!file_exists(ALCASAR_CHILLI)){
|
|
|
65 |
exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
|
|
|
66 |
}
|
|
|
67 |
if (!file_exists(ALCASAR_ETH0)){
|
|
|
68 |
exit("Fichier de configuration ".ALCASAR_ETH0." non présent");
|
|
|
69 |
}
|
|
|
70 |
if (!file_exists(ALCASAR_ETH0)){
|
|
|
71 |
exit("Fichier de configuration ".ALCASAR_ETH1." non présent");
|
|
|
72 |
}
|
|
|
73 |
if (!is_readable(ALCASAR_ETH0)){
|
|
|
74 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH0);
|
|
|
75 |
}
|
|
|
76 |
if (!is_readable(ALCASAR_ETH0)){
|
|
|
77 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH1);
|
|
|
78 |
}
|
|
|
79 |
|
59 |
richard |
80 |
//fonction pour faire une action (start,stop,restart) sur un service
|
|
|
81 |
function serviceExec($service, $action){
|
|
|
82 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
|
|
83 |
exec("sudo /sbin/service $service $action",$retval, $retstatus);
|
|
|
84 |
return $retstatus;
|
|
|
85 |
} else {
|
|
|
86 |
return false;
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
//fonction définissant le status d'un service
|
|
|
90 |
//(en fonction de la présence d'un mot clé dans la valeur de status)
|
|
|
91 |
function checkServiceStatus($service, $strMatch){
|
|
|
92 |
$response = false;
|
|
|
93 |
exec("sudo /sbin/service $service status",$retval);
|
|
|
94 |
foreach( $retval as $val ) {
|
|
|
95 |
if (strpos($val,$strMatch)){
|
|
|
96 |
$response = true;
|
|
|
97 |
break;
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
return $response;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
//-------------------------------
|
|
|
104 |
// Les actions sur un service
|
|
|
105 |
//-------------------------------
|
|
|
106 |
//sécurité sur les actions à réaliser
|
|
|
107 |
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","squid","named","sshd");
|
|
|
108 |
$autorizeAction = array("start","stop","restart");
|
|
|
109 |
|
|
|
110 |
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
|
|
|
111 |
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
|
|
|
112 |
$execStatus = serviceExec($_GET['service'], $_GET['action']);
|
|
|
113 |
// execStatus non exploité
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
//-------------------------------
|
|
|
117 |
//recherche du status des services
|
|
|
118 |
//-------------------------------
|
|
|
119 |
$serviceStatus = array();
|
|
|
120 |
$serviceStatus['radiusd'] = checkServiceStatus("radiusd","pid");
|
|
|
121 |
$serviceStatus['chilli'] = checkServiceStatus("chilli","pid");
|
|
|
122 |
$serviceStatus['dansguardian'] = checkServiceStatus("dansguardian","pid");
|
|
|
123 |
$serviceStatus['mysqld'] = checkServiceStatus("mysqld","OK");
|
|
|
124 |
$serviceStatus['squid'] = checkServiceStatus("squid","pid");
|
|
|
125 |
$serviceStatus['named'] = checkServiceStatus("named","up");
|
|
|
126 |
$serviceStatus['sshd'] = checkServiceStatus("sshd","pid");
|
|
|
127 |
|
|
|
128 |
// Fonction de test de connectivité internet
|
|
|
129 |
function internetTest(){
|
|
|
130 |
$host = "www.google.fr";
|
|
|
131 |
$port = "80";
|
|
|
132 |
//var $num; //non utilisé
|
|
|
133 |
//var $error; //non utilisé
|
|
|
134 |
|
|
|
135 |
if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
|
|
|
136 |
return false;
|
|
|
137 |
} else {
|
|
|
138 |
fclose($sock);
|
|
|
139 |
return true;
|
|
|
140 |
}
|
|
|
141 |
}
|
1 |
root |
142 |
/********************************************************************
|
|
|
143 |
* Lecture du fichier ALCASAR_CHILLI *
|
|
|
144 |
*********************************************************************/
|
|
|
145 |
$ouvre=fopen(ALCASAR_CHILLI,"r");
|
|
|
146 |
if ($ouvre){
|
|
|
147 |
while (!feof ($ouvre))
|
|
|
148 |
{
|
|
|
149 |
$tampon = fgets($ouvre, 4096);
|
|
|
150 |
if (strpos($tampon,"=")!==false){
|
|
|
151 |
$tmp = explode("=",$tampon);
|
|
|
152 |
$chilli[$tmp[0]] = $tmp[1];
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
}else{
|
|
|
156 |
exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
|
|
|
157 |
}
|
|
|
158 |
fclose($ouvre);
|
|
|
159 |
|
|
|
160 |
/********************************************************************
|
|
|
161 |
* Lecture du fichier ALCASAR_ETH0 *
|
|
|
162 |
*********************************************************************/
|
|
|
163 |
$ouvre=fopen(ALCASAR_ETH0,"r");
|
|
|
164 |
if ($ouvre){
|
|
|
165 |
while (!feof ($ouvre))
|
|
|
166 |
{
|
|
|
167 |
$tampon = fgets($ouvre, 4096);
|
|
|
168 |
if (strpos($tampon,"=")!==false){
|
|
|
169 |
$tmp = explode("=",$tampon);
|
|
|
170 |
$eth0[$tmp[0]] = $tmp[1];
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
}else{
|
|
|
174 |
exit("Erreur d'ouverture du fichier ".ALCASAR_ETH0);
|
|
|
175 |
}
|
|
|
176 |
fclose($ouvre);
|
|
|
177 |
|
|
|
178 |
/********************************************************************
|
|
|
179 |
* Lecture du fichier ALCASAR_ETH1 *
|
|
|
180 |
*********************************************************************/
|
|
|
181 |
$ouvre=fopen(ALCASAR_ETH1,"r");
|
|
|
182 |
if ($ouvre){
|
|
|
183 |
while (!feof ($ouvre))
|
|
|
184 |
{
|
|
|
185 |
$tampon = fgets($ouvre, 4096);
|
|
|
186 |
if (strpos($tampon,"=")!==false){
|
|
|
187 |
$tmp = explode("=",$tampon);
|
|
|
188 |
$eth1[$tmp[0]] = $tmp[1];
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
}else{
|
|
|
192 |
exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
|
|
|
193 |
}
|
|
|
194 |
fclose($ouvre);
|
|
|
195 |
|
|
|
196 |
/************************
|
30 |
richard |
197 |
* TO DO *
|
1 |
root |
198 |
*************************/
|
|
|
199 |
//modification de la conf réseau, cmd : ifconfig eth0 .....
|
30 |
richard |
200 |
//synchro de la modification réseau dans les différentes couches d'alcasar
|
1 |
root |
201 |
//gestion du dhcp (affichage,modification, ajout @static)
|
|
|
202 |
|
|
|
203 |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
59 |
richard |
204 |
<html><!-- written by steweb57 / rexy -->
|
1 |
root |
205 |
<head>
|
59 |
richard |
206 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
1 |
root |
207 |
<title><?php echo $l_network_title; ?></title>
|
|
|
208 |
<link rel="stylesheet" href="../css/style.css" type="text/css">
|
|
|
209 |
</head>
|
|
|
210 |
<body>
|
|
|
211 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
212 |
<tr><th><?php echo $l_network_title1; ?></th></tr>
|
|
|
213 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
214 |
</table>
|
|
|
215 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
|
|
|
216 |
<tr><td valign="middle" align="left">
|
|
|
217 |
<fieldset>
|
59 |
richard |
218 |
<legend><?php echo $l_internet_legend;
|
|
|
219 |
if (InternetTest()){
|
|
|
220 |
echo " <img src='/images/state_ok.gif'> $l_enable";
|
|
|
221 |
$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
|
|
|
222 |
else {
|
|
|
223 |
echo " <img src='/images/state_error.gif'> $l_disable";
|
|
|
224 |
$IP_PUB = "-.-.-.-";}
|
|
|
225 |
?></legend>
|
|
|
226 |
<table>
|
|
|
227 |
<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
|
|
|
228 |
<tr><td><?php echo $l_ip_dns1." : </td><td>".$eth0["DNS1"];?></td></tr>
|
|
|
229 |
<tr><td><?php echo $l_ip_dns2." : </td><td>".$eth0["DNS2"];?></td></tr>
|
|
|
230 |
</table>
|
|
|
231 |
</fieldset>
|
|
|
232 |
</td><td>
|
|
|
233 |
<fieldset>
|
1 |
root |
234 |
<legend><?php echo $l_eth0_legend; ?></legend>
|
|
|
235 |
<table>
|
30 |
richard |
236 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth0["IPADDR"];?></td></tr>
|
|
|
237 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth0["NETMASK"];?></td></tr>
|
|
|
238 |
<tr><td><?php echo $l_ip_router." : </td><td>".$eth0["GATEWAY"];?></td></tr>
|
1 |
root |
239 |
</table>
|
|
|
240 |
</fieldset>
|
59 |
richard |
241 |
</td><td>
|
1 |
root |
242 |
<fieldset>
|
|
|
243 |
<legend><?php echo $l_eth1_legend; ?></legend>
|
|
|
244 |
<table>
|
30 |
richard |
245 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth1["IPADDR"];?></td></tr>
|
|
|
246 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth1["NETMASK"];?></td></tr>
|
1 |
root |
247 |
</table>
|
|
|
248 |
</fieldset>
|
|
|
249 |
</td></tr>
|
|
|
250 |
</table>
|
59 |
richard |
251 |
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
252 |
<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>
|
|
|
253 |
<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>
|
|
|
254 |
</table>
|
|
|
255 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
256 |
<TR align="center">
|
|
|
257 |
<?php foreach( $serviceStatus as $serviceName => $statusOK ) { ?>
|
|
|
258 |
<tr>
|
|
|
259 |
<?php if ($statusOK) { ?>
|
|
|
260 |
<td><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
|
|
261 |
<td><?php echo $serviceName ;?></td>
|
|
|
262 |
<td width="30" align="center">---</td>
|
|
|
263 |
<td width="30" align="center"><a href="services.php?action=stop&service=<?php echo $serviceName;?>"><?php echo $l_service_stop;?></a></td>
|
|
|
264 |
<td width="30" align="center"><a href="services.php?action=restart&service=<?php echo $serviceName;?>"><?php echo $l_service_restart;?></a></td>
|
|
|
265 |
<?php } else { ?>
|
|
|
266 |
<td><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
|
|
|
267 |
<td><?php echo $serviceName ;?></td>
|
|
|
268 |
<td width="30" align="center"><a href="services.php?action=start&service=<?php echo $serviceName;?>"><?php echo $l_service_start;?></a></td>
|
|
|
269 |
<td width="30" align="center">---</td>
|
|
|
270 |
<td width="30" align="center">---</td>
|
|
|
271 |
<?php } ?>
|
|
|
272 |
</tr>
|
|
|
273 |
<?php } ?>
|
|
|
274 |
</td></tr></table>
|
|
|
275 |
</table>
|
1 |
root |
276 |
</body>
|
30 |
richard |
277 |
</html>
|