Subversion Repositories ALCASAR

Rev

Rev 2840 | Rev 2926 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
838 richard 1
<?php
2688 lucas.echa 2
/* written by steweb57 & Rexy */
838 richard 3
# Choice of language
4
$Language = 'en';
5
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
6
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
7
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
2853 rexy 8
if($Language == 'fr') {
838 richard 9
	$l_services_title	= "Configuration des services";
1157 stephane 10
	$l_main_services	= "Services principaux";
1476 richard 11
	$l_filter_services	= "Services de filtrage";
1157 stephane 12
	$l_opt_services		= "Services optionnels";
838 richard 13
	$l_service_title 	= "Nom du service";
2134 richard 14
	$l_service_start 	= "Démarrer";
15
	$l_service_stop 	= "Arréter";
16
	$l_service_restart 	= "Redémarrer";
838 richard 17
	$l_service_status 	= "Status";
1006 richard 18
	$l_service_status_img_ok= "Démarré";
19
	$l_service_status_img_ko= "Arrété";
838 richard 20
	$l_service_action 	= "Actions";
21
	$l_radiusd		= "Serveur d'authentification et d'autorisation";
2531 rexy 22
	$l_chilli		= "Passerelle d'interception et serveur DHCP";
2521 armand.ito 23
	$l_e2guardian		= "Filtre d'URL et de contenu WEB";
1476 richard 24
	$l_mysqld		= "Serveur de la base des usagers";
2488 lucas.echa 25
	$l_lighttpd		= "Serveur WEB (Alcasar Control Center)";
1476 richard 26
	$l_sshd			= "Accès sécurisée distant";
2776 rexy 27
	$l_clamav_freshclam	= "Mise à jour de l'antivirus (toutes les 4 heures)";
2840 rexy 28
	$l_clamav_daemon	= "Antimalware";
838 richard 29
	$l_ntpd			= "Service de mise à l'heure réseau";
2531 rexy 30
	$l_fail2ban		= "Détecteur d'intrusion";
2775 rexy 31
	$l_nfcapd 		= "Collecteur de flux NetFlow";
2531 rexy 32
	$l_vnstat		= "Grapheur de flux réseau";
2688 lucas.echa 33
	$l_unbound		= "Serveur DNS principal";
34
	$l_unbound_blacklist	= "Serveur DNS pour la Blacklist";
35
	$l_unbound_whitelist	= "Serveur DNS pour la Whitelist";
36
	$l_dnsmasq_whitelist	= "Serveur DNS pour la Whitelist (IPSET)";
37
	$l_unbound_blackhole	= "Serveur DNS 'trou noir'";
1484 richard 38
	$l_ulogd_ssh		= "journalisation des accès par SSH";
1476 richard 39
	$l_ulogd_ext_access	= "journalisation des tentatives d'accès externes";
40
	$l_ulogd_traceability	= "journalisation des connexions WEB filtrés";
1574 richard 41
	$l_execute		= "Exécuter";
42
	$l_stop_restart		= "Arret et redémarrage du système";
43
	$l_halt			= "Arréter le système";
44
	$l_reboot		= "Relancer le système";
2853 rexy 45
} else if($Language == 'es') {
46
	$l_services_title	= "Configuración de Servicios";
47
	$l_main_services	= "Servicios Principales";
48
	$l_filter_services	= "Servicios de Filtrado";
49
	$l_opt_services		= "Servicios Opcionales";
50
	$l_service_title 	= "Nombre del servicio";
51
	$l_service_start 	= "Iniciar";
52
	$l_service_stop 	= "Detener";
53
	$l_service_restart 	= "Reiniciar";
54
	$l_service_status 	= "Estado";
55
	$l_service_status_img_ok= "Corriendo";
56
	$l_service_status_img_ko= "Detenido";
57
	$l_service_action 	= "Acciones";
58
	$l_radiusd		= "Servidor de autenticación y autorización.";
59
	$l_chilli		= "Pasarela de interceptación y servidor DHCP";
60
	$l_e2guardian		= "Filtro de contenidos URL y WEB";
61
	$l_mysqld		= "Motor de base de datos para usuarios";
62
	$l_lighttpd		= "Servidor WEB (ALCASAR Control Center)";
63
	$l_sshd			= "Servidor Seguro Acceso Remoto";
64
	$l_clamav_freshclam		= "Proceso de actualización Antivirus (cada 4 horas)";
65
	$l_clamav_daemon	= "Antimalware";
66
	$l_ntpd			= "Servidor de hora";
67
	$l_fail2ban		= "Sistema de Detección de Intrusos";
68
	$l_nfcapd		= "Colector de flujo NetFlow";
69
	$l_vnstat		= "Graficador de tráfico de red";
70
	$l_unbound		= "Servidor DNS principal ";
71
	$l_unbound_blacklist	= "Servidor DNS de Lista Negra";
72
	$l_unbound_whitelist	= "Servidor DNS de Lista Blanca";
73
	$l_dnsmasq_whitelist	= "Servidor DNS de Lista Blanca (IPSET)";
74
	$l_unbound_blackhole	= "Agujero negro DNS";
75
	$l_ulogd_ssh		= "Proceso de registro para accesos SSH";
76
	$l_ulogd_ext_access	= "Proceso de registro de intentos de accesos externos";
77
	$l_ulogd_traceability	= "Proceso de registro de acceso WEB";
78
	$l_execute		= "Ejecutar";
79
	$l_stop_restart		= "Apagado y Reinicio del sistema";
80
	$l_halt			= "Apagar el sistema";
81
	$l_reboot		= "Reiniciar el sistema";
838 richard 82
} else {
83
	$l_services_title	= "Services configuration";
1157 stephane 84
	$l_main_services	= "Main services";
1476 richard 85
	$l_filter_services	= "Filtering services";
1157 stephane 86
	$l_opt_services		= "Optional services";
838 richard 87
	$l_service_title 	= "Service name";
88
	$l_service_start 	= "Start";
89
	$l_service_stop 	= "Stop";
90
	$l_service_restart 	= "Restart";
91
	$l_service_status 	= "Status";
1006 richard 92
	$l_service_status_img_ok= "Running";
93
	$l_service_status_img_ko= "Stopped";
838 richard 94
	$l_service_action 	= "Actions";
1572 richard 95
	$l_radiusd		= "Authentication and authorisation server";
2531 rexy 96
	$l_chilli		= "Interception gateway and DHCP server";
2521 armand.ito 97
	$l_e2guardian		= "URL and WEB content filter";
838 richard 98
	$l_mysqld		= "User database server";
2488 lucas.echa 99
	$l_lighttpd		= "WEB server (ALCASAR Control Center)";
838 richard 100
	$l_sshd			= "Secure remote access";
2776 rexy 101
	$l_clamav_freshclam	= "Antivirus update process (every 4 hours)";
2840 rexy 102
	$l_clamav_daemon= "Antimalware";
1572 richard 103
	$l_ntpd			= "Network time server";
2531 rexy 104
	$l_fail2ban		= "Intrusion Dectection System";
2775 rexy 105
	$l_nfcapd		= "Netflow collector";
2531 rexy 106
	$l_vnstat		= "Network grapher";
2688 lucas.echa 107
	$l_unbound		= "Main DNS server";
108
	$l_unbound_blacklist	= "Blacklist DNS server";
109
	$l_unbound_whitelist	= "Whitelist DNS server";
110
	$l_dnsmasq_whitelist	= "Whitelist DNS server (IPSET)";
111
	$l_unbound_blackhole	= "Blackhole DNS server";
1476 richard 112
	$l_ulogd_ssh		= "SSH access logging process";
1572 richard 113
	$l_ulogd_ext_access	= "Extern access attempts logging process";
1476 richard 114
	$l_ulogd_traceability	= "Filtering WEB access logging process";
1574 richard 115
	$l_execute		= "Execute";
116
	$l_stop_restart		= "Halt and restart the system";
117
	$l_halt			= "Halt le system";
118
	$l_reboot		= "Restart the system";
838 richard 119
}
120
 
