Subversion Repositories ALCASAR

Rev

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

Rev 2853 Rev 2874
1
<?php
1
<?php
2
# $Id: network.php 2853 2020-07-19 21:50:07Z rexy $
2
# $Id: network.php 2874 2020-10-31 13:54:28Z rexy $
3
 
3
 
4
// written by steweb57, Rexy & Tom HOUDAYER
4
// written by steweb57, Rexy & Tom HOUDAYER
5
 
5
 
6
/********************
6
/********************
7
*  READ CONF FILES  *
7
*  READ CONF FILES  *
8
*********************/
8
*********************/
9
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
9
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
10
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
10
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
11
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
11
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
12
define('DNS_LOCAL_FILE', '/etc/hosts');
12
define('DNS_LOCAL_FILE', '/etc/hosts');
13
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
13
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
14
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
14
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
15
 
15
 
16
// Files reading test
16
// Files reading test
17
foreach ($conf_files as $file) {
17
foreach ($conf_files as $file) {
18
	if (!file_exists($file)) {
18
	if (!file_exists($file)) {
19
		exit("Requested file $file isn't present");
19
		exit("Requested file $file isn't present");
20
	}
20
	}
21
	if (!is_readable($file)) {
21
	if (!is_readable($file)) {
22
		exit("Can't read the file $file");
22
		exit("Can't read the file $file");
23
	}
23
	}
24
}
24
}
25
 
25
 
26
// Read ALCASAR CONF_FILE
26
// Read ALCASAR CONF_FILE
27
$file_conf = fopen(CONF_FILE, 'r');
27
$file_conf = fopen(CONF_FILE, 'r');
28
if (!$file_conf) {
28
if (!$file_conf) {
29
	exit('Error opening the file '.CONF_FILE);
29
	exit('Error opening the file '.CONF_FILE);
30
}
30
}
31
while (!feof($file_conf)) {
31
while (!feof($file_conf)) {
32
	$buffer = fgets($file_conf, 4096);
32
	$buffer = fgets($file_conf, 4096);
33
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
33
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
34
		$tmp = explode('=', $buffer, 2);
34
		$tmp = explode('=', $buffer, 2);
35
		$conf[trim($tmp[0])] = trim($tmp[1]);
35
		$conf[trim($tmp[0])] = trim($tmp[1]);
36
	}
36
	}
37
}
37
}
38
fclose($file_conf);
38
fclose($file_conf);
39
 
39
 
