Subversion Repositories ALCASAR

Rev

Rev 2935 | Rev 2991 | 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
 
4
 
5
// partie $_POST du service mail
6
 
7
$php_self = htmlspecialchars($_SERVER['PHP_SELF']);
8
// Traiter les formulaires de la partie MAIL SERVICE
9
if(!empty($_POST)){
10
 
11
	var_dump($_POST);
12
/*	// procéder a l'installtion de postfix
13
	if (!empty($_POST['install'])){
14
		exec('sudo dnf install -y postfix', $output, $retval);
15
//		header("Location:services.php");
16
		var_dump($output);
17
		echo "<br>\$retval : " . $retval;
18
	}
19
*/
20
// La variable qui contiendra les options et les arguments a passer à l'install
21
	$optArg = "";
22
 
23
	if(!empty($_POST['testConf'])){ 	
24
		$optArg .= " -".trim($_POST['testConf']);
25
	}
26
	if(!empty($_POST['smtp'])){ 	
27
		$optArg .= " -s \"".trim($_POST['smtp'])."\"";
28
	}
29
	if(!empty($_POST['port'])){ 	
30
		$optArg .= " -p \"".trim($_POST['port'])."\"";
31
	}
32
	if(!empty($_POST['smtpPort'])){ 	
33
		$smtpPort = explode(" ", $_POST['smtpPort']);
34
		$optArg .= " -s \"".trim($smtpPort[0])."\" -p \"".trim($smtpPort[1])."\"";
35
	}
36
	if(!empty($_POST['smtpIP'])){ 	
37
		$optArg .= " -r \"".trim($_POST['smtpIP'])."\"";
38
	}
39
	if(!empty($_POST['mailAddr'])){ 	
40
		$optArg .= " -m \"".trim($_POST['mailAddr'])."\"";
41
	}
42
	if(!empty($_POST['pswd1']) && !empty($_POST['pswd2'])){
43
		if (trim($_POST['pswd1']) == trim($_POST['pswd2'])){
44
			$optArg .= " -o \"".trim($_POST['pswd2'])."\"";
45
		} else {
46
			echo "<script> alert(\"Les deux mots de passe sont différents\"); window.location.href=\"services.php\";</script>";
47
		}
48
	}
49
	if(!empty($_POST['adminMail'])){ 	
50
		$optArg .= " -a \"".$_POST['adminMail']."\"";
51
	}
52
	if(!empty($_POST['wld'])){ 	
53
		$optArg .= " -w \"".str_replace("\r"," ",trim($_POST['wld']))."\"";
54
	}
55
 
56
// Supprimer la WLD ou l'email de l'admin
57
	if(!empty($_POST['unset'])){
58
		exec("sudo sed -i '/". $_POST['unset']."/d' /usr/local/etc/alcasar-mail.conf", $output, $retval);
59
 
60
		var_dump($output);
61
		echo "<br>\$retval : " . $retval;
62
	}
63
 
64
// Supprimer toute la configuration actuelle
65
	if(!empty($_POST['uninstall'])){
66
//		echo "sudo /usr/local/bin/alcasar-mail-uninstall.sh <br>";
67
		exec("sudo /usr/local/bin/alcasar-mail-uninstall.sh", $output, $retval);
68
 
69
		var_dump($output);
70
		echo "<br>\$retval : " . $retval;
71
	}
72
 
73
	if(!empty($optArg)){
74
		echo "sudo /usr/local/bin/alcasar-mail-install.sh".$optArg;
75
		exec("sudo /usr/local/bin/alcasar-mail-install.sh".escapeshellcmd($optArg), $output, $retval);
76
		var_dump($output);
77
		echo "<br>\$retval : " . $retval;
78
	}
79
//	à décommenté une fois tests et debugs réalisé pour recharger la page sansle $_POST
80
//	header("Location:services.php");
81
 
82
}// Fin de la partie $_POST du service mail
83
 
84
 