121
/****************************************************************
2531 rexy 122
*	                   CONST				*
838 richard 123
*****************************************************************/
124
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
125
 
126
/********************************************************
2531 rexy 127
*			CONF FILE test 			*
838 richard 128
*********************************************************/
129
if (!file_exists(CONF_FILE)){
130
	exit("Fichier de configuration ".CONF_FILE." non présent");
131
}
132
if (!is_readable(CONF_FILE)){
133
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
134
}
135
 
2531 rexy 136
// Doing an action on a service (start,stop or restart)
838 richard 137
function serviceExec($service, $action){
138
	if (($action == "start")||($action == "stop")||($action == "restart")){
2299 tom.houday 139
		exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus);
2531 rexy 140
		if ($service == "sshd"){ // in order to keep that conf for SSH at next reboot
2688 lucas.echa 141
			if ($action == "start"){
2299 tom.houday 142
				exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
838 richard 143
				file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
2299 tom.houday 144
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
838 richard 145
				}
146
			if ($action == "stop"){
2299 tom.houday 147
			       	exec("sudo /usr/bin/systemctl disable ".escapeshellarg($service));
838 richard 148
				file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
2299 tom.houday 149
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
838 richard 150
				}
151
			}
152
		return $retstatus;
153
	} else {
154
		return false;
155
	}