40
// Choice of language
40
// Choice of language
41
$Language = 'en';
41
$Language = 'en';
42
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
42
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
43
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
43
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
44
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
44
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
45
}
45
}
46
if ($Language === 'fr') {
46
if ($Language === 'fr') {
47
	$l_network_title	= "Configuration réseau";
47
	$l_network_title	= "Configuration réseau";
48
	$l_internet_legend	= "INTERNET";
48
	$l_internet_legend	= "INTERNET";
49
	$l_ip_mask		= "Masque";
49
	$l_ip_mask		= "Masque";
50
	$l_ip_router		= "Passerelle";
50
	$l_ip_router		= "Passerelle";
51
	$l_ip_public		= "Adresse IP publique";
51
	$l_ip_public		= "Adresse IP publique";
52
	$l_ip_dns1		= "DNS n°1";
52
	$l_ip_dns1		= "DNS n°1";
53
	$l_ip_dns2		= "DNS n°2";
53
	$l_ip_dns2		= "DNS n°2";
54
	$l_dhcp_title		= "Service DHCP";
54
	$l_dhcp_title		= "Service DHCP";
55
	$l_dhcp_state		= "Mode actuel";
55
	$l_dhcp_state		= "Mode actuel";
56
	$l_DHCP_on		= "actif";
56
	$l_DHCP_on		= "actif";
57
	$l_DHCP_off		= "inactif";
57
	$l_DHCP_off		= "inactif";
58
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
58
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
59
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
59
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
60
	$l_mac_address		= "Adresse MAC";
60
	$l_mac_address		= "Adresse MAC";
61
	$l_ip_address		= "Adresse IP";
61
	$l_ip_address		= "Adresse IP";
62
	$l_host_name		= "Nom d'hôte";
62
	$l_host_name		= "Nom d'hôte";
63
	$l_del			= "Supprimer de la liste";
63
	$l_del			= "Supprimer de la liste";
64
	$l_add_to_list		= "Ajouter";
64
	$l_add_to_list		= "Ajouter";
65
	$l_apply		= "Appliquer les changements";
65
	$l_apply		= "Appliquer les changements";
66
	$l_local_dns		= "Résolution local de nom (DNS)";
66
	$l_local_dns		= "Résolution local de nom (DNS)";
67
	$l_import_cert		= "Import de certificat";
67
	$l_import_cert		= "Import de certificat";
68
	$l_private_key		= "Clé privée (.key) :";
68
	$l_private_key		= "Clé privée (.key) :";
69
	$l_certificate		= "Certificat (.crt ou .cer) :";
69
	$l_certificate		= "Certificat (.crt ou .cer) :";
70
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
70
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
71
	$l_default_cert		= "Revenir au certificat d'origine :";
71
	$l_default_cert		= "Revenir au certificat d'origine :";
72
	$l_import		= "Importer";
72
	$l_import		= "Importer";
73
	$l_current_certificate  = "Certificat actuel";
73
	$l_current_certificate  = "Certificat actuel";
74
	$l_validated		= "Validé par :";
74
	$l_validated		= "Validé par :";
75
	$l_empty		= "Vide";
75
	$l_empty		= "Vide";
76
	$l_yes			= "Oui";
76
	$l_yes			= "Oui";
77
	$l_no			= "Non";
77
	$l_no			= "Non";
78
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
78
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
79
	$l_cert_expiration	= "Date d'expiration :";
79
	$l_cert_expiration	= "Date d'expiration :";
80
	$l_cert_commonname	= "Nom commun :";
80
	$l_cert_commonname	= "Nom commun :";
81
	$l_cert_organization	= "Organisation :";
81
	$l_cert_organization	= "Organisation :";
82
	$l_upload_certificate	= "Importer un certificat officiel";
82
	$l_upload_certificate	= "Importer un certificat officiel";
83
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
83
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
84
	$l_le_status		= "Status :";
84
	$l_le_status		= "Status :";
85
	$l_disabled		= "Inactif";
85
	$l_disabled		= "Inactif";
86
	$l_pending_validation	= "En attente de validation";
86
	$l_pending_validation	= "En attente de validation";
87
	$l_enabled		= "Actif";
87
	$l_enabled		= "Actif";
88
	$l_le_email		= "Email :";
88
	$l_le_email		= "Email :";
89
	$l_le_domain_name	= "Nom de domaine :";
89
	$l_le_domain_name	= "Nom de domaine :";
90
	$l_send			= "Envoyer";
90
	$l_send			= "Envoyer";
91
	$l_le_ask_on		= "Demandé le :";
91
	$l_le_ask_on		= "Demandé le :";
92
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
92
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
93
	$l_le_challenge		= "Challenge :";
93
	$l_le_challenge		= "Challenge :";
94
	$l_recheck		= "Revérifier";
94
	$l_recheck		= "Revérifier";
95
	$l_cancel		= "Annuler";
95
	$l_cancel		= "Annuler";
96
	$l_le_api		= "API :";
96
	$l_le_api		= "API :";
97
	$l_le_next_renewal	= "Prochain renouvellement :";
97
	$l_le_next_renewal	= "Prochain renouvellement :";
98
	$l_renew		= "Renouveller";
98
	$l_renew		= "Renouveller";
99
	$l_renew_force		= "Renouveller (forcer)";
99
	$l_renew_force		= "Renouveller (forcer)";
100
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
100
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
101
} else if ($Language === 'es') {
101
} else if ($Language === 'es') {
102
	$l_network_title	= "Configuración de Red";
102
	$l_network_title	= "Configuración de Red";
103
	$l_internet_legend	= "INTERNET";
103
	$l_internet_legend	= "INTERNET";
104
	$l_ip_mask		= "Máscara";
104
	$l_ip_mask		= "Máscara";
105
	$l_ip_router		= "Puerta de enlace";
105
	$l_ip_router		= "Puerta de enlace";
106
	$l_ip_public		= "IP Pública";
106
	$l_ip_public		= "IP Pública";
107
	$l_ip_dns1		= "DNS n°1";
107
	$l_ip_dns1		= "DNS n°1";
108
	$l_ip_dns2		= "DNS n°2";
108
	$l_ip_dns2		= "DNS n°2";
109
	$l_dhcp_title		= "Servicio DHCP";
109
	$l_dhcp_title		= "Servicio DHCP";
110
	$l_dhcp_state		= "Modo actual";
110
	$l_dhcp_state		= "Modo actual";
111
	$l_DHCP_on		= "activado";
111
	$l_DHCP_on		= "activado";
112
	$l_DHCP_off		= "desactivado";
112
	$l_DHCP_off		= "desactivado";
113
	$l_DHCP_off_explain	= "/!\\ Antes de desactivar el servidor DHCP, debe escribir los parámetros externos de DHCP en el archivo de configuración (consulte la Documentación";
113
	$l_DHCP_off_explain	= "/!\\ Antes de desactivar el servidor DHCP, debe escribir los parámetros externos de DHCP en el archivo de configuración (consulte la Documentación";
114
	$l_static_dhcp_title	= "Reserva de direcciones IP estáticas (DHCP)";
114
	$l_static_dhcp_title	= "Reserva de direcciones IP estáticas (DHCP)";
115
	$l_mac_address		= "Dirección MAC";
115
	$l_mac_address		= "Dirección MAC";
116
	$l_ip_address		= "Dirección IP";
116
	$l_ip_address		= "Dirección IP";
117
	$l_host_name		= "Nombre de Host";
117
	$l_host_name		= "Nombre de Host";
118
	$l_del			= "Borrar de la lista";
118
	$l_del			= "Borrar de la lista";
119
	$l_add_to_list		= "Agregar";
119
	$l_add_to_list		= "Agregar";
120
	$l_apply		= "Aplicar cambios";
120
	$l_apply		= "Aplicar cambios";
121
	$l_local_dns		= "Resolución de Nombres Local (DNS)";
121
	$l_local_dns		= "Resolución de Nombres Local (DNS)";
122
	$l_import_cert		= "Importar Certificado";
122
	$l_import_cert		= "Importar Certificado";
123
	$l_private_key		= "Clave Privada (.key) :";
123
	$l_private_key		= "Clave Privada (.key) :";
124
	$l_certificate		= "Certificado (.crt) :";
124
	$l_certificate		= "Certificado (.crt) :";
125
	$l_server_chain		= "Cadena completa (de ser necesario: .crt) :";
125
	$l_server_chain		= "Cadena completa (de ser necesario: .crt) :";
126
	$l_default_cert		= "Volverl al certificado por defecto";
126
	$l_default_cert		= "Volverl al certificado por defecto";
127
	$l_import		= "Importar";
127
	$l_import		= "Importar";
128
	$l_current_certificate  = "Certificado en uso";
128
	$l_current_certificate  = "Certificado en uso";
129
	$l_validated		= "Validado por :";
129
	$l_validated		= "Validado por :";
130
	$l_empty		= "Vacío";
130
	$l_empty		= "Vacío";
131
	$l_yes			= "Si";
131
	$l_yes			= "Si";
132
	$l_no			= "No";
132
	$l_no			= "No";
133
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
133
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
134
	$l_cert_expiration	= "Fecha de vencimiento:";
134
	$l_cert_expiration	= "Fecha de vencimiento:";
135
	$l_cert_commonname	= "Common name:";
135
	$l_cert_commonname	= "Common name:";
136
	$l_cert_organization	= "Organización:";
136
	$l_cert_organization	= "Organización:";
137
	$l_upload_certificate	= "Importar un certificado";
137
	$l_upload_certificate	= "Importar un certificado";
138
	$l_le_integration	= "Integración con Let's Encrypt";
138
	$l_le_integration	= "Integración con Let's Encrypt";
139
	$l_le_status		= "Estado:";
139
	$l_le_status		= "Estado:";
140
	$l_disabled		= "Desactivado";
140
	$l_disabled		= "Desactivado";
141
	$l_pending_validation	= "Validación pendiente";
141
	$l_pending_validation	= "Validación pendiente";
142
	$l_enabled		= "Activado";
142
	$l_enabled		= "Activado";
143
	$l_le_email		= "Email:";
143
	$l_le_email		= "Email:";
144
	$l_le_domain_name	= "Nombre de dominio:";
144
	$l_le_domain_name	= "Nombre de dominio:";
145
	$l_send			= "Enviar";
145
	$l_send			= "Enviar";
146
	$l_le_ask_on		= "Preguntar el:";
146
	$l_le_ask_on		= "Preguntar el:";
147
	$l_le_dns_entry_txt	= "Entrada DNS TXT:";
147
	$l_le_dns_entry_txt	= "Entrada DNS TXT:";
148
	$l_le_challenge		= "Desafío:";
148
	$l_le_challenge		= "Desafío:";
149
	$l_recheck		= "Verificar";
149
	$l_recheck		= "Verificar";
150
	$l_cancel		= "Cancelar";
150
	$l_cancel		= "Cancelar";
151
	$l_le_api		= "API:";
151
	$l_le_api		= "API:";
152
	$l_le_next_renewal	= "Siguiente renovación:";
152
	$l_le_next_renewal	= "Siguiente renovación:";
153
	$l_renew		= "Renovar";
153
	$l_renew		= "Renovar";
154
	$l_renew_force		= "Renovar (forzado)";
154
	$l_renew_force		= "Renovar (forzado)";
155
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
155
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
156
} else {
156
} else {
157
	$l_network_title	= "Network configuration";
157
	$l_network_title	= "Network configuration";
158
	$l_internet_legend	= "INTERNET";
158
	$l_internet_legend	= "INTERNET";
159
	$l_ip_mask		= "Mask";
159
	$l_ip_mask		= "Mask";
160
	$l_ip_router		= "Gateway";
160
	$l_ip_router		= "Gateway";
161
	$l_ip_public		= "Public IP address";
161
	$l_ip_public		= "Public IP address";
162
	$l_ip_dns1		= "DNS n°1";
162
	$l_ip_dns1		= "DNS n°1";
163
	$l_ip_dns2		= "DNS n°2";
163
	$l_ip_dns2		= "DNS n°2";
164
	$l_dhcp_title		= "DHCP service";
164
	$l_dhcp_title		= "DHCP service";
165
	$l_dhcp_state		= "Current mode";
165
	$l_dhcp_state		= "Current mode";
166
	$l_DHCP_on		= "enabled";
166
	$l_DHCP_on		= "enabled";
167
	$l_DHCP_off		= "disabled";
167
	$l_DHCP_off		= "disabled";
168
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
168
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
169
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
169
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
170
	$l_mac_address		= "MAC address";
170
	$l_mac_address		= "MAC address";
171
	$l_ip_address		= "IP address";
171
	$l_ip_address		= "IP address";
172
	$l_host_name		= "Host name";
172
	$l_host_name		= "Host name";
173
	$l_del			= "Delete from list";
173
	$l_del			= "Delete from list";
174
	$l_add_to_list		= "Add";
174
	$l_add_to_list		= "Add";
175
	$l_apply		= "Apply changes";
175
	$l_apply		= "Apply changes";
176
	$l_local_dns		= "Local name resolution (DNS";
176
	$l_local_dns		= "Local name resolution (DNS";
177
	$l_import_cert		= "Certificate import";
177
	$l_import_cert		= "Certificate import";
178
	$l_private_key		= "Private key (.key) :";
178
	$l_private_key		= "Private key (.key) :";
179
	$l_certificate		= "Certificate (.crt or .cer) :";
179
	$l_certificate		= "Certificate (.crt or .cer) :";
180
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
180
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
181
	$l_default_cert		= "Back to default certificate :";
181
	$l_default_cert		= "Back to default certificate :";
182
	$l_import		= "Import";
182
	$l_import		= "Import";
183
	$l_current_certificate  = "Current certificate";
183
	$l_current_certificate  = "Current certificate";
184
	$l_validated		= "Validated by :";
184
	$l_validated		= "Validated by :";
185
	$l_empty		= "Empty";
185
	$l_empty		= "Empty";
186
	$l_yes			= "Yes";
186
	$l_yes			= "Yes";
187
	$l_no			= "No";
187
	$l_no			= "No";
188
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
188
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
189
	$l_cert_expiration	= "Expiration date:";
189
	$l_cert_expiration	= "Expiration date:";
190
	$l_cert_commonname	= "Common name:";
190
	$l_cert_commonname	= "Common name:";
191
	$l_cert_organization	= "Organization:";
191
	$l_cert_organization	= "Organization:";
192
	$l_upload_certificate	= "Import an officlal certificate";
192
	$l_upload_certificate	= "Import an officlal certificate";
193
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
193
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
194
	$l_le_status		= "Status:";
194
	$l_le_status		= "Status:";
195
	$l_disabled		= "Disabled";
195
	$l_disabled		= "Disabled";
196
	$l_pending_validation	= "Pending validation";
196
	$l_pending_validation	= "Pending validation";
197
	$l_enabled		= "Enabled";
197
	$l_enabled		= "Enabled";
198
	$l_le_email		= "Email:";
198
	$l_le_email		= "Email:";
199
	$l_le_domain_name	= "Domain name:";
199
	$l_le_domain_name	= "Domain name:";
200
	$l_send			= "Send";
200
	$l_send			= "Send";
201
	$l_le_ask_on		= "Ask on:";
201
	$l_le_ask_on		= "Ask on:";
202
	$l_le_dns_entry_txt	= "DNS TXT entry:";
202
	$l_le_dns_entry_txt	= "DNS TXT entry:";
203
	$l_le_challenge		= "Challenge:";
203
	$l_le_challenge		= "Challenge:";
204
	$l_recheck		= "Recheck";
204
	$l_recheck		= "Recheck";
205
	$l_cancel		= "Cancel";
205
	$l_cancel		= "Cancel";
206
	$l_le_api		= "API:";
206
	$l_le_api		= "API:";
207
	$l_le_next_renewal	= "Next renewal:";
207
	$l_le_next_renewal	= "Next renewal:";
208
	$l_renew		= "Renew";
208
	$l_renew		= "Renew";
209
	$l_renew_force		= "Renew (force)";
209
	$l_renew_force		= "Renew (force)";
210
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
210
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
211
}
211
}
212
 