838 richard 85
# Choice of language
86
$Language = 'en';
87
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
88
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
89
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
2853 rexy 90
if($Language == 'fr') {
838 richard 91
	$l_services_title	= "Configuration des services";
1157 stephane 92
	$l_main_services	= "Services principaux";
1476 richard 93
	$l_filter_services	= "Services de filtrage";
1157 stephane 94
	$l_opt_services		= "Services optionnels";
2926 rexy 95
	$l_service_title 	= "Rôle du service";
2134 richard 96
	$l_service_start 	= "Démarrer";
97
	$l_service_stop 	= "Arréter";
98
	$l_service_restart 	= "Redémarrer";
838 richard 99
	$l_service_status 	= "Status";
1006 richard 100
	$l_service_status_img_ok= "Démarré";
101
	$l_service_status_img_ko= "Arrété";
838 richard 102
	$l_service_action 	= "Actions";
103
	$l_radiusd		= "Serveur d'authentification et d'autorisation";
2531 rexy 104
	$l_chilli		= "Passerelle d'interception et serveur DHCP";
2521 armand.ito 105
	$l_e2guardian		= "Filtre d'URL et de contenu WEB";
1476 richard 106
	$l_mysqld		= "Serveur de la base des usagers";
2488 lucas.echa 107
	$l_lighttpd		= "Serveur WEB (Alcasar Control Center)";
1476 richard 108
	$l_sshd			= "Accès sécurisée distant";
2776 rexy 109
	$l_clamav_freshclam	= "Mise à jour de l'antivirus (toutes les 4 heures)";
2840 rexy 110
	$l_clamav_daemon	= "Antimalware";
838 richard 111
	$l_ntpd			= "Service de mise à l'heure réseau";
2990 rexy 112
	$l_postfix		= "Service de messagerie";
2531 rexy 113
	$l_fail2ban		= "Détecteur d'intrusion";
2775 rexy 114
	$l_nfcapd 		= "Collecteur de flux NetFlow";
2531 rexy 115
	$l_vnstat		= "Grapheur de flux réseau";
2688 lucas.echa 116
	$l_unbound		= "Serveur DNS principal";
117
	$l_unbound_blacklist	= "Serveur DNS pour la Blacklist";
118
	$l_unbound_whitelist	= "Serveur DNS pour la Whitelist";
119
	$l_dnsmasq_whitelist	= "Serveur DNS pour la Whitelist (IPSET)";
120
	$l_unbound_blackhole	= "Serveur DNS 'trou noir'";
1484 richard 121
	$l_ulogd_ssh		= "journalisation des accès par SSH";
1476 richard 122
	$l_ulogd_ext_access	= "journalisation des tentatives d'accès externes";
123
	$l_ulogd_traceability	= "journalisation des connexions WEB filtrés";
2926 rexy 124
	$l_wifi4eu_id	= "Entrez votre identifiant réseau";
1574 richard 125
	$l_execute		= "Exécuter";
2926 rexy 126
	$l_stop_restart		= "Arrêt et redémarrage du système";
1574 richard 127
	$l_halt			= "Arréter le système";
128
	$l_reboot		= "Relancer le système";
2853 rexy 129
} else if($Language == 'es') {
130
	$l_services_title	= "Configuración de Servicios";
131
	$l_main_services	= "Servicios Principales";
132
	$l_filter_services	= "Servicios de Filtrado";
133
	$l_opt_services		= "Servicios Opcionales";
2926 rexy 134
	$l_service_title 	= "función del servicio";
2853 rexy 135
	$l_service_start 	= "Iniciar";
136
	$l_service_stop 	= "Detener";
137
	$l_service_restart 	= "Reiniciar";
138
	$l_service_status 	= "Estado";
139
	$l_service_status_img_ok= "Corriendo";
140
	$l_service_status_img_ko= "Detenido";
141
	$l_service_action 	= "Acciones";
142
	$l_radiusd		= "Servidor de autenticación y autorización.";
143
	$l_chilli		= "Pasarela de interceptación y servidor DHCP";
144
	$l_e2guardian		= "Filtro de contenidos URL y WEB";
145
	$l_mysqld		= "Motor de base de datos para usuarios";
146
	$l_lighttpd		= "Servidor WEB (ALCASAR Control Center)";
147
	$l_sshd			= "Servidor Seguro Acceso Remoto";
148
	$l_clamav_freshclam		= "Proceso de actualización Antivirus (cada 4 horas)";
149
	$l_clamav_daemon	= "Antimalware";
150
	$l_ntpd			= "Servidor de hora";
151
	$l_fail2ban		= "Sistema de Detección de Intrusos";
152
	$l_nfcapd		= "Colector de flujo NetFlow";
153
	$l_vnstat		= "Graficador de tráfico de red";
154
	$l_unbound		= "Servidor DNS principal ";
155
	$l_unbound_blacklist	= "Servidor DNS de Lista Negra";
156
	$l_unbound_whitelist	= "Servidor DNS de Lista Blanca";
157
	$l_dnsmasq_whitelist	= "Servidor DNS de Lista Blanca (IPSET)";
158
	$l_unbound_blackhole	= "Agujero negro DNS";
159
	$l_ulogd_ssh		= "Proceso de registro para accesos SSH";
160
	$l_ulogd_ext_access	= "Proceso de registro de intentos de accesos externos";
161
	$l_ulogd_traceability	= "Proceso de registro de acceso WEB";
2926 rexy 162
	$l_wifi4eu_id	= "Introduzca su identificador de red";
2853 rexy 163
	$l_execute		= "Ejecutar";
164
	$l_stop_restart		= "Apagado y Reinicio del sistema";
165
	$l_halt			= "Apagar el sistema";
166
	$l_reboot		= "Reiniciar el sistema";
838 richard 167
} else {
168
	$l_services_title	= "Services configuration";
1157 stephane 169
	$l_main_services	= "Main services";
1476 richard 170
	$l_filter_services	= "Filtering services";
1157 stephane 171
	$l_opt_services		= "Optional services";
2926 rexy 172
	$l_service_title 	= "Role of the service";
838 richard 173
	$l_service_start 	= "Start";
174
	$l_service_stop 	= "Stop";
175
	$l_service_restart 	= "Restart";
176
	$l_service_status 	= "Status";
1006 richard 177
	$l_service_status_img_ok= "Running";
178
	$l_service_status_img_ko= "Stopped";
838 richard 179
	$l_service_action 	= "Actions";
1572 richard 180
	$l_radiusd		= "Authentication and authorisation server";
2531 rexy 181
	$l_chilli		= "Interception gateway and DHCP server";
2521 armand.ito 182
	$l_e2guardian		= "URL and WEB content filter";
838 richard 183
	$l_mysqld		= "User database server";
2488 lucas.echa 184
	$l_lighttpd		= "WEB server (ALCASAR Control Center)";
838 richard 185
	$l_sshd			= "Secure remote access";
2776 rexy 186
	$l_clamav_freshclam	= "Antivirus update process (every 4 hours)";
2840 rexy 187
	$l_clamav_daemon= "Antimalware";
1572 richard 188
	$l_ntpd			= "Network time server";
2531 rexy 189
	$l_fail2ban		= "Intrusion Dectection System";
2775 rexy 190
	$l_nfcapd		= "Netflow collector";
2531 rexy 191
	$l_vnstat		= "Network grapher";
2688 lucas.echa 192
	$l_unbound		= "Main DNS server";
193
	$l_unbound_blacklist	= "Blacklist DNS server";
194
	$l_unbound_whitelist	= "Whitelist DNS server";
195
	$l_dnsmasq_whitelist	= "Whitelist DNS server (IPSET)";
196
	$l_unbound_blackhole	= "Blackhole DNS server";
1476 richard 197
	$l_ulogd_ssh		= "SSH access logging process";
1572 richard 198
	$l_ulogd_ext_access	= "Extern access attempts logging process";
1476 richard 199
	$l_ulogd_traceability	= "Filtering WEB access logging process";
2926 rexy 200
	$l_wifi4eu_id	= "Enter your network identifier";
1574 richard 201
	$l_execute		= "Execute";
202
	$l_stop_restart		= "Halt and restart the system";
203
	$l_halt			= "Halt le system";
204
	$l_reboot		= "Restart the system";
838 richard 205
}
206
 
