Subversion Repositories ALCASAR

Rev

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