212
 
213
$reg_ip      = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
213
$reg_ip      = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
214
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
214
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
215
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
215
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
216
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
216
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
217
 
217
 
218
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
218
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
219
 
219
 
220
switch ($choix) {
220
switch ($choix) {
221
	case 'DHCP_On':
221
	case 'DHCP_On':
222
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
222
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
223
		header('Location: '.$_SERVER['PHP_SELF']);
223
		header('Location: '.$_SERVER['PHP_SELF']);
224
		exit();
224
		exit();
225
	case 'DHCP_Off':
225
	case 'DHCP_Off':
226
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
226
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
227
		header('Location: '.$_SERVER['PHP_SELF']);
227
		header('Location: '.$_SERVER['PHP_SELF']);
228
		exit();
228
		exit();
229
 
229
 
230
	case 'new_mac':
230
	case 'new_mac':
231
		$new_mac_addr = trim($_POST['add_mac']);
231
		$new_mac_addr = trim($_POST['add_mac']);
232
		$new_ip_addr  = trim($_POST['add_ip']);
232
		$new_ip_addr  = trim($_POST['add_ip']);
233
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
233
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
234
			$tab = file(ETHERS_FILE);
234
			$tab = file(ETHERS_FILE);
235
			if ($tab) { // the file isn't empty
235
			if ($tab) { // the file isn't empty
236
				$insert = true;
236
				$insert = true;
237
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
237
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
238
					$field = explode(' ', $line);
238
					$field = explode(' ', $line);
239
					$mac_addr = trim($field[0]);
239
					$mac_addr = trim($field[0]);
240
					$ip_addr  = trim($field[1]);
240
					$ip_addr  = trim($field[1]);
241
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
241
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
242
						$insert = false;
242
						$insert = false;
243
						break;
243
						break;
244
					}
244
					}
245
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
245
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
246
						$insert = false;
246
						$insert = false;
247
						break;
247
						break;
248
					}
248
					}
249
				}
249
				}
250
				if ($insert) {
250
				if ($insert) {
251
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
251
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
252
					$pointeur = fopen(ETHERS_FILE, 'a');
252
					$pointeur = fopen(ETHERS_FILE, 'a');
253
					fwrite($pointeur, $line);
253
					fwrite($pointeur, $line);
254
					fclose($pointeur);
254
					fclose($pointeur);
255
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
255
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
256
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
256
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
257
					fwrite($pointeur, $line);
257
					fwrite($pointeur, $line);
258
					fclose($pointeur);
258
					fclose($pointeur);
259
					exec('sudo /usr/bin/systemctl reload chilli');
259
					exec('sudo /usr/bin/systemctl reload chilli');
260
				}
260
				}
261
			}
261
			}
262
		}
262
		}
263
		header('Location: '.$_SERVER['PHP_SELF']);
263
		header('Location: '.$_SERVER['PHP_SELF']);
264
		exit();
264
		exit();
265
	case 'del_mac':
265
	case 'del_mac':
266
		foreach ($_POST as $key => $value) {
266
		foreach ($_POST as $key => $value) {
267
			if ($value == 'on') {
267
			if ($value == 'on') {
268
				$ether_file = ETHERS_FILE;
268
				$ether_file = ETHERS_FILE;
269
				$ether_file_info = ETHERS_INFO_FILE;
269
				$ether_file_info = ETHERS_INFO_FILE;
270
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
270
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
271
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
271
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
272
				exec('sudo /usr/bin/systemctl reload chilli');
272
				exec('sudo /usr/bin/systemctl reload chilli');
273
			}
273
			}
274
		}
274
		}
275
		header('Location: '.$_SERVER['PHP_SELF']);
275
		header('Location: '.$_SERVER['PHP_SELF']);
276
		exit();
276
		exit();
277
 
277
 
278
	case 'new_host':
278
	case 'new_host':
279
		$add_host = trim($_POST['add_host']);
279
		$add_host = trim($_POST['add_host']);
280
		$add_ip   = trim($_POST['add_ip']);
280
		$add_ip   = trim($_POST['add_ip']);
281
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
281
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
282
			$tab = file(DNS_LOCAL_FILE);
282
			$tab = file(DNS_LOCAL_FILE);
283
			if ($tab) { // the file isn't empty
283
			if ($tab) { // the file isn't empty
284
				$insert = true;
284
				$insert = true;
285
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
285
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
286
					if (preg_match('/^\d+/', $line)) {
286
					if (preg_match('/^\d+/', $line)) {
287
						$field = preg_split("/\s+/",$line);
287
						$field = preg_split("/\s+/",$line);
288
						$ip_addr = $field[0];
288
						$ip_addr = $field[0];
289
						$host_name = trim($field[1]);
289
						$host_name = trim($field[1]);
290
						if (strcasecmp($add_host, $host_name) === 0) {
290
						if (strcasecmp($add_host, $host_name) === 0) {
291
							$insert = false;
291
							$insert = false;
292
							break;
292
							break;
293
						}
293
						}
294
					}
294
					}
295
				}
295
				}
296
				if ($insert) {
296
				if ($insert) {
297
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
297
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
298
				}
298
				}
299
			}
299
			}
300
		}
300
		}
301
		header('Location: '.$_SERVER['PHP_SELF']);