207
/****************************************************************
2531 rexy 208
*	                   CONST				*
838 richard 209
*****************************************************************/
210
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
211
 
212
/********************************************************
2531 rexy 213
*			CONF FILE test 			*
838 richard 214
*********************************************************/
215
if (!file_exists(CONF_FILE)){
216
	exit("Fichier de configuration ".CONF_FILE." non présent");
217
}
218
if (!is_readable(CONF_FILE)){
219
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
220
}
2926 rexy 221
$file_conf = fopen(CONF_FILE, 'r');
222
if (!$file_conf) {
223
	exit('Error opening the file '.CONF_FILE);
224
}
225
while (!feof($file_conf)) {
226
	$buffer = fgets($file_conf, 4096);
227
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
228
		$tmp = explode('=', $buffer, 2);
229
		$conf[trim($tmp[0])] = trim($tmp[1]);
230
	}
231
}
232
fclose($file_conf);
233
$wifi4eu = $conf['WIFI4EU'];
234
$wifi4eu_code = $conf['WIFI4EU_CODE'];
2531 rexy 235
// Doing an action on a service (start,stop or restart)
838 richard 236
function serviceExec($service, $action){
237
	if (($action == "start")||($action == "stop")||($action == "restart")){
2934 rexy 238
		exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus);
2926 rexy 239
		if ($service == "sshd"){ 
2688 lucas.echa 240
			if ($action == "start"){
2931 rexy 241
				//exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
242
				file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE))); // in order to keep that conf for SSH at next reboot
2299 tom.houday 243
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
838 richard 244
				}
245
			if ($action == "stop"){
2931 rexy 246
				//exec("sudo /usr/bin/systemctl disable ".escapeshellarg($service));
838 richard 247
				file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
2299 tom.houday 248
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
838 richard 249
				}
250
			}
251
		return $retstatus;
252
	} else {
253
		return false;
254
	}
255
}
2531 rexy 256
 
257
// Testing if a service is active
1006 richard 258
function checkServiceStatus($service){
838 richard 259
	$response = false;
2299 tom.houday 260
	exec("sudo /usr/bin/systemctl is-active ".escapeshellarg("$service.service"), $retval);
838 richard 261
	foreach( $retval as $val ) {
1006 richard 262
		if ($val == "active"){
838 richard 263
			$response = true;
264
			break;
265
		}
266
	}
267
	return $response;
268
}
269
 
270
//-------------------------------
2926 rexy 271
// WIFI4EU
272
//-------------------------------
273
if (isset($_POST['wifi4eu'])){
2934 rexy 274
	switch ($_POST['wifi4eu']){
275
		case 'on' :
2935 rexy 276
			$network_code = trim($_POST['wifi4eu_id']);
277
		        if ($network_code == '') {
278
				$network_code = '123e4567-e89b-12d3-a456-426655440000'; // WIFI4EU test code
279
			}
280
			file_put_contents(CONF_FILE, preg_replace('/WIFI4EU_CODE=.*/', 'WIFI4EU_CODE='.$network_code, file_get_contents(CONF_FILE)));
2934 rexy 281
			exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
282
		break;
283
		case 'off' :
284
			exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
285
		break;
286
	}
287
	header('Location: '.$_SERVER['PHP_SELF']);
2926 rexy 288
}
2934 rexy 289
 