156
}
2531 rexy 157
 
158
// Testing if a service is active
1006 richard 159
function checkServiceStatus($service){
838 richard 160
	$response = false;
2299 tom.houday 161
	exec("sudo /usr/bin/systemctl is-active ".escapeshellarg("$service.service"), $retval);
838 richard 162
	foreach( $retval as $val ) {
1006 richard 163
		if ($val == "active"){
838 richard 164
			$response = true;
165
			break;
166
		}
167
	}
168
	return $response;
169
}
170
 
171
//-------------------------------
1574 richard 172
// Actions on services
838 richard 173
//-------------------------------
2840 rexy 174
$autorizeService = array("radiusd","chilli","mysqld","lighttpd","unbound-forward","ulogd-ssh","ulogd-ext-access","ulogd-traceability","unbound-blacklist","unbound-whitelist","dnsmasq-whitelist","unbound-blackhole","e2guardian","clamav-daemon","clamav-freshclam","sshd","ntpd","fail2ban","nfcapd","vnstat");
2531 rexy 175
$autorizeAction = array("start","stop","restart");
838 richard 176
 
177
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
178
    if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
179
    	$execStatus = serviceExec($_GET['service'], $_GET['action']);
180
		// execStatus non exploité
181
	}
182
}
183
//-------------------------------
1574 richard 184
// Actions on system
185
//-------------------------------
186
if (isset($_POST['choix'])){
187
	switch ($_POST['choix']){
188
		case 'reboot' :
1827 raphael.pi 189
			exec ("sudo /usr/local/bin/alcasar-logout.sh all");
1599 richard 190
			exec ("sudo /usr/sbin/shutdown -r now");
1574 richard 191
		break;
192
		case 'halt' :
1827 raphael.pi 193
			exec ("sudo /usr/local/bin/alcasar-logout.sh all");
1599 richard 194
			exec ("sudo /usr/sbin/shutdown -h now");
1574 richard 195
		break;
196
	}
197
}
198
 
199
//-------------------------------
2531 rexy 200
// Check services status
838 richard 201
//-------------------------------
202
$MainServiceStatus = array();
2531 rexy 203
$MainServiceStatus['chilli'] = checkServiceStatus("chilli");
1006 richard 204
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd");
205
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld");
2488 lucas.echa 206
$MainServiceStatus['lighttpd'] = checkServiceStatus("lighttpd");
2724 rexy 207
$MainServiceStatus['unbound'] = checkServiceStatus("unbound");
2775 rexy 208
$MainServiceStatus['nfcapd'] = checkServiceStatus("nfcapd");
2531 rexy 209
$MainServiceStatus['ulogd_ssh'] = checkServiceStatus("ulogd-ssh");
210
$MainServiceStatus['ulogd_ext_access'] = checkServiceStatus("ulogd-ext-access");
211
$MainServiceStatus['ulogd_traceability'] = checkServiceStatus("ulogd-traceability");
838 richard 212
 
1476 richard 213
$FilterServiceStatus = array();
2688 lucas.echa 214
$FilterServiceStatus['unbound_blacklist'] = checkServiceStatus("unbound-blacklist");
215
$FilterServiceStatus['unbound_whitelist'] = checkServiceStatus("unbound-whitelist");
2531 rexy 216
$FilterServiceStatus['dnsmasq_whitelist'] = checkServiceStatus("dnsmasq-whitelist");
2688 lucas.echa 217
$FilterServiceStatus['unbound_blackhole'] = checkServiceStatus("unbound-blackhole");
2531 rexy 218
$FilterServiceStatus['e2guardian'] = checkServiceStatus("e2guardian");
2840 rexy 219
$FilterServiceStatus['clamav_daemon'] = checkServiceStatus("clamav-daemon");
2776 rexy 220
$FilterServiceStatus['clamav_freshclam'] = checkServiceStatus("clamav-freshclam");
1476 richard 221
 