301
		header('Location: '.$_SERVER['PHP_SELF']);
302
		exit();
302
		exit();
303
	case 'del_host':
303
	case 'del_host':
304
		foreach ($_POST as $key => $value) {
304
		foreach ($_POST as $key => $value) {
305
			if ($value == 'on') {
305
			if ($value == 'on') {
306
				$del_host = explode ("|", $key);
306
				$del_host = explode ("|", $key);
307
				$del_ip = str_replace("_",".",$del_host[0]);
307
				$del_ip = str_replace("_",".",$del_host[0]);
308
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
308
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
309
			}
309
			}
310
		}
310
		}
311
		header('Location: '.$_SERVER['PHP_SELF']);
311
		header('Location: '.$_SERVER['PHP_SELF']);
312
		exit();
312
		exit();
313
 
313
 
314
	case 'set_default_cert':
314
	case 'set_default_cert':
315
		exec('sudo alcasar-importcert.sh -d');
315
		exec('sudo alcasar-importcert.sh -d');
316
		break;
316
		break;
317
	case 'set_last_LE_cert':
317
	case 'set_last_LE_cert':
318
		exec('sudo alcasar-letsencrypt.sh --install-cert');
318
		exec('sudo alcasar-letsencrypt.sh --install-cert');
319
		break;
319
		break;
320
	case 'import_cert':	// Import certificate
320
	case 'import_cert':	// Import certificate
321
		$maxsize = 100000;
321
		$maxsize = 100000;
322
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
322
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
323
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
323
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
324
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
324
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
325
					$dest = '/tmp/';
325
					$dest = '/tmp/';
326
					$scpath = '';
326
					$scpath = '';
327
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
327
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
328
						$scpath = $dest.'server-chain.pem';
328
						$scpath = $dest.'server-chain.pem';
329
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
329
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
330
					}
330
					}
331
					$keypath = $dest.'alcasar.key';
331
					$keypath = $dest.'alcasar.key';
332
					$crtpath = $dest.'alcasar.crt';
332
					$crtpath = $dest.'alcasar.crt';
333
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
333
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
334
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
334
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
335
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
335
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
336
					if (file_exists($crtpath)) unlink($crtpath);
336
					if (file_exists($crtpath)) unlink($crtpath);
337
					if (file_exists($keypath)) unlink($keypath);
337
					if (file_exists($keypath)) unlink($keypath);
338
					if (file_exists($scpath))  unlink($scpath);
338
					if (file_exists($scpath))  unlink($scpath);
339
				}
339
				}
340
			}
340
			}
341
		}
341
		}
342
		break;
342
		break;
343
 
343
 
344
	case 'https_login':	// Set HTTPS login status
344
	case 'https_login':	// Set HTTPS login status
345
		if ($_POST['https_login'] === 'on') {
345
		if ($_POST['https_login'] === 'on') {
346
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
346
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
347
		} else {
347
		} else {
348
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
348
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
349
		}
349
		}
350
		header('Location: '.$_SERVER['PHP_SELF']);
350
		header('Location: '.$_SERVER['PHP_SELF']);
351
		exit();
351
		exit();
352
}
352
}
353
 
353
 
354
// Network changes
354
// Network changes
355
if ($choix === 'network_change') {
355
if ($choix === 'network_change') {
356
	$network_modification = false;
356
	$network_modification = false;
357
 
357
 
358
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1']) && preg_match($reg_ip, $_POST['dns1'])) {
358
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1']) && preg_match($reg_ip, $_POST['dns1'])) {
359
		file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(CONF_FILE)));
359
		file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(CONF_FILE)));
360
		$network_modification = true;
360
		$network_modification = true;
361
	}
361
	}
362
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2']) && preg_match($reg_ip, $_POST['dns2'])) {
362
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2']) && preg_match($reg_ip, $_POST['dns2'])) {
363
		file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(CONF_FILE)));
363
		file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(CONF_FILE)));
364
		$network_modification = true;
364
		$network_modification = true;
365
	}
365
	}
366
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP']) && preg_match($reg_ip_cidr, $_POST['ip_public'])) {
366
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP']) && preg_match($reg_ip_cidr, $_POST['ip_public'])) {
367
		file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(CONF_FILE)));
367
		file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(CONF_FILE)));
368
		$network_modification = true;
368
		$network_modification = true;
369
	}
369
	}
370
	if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW']) && preg_match($reg_ip, $_POST['ip_gw'])) {
370
	if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW']) && preg_match($reg_ip, $_POST['ip_gw'])) {
371
		file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(CONF_FILE)));
371
		file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(CONF_FILE)));
372
		$network_modification = true;
372
		$network_modification = true;
373
	}
373
	}
374
	if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP']) && preg_match($reg_ip_cidr, $_POST['ip_private'])) {
374
	if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP']) && preg_match($reg_ip_cidr, $_POST['ip_private'])) {
375
		file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(CONF_FILE)));
375
		file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(CONF_FILE)));
376
		$network_modification = true;
376
		$network_modification = true;
377
	}
377
	}
378
 
378
 
379
	if ($network_modification) {
379
	if ($network_modification) {
380
		exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
380
		exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
381
	}
381
	}
382
 
382
 
383
	// Read CONF_FILE updated
383
	// Read CONF_FILE updated
384
	$file_conf = fopen(CONF_FILE, 'r');
384
	$file_conf = fopen(CONF_FILE, 'r');
385
	if (!$file_conf) {
385
	if (!$file_conf) {
386
		exit('Error opening the file '.CONF_FILE);
386
		exit('Error opening the file '.CONF_FILE);
387
	}
387
	}
388
	while (!feof($file_conf)) {
388
	while (!feof($file_conf)) {
389
		$buffer = fgets($file_conf, 4096);
389
		$buffer = fgets($file_conf, 4096);
390
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
390
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
391
			$tmp = explode('=', $buffer, 2);
391
			$tmp = explode('=', $buffer, 2);
392
			$conf[trim($tmp[0])] = trim($tmp[1]);
392
			$conf[trim($tmp[0])] = trim($tmp[1]);
393
		}
393
		}
394
	}
394
	}
395
	fclose($file_conf);
395
	fclose($file_conf);
396
}
396
}
397
 
397
 
398
// Let's Encrypt actions
398
// Let's Encrypt actions
399
if ($choix === 'le_issueCert') {
399
if ($choix === 'le_issueCert') {
400
	// TODO: check ndd & mail format
400
	// TODO: check ndd & mail format
401
	$email      = $_POST['email'];
401
	$email      = $_POST['email'];
402
	$domainName = $_POST['domainname'];
402
	$domainName = $_POST['domainname'];
403
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
403
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
404
	$cmdResponse = implode("<br>\n", $output);
404
	$cmdResponse = implode("<br>\n", $output);
405
}
405
}
406
if ($choix === 'le_renewCert') {
406
if ($choix === 'le_renewCert') {
407
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
407
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
408
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
408
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
409
 
409
 
410
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
410
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
411
 
411
 
412
		$cmdResponse = implode("<br>\n", $output);
412
		$cmdResponse = implode("<br>\n", $output);
413
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
413
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
414
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
414
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
415
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
415
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
416
	}
416
	}
417
}
417
}
418
 
418
 
419
// Read Let's Encrypt configuration file
419
// Read Let's Encrypt configuration file
420
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
420
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
421
if (!$file_conf_LE) {
421
if (!$file_conf_LE) {
422
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
422
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
423
}
423
}
424
while (!feof($file_conf_LE)) {
424
while (!feof($file_conf_LE)) {
425
	$buffer = fgets($file_conf_LE, 4096);
425
	$buffer = fgets($file_conf_LE, 4096);
426
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
426
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
427
		$tmp = explode('=', $buffer, 2);
427
		$tmp = explode('=', $buffer, 2);
428
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
428
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
429
	}
429
	}
430
}
430
}
431
fclose($file_conf_LE);
431
fclose($file_conf_LE);
432
 
432
 