2926 rexy 290
//-------------------------------
2934 rexy 291
// Stop/restart system
1574 richard 292
//-------------------------------
2934 rexy 293
if (isset($_POST['system'])){
294
	switch ($_POST['system']){
1574 richard 295
		case 'reboot' :
1827 raphael.pi 296
			exec ("sudo /usr/local/bin/alcasar-logout.sh all");
1599 richard 297
			exec ("sudo /usr/sbin/shutdown -r now");
1574 richard 298
		break;
299
		case 'halt' :
1827 raphael.pi 300
			exec ("sudo /usr/local/bin/alcasar-logout.sh all");
1599 richard 301
			exec ("sudo /usr/sbin/shutdown -h now");
1574 richard 302
		break;
303
	}
304
}
305
 
306
//-------------------------------
2934 rexy 307
// Actions on services
308
//-------------------------------
2990 rexy 309
$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 310
$autorizeAction = array("start","stop","restart");
311
 
312
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
313
    if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
314
    	$execStatus = serviceExec($_GET['service'], $_GET['action']);
315
		// execStatus non exploité
316
	}
317
}
318
 
319
//-------------------------------
2531 rexy 320
// Check services status
838 richard 321
//-------------------------------
322
$MainServiceStatus = array();
2531 rexy 323
$MainServiceStatus['chilli'] = checkServiceStatus("chilli");
1006 richard 324
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd");
325
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld");
2488 lucas.echa 326
$MainServiceStatus['lighttpd'] = checkServiceStatus("lighttpd");
2724 rexy 327
$MainServiceStatus['unbound'] = checkServiceStatus("unbound");
2775 rexy 328
$MainServiceStatus['nfcapd'] = checkServiceStatus("nfcapd");
2531 rexy 329
$MainServiceStatus['ulogd_ssh'] = checkServiceStatus("ulogd-ssh");
330
$MainServiceStatus['ulogd_ext_access'] = checkServiceStatus("ulogd-ext-access");
331
$MainServiceStatus['ulogd_traceability'] = checkServiceStatus("ulogd-traceability");
2926 rexy 332
$MainServiceStatus['sshd'] = checkServiceStatus("sshd");
333
$MainServiceStatus['ntpd'] = checkServiceStatus("ntpd");
334
$MainServiceStatus['fail2ban'] = checkServiceStatus("fail2ban");
335
$MainServiceStatus['vnstat'] = checkServiceStatus("vnstat");
2990 rexy 336
$MainServiceStatus['postfix'] = checkServiceStatus("postfix");
838 richard 337
 
1476 richard 338
$FilterServiceStatus = array();
2688 lucas.echa 339
$FilterServiceStatus['unbound_blacklist'] = checkServiceStatus("unbound-blacklist");
340
$FilterServiceStatus['unbound_whitelist'] = checkServiceStatus("unbound-whitelist");
2531 rexy 341
$FilterServiceStatus['dnsmasq_whitelist'] = checkServiceStatus("dnsmasq-whitelist");
2688 lucas.echa 342
$FilterServiceStatus['unbound_blackhole'] = checkServiceStatus("unbound-blackhole");
2531 rexy 343
$FilterServiceStatus['e2guardian'] = checkServiceStatus("e2guardian");
2840 rexy 344
$FilterServiceStatus['clamav_daemon'] = checkServiceStatus("clamav-daemon");
2776 rexy 345
$FilterServiceStatus['clamav_freshclam'] = checkServiceStatus("clamav-freshclam");
1476 richard 346
 
838 richard 347
/****************
348
*	MAIN	*
349
*****************/
350
 
2926 rexy 351
?><!DOCTYPE HTML>
352
<html>
838 richard 353
<head>
2926 rexy 354
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
355
	<title><?php echo $l_services_title; ?></title>
356
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
2990 rexy 357
	<script type="text/javascript" src="/js/jquery.min.js"></script>
838 richard 358
</head>
359
<body>
2926 rexy 360
<div class="panel">
361
	<div class="panel-header"><?= $l_main_services ?></div>
362
	<div class="panel-row">
363
	<table width="100%" border=0 cellspacing=0 cellpadding=0>
364
		<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>
365
		<?php foreach( $MainServiceStatus as $serviceName => $statusOK ) { ?>
366
		<tr>
2990 rexy 367
		<?php if ($serviceName != "postfix"){
368
			if ($statusOK) { ?>
2926 rexy 369
			<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
370
			<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
371
			<td width="80" align="center">---</td>
372
			<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>
373
			<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName)."\"> $l_service_restart";?></a></td>
374
		<?php } else { ?>
375
			<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
376
			<td align="center"><?php $comment="l_$serviceName"; echo "$serviceName</td><td>${$comment}" ;?> </td>
377
			<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=".str_replace('_','-',$serviceName)."\"> $l_service_start";?></a></td>
378
			<td width="80" align="center">---</td>
379
			<td width="80" align="center">---</td>
380
		<?php } ?>
381
		</tr>
2990 rexy 382
		<?php }
383
		} ?>
2926 rexy 384
	</table>
385
	</div>
