Subversion Repositories ALCASAR

Rev

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

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

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