433
// Fonction de test de connectivité internet
433
// Fonction de test de connectivité internet
434
function internetTest() {
434
function internetTest() {
435
	$host = 'www.google.fr'; # Google Test
435
	$host = 'www.google.fr'; # Google Test
436
	$port = '80';
436
	$port = '80';
437
 
437
 
438
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
438
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
439
		return false;
439
		return false;
440
	} else {
440
	} else {
441
		fclose($sock);
441
		fclose($sock);
442
		return true;
442
		return true;
443
	}
443
	}
444
}
444
}
445
 
445
 
446
$internet_connected = InternetTest();
446
$internet_connected = InternetTest();
447
if ($internet_connected) {
447
if ($internet_connected) {
448
	$ch = curl_init('https://api.ipify.org/');
448
	$ch = curl_init('https://api.ipify.org/');
449
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
449
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
450
	$internet_publicIP = curl_exec($ch);
450
	$internet_publicIP = curl_exec($ch);
451
	curl_close($ch);
451
	curl_close($ch);
452
} else {
452
} else {
453
	$internet_publicIP = '-.-.-.-';
453
	$internet_publicIP = '-.-.-.-';
454
}
454
}
455
 
455
 
456
// Network interfaces
456
// Network interfaces
457
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
457
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
458
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
458
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
459
 
459
 
460
// TODO: Pending the next version
460
// TODO: Pending the next version
461
$externalNetworks = [
461
$externalNetworks = [
462
	(object) [
462
	(object) [
463
		'interface' => $conf['EXTIF'],
463
		'interface' => $conf['EXTIF'],
464
		'ip'        => $conf['PUBLIC_IP'],
464
		'ip'        => $conf['PUBLIC_IP'],
465
		'gateway'   => $conf['GW']
465
		'gateway'   => $conf['GW']
466
	]
466
	]
467
];
467
];
468
$internalNetworks = [
468
$internalNetworks = [
469
	(object) [
469
	(object) [
470
		'interface' => $conf['INTIF'],
470
		'interface' => $conf['INTIF'],
471
		'ip'        => $conf['PRIVATE_IP']
471
		'ip'        => $conf['PRIVATE_IP']
472
	]
472
	]
473
];
473
];
474
 
474
 
475
?>
475
?>
476
<!DOCTYPE HTML>
476
<!DOCTYPE HTML>
477
<html>
477
<html>
478
<head>
478
<head>
479
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
479
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
480
	<title><?= $l_network_title ?></title>
480
	<title><?= $l_network_title ?></title>
481
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
481
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
482
	<script src="/js/jquery.min.js"></script>
482
	<script src="/js/jquery.min.js"></script>
483
	<script src="/js/jquery.connections.js"></script>
483
	<script src="/js/jquery.connections.js"></script>
484
	<script type="text/javascript">
484
	<script type="text/javascript">
485
	function MAC_Control(formulaire){
485
	function MAC_Control(formulaire){
486
		// MAC control (upper case and '-' separator)
486
		// MAC control (upper case and '-' separator)
487
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
487
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
488
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
488
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
489
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
489
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
490
			return true;
490
			return true;
491
		} else {
491
		} else {
492
			alert('Invalid MAC address');
492
			alert('Invalid MAC address');
493
			return false;
493
			return false;
494
		}
494
		}
495
	}
495
	}
496
	</script>
496
	</script>
497
	<style>
497
	<style>
498
		.network-configurator {
498
		.network-configurator {
499
			width: 100%;
499
			width: 100%;
500
		}
500
		}
501
		.network-configurator > * {
501
		.network-configurator > * {
502
			display: inline-block;
502
			display: inline-block;
503
			vertical-align: top;
503
			vertical-align: top;
504
			text-align: center;
504
			text-align: center;
505
		}
505
		}
506
		.network-configurator > .internet, .network-configurator > .alcasar {
506
		.network-configurator > .internet, .network-configurator > .alcasar {
507
			width: 20%;
507
			width: 20%;
508
		}
508
		}
509
		.network-configurator > .externals, .network-configurator > .internals {
509
		.network-configurator > .externals, .network-configurator > .internals {
510
			width: 30%;
510
			width: 30%;
511
		}
511
		}
512
		.network-configurator .actions {
512
		.network-configurator .actions {
513
			position: absolute;
513
			position: absolute;
514
			background-color: #ddd;
514
			background-color: #ddd;
515
			padding: 0 2px;
515
			padding: 0 2px;
516
		}
516
		}
517
		.network-configurator .actions a {
517
		.network-configurator .actions a {
518
			text-decoration: none;
518
			text-decoration: none;
519
		}
519
		}
520
		.network-configurator .actions a:hover {
520
		.network-configurator .actions a:hover {
521
			font-weight: bold;
521
			font-weight: bold;
522
		}
522
		}
523
		.network-configurator > .alcasar .actions-externals {
523
		.network-configurator > .alcasar .actions-externals {
524
			bottom: 0;
524
			bottom: 0;
525
			left: 0;
525
			left: 0;
526
			border-radius: 0 5px;
526
			border-radius: 0 5px;
527
		}
527
		}
528
		.network-configurator > .alcasar .actions-internals {
528
		.network-configurator > .alcasar .actions-internals {
529
			bottom: 0;
529
			bottom: 0;
530
			right: 0;
530
			right: 0;
531
			border-radius: 5px 0;
531
			border-radius: 5px 0;
532
		}
532
		}
533
		.network-configurator .actions-network {
533
		.network-configurator .actions-network {
534
			top: 0;
534
			top: 0;
535
			right: 0;
535
			right: 0;
536
			border-radius: 0 5px;
536
			border-radius: 0 5px;
537
		}
537
		}
538
		.network-configurator .network-box {
538
		.network-configurator .network-box {
539
			display: inline-block;
539
			display: inline-block;
540
			min-height: 100px;
540
			min-height: 100px;
541
			margin: 5px;
541
			margin: 5px;
542
			padding: 3px;
542
			padding: 3px;
543
			text-align: left;
543
			text-align: left;
544
			background-color: #f7f3ef;
544
			background-color: #f7f3ef;
545
			position: relative;
545
			position: relative;
546
			border-radius: 5px;
546
			border-radius: 5px;
547
			border: 2px solid grey;
547
			border: 2px solid grey;
548
		}
548
		}
549
		.network-configurator .network-connector {
549
		.network-configurator .network-connector {
550
			display: inline-block;
550
			display: inline-block;
551
			position: absolute;
551
			position: absolute;
552
			top: 50%;
552
			top: 50%;
553
			margin-top: -5px;
553
			margin-top: -5px;
554
			margin-left: -5px;
554
			margin-left: -5px;
555
			width: 10px;
555
			width: 10px;
556
			height: 10px;
556
			height: 10px;
557
			border-radius: 5px;
557
			border-radius: 5px;
558
			background-color: black;
558
			background-color: black;
559
		}
559
		}
560
		.network-configurator .network-connector[data-connector-direction="left"] {
560
		.network-configurator .network-connector[data-connector-direction="left"] {
561
			border-radius: 5px 0px 0px 5px;
561
			border-radius: 5px 0px 0px 5px;
562
		}
562
		}
563
		.network-configurator .network-connector[data-connector-direction="right"] {
563
		.network-configurator .network-connector[data-connector-direction="right"] {
564
			border-radius: 0px 5px 5px 0px;
564
			border-radius: 0px 5px 5px 0px;
565
		}
565
		}
566
		.network-configurator div[data-network-type] {
566
		.network-configurator div[data-network-type] {
567
			position: relative;
567
			position: relative;
568
		}
568
		}
569
	</style>
569
	</style>
570
	<script>
570
	<script>