386
</div>
387
<div class="panel">
388
	<div class="panel-header"><?= $l_filter_services ?></div>
389
	<div class="panel-row">
390
	<table width="100%" border=0 cellspacing=0 cellpadding=0>
391
		<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>
392
		<!--	<TR align="center"> -->
393
		<?php foreach( $FilterServiceStatus as $serviceName => $statusOK ) { ?>
394
		<tr>
395
		<?php if ($statusOK) { ?>
396
			<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
397
			<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
398
			<td width="80" align="center">---</td>
399
			<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=".str_replace('_','-',$serviceName)."\"> $l_service_stop";?></a></td>
400
			<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName)."\"> $l_service_restart";?></a></td>
401
			<?php } else { ?>
402
			<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
403
			<td align="center"><?php $comment="l_$serviceName"; echo "$serviceName</td><td>${$comment}" ;?> </td>
404
			<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=".str_replace('_','-',$serviceName)."\"> $l_service_start";?></a></td>
405
			<td width="80" align="center">---</td>
406
			<td width="80" align="center">---</td>
407
			<?php } ?>
408
		</tr>
409
		<?php } ?>
410
	</table>
411
	</div>
412
</div>
413
<div class="panel">
414
	<div class="panel-header"><?= $l_opt_services ?></div>
415
	<div class="panel-row">
2990 rexy 416
 
2926 rexy 417
	<table width="100%" border=0 cellspacing=0 cellpadding=0>
418
		<tr align="center"><td><?php echo $l_service_status;?></td><td colspan="2"> </td><td colspan="3"><?php echo $l_service_action;?></td></tr>
2990 rexy 419
 
420
<?php
421
/*
422
// POSTFIX
423
exec("sudo rpm" . escapeshellarg("-q postfix"), $output, $retval);
424
		var_dump($output);
425
		echo "<br>\$retval : " . $retval;
426
exec("sudo ip" . escapeshellarg("a"), $output, $retval);
427
		var_dump($output);
428
		echo "<br>\$retval : " . $retval;
429
// si POSTFIX n'est pas installé, on propose l'installation
430
if ($retval == 1){  
431
 
432
echo <<<EOT
433
		<tr align="center">
434
			<td colspan="3"><b>POSTFIX n'est pas installé.</b></td>
435
			<td>
436
				<form id="install" action="$php_self" method=POST>
437
					<input type="hidden" name="install" value="install">
438
					<input type=submit form="install" value="Install">
439
				</form>
440
			</td>
441
		</tr>
442
EOT;
443
 
444
// si POSFIX est installé
445
} else {
446
*/
447
// la partie tableau qui affiche les statut du service POSTFIX, et possiblité de start, restart & stop
448
		$serviceName = "postfix";
449
		if(array_key_exists($serviceName, $MainServiceStatus)){
450
 
451
			$statusOK = $MainServiceStatus['postfix'];
452
			$comment="l_$serviceName";
453
			$stopService =  $_SERVER['PHP_SELF']."?action=stop&service=".str_replace('_','-',$serviceName);
454
			$startService = $_SERVER['PHP_SELF']."?action=start&service=".str_replace('_','-',$serviceName);
455
			$restartService = $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName);
456
//			$restartService = $_SERVER['PHP_SELF']."?action=restart&service=".str_replace('_','-',$serviceName)."\\";
457
 
458
			echo "<tr>";
459
			if ($statusOK) {
460
echo <<<EOT
461
				<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="$l_service_status_img_ok"></td>
462
				<td align="center"><b>$serviceName</b></td>
463
				<td align="center">${$comment}</td>
464
				<td width="80" align="center">---</td>
465
				<td width="80" align="center">
466
					<a href=$stopService>$l_service_stop</a></td>
467
				<td width="80" align="center">
468
					<a href=$restartService>$l_service_restart</a></td>
469
EOT;
470
			} else {
471
echo <<<EOT
472
				<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="$l_service_status_img_ko"></td>
473
				<td align="center">$serviceName</td>
474
				<td align="center">${$comment}</td>
475
				<td width="80" align="center">
476
					<a href=$startService>$l_service_start</a></td>
477
				<td width="80" align="center">---</td>
478
				<td width="80" align="center">---</td>
479
EOT;
480
			}
481
			echo "</tr>";
482
		}
483
//}
484
// POSTFIX end
485
?>
486
 
487
		<form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST>
2926 rexy 488
		<tr>
489
			<?php if ($wifi4eu == "on") { ?>
490
			<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
491
			<td align="center"><b>WIFI4EU</b></td><td><?php echo "network ID : $wifi4eu_code"; ?></td>
492
			<td width="80" align="center">---</td>
2934 rexy 493
			<td width="80" align="center"><input type=submit value="<?echo $l_service_stop;?>"><input type=hidden name="wifi4eu" value="off"></td>
2926 rexy 494
			<td width="80" align="center">---</td>
495
			<?php } else { ?>
496
			<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko; ?>"></td>
2935 rexy 497
			<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>
2934 rexy 498
			<td width="80" align="center"><input type=submit value="<?echo $l_service_start;?>"><input type=hidden name="wifi4eu" value="on"></td>
2926 rexy 499
			<td width="80" align="center">---</td>
500
			<td width="80" align="center">---</td>
501
			<?php } ?>
