Subversion Repositories ALCASAR

Rev

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