571
	$(document).ready(function () {
571
	$(document).ready(function () {
572
		const interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
572
		const interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
573
 
573
 
574
		const wireStyles = {
574
		const wireStyles = {
575
			available: { border: '5px double green' }
575
			available: { border: '5px double green' }
576
		};
576
		};
577
 
577
 
578
		// Add external network
578
		// Add external network
579
		$('.network-configurator .add-external-network').click(function (event) {
579
		$('.network-configurator .add-external-network').click(function (event) {
580
			event.preventDefault();
580
			event.preventDefault();
581
			let options = '';
581
			let options = '';
582
			if (interfacesAvailable.length === 0) {
582
			if (interfacesAvailable.length === 0) {
583
				options = '<option value=""></option>';
583
				options = '<option value=""></option>';
584
			} else {
584
			} else {
585
				for (let i = 0; i < interfacesAvailable.length; i++) {
585
				for (let i = 0; i < interfacesAvailable.length; i++) {
586
					options += '<option value="' + interfacesAvailable[i] + '">' + interfacesAvailable[i] + '</option>';
586
					options += '<option value="' + interfacesAvailable[i] + '">' + interfacesAvailable[i] + '</option>';
587
				}
587
				}
588
			}
588
			}
589
			$('.network-configurator .externals').append(' \
589
			$('.network-configurator .externals').append(' \
590
				<div data-network-type="external"> \
590
				<div data-network-type="external"> \
591
					<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div> \
591
					<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div> \
592
					<div class="network-box"> \
592
					<div class="network-box"> \
593
						<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
593
						<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
594
						<label for="ext_interface_X"><?= 'Interface' ?></label> <select name="interface" id="ext_interface_X">' + options + '</select><br> \
594
						<label for="ext_interface_X"><?= 'Interface' ?></label> <select name="interface" id="ext_interface_X">' + options + '</select><br> \
595
						<label for="ext_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_X" value="" /><br> \
595
						<label for="ext_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_X" value="" /><br> \
596
						<label for="ext_gateway_X"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_X" value="" /> \
596
						<label for="ext_gateway_X"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_X" value="" /> \
597
					</div> \
597
					</div> \
598
					<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div> \
598
					<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div> \
599
				</div>');
599
				</div>');
600
			addWire($('div[data-network-type="external"]:last'));
600
			addWire($('div[data-network-type="external"]:last'));
601
		});
601
		});
602
 
602
 
603
		// Add internal network
603
		// Add internal network
604
		$('.network-configurator .add-internal-network').click(function (event) {
604
		$('.network-configurator .add-internal-network').click(function (event) {
605
			event.preventDefault();
605
			event.preventDefault();
606
			$('.network-configurator .internals').append(' \
606
			$('.network-configurator .internals').append(' \
607
					<div data-network-type="internal"> \
607
					<div data-network-type="internal"> \
608
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
608
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
609
						<div class="network-box"> \
609
						<div class="network-box"> \
610
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
610
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
611
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><br> \
611
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><br> \
612
							<label for="int_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_X" value="" /><br> \
612
							<label for="int_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_X" value="" /><br> \
613
						</div> \
613
						</div> \
614
					</div>');
614
					</div>');
615
			addWire($('div[data-network-type="internal"]:last'));
615
			addWire($('div[data-network-type="internal"]:last'));
616
		});
616
		});
617
 
617
 
618
		// Remove network
618
		// Remove network
619
		$('.network-configurator').on('click', '.remove-network', function (event) {
619
		$('.network-configurator').on('click', '.remove-network', function (event) {
620
			event.preventDefault();
620
			event.preventDefault();
621
			$(this).parent().parent().parent().fadeOut(200, function() {
621
			$(this).parent().parent().parent().fadeOut(200, function() {
622
				const networkType = $(this).data('networkType');
622
				const networkType = $(this).data('networkType');
623
				$(this).remove();
623
				$(this).remove();
624
 
624
 
625
				// Update wires
625
				// Update wires
626
				if (networkType === 'external') {
626
				if (networkType === 'external') {
627
					$('div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]').connections('update');
627
					$('div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]').connections('update');
628
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]').connections('update');
628
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]').connections('update');
629
				} else if (networkType === 'internal') {
629
				} else if (networkType === 'internal') {
630
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]').connections('update');
630
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]').connections('update');
631
				}
631
				}
632
			});
632
			});
633
		});
633
		});
634
 
634
 
635
		const addWire = function (network) {
635
		const addWire = function (network) {
636
			const networkType = network.data('networkType');
636
			const networkType = network.data('networkType');
637
			if (networkType === 'external') {
637
			if (networkType === 'external') {
638
				$().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="internet"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
638
				$().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="internet"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
639
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="external"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
639
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="external"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
640
			} else if (networkType === 'internal') {
640
			} else if (networkType === 'internal') {
641
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: 'div[data-network-type="internal"]>div.network-connector[data-connector-network="internal"]:last', css: wireStyles.available, within: 'div[data-network-type="internal"]:last' });
641
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: 'div[data-network-type="internal"]>div.network-connector[data-connector-network="internal"]:last', css: wireStyles.available, within: 'div[data-network-type="internal"]:last' });
642
			}
642
			}
643
		};
643
		};
644
 
644
 
645
		window.addEventListener('resize', function () {
645
		window.addEventListener('resize', function () {
646
			$('div.network-connector[data-connector-network]').connections('update');
646
			$('div.network-connector[data-connector-network]').connections('update');
647
		});
647
		});
648
 
648
 
649
		// Add wires to existing networks
649
		// Add wires to existing networks
650
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
650
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
651
			addWire($(this));
651
			addWire($(this));
652
		});
652
		});
653
	});
653
	});
654
	</script>
654
	</script>
655
</head>
655
</head>
656
<body>
656
<body>
657
<div class="panel">
657
<div class="panel">
658
	<div class="panel-header"><?= $l_network_title ?></div>
658
	<div class="panel-header"><?= $l_network_title ?></div>
659
	<div class="panel-row">
659
	<div class="panel-row">
660
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
660
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
661
			<div class="network-configurator">
661
			<div class="network-configurator">
662
				<div class="internet">
662
				<div class="internet">
663
					<div data-network-type="internet">
663
					<div data-network-type="internet">
664
						<div class="network-box">
664
						<div class="network-box">
665
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
665
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
666
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
666
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
667
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
667
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
668
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
668
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
669
						</div>
669
						</div>
670
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
670
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
671
					</div>
671
					</div>
672
				</div><div class="externals">
672
				</div><div class="externals">
673
					<?php foreach ($externalNetworks as $index => $network): ?>
673
					<?php foreach ($externalNetworks as $index => $network): ?>
674
						<div data-network-type="external">
674
						<div data-network-type="external">
675
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
675
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
676
							<div class="network-box">
676
							<div class="network-box">
677
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
677
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
678
								<label for="ext_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="ext_interface[<?= $index ?>]" id="ext_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
678
								<label for="ext_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="ext_interface[<?= $index ?>]" id="ext_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
679
								<label for="ext_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
679
								<label for="ext_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
680
								<label for="ext_gateway_<?= $index ?>"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
680
								<label for="ext_gateway_<?= $index ?>"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
681
							</div>
681
							</div>
682
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
682
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
683
						</div>
683
						</div>
684
					<? endforeach; ?>
684
					<? endforeach; ?>
685
				</div><div class="alcasar">
685
				</div><div class="alcasar">
686
					<div data-network-type="alcasar">
686
					<div data-network-type="alcasar">
687
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
687
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
688
						<div class="network-box">
688
						<div class="network-box">
689
							<!-- <div class="actions actions-externals">
689
							<!-- <div class="actions actions-externals">
690
								<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
690
								<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
691
							</div> -->
691
							</div> -->
692
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
692
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
693
							<!-- <div class="actions actions-internals">
693
							<!-- <div class="actions actions-internals">
694
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
694
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
695
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
695
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
696
							</div> -->
696
							</div> -->
697
						</div>
697
						</div>
698
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
698
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
699
					</div>
699
					</div>
700
				</div><div class="internals">
700
				</div><div class="internals">
701
					<?php foreach ($internalNetworks as $network): ?>
701
					<?php foreach ($internalNetworks as $network): ?>
702
						<div data-network-type="internal">
702
						<div data-network-type="internal">