502
		</tr>
2990 rexy 503
		</form>
504
 
2926 rexy 505
	</table>
506
	</div>
507
</div>
2990 rexy 508
 
509
 
2926 rexy 510
<div class="panel">
511
	<div class="panel-header"><?= $l_stop_restart ?></div>
512
	<div class="panel-row">
513
	<table width="100%" border=0 cellspacing=0 cellpadding=1>
514
		<tr><td valign="middle" align="left">
515
			<form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST>
2934 rexy 516
			<select name='system'>
2926 rexy 517
				<option selected value="reboot"><?echo "$l_reboot";?>
518
				<option value="halt"><?echo "$l_halt";?>
519
			</select>
520
			<input type=submit value="<?echo "$l_execute";?>">
521
			</form>
522
		</td></tr>
523
	</table>
524
	</div>
525
</div>
2990 rexy 526
 
527
 
528
<!-- Code de la partie mail service, il ne faut pas oublier de rajouter jquery dans le head du html -->
529
 
530
<?php
531
 
532
echo <<<EOT
533
 
534
<div class="panel">
535
	<div class="panel-header">POSTFIX actuelle Configuration</div>
536
	<div class="panel-row">
537
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
538
 
539
EOT;
540
 
541
// la conf actuelle, si le fichier alcasar-mail.conf est présent
542
			$alcasarMailConf = "/usr/local/etc/alcasar-mail.conf";
543
			if (is_file ($alcasarMailConf)){
544
 
545
				$tab=file($alcasarMailConf);
546
 
547
				if ($tab){
548
					foreach ($tab as $line)		{
549
 
550
						$field=explode("=", $line);
551
 
552
						switch ($field[0]) {
553
 
554
							case 'smtp':
555
								$smtp = trim($field[1]);
556
echo <<<EOT
557
								<tr align="center">
558
									<td><b>SMTP : </b>$smtp</td>
559
								</tr>
560
EOT;
561
							break;
562
							case 'port':
563
								$port = trim($field[1]);
564
echo <<<EOT
565
								<tr align="center">
566
									<td><b>Port : </b>$port</td>
567
								</tr>
568
EOT;
569
							break;
570
							case 'smtpIP':
571
								$smtpIP = trim($field[1]);
572
echo <<<EOT
573
								<tr align="center">
574
									<td><b>SMTP ip : </b>$smtpIP</td>
575
								</tr>
576
EOT;
577
							break;
578
							case 'mailAddr':
579
								$mailAddr = trim($field[1]);
580
echo <<<EOT
581
								<tr align="center">
582
									<td><b>Email Addr : </b>$mailAddr</td>
583
								</tr>
584
EOT;
585
							break;
586
							case 'adminMail':
587
								$adminMail = trim($field[1]);
588
echo <<<EOT
589
								<tr align="center">
590
									<td><b>Admin email : </b>$adminMail</td>
591
								</tr>
592
EOT;
593
							break;
594
							case 'whiteDomain':
595
								$whiteDomain = explode(" ", trim($field[1]));
596
							break;
597
						}
598
					}
599
				}
600
echo <<<EOT
601
			<form action="$php_self" method="post">
602
				<tr align="center">
603
					<td colspan="2">
604
						<input type="hidden" name="uninstall" value="uninstall">
605
						<br><input type="submit" class="btn btn-default" name="submit" value="Supprimer toute la configuration">
606
					</td>
607
				</tr>
608
			</form>
609
				<tr align="center">
610
					<td colspan="2"><font color=red>ATTENTION : la suppression enlève toute la configuration du SERVICE MAIL</font>
611
 
612
					</td>
613
				</tr>
614
EOT;
615
			// si le fichier alcasar-mail.conf n'existe pas
616
			} else {
617
 
618
echo <<<EOT
619
			<tr align="center">
620
				<td><b>POSTFIX n'est pas configuré par ALCASAR.</b></td>
621
			</tr>
622
EOT;
623
 
624
			}
625
 
626
// Partie de paramétrage de la configuration
627
 
628
// Configuration de l'adresse email de l'administrateur
629
echo <<<EOT
630
		</table><br>
631
	</div>
632
</div><br>
633
<div class="panel">
634
	<div class="panel-header">POSTFIX Configuration</div>
635
	<div class="panel-row conf" id="conf">	
636
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
637
			<tr align="center">
638
				<td><input type="radio" name="conf" class="mail" value="One"/><b>Service autonome</b></td>
639
				<td><input type="radio" name="conf" class="mail" value="Two"/><b>Service relay</b></td>
640
				<td><input type="radio" name="conf" class="mail" value="Three"/> <b>Adresse mail</b></td>
641
			</tr>
642
		</table><br>
643
	</div>
644
	<div class="myDiv hide" id="showOne">
645
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
646
			<tr align="center">
647
				<td><b>Serveur mail est autonome :</b></td>
648
			</tr>
649
			<tr align="center">
650
				<td>
651
					<form action="$php_self" method="post">
652
						<input type="hidden" name="testConf" value="1">
