Subversion Repositories ALCASAR

Rev

Rev 2935 | Rev 2991 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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

Generated by GNU Enscript 1.6.6.
-
 
916
 
-
 
917
 
-
 
918