Line 10... |
Line 10... |
10 |
$l_network_title = "Configuration réseau";
|
10 |
$l_network_title = "Configuration réseau";
|
11 |
$l_network_title1 = "Gestion de la configuration réseau";
|
11 |
$l_network_title1 = "Gestion de la configuration réseau";
|
12 |
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
|
12 |
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
|
13 |
$l_eth1_legend = "Eth1 (Réseau de consultation)";
|
13 |
$l_eth1_legend = "Eth1 (Réseau de consultation)";
|
14 |
$l_internet_legend = "INTERNET";
|
14 |
$l_internet_legend = "INTERNET";
|
15 |
$l_ip_adr = "Adresse IP";
|
15 |
$l_ip_adr = "Adresse IP";
|
16 |
$l_ip_mask = "Masque";
|
16 |
$l_ip_mask = "Masque";
|
17 |
$l_ip_router = "Passerelle";
|
17 |
$l_ip_router = "Passerelle";
|
18 |
$l_ip_public = "Adresse IP public";
|
18 |
$l_ip_public = "Adresse IP public";
|
19 |
$l_ip_dns1 = "DNS1";
|
19 |
$l_ip_dns1 = "DNS1";
|
20 |
$l_ip_dns2 = "DNS2";
|
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";
|
21 |
} else {
|
29 |
} else {
|
22 |
$l_network_title = "Network configuration";
|
30 |
$l_network_title = "Network configuration";
|
23 |
$l_network_title1 = "Network configuration managment";
|
31 |
$l_network_title1 = "Network configuration managment";
|
24 |
$l_eth0_legend = "Eth0 (Internet connected interface)";
|
32 |
$l_eth0_legend = "Eth0 (Internet connected interface)";
|
25 |
$l_eth1_legend = "Eth1 (Private network)";
|
33 |
$l_eth1_legend = "Eth1 (Private network)";
|
26 |
$l_internet_legend = "INTERNET";
|
34 |
$l_internet_legend = "INTERNET";
|
27 |
$l_ip_adr = "IP Address";
|
35 |
$l_ip_adr = "IP Address";
|
28 |
$l_ip_mask = "Mask";
|
36 |
$l_ip_mask = "Mask";
|
29 |
$l_ip_router = "Router";
|
37 |
$l_ip_router = "Router";
|
30 |
$l_ip_public = "Public IP address";
|
38 |
$l_ip_public = "Public IP address";
|
31 |
$l_ip_dns1 = "DNS1 :";
|
39 |
$l_ip_dns1 = "DNS1 :";
|
32 |
$l_ip_dns2 = "DNS2";
|
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";
|
33 |
}
|
49 |
}
|
34 |
|
50 |
|
35 |
/********************************************************************
|
51 |
/********************************************************************
|
36 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
52 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
37 |
*********************************************************************/
|
53 |
*********************************************************************/
|
Line 59... |
Line 75... |
59 |
}
|
75 |
}
|
60 |
if (!is_readable(ALCASAR_ETH0)){
|
76 |
if (!is_readable(ALCASAR_ETH0)){
|
61 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH1);
|
77 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH1);
|
62 |
}
|
78 |
}
|
63 |
|
79 |
|
- |
|
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 |
}
|
64 |
/********************************************************************
|
142 |
/********************************************************************
|
65 |
* Lecture du fichier ALCASAR_CHILLI *
|
143 |
* Lecture du fichier ALCASAR_CHILLI *
|
66 |
*********************************************************************/
|
144 |
*********************************************************************/
|
67 |
//Lecture du fichier ALCASAR_ETH0
|
- |
|
68 |
$ouvre=fopen(ALCASAR_CHILLI,"r");
|
145 |
$ouvre=fopen(ALCASAR_CHILLI,"r");
|
69 |
if ($ouvre){
|
146 |
if ($ouvre){
|
70 |
while (!feof ($ouvre))
|
147 |
while (!feof ($ouvre))
|
71 |
{
|
148 |
{
|
72 |
$tampon = fgets($ouvre, 4096);
|
149 |
$tampon = fgets($ouvre, 4096);
|
Line 81... |
Line 158... |
81 |
fclose($ouvre);
|
158 |
fclose($ouvre);
|
82 |
|
159 |
|
83 |
/********************************************************************
|
160 |
/********************************************************************
|
84 |
* Lecture du fichier ALCASAR_ETH0 *
|
161 |
* Lecture du fichier ALCASAR_ETH0 *
|
85 |
*********************************************************************/
|
162 |
*********************************************************************/
|
86 |
|
- |
|
87 |
//Lecture du fichier ALCASAR_ETH0
|
- |
|
88 |
$ouvre=fopen(ALCASAR_ETH0,"r");
|
163 |
$ouvre=fopen(ALCASAR_ETH0,"r");
|
89 |
if ($ouvre){
|
164 |
if ($ouvre){
|
90 |
while (!feof ($ouvre))
|
165 |
while (!feof ($ouvre))
|
91 |
{
|
166 |
{
|
92 |
$tampon = fgets($ouvre, 4096);
|
167 |
$tampon = fgets($ouvre, 4096);
|
Line 101... |
Line 176... |
101 |
fclose($ouvre);
|
176 |
fclose($ouvre);
|
102 |
|
177 |
|
103 |
/********************************************************************
|
178 |
/********************************************************************
|
104 |
* Lecture du fichier ALCASAR_ETH1 *
|
179 |
* Lecture du fichier ALCASAR_ETH1 *
|
105 |
*********************************************************************/
|
180 |
*********************************************************************/
|
106 |
|
- |
|
107 |
//Lecture du fichier ALCASAR_ETH1
|
- |
|
108 |
$ouvre=fopen(ALCASAR_ETH1,"r");
|
181 |
$ouvre=fopen(ALCASAR_ETH1,"r");
|
109 |
if ($ouvre){
|
182 |
if ($ouvre){
|
110 |
while (!feof ($ouvre))
|
183 |
while (!feof ($ouvre))
|
111 |
{
|
184 |
{
|
112 |
$tampon = fgets($ouvre, 4096);
|
185 |
$tampon = fgets($ouvre, 4096);
|
Line 118... |
Line 191... |
118 |
}else{
|
191 |
}else{
|
119 |
exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
|
192 |
exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
|
120 |
}
|
193 |
}
|
121 |
fclose($ouvre);
|
194 |
fclose($ouvre);
|
122 |
|
195 |
|
123 |
|
- |
|
124 |
/********************************************************************
|
- |
|
125 |
* Recherche IP public *
|
- |
|
126 |
*********************************************************************/
|
- |
|
127 |
$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");
|
- |
|
128 |
|
- |
|
129 |
|
- |
|
130 |
|
- |
|
131 |
/************************
|
196 |
/************************
|
132 |
* TO DO *
|
197 |
* TO DO *
|
133 |
*************************/
|
198 |
*************************/
|
134 |
//modification de la conf réseau, cmd : ifconfig eth0 .....
|
199 |
//modification de la conf réseau, cmd : ifconfig eth0 .....
|
135 |
//synchro de la modification réseau dans les différentes couches d'alcasar
|
200 |
//synchro de la modification réseau dans les différentes couches d'alcasar
|
136 |
//gestion du dhcp (affichage,modification, ajout @static)
|
201 |
//gestion du dhcp (affichage,modification, ajout @static)
|
137 |
|
202 |
|
138 |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
203 |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
139 |
<html><!-- written by steweb57 -->
|
204 |
<html><!-- written by steweb57 / rexy -->
|
140 |
<head>
|
205 |
<head>
|
141 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
206 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
142 |
<title><?php echo $l_network_title; ?></title>
|
207 |
<title><?php echo $l_network_title; ?></title>
|
143 |
<link rel="stylesheet" href="../css/style.css" type="text/css">
|
208 |
<link rel="stylesheet" href="../css/style.css" type="text/css">
|
144 |
</head>
|
209 |
</head>
|
145 |
<body>
|
210 |
<body>
|
146 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
211 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
Line 148... |
Line 213... |
148 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
213 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
149 |
</table>
|
214 |
</table>
|
150 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
|
215 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
|
151 |
<tr><td valign="middle" align="left">
|
216 |
<tr><td valign="middle" align="left">
|
152 |
<fieldset>
|
217 |
<fieldset>
|
- |
|
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>
|
153 |
<legend><?php echo $l_eth0_legend; ?></legend>
|
234 |
<legend><?php echo $l_eth0_legend; ?></legend>
|
154 |
<table>
|
235 |
<table>
|
155 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth0["IPADDR"];?></td></tr>
|
236 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth0["IPADDR"];?></td></tr>
|
156 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth0["NETMASK"];?></td></tr>
|
237 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth0["NETMASK"];?></td></tr>
|
157 |
<tr><td><?php echo $l_ip_router." : </td><td>".$eth0["GATEWAY"];?></td></tr>
|
238 |
<tr><td><?php echo $l_ip_router." : </td><td>".$eth0["GATEWAY"];?></td></tr>
|
158 |
</table>
|
239 |
</table>
|
159 |
</fieldset>
|
240 |
</fieldset>
|
160 |
<br />
|
241 |
</td><td>
|
161 |
<fieldset>
|
242 |
<fieldset>
|
162 |
<legend><?php echo $l_eth1_legend; ?></legend>
|
243 |
<legend><?php echo $l_eth1_legend; ?></legend>
|
163 |
<table>
|
244 |
<table>
|
164 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth1["IPADDR"];?></td></tr>
|
245 |
<tr><td><?php echo $l_ip_adr." : </td><td>".$eth1["IPADDR"];?></td></tr>
|
165 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth1["NETMASK"];?></td></tr>
|
246 |
<tr><td><?php echo $l_ip_mask." : </td><td>".$eth1["NETMASK"];?></td></tr>
|
166 |
</table>
|
247 |
</table>
|
167 |
</fieldset>
|
248 |
</fieldset>
|
168 |
<br />
|
- |
|
169 |
<fieldset>
|
- |
|
170 |
<legend><?php echo $l_internet_legend; ?></legend>
|
- |
|
171 |
<table>
|
- |
|
172 |
<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
|
- |
|
173 |
<tr><td><?php echo $l_ip_dns1." : </td><td>".$eth0["DNS1"];?></td></tr>
|
- |
|
174 |
<tr><td><?php echo $l_ip_dns2." : </td><td>".$eth0["DNS2"];?></td></tr>
|
- |
|
175 |
</table>
|
- |
|
176 |
</fieldset>
|
- |
|
177 |
<br />
|
- |
|
178 |
</td></tr>
|
249 |
</td></tr>
|
179 |
</table>
|
250 |
</table>
|
- |
|
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>
|
180 |
</body>
|
276 |
</body>
|
181 |
</html>
|
277 |
</html>
|