653
						<input type="submit" class="btn btn-default" name="submit" value="Configurer"><br>
654
					</form>
655
				</td>
656
			</tr>
657
		</table>
658
	</div>
659
 
660
	<div class="myDiv hide" id="showTwo">
661
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
662
			<form action="$php_self" method="post">
663
				<tr align="center">
664
					<td colspan="2"><b>SMTP Relais :</b></td>
665
				</tr>
666
				<tr align="center">
667
					<td colspan="2">Postfix envois, ralaye les emails sorants à un autre serveur SMTP.</td>
668
				</tr>
669
				<tr>
670
					<td><label>Enterez le serveur SMTP relai en FQDN ou IP</label></td>
671
					<td><input type="text" name="smtp" placeholder="SMTP" required/></td>
672
				</tr>
673
				<tr>
674
					<td><label>Enterez le port SMTP</label></td>
675
					<td><input type="text" name="port" placeholder="port" required/></td>
676
				</tr>
677
				<tr>
678
					<td><label>Enterez l'IP du serveur SMTP relais (0.0.0.0/0 si c'est dynamique/par défaut si vide)</label></td>
679
					<td><input type="text" name="smtpIP" placeholder="IP du SMTP relais" required/></td>
680
				</tr>
681
				<tr align="center">
682
					<td colspan="2">
683
						<input type="hidden" name="testConf" value="2">
684
						<input type="submit" class="btn btn-default" name="submit" value="Valider"><br>
685
					</td>
686
				</tr>
687
			</form>
688
		</table><br>
689
	</div>
690
 
691
	<div class="myDiv hide" id="showThree">
692
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
693
			<form method="post" action="$php_self">
694
				<tr colspan="2" align="center">
695
					<td><b>Configuration de serveur mail via un compte email :</b></td>
696
				</tr>
697
				<tr align="center">
698
					<td>
699
						<table class="table table-striped">
700
							<tr>
701
								<td><label>Entez votre email</label></td>
702
								<td><input type="email" name="mailAddr" placeholder="Enter your email" required/></td>
703
							</tr>
704
							<tr>
705
								<td><label>Entez le mot de passe</label></td>
706
								<td><input type="password" id="pswd1" name="pswd1" required/></td>
707
							</tr>
708
							<tr>
709
								<td><label>Confirmer le mot de passe</label></td>
710
								<td><input type="password" id="pswd2" name="pswd2" required/></td>
711
							</tr>
712
 
713
						</table>
714
						<table class="table table-striped">
715
						  <thead>
716
							    <tr>
717
							      <th scope="col">#</th>
718
							      <th scope="col">compte de messagerie</th>
719
							      <th scope="col">adresse de messagerie</th>
720
							      <th scope="col">serveur sortant</th>
721
							      <th scope="col">port sortant</th>
722
							    </tr>
723
						  </thead>
724
						  <tbody>
725
EOT;
726
$smtpsConf = [
727
	["Orange", "Orange/Wanadoo", "orange.fr /wanadoo.fr", "smtp.orange.fr", 465],
728
	["Hotmail", "Hotmail", "hotmail.com/.fr / live.com/.fr / msn.com", "smtp.live.com", 587],
729
	["Outlook", "Outlook", "hotmail.xx/live.xx/msn.com/outlook/office365", "smtp.office365.com", 587],
730
	["SFR", "SFR", "sfr.fr", "smtp.sfr.fr", 465],
731
	["Free", "Free", "free.fr", "smtp.free.fr", 465],
732
	["Gmail", "Gmail", "gmail.com", "smtp.gmail.com", 587],
733
	["Laposte", "Laposte", "laposte.net", "smtp.laposte.net", 465],
734
	["Bouygues", "Bouygues Telecom", "bbox.fr", "smtp.bbox.fr", 587]
735
];
736
 
737
foreach( $smtpsConf as $smtpConf ) {
738
echo <<< EOT
739
							    <tr>
740
							      <th scope="row"><input class="form-check-input blur" type="radio" name="smtpPort" value="$smtpConf[3] $smtpConf[4]"/></th>
741
 
742
							      <td>$smtpConf[1]</td>
743
							      <td>$smtpConf[2]</td>
744
							      <td>$smtpConf[3]</td>
745
							      <td align="center">$smtpConf[4]</td>
746
							    </tr>
747
EOT;
748
}
749
echo<<<EOT
750
							    <tr>
751
							      <th scope="row"><input id="perso" class="form-check-input" type="radio" name="smtpPort"/></th>
752
							      <td>Personalisez votre smtp</td>
753
							      <td><input type="text" id="smtpPerso" name="smtpPerso" class="perso" oninput="valPerso()" placeholder="Entrez le serveur SMTP" disabled/></td>
754
							      <td>Personalisez le port</td>
755
							      <td><input type="text" id="portPerso" name="portPerso" class="perso" oninput="valPerso()" placeholder="Entrez le serveur Port" disabled/></td>
756
							    </tr>
757
						  </tbody>
758
						</table>
759
			  		</td>
760
				</tr>
761
				<tr align="center">
762
					<td class="testConf3">
763
					</td>
764
				</tr>
765
				<tr align="center">
766
					<td>
