Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
/* written by steweb57 */
|
2 |
/* written by steweb57 & Rexy */
|
3 |
|
3 |
|
4 |
# Choice of language
|
4 |
# Choice of language
|
5 |
$Language = 'en';
|
5 |
$Language = 'en';
|
6 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
6 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
7 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
7 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
8 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
8 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
9 |
if($Language == 'fr'){
|
9 |
if($Language == 'fr'){
|
10 |
$l_network_title = "Configuration réseau";
|
10 |
$l_network_title = "Configuration réseau";
|
11 |
$l_main_services = "Services réseau principaux";
|
- |
|
12 |
$l_opt_services = "Services réseau optionnels";
|
- |
|
13 |
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
|
11 |
$l_eth0_legend = "Eth0 (Interface connectée à Internet)";
|
14 |
$l_eth1_legend = "Eth1 (Réseau de consultation)";
|
12 |
$l_eth1_legend = "Eth1 (Réseau de consultation)";
|
15 |
$l_internet_legend = "INTERNET";
|
13 |
$l_internet_legend = "INTERNET";
|
16 |
$l_ip_adr = "Adresse IP";
|
14 |
$l_ip_adr = "Adresse IP";
|
17 |
$l_ip_mask = "Masque";
|
15 |
$l_ip_mask = "Masque";
|
18 |
$l_ip_router = "Passerelle";
|
16 |
$l_ip_router = "Passerelle";
|
19 |
$l_ip_public = "Adresse IP publique";
|
17 |
$l_ip_public = "Adresse IP publique";
|
20 |
$l_ip_dns1 = "DNS1";
|
18 |
$l_ip_dns1 = "DNS1";
|
21 |
$l_ip_dns2 = "DNS2";
|
19 |
$l_ip_dns2 = "DNS2";
|
22 |
$l_service_title = "Nom du service";
|
- |
|
23 |
$l_service_start = "Démarrer";
|
- |
|
24 |
$l_service_stop = "Arrêter";
|
- |
|
25 |
$l_service_restart = "Redémarrer";
|
- |
|
26 |
$l_service_status = "Status";
|
- |
|
27 |
$l_service_action = "Actions";
|
- |
|
28 |
$l_enable = "actif";
|
- |
|
29 |
$l_disable = "inactif";
|
- |
|
30 |
$l_radiusd = "Serveur d'authentification et d'autorisation";
|
- |
|
31 |
$l_chilli = "Passerelle d'interception";
|
- |
|
32 |
$l_dansguardian = "Filtre d'URL et de contenu WEB";
|
- |
|
33 |
$l_mysqld = "Serveur de la base de données usager";
|
- |
|
34 |
$l_squid = "Serveur de cache WEB";
|
- |
|
35 |
$l_dnsmasq = "Serveur DNS et filtre de domaine";
|
- |
|
36 |
$l_httpd = "Serveur WEB (Centre de Gestion d'ALCASAR)";
|
- |
|
37 |
$l_havp = "Filtre antivirus WEB";
|
- |
|
38 |
$l_sshd = "Accès sécurisée à distance";
|
- |
|
39 |
$l_freshclam = "Mise à jour de l'antivirus toutes les 2 heures";
|
- |
|
40 |
$l_ntpd = "Service de mise à l'heure réseau";
|
- |
|
41 |
} else {
|
20 |
} else {
|
42 |
$l_network_title = "Network configuration";
|
21 |
$l_network_title = "Network configuration";
|
43 |
$l_main_services = "Main network services";
|
- |
|
44 |
$l_opt_services = "Optional network services";
|
- |
|
45 |
$l_eth0_legend = "Eth0 (Internet connected interface)";
|
22 |
$l_eth0_legend = "Eth0 (Internet connected interface)";
|
46 |
$l_eth1_legend = "Eth1 (Private network)";
|
23 |
$l_eth1_legend = "Eth1 (Private network)";
|
47 |
$l_internet_legend = "INTERNET";
|
24 |
$l_internet_legend = "INTERNET";
|
48 |
$l_ip_adr = "IP Address";
|
25 |
$l_ip_adr = "IP Address";
|
49 |
$l_ip_mask = "Mask";
|
26 |
$l_ip_mask = "Mask";
|
50 |
$l_ip_router = "Router";
|
27 |
$l_ip_router = "Router";
|
51 |
$l_ip_public = "Public IP address";
|
28 |
$l_ip_public = "Public IP address";
|
52 |
$l_ip_dns1 = "DNS1 :";
|
29 |
$l_ip_dns1 = "DNS1 :";
|
53 |
$l_ip_dns2 = "DNS2";
|
30 |
$l_ip_dns2 = "DNS2";
|
54 |
$l_service_title = "Service name";
|
- |
|
55 |
$l_service_start = "Start";
|
- |
|
56 |
$l_service_stop = "Stop";
|
- |
|
57 |
$l_service_restart = "Restart";
|
- |
|
58 |
$l_service_status = "Status";
|
- |
|
59 |
$l_service_action = "Actions";
|
- |
|
60 |
$l_enable = "enable";
|
- |
|
61 |
$l_disable = "disable";
|
- |
|
62 |
$l_radiusd = "Authentication and authorisation serveur";
|
- |
|
63 |
$l_chilli = "Interception gateway";
|
- |
|
64 |
$l_dansguardian = "URL and WEB content filter";
|
- |
|
65 |
$l_mysqld = "User database server";
|
- |
|
66 |
$l_squid = "Proxy Cache WEB";
|
- |
|
67 |
$l_dnsmasq = "DNS and domain name filter";
|
- |
|
68 |
$l_httpd = "WEB server (ALCASAR Control Center)";
|
- |
|
69 |
$l_havp = "WEB antivirus filter";
|
- |
|
70 |
$l_sshd = "Secure remote access";
|
- |
|
71 |
$l_freshclam = "WEB antivirus update (every 2 hours)";
|
- |
|
72 |
$l_ntpd = "Network time";
|
- |
|
73 |
}
|
31 |
}
|
74 |
|
32 |
|
75 |
/********************************************************************
|
33 |
/********************************************************************
|
76 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
34 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
77 |
*********************************************************************/
|
35 |
*********************************************************************/
|
78 |
|
- |
|
79 |
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
|
36 |
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
|
80 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
37 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
- |
|
38 |
|
81 |
/********************************************************************
|
39 |
/********************************************************************
|
82 |
* TEST DES FICHIERS DE CONFIGURATION *
|
40 |
* TEST DES FICHIERS DE CONFIGURATION *
|
83 |
*********************************************************************/
|
41 |
*********************************************************************/
|
84 |
|
- |
|
85 |
//Test de présence et des droits en lecture des fichiers de configuration.
|
42 |
//Test de présence et des droits en lecture des fichiers de configuration.
|
86 |
if (!file_exists(ALCASAR_CHILLI)){
|
43 |
if (!file_exists(ALCASAR_CHILLI)){
|
87 |
exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
|
44 |
exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
|
88 |
}
|
45 |
}
|
89 |
if (!file_exists(CONF_FILE)){
|
46 |
if (!file_exists(CONF_FILE)){
|
Line 94... |
Line 51... |
94 |
}
|
51 |
}
|
95 |
if (!is_readable(CONF_FILE)){
|
52 |
if (!is_readable(CONF_FILE)){
|
96 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
|
53 |
exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
|
97 |
}
|
54 |
}
|
98 |
|
55 |
|
99 |
//fonction pour faire une action (start,stop,restart) sur un service
|
- |
|
100 |
function serviceExec($service, $action){
|
- |
|
101 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
- |
|
102 |
exec("sudo /sbin/service $service $action",$retval, $retstatus);
|
- |
|
103 |
if ($service == "sshd"){
|
- |
|
104 |
if ($action == "start"){
|
- |
|
105 |
exec("sudo /sbin/chkconfig --add $service");
|
- |
|
106 |
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
|
- |
|
107 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
- |
|
108 |
}
|
- |
|
109 |
if ($action == "stop"){
|
- |
|
110 |
exec("sudo /sbin/chkconfig --del $service");
|
- |
|
111 |
file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
|
- |
|
112 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
- |
|
113 |
}
|
- |
|
114 |
}
|
- |
|
115 |
return $retstatus;
|
- |
|
116 |
} else {
|
- |
|
117 |
return false;
|
- |
|
118 |
}
|
- |
|
119 |
}
|
- |
|
120 |
//fonction définissant le status d'un service
|
- |
|
121 |
//(en fonction de la présence d'un mot clé dans la valeur de status)
|
- |
|
122 |
function checkServiceStatus($service, $strMatch){
|
- |
|
123 |
$response = false;
|
- |
|
124 |
exec("sudo /sbin/service $service status",$retval);
|
- |
|
125 |
foreach( $retval as $val ) {
|
- |
|
126 |
if (strpos($val,$strMatch)){
|
- |
|
127 |
$response = true;
|
- |
|
128 |
break;
|
- |
|
129 |
}
|
- |
|
130 |
}
|
- |
|
131 |
return $response;
|
- |
|
132 |
}
|
- |
|
133 |
|
- |
|
134 |
//-------------------------------
|
- |
|
135 |
// Les actions sur un service
|
- |
|
136 |
//-------------------------------
|
- |
|
137 |
//sécurité sur les actions à réaliser
|
- |
|
138 |
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","squid","dnsmasq","httpd","havp","sshd","freshclam","ntpd");
|
- |
|
139 |
$autorizeAction = array("start","stop","restart");
|
- |
|
140 |
|
- |
|
141 |
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
|
- |
|
142 |
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
|
- |
|
143 |
$execStatus = serviceExec($_GET['service'], $_GET['action']);
|
- |
|
144 |
// execStatus non exploité
|
- |
|
145 |
}
|
- |
|
146 |
}
|
- |
|
147 |
//-------------------------------
|
- |
|
148 |
//recherche du status des services
|
- |
|
149 |
//-------------------------------
|
- |
|
150 |
$MainServiceStatus = array();
|
- |
|
151 |
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd","pid");
|
- |
|
152 |
$MainServiceStatus['chilli'] = checkServiceStatus("chilli","pid");
|
- |
|
153 |
$MainServiceStatus['dansguardian'] = checkServiceStatus("dansguardian","pid");
|
- |
|
154 |
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld","OK");
|
- |
|
155 |
$MainServiceStatus['squid'] = checkServiceStatus("squid","pid");
|
- |
|
156 |
$MainServiceStatus['dnsmasq'] = checkServiceStatus("dnsmasq","pid");
|
- |
|
157 |
$MainServiceStatus['httpd'] = checkServiceStatus("httpd","pid");
|
- |
|
158 |
$MainServiceStatus['havp'] = checkServiceStatus("havp","pid");
|
- |
|
159 |
|
- |
|
160 |
$OptServiceStatus = array();
|
- |
|
161 |
$OptServiceStatus['sshd'] = checkServiceStatus("sshd","pid");
|
- |
|
162 |
$OptServiceStatus['freshclam'] = checkServiceStatus("freshclam","pid");
|
- |
|
163 |
$OptServiceStatus['ntpd'] = checkServiceStatus("ntpd","pid");
|
- |
|
164 |
|
- |
|
165 |
// Fonction de test de connectivité internet
|
56 |
// Fonction de test de connectivité internet
|
166 |
function internetTest(){
|
57 |
function internetTest(){
|
167 |
$host = "www.google.fr"; # Google Test
|
58 |
$host = "www.google.fr"; # Google Test
|
168 |
$port = "80";
|
59 |
$port = "80";
|
169 |
//var $num; //non utilisé
|
60 |
//var $num; //non utilisé
|
Line 174... |
Line 65... |
174 |
} else {
|
65 |
} else {
|
175 |
fclose($sock);
|
66 |
fclose($sock);
|
176 |
return true;
|
67 |
return true;
|
177 |
}
|
68 |
}
|
178 |
}
|
69 |
}
|
179 |
/********************************************************************
|
70 |
/********************************************************
|
180 |
* Lecture du fichier ALCASAR_CHILLI *
|
71 |
* Lecture du fichier ALCASAR_CHILLI *
|
181 |
*********************************************************************/
|
72 |
*********************************************************/
|
182 |
$ouvre=fopen(ALCASAR_CHILLI,"r");
|
73 |
$ouvre=fopen(ALCASAR_CHILLI,"r");
|
183 |
if ($ouvre){
|
74 |
if ($ouvre){
|
184 |
while (!feof ($ouvre))
|
75 |
while (!feof ($ouvre))
|
185 |
{
|
76 |
{
|
186 |
$tampon = fgets($ouvre, 4096);
|
77 |
$tampon = fgets($ouvre, 4096);
|
Line 192... |
Line 83... |
192 |
}else{
|
83 |
}else{
|
193 |
exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
|
84 |
exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
|
194 |
}
|
85 |
}
|
195 |
fclose($ouvre);
|
86 |
fclose($ouvre);
|
196 |
|
87 |
|
197 |
/********************************************************************
|
88 |
/****************************************************************
|
198 |
* Lecture du fichier CONF_FILE *
|
89 |
* Lecture du fichier CONF_FILE *
|
199 |
*********************************************************************/
|
90 |
*****************************************************************/
|
200 |
$ouvre=fopen(CONF_FILE,"r");
|
91 |
$ouvre=fopen(CONF_FILE,"r");
|
201 |
if ($ouvre){
|
92 |
if ($ouvre){
|
202 |
while (!feof ($ouvre))
|
93 |
while (!feof ($ouvre))
|
203 |
{
|
94 |
{
|
204 |
$tampon = fgets($ouvre, 4096);
|
95 |
$tampon = fgets($ouvre, 4096);
|
Line 213... |
Line 104... |
213 |
fclose($ouvre);
|
104 |
fclose($ouvre);
|
214 |
|
105 |
|
215 |
/************************
|
106 |
/************************
|
216 |
* TO DO *
|
107 |
* TO DO *
|
217 |
*************************/
|
108 |
*************************/
|
218 |
//modification de la conf réseau, cmd : ifconfig eth0 .....
|
109 |
//modification de la conf réseau --> V3.0
|
219 |
//synchro de la modification réseau dans les différentes couches d'alcasar
|
- |
|
220 |
//gestion du dhcp (affichage,modification, ajout @static)
|
110 |
//gestion du dhcp (affichage,modification, ajout @static)
|
221 |
|
111 |
|
222 |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
112 |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
223 |
<html><!-- written by steweb57 / rexy -->
|
113 |
<html><!-- written by steweb57 / rexy -->
|
224 |
<head>
|
114 |
<head>
|
Line 267... |
Line 157... |
267 |
</table>
|
157 |
</table>
|
268 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
158 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
269 |
<tr><th><?php echo $l_main_services; ?></th></tr>
|
159 |
<tr><th><?php echo $l_main_services; ?></th></tr>
|
270 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
160 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
271 |
</table>
|
161 |
</table>
|
272 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
- |
|
273 |
<tr align="center"><td><?php echo $l_service_status;?></td><td colspan="2"><?php echo $l_service_title;?></td><td colspan="3"><?php echo $l_service_action;?></td></tr>
|
- |
|
274 |
<TR align="center">
|
- |
|
275 |
<?php foreach( $MainServiceStatus as $serviceName => $statusOK ) { ?>
|
- |
|
276 |
<tr>
|
- |
|
277 |
<?php if ($statusOK) { ?>
|
- |
|
278 |
<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
- |
|
279 |
<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
|
- |
|
280 |
<td width="80" align="center">---</td>
|
- |
|
281 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop";?></a></td>
|
- |
|
282 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
|
- |
|
283 |
<?php } else { ?>
|
- |
|
284 |
<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
|
- |
|
285 |
<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
|
- |
|
286 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
|
- |
|
287 |
<td width="80" align="center">---</td>
|
- |
|
288 |
<td width="80" align="center">---</td>
|
- |
|
289 |
<?php } ?>
|
- |
|
290 |
</tr>
|
- |
|
291 |
<?php } ?>
|
- |
|
292 |
</td></tr>
|
- |
|
293 |
</table>
|
- |
|
294 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
- |
|
295 |
<tr><th><?php echo $l_opt_services; ?></th></tr>
|
- |
|
296 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
- |
|
297 |
</table>
|
- |
|
298 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
- |
|
299 |
<tr align="center"><td><?php echo $l_service_status;?></td><td colspan="2"><?php echo $l_service_title;?></td><td colspan="3"><?php echo $l_service_action;?></td></tr>
|
- |
|
300 |
<TR align="center">
|
- |
|
301 |
<?php foreach( $OptServiceStatus as $serviceName => $statusOK ) { ?>
|
- |
|
302 |
<tr>
|
- |
|
303 |
<?php if ($statusOK) { ?>
|
- |
|
304 |
<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
- |
|
305 |
<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
|
- |
|
306 |
<td width="80" align="center">---</td>
|
- |
|
307 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop";?></a></td>
|
- |
|
308 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
|
- |
|
309 |
<?php } else { ?>
|
- |
|
310 |
<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
|
- |
|
311 |
<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
|
- |
|
312 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
|
- |
|
313 |
<td width="80" align="center">---</td>
|
- |
|
314 |
<td width="80" align="center">---</td>
|
- |
|
315 |
<?php } ?>
|
- |
|
316 |
</tr>
|
- |
|
317 |
<?php } ?>
|
- |
|
318 |
</td></tr>
|
- |
|
319 |
</table>
|
- |
|
320 |
</body>
|
162 |
</body>
|
321 |
</html>
|
163 |
</html>
|