703
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
703
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
704
							<div class="network-box">
704
							<div class="network-box">
705
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
705
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
706
								<label for="int_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="int_interface[<?= $index ?>]" id="int_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
706
								<label for="int_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="int_interface[<?= $index ?>]" id="int_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
707
								<label for="int_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
707
								<label for="int_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
708
							</div>
708
							</div>
709
						</div>
709
						</div>
710
					<? endforeach; ?>
710
					<? endforeach; ?>
711
				</div>
711
				</div>
712
			</div>
712
			</div>
713
			<hr>
713
			<hr>
714
			<div style="text-align: center; margin: 5px">
714
			<div style="text-align: center; margin: 5px">
715
				<input type="hidden" name="choix" value="network_change">
715
				<input type="hidden" name="choix" value="network_change">
716
				<input type="submit" value="<?= $l_apply ?>">
716
				<input type="submit" value="<?= $l_apply ?>">
717
			</div>
717
			</div>
718
		</form>
718
		</form>
719
	</div>
719
	</div>
720
</div>
720
</div>
721
<br>
721
<br>
722
<div class="panel">
722
<div class="panel">
723
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
723
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
724
</div>
724
</div>
725
<table width="100%" cellspacing="0" cellpadding="5" border="1">
725
<table width="100%" cellspacing="0" cellpadding="5" border="1">
726
	<tr><td width="50%" align="center" valign="middle">
726
	<tr><td width="50%" align="center" valign="middle">
727
		<form action="network.php" method="POST">
727
		<form action="network.php" method="POST">
728
		<table cellspacing="2" cellpadding="3" border="1">
728
		<table cellspacing="2" cellpadding="3" border="1">
729
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
729
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
730
		<?php
730
		<?php
731
		// Read the "ether" file
731
		// Read the "ether" file
732
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
732
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
733
		$detail = explode(' ', $output[1]);
733
		$detail = explode(' ', $output[1]);
734
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
734
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
735
		unset($output); unset($detail);
735
		unset($output); unset($detail);
736
		$line_exist = false;
736
		$line_exist = false;
737
		$tab = file(ETHERS_INFO_FILE);
737
		$tab = file(ETHERS_INFO_FILE);
738
		if ($tab) { // le fichier n'est pas vide
738
		if ($tab) { // le fichier n'est pas vide
739
			foreach ($tab as $line) {
739
			foreach ($tab as $line) {
740
				$fields = explode(' ', $line);
740
				$fields = explode(' ', $line);
741
				$mac_addr = $fields[0];
741
				$mac_addr = $fields[0];
742
				$ip_addr  = $fields[1];
742
				$ip_addr  = $fields[1];
743
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
743
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
744
 
-
 
745
				echo '<tr>';
744
				echo '<tr>';
746
				echo "<td>$mac_addr</td>";
745
				echo "<td>$mac_addr</td>";
747
				echo "<td>$ip_addr</td>";
746
				echo "<td>$ip_addr</td>";
748
				if ($mac_addr !== $intif_mac_addr) {
747
				if ($mac_addr !== $intif_mac_addr) {
749
					echo '<td>'.ltrim($info, '#').'</td>';
748
					echo '<td>'.ltrim($info, '#').'</td>';
750
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
749
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
751
					$line_exist=True;
750
					$line_exist=True;
752
				} else {
751
				} else {
753
					echo '<td>ALCASAR</td>';
752
					echo '<td>ALCASAR</td>';
754
					echo '<td></td>';
753
					echo '<td></td>';
755
				}
754
				}
756
				echo '</tr>';
755
				echo '</tr>';
757
			}
756
			}
758
		}
757
		}
759
		?>
758
		?>
760
		</table>
759
		</table>
761
		<?php if ($line_exist): ?>
760
		<?php if ($line_exist): ?>
762
			<input type="hidden" name="choix" value="del_mac">
761
			<input type="hidden" name="choix" value="del_mac">
763
			<input type="submit" value="<?= $l_apply ?>">
762
			<input type="submit" value="<?= $l_apply ?>">
764
		<?php endif; ?>
763
		<?php endif; ?>
765
		</form>
764
		</form>
766
	</td><td width="50%" valign="middle" align="center">
765
	</td><td width="50%" valign="middle" align="center">
767
		<form name="new_mac" action="network.php" method="POST">
766
		<form name="new_mac" action="network.php" method="POST">
768
			<table cellspacing="2" cellpadding="3" border="1">
767
			<table cellspacing="2" cellpadding="3" border="1">
769
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
768
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
770
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
769
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
771
				<tr><td><input type="text" name="add_mac" size="17"></td>
770
				<tr><td><input type="text" name="add_mac" size="17"></td>
772
				<td><input type="text" name="add_ip" size="10"></td>
771
				<td><input type="text" name="add_ip" size="10"></td>
773
				<td><input type="text" name="info" size="10"></td>
772
				<td><input type="text" name="info" size="10"></td>
774
				<td>
773
				<td>
775
					<input type="hidden" name="choix" value="new_mac">
774
					<input type="hidden" name="choix" value="new_mac">
776
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
775
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
777
				</td>
776
				</td>
778
			</tr></table>
777
			</tr></table>
779
		</form>
778
		</form>
780
	</td></tr>
779
	</td></tr>
781
</table>
780
</table>
782
<br>
781
<br>
783
<div class="panel">
782
<div class="panel">
784
	<div class="panel-header"><?= $l_local_dns ?></div>
783
	<div class="panel-header"><?= $l_local_dns ?></div>
785
</div>
784
</div>
786
<table width="100%" cellspacing="0" cellpadding="5" border="1">
785
<table width="100%" cellspacing="0" cellpadding="5" border="1">
787
	<tr>
786
	<tr>
788
		<td width="50%" align="center">
787
		<td width="50%" align="center">
789
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
788
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
790
			<table cellspacing="2" cellpadding="3" border="1">
789
			<table cellspacing="2" cellpadding="3" border="1">
791
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
790
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
792
			<?php
791
			<?php
793
			// Read the "dns_local" file
792
			// Read the "dns_local" file
794
			$line_exist = false;
793
			$line_exist = false;
795
			$tab = file(DNS_LOCAL_FILE);
794
			$tab = file(DNS_LOCAL_FILE);
796
			if ($tab) { // not empty
795
			if ($tab) { // not empty
797
				foreach ($tab as $line) {
796
				foreach ($tab as $line) {
798
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
797
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
799
						$line_exist = true;
798
						$line_exist = true;
800
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
799
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
801
						$ip_addr   = $field[0];
800
						$ip_addr   = $field[0];
802
						$host_name = $field[1];
801
						$host_name = $field[1];
803
						echo "<tr><td>$ip_addr</td>";
802
						echo "<tr><td>$ip_addr</td>";
804
						echo "<td>$host_name</td>";
803
						echo "<td>$host_name</td>";
805
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
804
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
806
							echo "<td>";}
805
							echo "<td>";}
807
						else {
806
						else {
808
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
807
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
809
						}
808
						}
810
						echo "</td></tr>";
809
						echo "</td></tr>";
811
					}
810
					}
812
				}
811
				}
813
			}
812
			}
814
			if (!$line_exist) {
813
			if (!$line_exist) {
815
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
814
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
816
			}
815
			}
817
			?>
816
			?>
818
			</table>
817
			</table>
819
			<?php if ($line_exist): ?>
818
			<?php if ($line_exist): ?>
820
				<input type="hidden" name="choix" value="del_host">
819
				<input type="hidden" name="choix" value="del_host">
821
				<input type="submit" value="<?= $l_apply ?>">
820
				<input type="submit" value="<?= $l_apply ?>">
822
			<?php endif; ?>
821
			<?php endif; ?>
823
			</form>
822
			</form>
824
		</td>
823
		</td>
825
		<td width="50%" valign="middle" align="center">
824
		<td width="50%" valign="middle" align="center">
826
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
825
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
827
			<table cellspacing="2" cellpadding="3" border="1">