838 richard 222
$OptServiceStatus = array();
1006 richard 223
$OptServiceStatus['sshd'] = checkServiceStatus("sshd");
224
$OptServiceStatus['ntpd'] = checkServiceStatus("ntpd");
2531 rexy 225
$OptServiceStatus['fail2ban'] = checkServiceStatus("fail2ban");
226
$OptServiceStatus['vnstat'] = checkServiceStatus("vnstat");
838 richard 227
/****************
228
*	MAIN	*
229
*****************/
230
 
231
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
232
<html><!-- written by steweb57 / rexy -->
233
<head>
234
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
235
<title><?php echo $l_services_title; ?></title>
2817 rexy 236
<link rel="stylesheet" href="/css/acc.css" type="text/css">
838 richard 237
</head>
238
<body>
239
<table width="100%" border="0" cellspacing="0" cellpadding="0">
240
	<tr><th><?php echo $l_main_services; ?></th></tr>
241
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
242
</table>
243
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
244
	<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>
245
<?php foreach( $MainServiceStatus as $serviceName => $statusOK ) { ?>
246
<tr>
247
	<?php if ($statusOK) { ?>
2531 rexy 248
	<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
249
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
250
	<td width="80" align="center">---</td>
251
	<td width="80" align="center"><?php if (($serviceName != "chilli") && ($serviceName != "lighttpd")) { echo "<a href=\"".$_SERVER['PHP_SELF']."?action=stop&service=".str_replace('_','-',$serviceName)."\"> $l_service_stop</a>"; } else echo "---";?></td>
252
	<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName)."\"> $l_service_restart";?></a></td>
838 richard 253
	<?php } else { ?>
2531 rexy 254
	<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
255
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
256
	<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=".str_replace('_','-',$serviceName)."\"> $l_service_start";?></a></td>
257
	<td width="80" align="center">---</td>
258
	<td width="80" align="center">---</td>
838 richard 259
    <?php } ?>
260
</tr>
261
<?php } ?>
262
</table>
263
<table width="100%" border="0" cellspacing="0" cellpadding="0">
1476 richard 264
	<tr><th><?php echo $l_filter_services; ?></th></tr>
265
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
266
</table>
267
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
268
	<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>
2134 richard 269
<!--	<TR align="center"> -->
1476 richard 270
<?php foreach( $FilterServiceStatus as $serviceName => $statusOK ) { ?>
271
<tr>
272
	<?php if ($statusOK) { ?>
273
    <td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
2531 rexy 274
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
1476 richard 275
    <td width="80" align="center">---</td>
2531 rexy 276
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=".str_replace('_','-',$serviceName)."\"> $l_service_stop";?></a></td>
277
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName)."\"> $l_service_restart";?></a></td>
1476 richard 278
	<?php } else { ?>
279
    <td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
2531 rexy 280
    <td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
281
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=".str_replace('_','-',$serviceName)."\"> $l_service_start";?></a></td>
1476 richard 282
    <td width="80" align="center">---</td>
283
    <td width="80" align="center">---</td>
284
    <?php } ?>
285
</tr>
286
<?php } ?>
287
</table>
288
<table width="100%" border="0" cellspacing="0" cellpadding="0">
838 richard 289
	<tr><th><?php echo $l_opt_services; ?></th></tr>
290
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
291
</table>
292
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
293
	<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>
294
<?php foreach( $OptServiceStatus as $serviceName => $statusOK ) { ?>
295
<tr>
296
	<?php if ($statusOK) { ?>
297
    <td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
2531 rexy 298
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
838 richard 299
    <td width="80" align="center">---</td>
300
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop";?></a></td>
301
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
302
	<?php } else { ?>
303
    <td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
2531 rexy 304
    <td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
838 richard 305
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
306
    <td width="80" align="center">---</td>
307
    <td width="80" align="center">---</td>
308
    <?php } ?>
309
</tr>
310
<?php } ?>
2134 richard 311
</table>
312
<table width="100%" border="0" cellspacing="0" cellpadding="0">
1574 richard 313
	<tr><th><? echo $l_stop_restart;?></th></tr>
314
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
2134 richard 315
</table>
316
<table width="100%" border=1 cellspacing=0 cellpadding=1>
1574 richard 317
	<tr><td valign="middle" align="left">
2134 richard 318
	<FORM action="services.php" method=POST>
319
		<select name='choix'>
1574 richard 320
			<option selected value="reboot"><?echo "$l_reboot";?>
321
			<option value="halt"><?echo "$l_halt";?>
322
		</select>
323
		<input type=submit value="<?echo "$l_execute";?>">
324
	</FORM>
325
	</td></tr>
2134 richard 326
</table>
838 richard 327
</body>
328
</html>