767
						<input type="hidden" name="testConf" value="3">
768
						<input type="submit" class="btn btn-default" name="submit" value="Valider" id="testConf3"><br>
769
					</td>
770
				</tr>
771
			</form>	  
772
		</table><br>
773
	</div>
774
</div><br>
775
<div class="panel">
776
	<div class="panel-header">Mail admin</div>
777
	<div class="panel-row conf" id="conf">	
778
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
779
			<form action="$php_self" method="post">
780
				<tr align="center">
781
					<td colspan="2"><b>Mail admin</b></td>
782
				</tr>
783
				<tr align="center">
784
					<td colspan="2">L'adresse email de l'administrateur pour recevoir les alertes des nouvelles inscriptions, et l'archive hebdomadaire des logs</td>
785
				</tr>
786
				<tr>
787
EOT;
788
					if (empty($adminMail)){
789
						echo "<td><label>Enterez l'adresse email</label></td>";
790
					} else {
791
						echo "<td>L'email configuré actuellement est : " . $adminMail . "</td>";
792
					}
793
echo <<<EOT
794
					<td><input type="email" name="adminMail" placeholder="Enter your email" required/></td>
795
				</tr>
796
 
797
				<tr align="center">
798
					<td colspan="2">
799
						<input type="submit" class="btn btn-default" name="submit" value="Valider"><br>
800
					</td>
801
				</tr>
802
			</form>
803
			<form action="$php_self" method="post">
804
				<tr align="center">
805
					<td colspan="2">
806
						<input type="hidden" name="unset" value="adminMail">
807
						<input type="submit" class="btn btn-default" name="submit" value="Supprimer l'admin email"><br>
808
					</td>
809
				</tr>
810
			</form>
811
		</table><br>
812
	</div>
813
</div><br>
814
<div class="panel">
815
	<div class="panel-header">WhiteList Domains Configuration</div>
816
	<div class="panel-row conf" id="conf">	
817
		<table width="100%" border=0 cellspacing=0 cellpadding=0><br>
818
			<tr align="center">
819
				<td>La liste blanche limite les inscriptions utilisateurs à un, ou plusieurs domaines.</td>
820
			</tr>
821
			<form method="post" action="$php_self">
822
				<tr align="center">
823
					<td width="50%" align="center">Mettez vos domaines à configurer. Un par ligne</td>
824
				</tr>
825
				<tr align="center">
826
					<td>
827
 						<br><textarea name='wld' rows=5 cols=50 placeholder="Aucune WLD configurée actuellement"">
828
EOT;
829
if(!empty($whiteDomain)){
830
	foreach ($whiteDomain as $domain){
831
		echo "$domain\n";
832
	}
833
}
834
echo<<<EOT
835
</textarea>
836
					</td>
837
				</tr>
838
				<tr align="center">
839
					<td colspan="2">
840
						<br><input type="submit" class="btn btn-default" name="submit" value="Valider"><br>
841
					</td>
842
				</tr>
843
			</form>
844
			<form action="$php_self" method="post">
845
				<tr align="center">
846
					<td colspan="2">
847
						<input type="hidden" name="unset" value="whiteDomain">
848
						<input type="submit" class="btn btn-default" name="submit" value="Supprimer la WLD"><br>
849
					</td>
850
				</tr>
851
			</form>
852
		</table><br>
853
	</div>
854
</div><br>
855
 
856
EOT;
857
 
858
?>
859
 
860
<script>
861
	$(document).ready(function(){
862
		$("div.hide").hide();
863
 
864
		$('#conf input[type="radio"]').click(function(){
865
			var value = $(this).val(); 
866
			$("div.myDiv").hide();
867
			$("#show"+value).show();
868
		});
869
 
870
		//On vérifie si le mot de passe est ok
871
		$("#pswd2").keyup(function(){
872
			if($("#pswd1").val() != "" && $("#pswd2").val() != "" && $("#pswd1").val() != $("#pswd2").val()){
873
				$(".testConf3").html("<br>Les deux mots de passe sont différents");
874
				$("#testConf3").attr("disabled", true);
875
			} else {
876
				$("#testConf3").attr("disabled", false);
877
				$(".testConf3").fadeOut(800);
878
			}
879
		})
880
	});
881
 
882
	$('#perso').click(function(){
883
 
884
		$(".perso").attr("disabled", false);
885
	});
886
 
887
	$('.blur').click(function(){
888
 
889
		$(".perso").attr("disabled", true);
890
	});
891
 
892
	function valPerso(){
893
		var valSmtpPerso = document.getElementById("smtpPerso").value;
894
		var valPortPerso = document.getElementById("portPerso").value;
895
		document.getElementById("perso").value = valSmtpPerso + " " + valPortPerso;
896
	};
897
 
898
	function hideShow(x){
899
		$("div." + x).toggle();
900
		var value = $("input." + x).val();
901
		var elem = document.getElementById("btn-" + x);
902
		if (elem.value=="Configurer"){
903
			elem.value = "Annuler";
904
		} else{
905
			elem.value = "Configurer";
906
		}
907
	};
908
 
909
</script>
910
 
911
 
838 richard 912
</body>
2990 rexy 913
</html>