826
			<table cellspacing="2" cellpadding="3" border="1">
828
			<tr>
827
			<tr>
829
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
828
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
830
			</tr>
829
			</tr>
831
			<tr>
830
			<tr>
832
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
831
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
833
			</tr>
832
			</tr>
834
			<tr>
833
			<tr>
835
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
834
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
836
				<td><input type="text" name="add_host" size="17"></td>
835
				<td><input type="text" name="add_host" size="17"></td>
837
				<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
836
				<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
838
			</tr>
837
			</tr>
839
			</table>
838
			</table>
840
			</form>
839
			</form>
841
		</td>
840
		</td>
842
	</tr>
841
	</tr>
843
</table>
842
</table>
844
<br>
843
<br>
845
<div class="panel">
844
<div class="panel">
846
	<div class="panel-header"><?= $l_ssl_title ?></div>
845
	<div class="panel-header"><?= $l_ssl_title ?></div>
847
	<div class="panel-row">
846
	<div class="panel-row">
848
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
847
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
849
		<input type="hidden" name="choix" value="https_login">
848
		<input type="hidden" name="choix" value="https_login">
850
		<select name="https_login">
849
		<select name="https_login">
851
			<option value="on"<?=  (($conf['HTTPS_LOGIN'] === 'on')  ? ' selected' : '') ?>><?= $l_yes ?></option>
850
			<option value="on"<?=  (($conf['HTTPS_LOGIN'] === 'on')  ? ' selected' : '') ?>><?= $l_yes ?></option>
852
			<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
851
			<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
853
		</select>
852
		</select>
854
		<input type="submit" value="<?= $l_apply ?>"><br>
853
		<input type="submit" value="<?= $l_apply ?>"><br>
855
		</form>
854
		</form>
856
	</div>
855
	</div>
857
</div>
856
</div>
858
<br>
857
<br>
859
<div class="panel">
858
<div class="panel">
860
	<div class="panel-header"><?= $l_import_cert ?></div>
859
	<div class="panel-header"><?= $l_import_cert ?></div>
861
	<div class="panel-row">
860
	<div class="panel-row">
862
		<div class="panel-cell">
861
		<div class="panel-cell">
863
			<?php
862
			<?php
864
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
863
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
865
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
864
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
866
			$domain               = $certificateInfos['subject']['CN'];
865
			$domain               = $certificateInfos['subject']['CN'];
867
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
866
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
868
			$CAdomain             = $certificateInfos['issuer']['CN'];
867
			$CAdomain             = $certificateInfos['issuer']['CN'];
869
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
868
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
870
			?>
869
			?>
871
			<h3><?= $l_current_certificate ?></h3>
870
			<h3><?= $l_current_certificate ?></h3>
872
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
871
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
873
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
872
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
874
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
873
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
875
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
874
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
876
		</div>
875
		</div>
877
		<div class="panel-cell">
876
		<div class="panel-cell">
878
			<?
877
			<?
879
			if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
878
			if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
880
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
879
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
881
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
880
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
882
				echo "\t\t\t\t<input type=\"submit\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
881
				echo "\t\t\t\t<input type=\"submit\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
883
				echo "\t\t\t</form>\n";}
882
				echo "\t\t\t</form>\n";}
884
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
883
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
885
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
884
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
886
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
885
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
887
				echo "\t\t\t\t<input type=\"submit\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
886
				echo "\t\t\t\t<input type=\"submit\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
888
				echo "\t\t\t</form>\n";}
887
				echo "\t\t\t</form>\n";}
889
			?>
888
			?>
890
		</div>
889
		</div>
891
	</div>
890
	</div>
892
	<div class="panel-row">
891
	<div class="panel-row">
893
		<div class="panel-cell">
892
		<div class="panel-cell">
894
			<h3><?= $l_upload_certificate ?></h3>
893
			<h3><?= $l_upload_certificate ?></h3>
895
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
894
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
896
				<?= $l_private_key;?> <input type="file" name="key"><br>
895
				<?= $l_private_key;?> <input type="file" name="key"><br>
897
				<?= $l_certificate;?> <input type="file" name="crt"><br>
896
				<?= $l_certificate;?> <input type="file" name="crt"><br>
898
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
897
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
899
				<input type="hidden" name="choix" value="import_cert">
898
				<input type="hidden" name="choix" value="import_cert">
900
				<input type="submit" value="<?= $l_import ?>">
899
				<input type="submit" value="<?= $l_import ?>">
901
			</form>
900
			</form>
902
		</div>
901
		</div>
903
		<div class="panel-cell">
902
		<div class="panel-cell">
904
			<?php
903
			<?php
905
			// Get step
904
			// Get step
906
			if (empty($LE_conf['domainRequest'])) {
905
			if (empty($LE_conf['domainRequest'])) {
907
				$step = 1;
906
				$step = 1;
908
			} else if (!empty($LE_conf['challenge'])) {
907
			} else if (!empty($LE_conf['challenge'])) {
909
				$step = 2;
908
				$step = 2;
910
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
909
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
911
				$step = 3;
910
				$step = 3;
912
			} else {
911
			} else {
913
				$step = 1;
912
				$step = 1;
914
			}
913
			}
915
			?>
914
			?>
916
			<h3><?= $l_le_integration ?></h3>
915
			<h3><?= $l_le_integration ?></h3>
917
			<?php if ($step === 1): ?>
916
			<?php if ($step === 1): ?>
918
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
917
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
919
					<input type="hidden" name="choix" value="le_issueCert">
918
					<input type="hidden" name="choix" value="le_issueCert">
920
					<?= $l_le_status ?> <?= $l_disabled ?><br>
919
					<?= $l_le_status ?> <?= $l_disabled ?><br>
921
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
920
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
922
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
921
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
923
					<input type="submit" name="issue" value="<?= $l_send ?>"><br>
922
					<input type="submit" name="issue" value="<?= $l_send ?>"><br>
924
				</form>
923
				</form>
925
			<?php elseif ($step === 2): ?>
924
			<?php elseif ($step === 2): ?>
926
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
925
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
927
					<input type="hidden" name="choix" value="le_renewCert">
926
					<input type="hidden" name="choix" value="le_renewCert">
928
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
927
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
929
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
928
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
930
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
929
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
931
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
930
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
932
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
931
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
933
					<input type="submit" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" name="cancel" value="<?= $l_cancel ?>"><br>
932
					<input type="submit" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" name="cancel" value="<?= $l_cancel ?>"><br>
934
				</form>
933
				</form>
935
			<?php elseif ($step === 3): ?>
934
			<?php elseif ($step === 3): ?>
936
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
935
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
937
					<input type="hidden" name="choix" value="le_renewCert">
936
					<input type="hidden" name="choix" value="le_renewCert">
938
					<?= $l_le_status ?> <?= $l_enabled ?><br>
937
					<?= $l_le_status ?> <?= $l_enabled ?><br>
939
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
938
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
940
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
939
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
941
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
940
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
942
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
941
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
943
						<input type="submit" name="recheck" value="<?= $l_renew ?>"><br>
942
						<input type="submit" name="recheck" value="<?= $l_renew ?>"><br>
944
					<?php else: ?>
943
					<?php else: ?>
945
						<input type="submit" name="recheck_force" value="<?= $l_renew_force ?>"><br>
944
						<input type="submit" name="recheck_force" value="<?= $l_renew_force ?>"><br>
946
					<?php endif; ?>
945
					<?php endif; ?>
947
				</form>
946
				</form>
948
			<?php endif; ?>
947
			<?php endif; ?>
949
			<?php if (isset($cmdResponse)): ?>
948
			<?php if (isset($cmdResponse)): ?>
950
				<p><?= $cmdResponse ?></p>
949
				<p><?= $cmdResponse ?></p>
951
			<?php endif; ?>
950
			<?php endif; ?>
952
		</div>
951
		</div>
953
	</div>
952
	</div>
954
</div>
953
</div>
955
</body>
954
</body>
956
</html>
955
</html>
957
 
956