Subversion Repositories ALCASAR

Rev

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

Rev 3041 Rev 3042
1
<?php
1
<?php
2
# $Id: network.php 3041 2022-07-20 21:06:54Z rexy $
2
# $Id: network.php 3042 2022-07-22 12:35:45Z rexy $
3
 
3
 
4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
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
define('TEMP_FILE', '/tmp/alcasar.conf.temp');
14
define('TEMP_FILE', '/tmp/alcasar.conf.temp');
15
 
15
 
16
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
16
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
17
 
17
 
18
// Files reading test
18
// Files reading test
19
foreach ($conf_files as $file) {
19
foreach ($conf_files as $file) {
20
	if (!file_exists($file)) {
20
	if (!file_exists($file)) {
21
		exit("Requested file $file isn't present");
21
		exit("Requested file $file isn't present");
22
	}
22
	}
23
	if (!is_readable($file)) {
23
	if (!is_readable($file)) {
24
		exit("Can't read the file $file");
24
		exit("Can't read the file $file");
25
	}
25
	}
26
}
26
}
27
 
27
 
28
// Read ALCASAR CONF_FILE
28
// Read ALCASAR CONF_FILE
29
$file_conf = fopen(CONF_FILE, 'r');
29
$file_conf = fopen(CONF_FILE, 'r');
30
if (!$file_conf) {
30
if (!$file_conf) {
31
	exit('Error opening the file '.CONF_FILE);
31
	exit('Error opening the file '.CONF_FILE);
32
}
32
}
33
while (!feof($file_conf)) {
33
while (!feof($file_conf)) {
34
	$buffer = fgets($file_conf, 4096);
34
	$buffer = fgets($file_conf, 4096);
35
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
35
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
36
		$tmp = explode('=', $buffer, 2);
36
		$tmp = explode('=', $buffer, 2);
37
		$conf[trim($tmp[0])] = trim($tmp[1]);
37
		$conf[trim($tmp[0])] = trim($tmp[1]);
38
	}
38
	}
39
}
39
}
40
fclose($file_conf);
40
fclose($file_conf);
41
 
41
 
42
// Choice of language
42
// Choice of language
43
$Language = 'en';
43
$Language = 'en';
44
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
44
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
45
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
45
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
46
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
46
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
47
}
47
}
48
if ($Language === 'fr') {
48
if ($Language === 'fr') {
49
	$l_network_title	= "Configuration réseau";
49
	$l_network_title	= "Configuration réseau";
50
	$l_internet_legend	= "INTERNET";
50
	$l_internet_legend	= "INTERNET";
51
	$l_ip_mask		= "Masque";
51
	$l_ip_mask		= "Masque";
52
	$l_ip_router		= "Passerelle";
52
	$l_ip_router		= "Passerelle";
53
	$l_ip_public		= "Adresse IP publique";
53
	$l_ip_public		= "Adresse IP publique";
54
	$l_ip_dns1		= "DNS n°1";
54
	$l_ip_dns1		= "DNS n°1";
55
	$l_ip_dns2		= "DNS n°2";
55
	$l_ip_dns2		= "DNS n°2";
56
	$l_dhcp_title		= "Service DHCP";
56
	$l_dhcp_title		= "Service DHCP";
57
	$l_dhcp_state		= "Mode actuel";
57
	$l_dhcp_state		= "Mode actuel";
58
	$l_DHCP_on		= "actif";
58
	$l_DHCP_on		= "actif";
59
	$l_DHCP_off		= "inactif";
59
	$l_DHCP_off		= "inactif";
60
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
60
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
61
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
61
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
62
	$l_mac_address		= "Adresse MAC";
62
	$l_mac_address		= "Adresse MAC";
63
	$l_ip_address		= "Adresse IP";
63
	$l_ip_address		= "Adresse IP";
64
	$l_host_name		= "Nom d'hôte";
64
	$l_host_name		= "Nom d'hôte";
65
	$l_del			= "Supprimer de la liste";
65
	$l_del			= "Supprimer de la liste";
66
	$l_add_to_list		= "Ajouter";
66
	$l_add_to_list		= "Ajouter";
67
	$l_apply		= "Appliquer les changements";
67
	$l_apply		= "Appliquer les changements";
68
	$l_local_dns		= "Résolution local de nom (DNS)";
68
	$l_local_dns		= "Résolution local de nom (DNS)";
69
	$l_import_cert		= "Import de certificat";
69
	$l_import_cert		= "Import de certificat";
70
	$l_private_key		= "Clé privée (.key) :";
70
	$l_private_key		= "Clé privée (.key) :";
71
	$l_certificate		= "Certificat (.crt ou .cer) :";
71
	$l_certificate		= "Certificat (.crt ou .cer) :";
72
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
72
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
73
	$l_default_cert		= "Revenir au certificat d'origine :";
73
	$l_default_cert		= "Revenir au certificat d'origine :";
74
	$l_import		= "Importer";
74
	$l_import		= "Importer";
75
	$l_current_certificate  = "Certificat actuel";
75
	$l_current_certificate  = "Certificat actuel";
76
	$l_validated		= "Validé par :";
76
	$l_validated		= "Validé par :";
77
	$l_empty		= "Vide";
77
	$l_empty		= "Vide";
78
	$l_yes			= "Oui";
78
	$l_yes			= "Oui";
79
	$l_no			= "Non";
79
	$l_no			= "Non";
80
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
80
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
81
	$l_ssh_title		= "SSH";
81
	$l_ssh_title		= "SSH";
82
	$l_ssh_port			= "Port";
82
	$l_ssh_port			= "Port";
83
	$l_ssh_from			= "IP autorisée";
83
	$l_ssh_from			= "IP autorisée";
84
	$l_ssh_wan_activate	= "Activer SSH sur WAN";
84
	$l_ssh_wan_activate	= "Activer SSH sur WAN";
85
	$l_ssh_lan_activate	= "Activer SSH sur LAN";
85
	$l_ssh_lan_activate	= "Activer SSH sur LAN";
86
	$l_cert_expiration	= "Date d'expiration :";
86
	$l_cert_expiration	= "Date d'expiration :";
87
	$l_cert_commonname	= "Nom commun :";
87
	$l_cert_commonname	= "Nom commun :";
88
	$l_cert_organization	= "Organisation :";
88
	$l_cert_organization	= "Organisation :";
89
	$l_upload_certificate	= "Importer un certificat officiel";
89
	$l_upload_certificate	= "Importer un certificat officiel";
90
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
90
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
91
	$l_le_status		= "Status :";
91
	$l_le_status		= "Status :";
92
	$l_disabled		= "Inactif";
92
	$l_disabled		= "Inactif";
93
	$l_pending_validation	= "En attente de validation";
93
	$l_pending_validation	= "En attente de validation";
94
	$l_enabled		= "Actif";
94
	$l_enabled		= "Actif";
95
	$l_le_email		= "Email :";
95
	$l_le_email		= "Email :";
96
	$l_le_domain_name	= "Nom de domaine :";
96
	$l_le_domain_name	= "Nom de domaine :";
97
	$l_send			= "Envoyer";
97
	$l_send			= "Envoyer";
98
	$l_le_ask_on		= "Demandé le :";
98
	$l_le_ask_on		= "Demandé le :";
99
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
99
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
100
	$l_le_challenge		= "Challenge :";
100
	$l_le_challenge		= "Challenge :";
101
	$l_recheck		= "Revérifier";
101
	$l_recheck		= "Revérifier";
102
	$l_cancel		= "Annuler";
102
	$l_cancel		= "Annuler";
103
	$l_le_api		= "API :";
103
	$l_le_api		= "API :";
104
	$l_le_next_renewal	= "Prochain renouvellement :";
104
	$l_le_next_renewal	= "Prochain renouvellement :";
105
	$l_renew		= "Renouveller";
105
	$l_renew		= "Renouveller";
106
	$l_renew_force		= "Renouveller (forcer)";
106
	$l_renew_force		= "Renouveller (forcer)";
107
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
107
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
108
	$l_gw_weight    = "Poids";
108
	$l_gw_weight    = "Poids";
109
	$l_error        = "Erreur";
109
	$l_error        = "Erreur";
110
	$l_error_bad_ip = "Ceci n'est pas une adresse IP valide";
110
	$l_error_bad_ip = "Ceci n'est pas une adresse IP valide";
111
	$l_error_bad_ip_CIDR = "Ceci n'est pas une adresse CIDR valide";
111
	$l_error_bad_ip_CIDR = "Ceci n'est pas une adresse CIDR valide";
112
	$l_error_bad_ip_port = "Ceci n'est pas une adresse IP + port valide";
112
	$l_error_bad_ip_port = "Ceci n'est pas une adresse IP + port valide";
113
	$l_error_weight = "Ceci n'est pas un poids valide";
113
	$l_error_weight = "Ceci n'est pas un poids valide";
114
    $l_change_successful = "Changement effectué avec succès";
114
    $l_change_successful = "Changement effectué avec succès";
115
 
115
 
116
} else if ($Language === 'es') {
116
} else if ($Language === 'es') {
117
	$l_network_title	= "Configuración de Red";
117
	$l_network_title	= "Configuración de Red";
118
	$l_internet_legend	= "INTERNET";
118
	$l_internet_legend	= "INTERNET";
119
	$l_ip_mask		= "Máscara";
119
	$l_ip_mask		= "Máscara";
120
	$l_ip_router		= "Puerta de enlace";
120
	$l_ip_router		= "Puerta de enlace";
121
	$l_ip_public		= "IP Pública";
121
	$l_ip_public		= "IP Pública";
122
	$l_ip_dns1		= "DNS n°1";
122
	$l_ip_dns1		= "DNS n°1";
123
	$l_ip_dns2		= "DNS n°2";
123
	$l_ip_dns2		= "DNS n°2";
124
	$l_dhcp_title		= "Servicio DHCP";
124
	$l_dhcp_title		= "Servicio DHCP";
125
	$l_dhcp_state		= "Modo actual";
125
	$l_dhcp_state		= "Modo actual";
126
	$l_DHCP_on		= "activado";
126
	$l_DHCP_on		= "activado";
127
	$l_DHCP_off		= "desactivado";
127
	$l_DHCP_off		= "desactivado";
128
	$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";
128
	$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";
129
	$l_static_dhcp_title	= "Reserva de direcciones IP estáticas (DHCP)";
129
	$l_static_dhcp_title	= "Reserva de direcciones IP estáticas (DHCP)";
130
	$l_mac_address		= "Dirección MAC";
130
	$l_mac_address		= "Dirección MAC";
131
	$l_ip_address		= "Dirección IP";
131
	$l_ip_address		= "Dirección IP";
132
	$l_host_name		= "Nombre de Host";
132
	$l_host_name		= "Nombre de Host";
133
	$l_del			= "Borrar de la lista";
133
	$l_del			= "Borrar de la lista";
134
	$l_add_to_list		= "Agregar";
134
	$l_add_to_list		= "Agregar";
135
	$l_apply		= "Aplicar cambios";
135
	$l_apply		= "Aplicar cambios";
136
	$l_local_dns		= "Resolución de Nombres Local (DNS)";
136
	$l_local_dns		= "Resolución de Nombres Local (DNS)";
137
	$l_import_cert		= "Importar Certificado";
137
	$l_import_cert		= "Importar Certificado";
138
	$l_private_key		= "Clave Privada (.key) :";
138
	$l_private_key		= "Clave Privada (.key) :";
139
	$l_certificate		= "Certificado (.crt) :";
139
	$l_certificate		= "Certificado (.crt) :";
140
	$l_server_chain		= "Cadena completa (de ser necesario: .crt) :";
140
	$l_server_chain		= "Cadena completa (de ser necesario: .crt) :";
141
	$l_default_cert		= "Volverl al certificado por defecto";
141
	$l_default_cert		= "Volverl al certificado por defecto";
142
	$l_import		= "Importar";
142
	$l_import		= "Importar";
143
	$l_current_certificate  = "Certificado en uso";
143
	$l_current_certificate  = "Certificado en uso";
144
	$l_validated		= "Validado por :";
144
	$l_validated		= "Validado por :";
145
	$l_empty		= "Vacío";
145
	$l_empty		= "Vacío";
146
	$l_yes			= "Si";
146
	$l_yes			= "Si";
147
	$l_no			= "No";
147
	$l_no			= "No";
148
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
148
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
149
	$l_ssh_title		= "SSH";
149
	$l_ssh_title		= "SSH";
150
	$l_ssh_port			= "Puerto";
150
	$l_ssh_port			= "Puerto";
151
	$l_ssh_from			= "IP autorizada";
151
	$l_ssh_from			= "IP autorizada";
152
	$l_ssh_wan_activate	= "Activar SSH on WAN";
152
	$l_ssh_wan_activate	= "Activar SSH on WAN";
153
	$l_ssh_lan_activate	= "Activar SSH on LAN";
153
	$l_ssh_lan_activate	= "Activar SSH on LAN";
154
	$l_cert_expiration	= "Fecha de vencimiento:";
154
	$l_cert_expiration	= "Fecha de vencimiento:";
155
	$l_cert_commonname	= "Common name:";
155
	$l_cert_commonname	= "Common name:";
156
	$l_cert_organization	= "Organización:";
156
	$l_cert_organization	= "Organización:";
157
	$l_upload_certificate	= "Importar un certificado";
157
	$l_upload_certificate	= "Importar un certificado";
158
	$l_le_integration	= "Integración con Let's Encrypt";
158
	$l_le_integration	= "Integración con Let's Encrypt";
159
	$l_le_status		= "Estado:";
159
	$l_le_status		= "Estado:";
160
	$l_disabled		= "Desactivado";
160
	$l_disabled		= "Desactivado";
161
	$l_pending_validation	= "Validación pendiente";
161
	$l_pending_validation	= "Validación pendiente";
162
	$l_enabled		= "Activado";
162
	$l_enabled		= "Activado";
163
	$l_le_email		= "Email:";
163
	$l_le_email		= "Email:";
164
	$l_le_domain_name	= "Nombre de dominio:";
164
	$l_le_domain_name	= "Nombre de dominio:";
165
	$l_send			= "Enviar";
165
	$l_send			= "Enviar";
166
	$l_le_ask_on		= "Preguntar el:";
166
	$l_le_ask_on		= "Preguntar el:";
167
	$l_le_dns_entry_txt	= "Entrada DNS TXT:";
167
	$l_le_dns_entry_txt	= "Entrada DNS TXT:";
168
	$l_le_challenge		= "Desafío:";
168
	$l_le_challenge		= "Desafío:";
169
	$l_recheck		= "Verificar";
169
	$l_recheck		= "Verificar";
170
	$l_cancel		= "Cancelar";
170
	$l_cancel		= "Cancelar";
171
	$l_le_api		= "API:";
171
	$l_le_api		= "API:";
172
	$l_le_next_renewal	= "Siguiente renovación:";
172
	$l_le_next_renewal	= "Siguiente renovación:";
173
	$l_renew		= "Renovar";
173
	$l_renew		= "Renovar";
174
	$l_renew_force		= "Renovar (forzado)";
174
	$l_renew_force		= "Renovar (forzado)";
175
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
175
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
176
    $l_gw_weight	= "Peso";
176
    $l_gw_weight	= "Peso";
177
    $l_error		= "Error";
177
    $l_error		= "Error";
178
    $l_error_bad_ip	= "Esta no es una dirección IP válida";
178
    $l_error_bad_ip	= "Esta no es una dirección IP válida";
179
    $l_error_bad_ip_CIDR	= "Esta no es una dirección CIDR válida";
179
    $l_error_bad_ip_CIDR	= "Esta no es una dirección CIDR válida";
180
    $l_error_bad_ip_port	= "Esto no es una dirección IP + puerto válidos";
180
    $l_error_bad_ip_port	= "Esto no es una dirección IP + puerto válidos";
181
    $l_error_weight	= "Esto no es un peso válido";
181
    $l_error_weight	= "Esto no es un peso válido";
182
    $l_change_successful	= "Cambio completado con éxito";
182
    $l_change_successful	= "Cambio completado con éxito";
183
} else {
183
} else {
184
	$l_network_title	= "Network configuration";
184
	$l_network_title	= "Network configuration";
185
	$l_internet_legend	= "INTERNET";
185
	$l_internet_legend	= "INTERNET";
186
	$l_ip_mask		= "Mask";
186
	$l_ip_mask		= "Mask";
187
	$l_ip_router		= "Gateway";
187
	$l_ip_router		= "Gateway";
188
	$l_ip_public		= "Public IP address";
188
	$l_ip_public		= "Public IP address";
189
	$l_ip_dns1		= "DNS n°1";
189
	$l_ip_dns1		= "DNS n°1";
190
	$l_ip_dns2		= "DNS n°2";
190
	$l_ip_dns2		= "DNS n°2";
191
	$l_dhcp_title		= "DHCP service";
191
	$l_dhcp_title		= "DHCP service";
192
	$l_dhcp_state		= "Current mode";
192
	$l_dhcp_state		= "Current mode";
193
	$l_DHCP_on		= "enabled";
193
	$l_DHCP_on		= "enabled";
194
	$l_DHCP_off		= "disabled";
194
	$l_DHCP_off		= "disabled";
195
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
195
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
196
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
196
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
197
	$l_mac_address		= "MAC address";
197
	$l_mac_address		= "MAC address";
198
	$l_ip_address		= "IP address";
198
	$l_ip_address		= "IP address";
199
	$l_host_name		= "Host name";
199
	$l_host_name		= "Host name";
200
	$l_del			= "Delete from list";
200
	$l_del			= "Delete from list";
201
	$l_add_to_list		= "Add";
201
	$l_add_to_list		= "Add";
202
	$l_apply		= "Apply changes";
202
	$l_apply		= "Apply changes";
203
	$l_local_dns		= "Local name resolution (DNS";
203
	$l_local_dns		= "Local name resolution (DNS";
204
	$l_import_cert		= "Certificate import";
204
	$l_import_cert		= "Certificate import";
205
	$l_private_key		= "Private key (.key) :";
205
	$l_private_key		= "Private key (.key) :";
206
	$l_certificate		= "Certificate (.crt or .cer) :";
206
	$l_certificate		= "Certificate (.crt or .cer) :";
207
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
207
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
208
	$l_default_cert		= "Back to default certificate :";
208
	$l_default_cert		= "Back to default certificate :";
209
	$l_import		= "Import";
209
	$l_import		= "Import";
210
	$l_current_certificate  = "Current certificate";
210
	$l_current_certificate  = "Current certificate";
211
	$l_validated		= "Validated by :";
211
	$l_validated		= "Validated by :";
212
	$l_empty		= "Empty";
212
	$l_empty		= "Empty";
213
	$l_yes			= "Yes";
213
	$l_yes			= "Yes";
214
	$l_no			= "No";
214
	$l_no			= "No";
215
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
215
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
216
	$l_ssh_title		= "SSH";
216
	$l_ssh_title		= "SSH";
217
	$l_ssh_port			= "Port";
217
	$l_ssh_port			= "Port";
218
	$l_ssh_from			= "Authorized IP";
218
	$l_ssh_from			= "Authorized IP";
219
	$l_ssh_wan_activate	= "Activate SSH on WAN";
219
	$l_ssh_wan_activate	= "Activate SSH on WAN";
220
	$l_ssh_lan_activate	= "Activate SSH on LAN";
220
	$l_ssh_lan_activate	= "Activate SSH on LAN";
221
	$l_cert_expiration	= "Expiration date:";
221
	$l_cert_expiration	= "Expiration date:";
222
	$l_cert_commonname	= "Common name:";
222
	$l_cert_commonname	= "Common name:";
223
	$l_cert_organization	= "Organization:";
223
	$l_cert_organization	= "Organization:";
224
	$l_upload_certificate	= "Import an officlal certificate";
224
	$l_upload_certificate	= "Import an officlal certificate";
225
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
225
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
226
	$l_le_status		= "Status:";
226
	$l_le_status		= "Status:";
227
	$l_disabled		= "Disabled";
227
	$l_disabled		= "Disabled";
228
	$l_pending_validation	= "Pending validation";
228
	$l_pending_validation	= "Pending validation";
229
	$l_enabled		= "Enabled";
229
	$l_enabled		= "Enabled";
230
	$l_le_email		= "Email:";
230
	$l_le_email		= "Email:";
231
	$l_le_domain_name	= "Domain name:";
231
	$l_le_domain_name	= "Domain name:";
232
	$l_send			= "Send";
232
	$l_send			= "Send";
233
	$l_le_ask_on		= "Ask on:";
233
	$l_le_ask_on		= "Ask on:";
234
	$l_le_dns_entry_txt	= "DNS TXT entry:";
234
	$l_le_dns_entry_txt	= "DNS TXT entry:";
235
	$l_le_challenge		= "Challenge:";
235
	$l_le_challenge		= "Challenge:";
236
	$l_recheck		= "Recheck";
236
	$l_recheck		= "Recheck";
237
	$l_cancel		= "Cancel";
237
	$l_cancel		= "Cancel";
238
	$l_le_api		= "API:";
238
	$l_le_api		= "API:";
239
	$l_le_next_renewal	= "Next renewal:";
239
	$l_le_next_renewal	= "Next renewal:";
240
	$l_renew		= "Renew";
240
	$l_renew		= "Renew";
241
	$l_renew_force		= "Renew (force)";
241
	$l_renew_force		= "Renew (force)";
242
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
242
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
243
    $l_gw_weight = "Weight";
243
    $l_gw_weight = "Weight";
244
    $l_error        = "Error";
244
    $l_error        = "Error";
245
    $l_error_bad_ip = "This is not a valid IP";
245
    $l_error_bad_ip = "This is not a valid IP";
246
    $l_error_bad_ip_CIDR = "This is not a valid CIDR IP";
246
    $l_error_bad_ip_CIDR = "This is not a valid CIDR IP";
247
    $l_error_bad_ip_port = "This is not a valid IP + port";
247
    $l_error_bad_ip_port = "This is not a valid IP + port";
248
    $l_error_weight = "This is not a valid weight";
248
    $l_error_weight = "This is not a valid weight";
249
    $l_change_successful = "Network updated successfully";
249
    $l_change_successful = "Network updated successfully";
250
}
250
}
251
 
251
 
252
$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])$/';
252
$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])$/';
253
$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]))$/';
253
$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]))$/';
254
$reg_ip_port = '/^(([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])(\:([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))$/';
254
$reg_ip_port = '/^(([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])(\:([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))$/';
255
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
255
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
256
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
256
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
257
$reg_weight  = '/^[0-9]*$/';
257
$reg_weight  = '/^[0-9]*$/';
258
$ext_conf_error = false;
258
$ext_conf_error = false;
259
 
259
 
260
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
260
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
261
switch ($choix) {
261
switch ($choix) {
262
	case 'DHCP_On':
262
	case 'DHCP_On':
263
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
263
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
264
		header('Location: '.$_SERVER['PHP_SELF']);
264
		header('Location: '.$_SERVER['PHP_SELF']);
265
		exit();
265
		exit();
266
	case 'DHCP_Off':
266
	case 'DHCP_Off':
267
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
267
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
268
		header('Location: '.$_SERVER['PHP_SELF']);
268
		header('Location: '.$_SERVER['PHP_SELF']);
269
		exit();
269
		exit();
270
	case 'new_mac':
270
	case 'new_mac':
271
		$new_mac_addr = trim($_POST['add_mac']);
271
		$new_mac_addr = trim($_POST['add_mac']);
272
		$new_ip_addr  = trim($_POST['add_ip']);
272
		$new_ip_addr  = trim($_POST['add_ip']);
273
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
273
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
274
			$tab = file(ETHERS_FILE);
274
			$tab = file(ETHERS_FILE);
275
			if ($tab) { // the file isn't empty
275
			if ($tab) { // the file isn't empty
276
				$insert = true;
276
				$insert = true;
277
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
277
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
278
					$field = explode(' ', $line);
278
					$field = explode(' ', $line);
279
					$mac_addr = trim($field[0]);
279
					$mac_addr = trim($field[0]);
280
					$ip_addr  = trim($field[1]);
280
					$ip_addr  = trim($field[1]);
281
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
281
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
282
						$insert = false;
282
						$insert = false;
283
						break;
283
						break;
284
					}
284
					}
285
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
285
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
286
						$insert = false;
286
						$insert = false;
287
						break;
287
						break;
288
					}
288
					}
289
				}
289
				}
290
				if ($insert) {
290
				if ($insert) {
291
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
291
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
292
					$pointeur = fopen(ETHERS_FILE, 'a');
292
					$pointeur = fopen(ETHERS_FILE, 'a');
293
					fwrite($pointeur, $line);
293
					fwrite($pointeur, $line);
294
					fclose($pointeur);
294
					fclose($pointeur);
295
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
295
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
296
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
296
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
297
					fwrite($pointeur, $line);
297
					fwrite($pointeur, $line);
298
					fclose($pointeur);
298
					fclose($pointeur);
299
					exec('sudo /usr/bin/systemctl reload chilli');
299
					exec('sudo /usr/bin/systemctl reload chilli');
300
				}
300
				}
301
			}
301
			}
302
		}
302
		}
303
		header('Location: '.$_SERVER['PHP_SELF']);
303
		header('Location: '.$_SERVER['PHP_SELF']);
304
		exit();
304
		exit();
305
	case 'del_mac':
305
	case 'del_mac':
306
		foreach ($_POST as $key => $value) {
306
		foreach ($_POST as $key => $value) {
307
			if ($value == 'on') {
307
			if ($value == 'on') {
308
				$ether_file = ETHERS_FILE;
308
				$ether_file = ETHERS_FILE;
309
				$ether_file_info = ETHERS_INFO_FILE;
309
				$ether_file_info = ETHERS_INFO_FILE;
310
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
310
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
311
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
311
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
312
				exec('sudo /usr/bin/systemctl reload chilli');
312
				exec('sudo /usr/bin/systemctl reload chilli');
313
			}
313
			}
314
		}
314
		}
315
		header('Location: '.$_SERVER['PHP_SELF']);
315
		header('Location: '.$_SERVER['PHP_SELF']);
316
		exit();
316
		exit();
317
	case 'new_host':
317
	case 'new_host':
318
		$add_host = trim($_POST['add_host']);
318
		$add_host = trim($_POST['add_host']);
319
		$add_ip   = trim($_POST['add_ip']);
319
		$add_ip   = trim($_POST['add_ip']);
320
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
320
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
321
			$tab = file(DNS_LOCAL_FILE);
321
			$tab = file(DNS_LOCAL_FILE);
322
			if ($tab) { // the file isn't empty
322
			if ($tab) { // the file isn't empty
323
				$insert = true;
323
				$insert = true;
324
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
324
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
325
					if (preg_match('/^\d+/', $line)) {
325
					if (preg_match('/^\d+/', $line)) {
326
						$field = preg_split("/\s+/",$line);
326
						$field = preg_split("/\s+/",$line);
327
						$ip_addr = $field[0];
327
						$ip_addr = $field[0];
328
						$host_name = trim($field[1]);
328
						$host_name = trim($field[1]);
329
						if (strcasecmp($add_host, $host_name) === 0) {
329
						if (strcasecmp($add_host, $host_name) === 0) {
330
							$insert = false;
330
							$insert = false;
331
							break;
331
							break;
332
						}
332
						}
333
					}
333
					}
334
				}
334
				}
335
				if ($insert) {
335
				if ($insert) {
336
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
336
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
337
				}
337
				}
338
			}
338
			}
339
		}
339
		}
340
		header('Location: '.$_SERVER['PHP_SELF']);
340
		header('Location: '.$_SERVER['PHP_SELF']);
341
		exit();
341
		exit();
342
	case 'del_host':
342
	case 'del_host':
343
		foreach ($_POST as $key => $value) {
343
		foreach ($_POST as $key => $value) {
344
			if ($value == 'on') {
344
			if ($value == 'on') {
345
				$del_host = explode ("|", $key);
345
				$del_host = explode ("|", $key);
346
				$del_ip = str_replace("_",".",$del_host[0]);
346
				$del_ip = str_replace("_",".",$del_host[0]);
347
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
347
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
348
			}
348
			}
349
		}
349
		}
350
		header('Location: '.$_SERVER['PHP_SELF']);
350
		header('Location: '.$_SERVER['PHP_SELF']);
351
		exit();
351
		exit();
352
 
352
 
353
	case 'set_default_cert':
353
	case 'set_default_cert':
354
		exec('sudo alcasar-importcert.sh -d');
354
		exec('sudo alcasar-importcert.sh -d');
355
		break;
355
		break;
356
	case 'set_last_LE_cert':
356
	case 'set_last_LE_cert':
357
		exec('sudo alcasar-letsencrypt.sh --install-cert');
357
		exec('sudo alcasar-letsencrypt.sh --install-cert');
358
		break;
358
		break;
359
	case 'import_cert':	// Import certificate
359
	case 'import_cert':	// Import certificate
360
		$maxsize = 100000;
360
		$maxsize = 100000;
361
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
361
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
362
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
362
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
363
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
363
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
364
					$dest = '/tmp/';
364
					$dest = '/tmp/';
365
					$scpath = '';
365
					$scpath = '';
366
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
366
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
367
						$scpath = $dest.'server-chain.pem';
367
						$scpath = $dest.'server-chain.pem';
368
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
368
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
369
					}
369
					}
370
					$keypath = $dest.'alcasar.key';
370
					$keypath = $dest.'alcasar.key';
371
					$crtpath = $dest.'alcasar.crt';
371
					$crtpath = $dest.'alcasar.crt';
372
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
372
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
373
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
373
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
374
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
374
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
375
					if (file_exists($crtpath)) unlink($crtpath);
375
					if (file_exists($crtpath)) unlink($crtpath);
376
					if (file_exists($keypath)) unlink($keypath);
376
					if (file_exists($keypath)) unlink($keypath);
377
					if (file_exists($scpath))  unlink($scpath);
377
					if (file_exists($scpath))  unlink($scpath);
378
				}
378
				}
379
			}
379
			}
380
		}
380
		}
381
		break;
381
		break;
382
	case 'enable_lan_ssh': // Activate SSH on LAN
382
	case 'enable_lan_ssh': // Activate SSH on LAN
383
		if (isset($_POST['sshlan'])) {
383
		if (isset($_POST['sshlan'])) {
384
			exec('sudo /usr/local/bin/alcasar-ssh.sh --on -l');
384
			exec('sudo /usr/local/bin/alcasar-ssh.sh --on -l -p'.escapeshellarg($_POST["ssh_port"]).' -i'.escapeshellarg($_POST["ssh_from"]),$output,$exitCode);
-
 
385
			if($exitCode === 1){
-
 
386
				echo("<html><script>if(!alert(`$l_error_bad_ip_port`)){window.location.href = window.location.href;}</script></html>");
-
 
387
			}else{
385
			header('Location: '.$_SERVER['PHP_SELF']);
388
				header('Location: '.$_SERVER['PHP_SELF']);
-
 
389
			}
386
		} else{
390
		} else{
387
			exec('sudo /usr/local/bin/alcasar-ssh.sh --off -l');
391
			exec('sudo /usr/local/bin/alcasar-ssh.sh --off -l');
388
			header('Location: '.$_SERVER['PHP_SELF']);
392
			header('Location: '.$_SERVER['PHP_SELF']);
389
		}
393
		}
390
		exit();	
394
		exit();	
391
	case 'enable_wan_ssh': // Activate SSH on WAN
395
	case 'enable_wan_ssh': // Activate SSH on WAN
392
		if (isset($_POST['togglessh'])) {
396
		if (isset($_POST['togglessh'])) {
393
			exec('sudo /usr/local/bin/alcasar-ssh.sh --on -w -p'.escapeshellarg($_POST["ssh_port"]).' -i'.escapeshellarg($_POST["ssh_from"]),$output,$exitCode);
397
			exec('sudo /usr/local/bin/alcasar-ssh.sh --on -w -p'.escapeshellarg($_POST["ssh_port"]).' -i'.escapeshellarg($_POST["ssh_from"]),$output,$exitCode);
394
			if($exitCode === 1){
398
			if($exitCode === 1){
395
				echo("<html><script>if(!alert(`$l_error_bad_ip_port`)){window.location.href = window.location.href;}</script></html>");
399
				echo("<html><script>if(!alert(`$l_error_bad_ip_port`)){window.location.href = window.location.href;}</script></html>");
396
			}else{
400
			}else{
397
				header('Location: '.$_SERVER['PHP_SELF']);
401
				header('Location: '.$_SERVER['PHP_SELF']);
398
			}
402
			}
399
		} else{
403
		} else{
400
			exec('sudo /usr/local/bin/alcasar-ssh.sh --off -w');
404
			exec('sudo /usr/local/bin/alcasar-ssh.sh --off -w');
401
			header('Location: '.$_SERVER['PHP_SELF']);
405
			header('Location: '.$_SERVER['PHP_SELF']);
402
		}
406
		}
403
		exit();
407
		exit();
404
	case 'https_login':	// Set HTTPS login status
408
	case 'https_login':	// Set HTTPS login status
405
		if (isset($_POST['https_login']))	 {
409
		if (isset($_POST['https_login']))	 {
406
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
410
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
407
		} else {
411
		} else {
408
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
412
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
409
		}
413
		}
410
		header('Location: '.$_SERVER['PHP_SELF']);
414
		header('Location: '.$_SERVER['PHP_SELF']);
411
		exit();
415
		exit();
412
}
416
}
413
 
417
 
414
// Network changes
418
// Network changes
415
if ($choix === 'network_change') {
419
if ($choix === 'network_change') {
416
    exec('sudo /usr/local/bin/alcasar-network.sh --save');
420
    exec('sudo /usr/local/bin/alcasar-network.sh --save');
417
	$modification_network = false;
421
	$modification_network = false;
418
	$modification_dns = false;
422
	$modification_dns = false;
419
	$modification_proxy = false;
423
	$modification_proxy = false;
420
	$ext_conf_error_list = [];
424
	$ext_conf_error_list = [];
421
	copy(CONF_FILE, TEMP_FILE);
425
	copy(CONF_FILE, TEMP_FILE);
422
 
426
 
423
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1'])) {
427
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1'])) {
424
	    if (!preg_match($reg_ip, $_POST['dns1'])) {
428
	    if (!preg_match($reg_ip, $_POST['dns1'])) {
425
            $ext_conf_error = true;
429
            $ext_conf_error = true;
426
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns1.': '.$l_error_bad_ip;
430
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns1.': '.$l_error_bad_ip;
427
        }
431
        }
428
		file_put_contents(TEMP_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(TEMP_FILE)));
432
		file_put_contents(TEMP_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(TEMP_FILE)));
429
		$modification_dns = true;
433
		$modification_dns = true;
430
	}
434
	}
431
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2'])) {
435
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2'])) {
432
	    if (!preg_match($reg_ip, $_POST['dns2'])) {
436
	    if (!preg_match($reg_ip, $_POST['dns2'])) {
433
            $ext_conf_error = true;
437
            $ext_conf_error = true;
434
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns2.': '.$l_error_bad_ip;
438
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns2.': '.$l_error_bad_ip;
435
        }
439
        }
436
		file_put_contents(TEMP_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(TEMP_FILE)));
440
		file_put_contents(TEMP_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(TEMP_FILE)));
437
		$modification_dns = true;
441
		$modification_dns = true;
438
	}
442
	}
439
    if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP'])) {
443
    if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP'])) {
440
        if (!preg_match($reg_ip_cidr, $_POST['ip_private'])) {
444
        if (!preg_match($reg_ip_cidr, $_POST['ip_private'])) {
441
            $ext_conf_error = true;
445
            $ext_conf_error = true;
442
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' LAN: '.$l_error_bad_ip_CIDR;
446
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' LAN: '.$l_error_bad_ip_CIDR;
443
        }
447
        }
444
        file_put_contents(TEMP_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(TEMP_FILE)));
448
        file_put_contents(TEMP_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(TEMP_FILE)));
445
        $modification_network = true;
449
        $modification_network = true;
446
    }
450
    }
447
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP'])) {
451
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP'])) {
448
	    if (!preg_match($reg_ip_cidr, $_POST['ip_public'])) {
452
	    if (!preg_match($reg_ip_cidr, $_POST['ip_public'])) {
449
            $ext_conf_error = true;
453
            $ext_conf_error = true;
450
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' WAN: '.$l_error_bad_ip_CIDR;
454
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' WAN: '.$l_error_bad_ip_CIDR;
451
        }
455
        }
452
		file_put_contents(TEMP_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(TEMP_FILE)));
456
		file_put_contents(TEMP_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(TEMP_FILE)));
453
		$modification_network = true;
457
		$modification_network = true;
454
	}
458
	}
455
    if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW'])) {
459
    if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW'])) {
456
        if (!preg_match($reg_ip, $_POST['ip_gw'])) {
460
        if (!preg_match($reg_ip, $_POST['ip_gw'])) {
457
            $ext_conf_error = true;
461
            $ext_conf_error = true;
458
            $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' 1: '.$l_error_bad_ip;
462
            $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' 1: '.$l_error_bad_ip;
459
        }
463
        }
460
        file_put_contents(TEMP_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(TEMP_FILE)));
464
        file_put_contents(TEMP_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(TEMP_FILE)));
461
        $modification_network = true;
465
        $modification_network = true;
462
    }
466
    }
463
    if (isset($_POST['enable_proxy']) && $_POST['enable_proxy'] == 'P_Enabled')
467
    if (isset($_POST['enable_proxy']) && $_POST['enable_proxy'] == 'P_Enabled')
464
    {
468
    {
465
        if ($conf['PROXY'] !== 'On')
469
        if ($conf['PROXY'] !== 'On')
466
        {
470
        {
467
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=On', file_get_contents(TEMP_FILE)));
471
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=On', file_get_contents(TEMP_FILE)));
468
            $modification_proxy = true;
472
            $modification_proxy = true;
469
        }
473
        }
470
        if (isset($_POST['proxy']) && (trim($_POST['proxy']) !== $conf['PROXY_IP'])) {
474
        if (isset($_POST['proxy']) && (trim($_POST['proxy']) !== $conf['PROXY_IP'])) {
471
            if (!preg_match($reg_ip_port, $_POST['proxy'])) {
475
            if (!preg_match($reg_ip_port, $_POST['proxy'])) {
472
                $ext_conf_error = true;
476
                $ext_conf_error = true;
473
                $ext_conf_error_list[] = $l_error.': Proxy: '.$l_error_bad_ip_port;
477
                $ext_conf_error_list[] = $l_error.': Proxy: '.$l_error_bad_ip_port;
474
            }
478
            }
475
            file_put_contents(TEMP_FILE, str_replace('PROXY_IP='.$conf['PROXY_IP'], 'PROXY_IP='.trim($_POST['proxy']), file_get_contents(TEMP_FILE)));
479
            file_put_contents(TEMP_FILE, str_replace('PROXY_IP='.$conf['PROXY_IP'], 'PROXY_IP='.trim($_POST['proxy']), file_get_contents(TEMP_FILE)));
476
            $modification_proxy = true;
480
            $modification_proxy = true;
477
        }
481
        }
478
        if ($conf['MULTIWAN'] !== 'off')
482
        if ($conf['MULTIWAN'] !== 'off')
479
        {
483
        {
480
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=off', file_get_contents(TEMP_FILE)));
484
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=off', file_get_contents(TEMP_FILE)));
481
            $modification_network = true;
485
            $modification_network = true;
482
        }
486
        }
483
    }
487
    }
484
    else
488
    else
485
    {
489
    {
486
        //set multiwan value to off and delete every "WANx=" line
490
        //set multiwan value to off and delete every "WANx=" line
487
        if ($_POST['gw_count'] === "1" && $conf['MULTIWAN'] !== 'off')
491
        if ($_POST['gw_count'] === "1" && $conf['MULTIWAN'] !== 'off')
488
        {
492
        {
489
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=off', file_get_contents(TEMP_FILE)));
493
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=off', file_get_contents(TEMP_FILE)));
490
            $temp = 1;
494
            $temp = 1;
491
            while (isset($conf['WAN'.$temp]))
495
            while (isset($conf['WAN'.$temp]))
492
            {
496
            {
493
                file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
497
                file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
494
                $temp++;
498
                $temp++;
495
            }
499
            }
496
            $modification_network = true;
500
            $modification_network = true;
497
        }
501
        }
498
        if ($_POST['gw_count'] !== "1")
502
        if ($_POST['gw_count'] !== "1")
499
        {
503
        {
500
            $changed = false;
504
            $changed = false;
501
            //testing the existence of a change in the routing configuration
505
            //testing the existence of a change in the routing configuration
502
            exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nb_gw);
506
            exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nb_gw);
503
            if ($_POST['gw_count'] == ($nb_gw[0] + 1))
507
            if ($_POST['gw_count'] == ($nb_gw[0] + 1))
504
            {
508
            {
505
                if ($_POST['weight'] !== $conf['PUBLIC_WEIGHT']) {
509
                if ($_POST['weight'] !== $conf['PUBLIC_WEIGHT']) {
506
                    $changed = true;
510
                    $changed = true;
507
                }
511
                }
508
                else {
512
                else {
509
                    for($i=1;$i<$_POST['gw_count'];$i++)
513
                    for($i=1;$i<$_POST['gw_count'];$i++)
510
                    {
514
                    {
511
                        if( '"'.$_POST['ip_gw_'.$i].','.$_POST['weight_'.$i].'"' != $conf['WAN'.$i])
515
                        if( '"'.$_POST['ip_gw_'.$i].','.$_POST['weight_'.$i].'"' != $conf['WAN'.$i])
512
                        {
516
                        {
513
                            $changed = true;
517
                            $changed = true;
514
                            break;
518
                            break;
515
                        }
519
                        }
516
                    }
520
                    }
517
                }
521
                }
518
            }
522
            }
519
            else
523
            else
520
            {
524
            {
521
                $changed = true;
525
                $changed = true;
522
            }
526
            }
523
 
527
 
524
            if ($changed == true)
528
            if ($changed == true)
525
            {
529
            {
526
                //deleting all the old lines containing "WANx="
530
                //deleting all the old lines containing "WANx="
527
                $temp = 1;
531
                $temp = 1;
528
                while (isset($conf['WAN'.$temp]))
532
                while (isset($conf['WAN'.$temp]))
529
                {
533
                {
530
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
534
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
531
                    $temp++;
535
                    $temp++;
532
                }
536
                }
533
                //setting back the line "WAN1=" which will be our base
537
                //setting back the line "WAN1=" which will be our base
534
                if (!preg_match($reg_weight, $_POST['weight'])) {
538
                if (!preg_match($reg_weight, $_POST['weight'])) {
535
                    $ext_conf_error = true;
539
                    $ext_conf_error = true;
536
                    $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' 1: '.$l_error_weight;
540
                    $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' 1: '.$l_error_weight;
537
                }
541
                }
538
                file_put_contents(TEMP_FILE, str_replace('PUBLIC_WEIGHT='.$conf['PUBLIC_WEIGHT'], 'PUBLIC_WEIGHT='.(($_POST['weight'] !== '')?$_POST['weight']:1), file_get_contents(TEMP_FILE)));
542
                file_put_contents(TEMP_FILE, str_replace('PUBLIC_WEIGHT='.$conf['PUBLIC_WEIGHT'], 'PUBLIC_WEIGHT='.(($_POST['weight'] !== '')?$_POST['weight']:1), file_get_contents(TEMP_FILE)));
539
                //Set Multiwan status
543
                //Set Multiwan status
540
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], "MULTIWAN=on\nWAN1=", file_get_contents(TEMP_FILE)));
544
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], "MULTIWAN=on\nWAN1=", file_get_contents(TEMP_FILE)));
541
                //Adding the correct number of "WANx=" lines, numbered
545
                //Adding the correct number of "WANx=" lines, numbered
542
                for($i=2;$i<$_POST['gw_count'];$i++)
546
                for($i=2;$i<$_POST['gw_count'];$i++)
543
                {
547
                {
544
                    file_put_contents(TEMP_FILE, str_replace('WAN'.($i-1).'=', 'WAN'.($i-1)."=\nWAN".$i.'=', file_get_contents(TEMP_FILE)));
548
                    file_put_contents(TEMP_FILE, str_replace('WAN'.($i-1).'=', 'WAN'.($i-1)."=\nWAN".$i.'=', file_get_contents(TEMP_FILE)));
545
                }
549
                }
546
                //Adding the content
550
                //Adding the content
547
                for($i=1;$i<$_POST['gw_count'];$i++)
551
                for($i=1;$i<$_POST['gw_count'];$i++)
548
                {
552
                {
549
                    if (!preg_match($reg_ip, $_POST['ip_gw_'.$i])) {
553
                    if (!preg_match($reg_ip, $_POST['ip_gw_'.$i])) {
550
                        $ext_conf_error = true;
554
                        $ext_conf_error = true;
551
                        $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' '.($i+1).': '.$l_error_bad_ip;
555
                        $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' '.($i+1).': '.$l_error_bad_ip;
552
                    }
556
                    }
553
                    if (!preg_match($reg_weight, $_POST['weight_'.$i])) {
557
                    if (!preg_match($reg_weight, $_POST['weight_'.$i])) {
554
                        $ext_conf_error = true;
558
                        $ext_conf_error = true;
555
                        $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' '.($i+1).': '.$l_error_weight;
559
                        $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' '.($i+1).': '.$l_error_weight;
556
                    }
560
                    }
557
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$i.'=', 'WAN'.$i.'="'.$_POST['ip_gw_'.$i].','.(($_POST['weight_'.$i] === "0" || $_POST['weight_'.$i] === "")?"1":$_POST['weight_'.$i]).'"', file_get_contents(TEMP_FILE)));
561
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$i.'=', 'WAN'.$i.'="'.$_POST['ip_gw_'.$i].','.(($_POST['weight_'.$i] === "0" || $_POST['weight_'.$i] === "")?"1":$_POST['weight_'.$i]).'"', file_get_contents(TEMP_FILE)));
558
                }
562
                }
559
                $modification_network = true;
563
                $modification_network = true;
560
            }
564
            }
561
        }
565
        }
562
        //set proxy value to off
566
        //set proxy value to off
563
        if ($conf['PROXY'] !== 'Off')
567
        if ($conf['PROXY'] !== 'Off')
564
        {
568
        {
565
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=Off', file_get_contents(TEMP_FILE)));
569
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=Off', file_get_contents(TEMP_FILE)));
566
            if($_POST['gw_count'] !== "1" && $conf['MULTIWAN'] !== 'on') {
570
            if($_POST['gw_count'] !== "1" && $conf['MULTIWAN'] !== 'on') {
567
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=on', file_get_contents(TEMP_FILE)));
571
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=on', file_get_contents(TEMP_FILE)));
568
                $modification_network = true;
572
                $modification_network = true;
569
            }
573
            }
570
            $modification_proxy = true;
574
            $modification_proxy = true;
571
        }
575
        }
572
    }
576
    }
573
 
577
 
574
    //if no errors are detected
578
    //if no errors are detected
575
    if ($ext_conf_error == false) {
579
    if ($ext_conf_error == false) {
576
        copy(TEMP_FILE, CONF_FILE);
580
        copy(TEMP_FILE, CONF_FILE);
577
        //DNS values modification, several services needs to be reloading, reloads the full server.
581
        //DNS values modification, several services needs to be reloading, reloads the full server.
578
        if ($modification_dns) {
582
        if ($modification_dns) {
579
            exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
583
            exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
580
        }
584
        }
581
        //External network modifications, no service reloading
585
        //External network modifications, no service reloading
582
        if ($modification_network) {
586
        if ($modification_network) {
583
            exec('sudo /usr/local/bin/alcasar-network.sh');
587
            exec('sudo /usr/local/bin/alcasar-network.sh');
584
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
588
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
585
        }
589
        }
586
        //If only the proxy has been modified, only the firewall needs a change
590
        //If only the proxy has been modified, only the firewall needs a change
587
        else if ($modification_proxy) {
591
        else if ($modification_proxy) {
588
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
592
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
589
        }
593
        }
590
    }
594
    }
591
    unlink(TEMP_FILE);
595
    unlink(TEMP_FILE);
592
 
596
 
593
	// Read CONF_FILE updated
597
	// Read CONF_FILE updated
594
	$file_conf = fopen(CONF_FILE, 'r');
598
	$file_conf = fopen(CONF_FILE, 'r');
595
	if (!$file_conf) {
599
	if (!$file_conf) {
596
		exit('Error opening the file '.CONF_FILE);
600
		exit('Error opening the file '.CONF_FILE);
597
	}
601
	}
598
	while (!feof($file_conf)) {
602
	while (!feof($file_conf)) {
599
		$buffer = fgets($file_conf, 4096);
603
		$buffer = fgets($file_conf, 4096);
600
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
604
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
601
			$tmp = explode('=', $buffer, 2);
605
			$tmp = explode('=', $buffer, 2);
602
			$conf[trim($tmp[0])] = trim($tmp[1]);
606
			$conf[trim($tmp[0])] = trim($tmp[1]);
603
		}
607
		}
604
	}
608
	}
605
	fclose($file_conf);
609
	fclose($file_conf);
606
}
610
}
607
 
611
 
608
// Let's Encrypt actions
612
// Let's Encrypt actions
609
if ($choix === 'le_issueCert') {
613
if ($choix === 'le_issueCert') {
610
	// TODO: check ndd & mail format
614
	// TODO: check ndd & mail format
611
	$email      = $_POST['email'];
615
	$email      = $_POST['email'];
612
	$domainName = $_POST['domainname'];
616
	$domainName = $_POST['domainname'];
613
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
617
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
614
	$cmdResponse = implode("<br>\n", $output);
618
	$cmdResponse = implode("<br>\n", $output);
615
}
619
}
616
if ($choix === 'le_renewCert') {
620
if ($choix === 'le_renewCert') {
617
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
621
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
618
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
622
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
619
 
623
 
620
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
624
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
621
 
625
 
622
		$cmdResponse = implode("<br>\n", $output);
626
		$cmdResponse = implode("<br>\n", $output);
623
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
627
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
624
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
628
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
625
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
629
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
626
	}
630
	}
627
}
631
}
628
 
632
 
629
// Read Let's Encrypt configuration file
633
// Read Let's Encrypt configuration file
630
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
634
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
631
if (!$file_conf_LE) {
635
if (!$file_conf_LE) {
632
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
636
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
633
}
637
}
634
while (!feof($file_conf_LE)) {
638
while (!feof($file_conf_LE)) {
635
	$buffer = fgets($file_conf_LE, 4096);
639
	$buffer = fgets($file_conf_LE, 4096);
636
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
640
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
637
		$tmp = explode('=', $buffer, 2);
641
		$tmp = explode('=', $buffer, 2);
638
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
642
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
639
	}
643
	}
640
}
644
}
641
fclose($file_conf_LE);
645
fclose($file_conf_LE);
642
 
646
 
643
// Fonction de test de connectivité internet
647
// Fonction de test de connectivité internet
644
function internetTest() {
648
function internetTest() {
645
	$host = 'www.google.fr'; # Google Test
649
	$host = 'www.google.fr'; # Google Test
646
	$port = '80';
650
	$port = '80';
647
 
651
 
648
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
652
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
649
		return false;
653
		return false;
650
	} else {
654
	} else {
651
		fclose($sock);
655
		fclose($sock);
652
		return true;
656
		return true;
653
	}
657
	}
654
}
658
}
655
 
659
 
656
$internet_connected = InternetTest();
660
$internet_connected = InternetTest();
657
if ($internet_connected) {
661
if ($internet_connected) {
658
	$ch = curl_init('https://api.ipify.org/');
662
	$ch = curl_init('https://api.ipify.org/');
659
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
663
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
660
	$internet_publicIP = curl_exec($ch);
664
	$internet_publicIP = curl_exec($ch);
661
	curl_close($ch);
665
	curl_close($ch);
662
} else {
666
} else {
663
	$internet_publicIP = '-.-.-.-';
667
	$internet_publicIP = '-.-.-.-';
664
}
668
}
665
 
669
 
666
// Network interfaces, will be use later for multiple LAN interfaces
670
// Network interfaces, will be use later for multiple LAN interfaces
667
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['INTIF']];
671
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['INTIF']];
668
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
672
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
669
 
673
 
670
//retreive gateway(s) parameters
674
//retreive gateway(s) parameters
671
$gateways = [
675
$gateways = [
672
	(object) [
676
	(object) [
673
		'gateway'   => $conf['GW'],
677
		'gateway'   => $conf['GW'],
674
        'weight'    => $conf['PUBLIC_WEIGHT']
678
        'weight'    => $conf['PUBLIC_WEIGHT']
675
	]
679
	]
676
];
680
];
677
exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nbIfaces);
681
exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nbIfaces);
678
if ($nbIfaces > 0)
682
if ($nbIfaces > 0)
679
{
683
{
680
    for ($i = 1; $i <= $nbIfaces[0]; $i++) {
684
    for ($i = 1; $i <= $nbIfaces[0]; $i++) {
681
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $1 }'", $temp_gw);
685
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $1 }'", $temp_gw);
682
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $2 }'", $temp_weight);
686
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $2 }'", $temp_weight);
683
        $gateways[] = (object) [
687
        $gateways[] = (object) [
684
            'gateway'   => $temp_gw[0],
688
            'gateway'   => $temp_gw[0],
685
            'weight'    => $temp_weight[0]
689
            'weight'    => $temp_weight[0]
686
        ];
690
        ];
687
        $temp_gw = "";
691
        $temp_gw = "";
688
        $temp_weight = "";
692
        $temp_weight = "";
689
    }
693
    }
690
}
694
}
691
 
695
 
692
//retreive internal networks parameters
696
//retreive internal networks parameters
693
$internalNetworks = [
697
$internalNetworks = [
694
	(object) [
698
	(object) [
695
		'interface' => $conf['INTIF'],
699
		'interface' => $conf['INTIF'],
696
		'ip'        => $conf['PRIVATE_IP']
700
		'ip'        => $conf['PRIVATE_IP']
697
	]
701
	]
698
];
702
];
699
 
703
 
700
?>
704
?>
701
<!DOCTYPE HTML>
705
<!DOCTYPE HTML>
702
<html>
706
<html>
703
<head>
707
<head>
704
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
708
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
705
	<title><?= $l_network_title ?></title>
709
	<title><?= $l_network_title ?></title>
706
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
710
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
707
	<script src="/js/jquery.min.js"></script>
711
	<script src="/js/jquery.min.js"></script>
708
	<script src="/js/jquery.connections.js"></script>
712
	<script src="/js/jquery.connections.js"></script>
709
	<script type="text/javascript">
713
	<script type="text/javascript">
710
	function MAC_Control(formulaire){
714
	function MAC_Control(formulaire){
711
		// MAC control (upper case and '-' separator)
715
		// MAC control (upper case and '-' separator)
712
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
716
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
713
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
717
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
714
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
718
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
715
			return true;
719
			return true;
716
		} else {
720
		} else {
717
			alert('Invalid MAC address');
721
			alert('Invalid MAC address');
718
			return false;
722
			return false;
719
		}
723
		}
720
	}
724
	}
721
	</script>
725
	</script>
722
	<style>
726
	<style>
723
		.network-configurator {
727
		.network-configurator {
724
			width: 100%;
728
			width: 100%;
725
		}
729
		}
726
		.network-configurator > * {
730
		.network-configurator > * {
727
			display: inline-block;
731
			display: inline-block;
728
			vertical-align: top;
732
			vertical-align: top;
729
			text-align: center;
733
			text-align: center;
730
		}
734
		}
731
		.network-configurator > .internet, .network-configurator > .alcasar {
735
		.network-configurator > .internet, .network-configurator > .alcasar {
732
			width: 20%;
736
			width: 20%;
733
		}
737
		}
734
		.network-configurator > .externals, .network-configurator > .internals {
738
		.network-configurator > .externals, .network-configurator > .internals {
735
			width: 30%;
739
			width: 30%;
736
		}
740
		}
737
		.network-configurator .actions {
741
		.network-configurator .actions {
738
            position: absolute;
742
            position: absolute;
739
			background-color: #ddd;
743
			background-color: #ddd;
740
			padding: 0 2px;
744
			padding: 0 2px;
741
		}
745
		}
742
		.network-configurator .actions a {
746
		.network-configurator .actions a {
743
			text-decoration: none;
747
			text-decoration: none;
744
		}
748
		}
745
		.network-configurator .actions a:hover {
749
		.network-configurator .actions a:hover {
746
			font-weight: bold;
750
			font-weight: bold;
747
		}
751
		}
748
		.network-configurator .actions-externals {
752
		.network-configurator .actions-externals {
749
			right: 0;
753
			right: 0;
750
			border-radius: 5px;
754
			border-radius: 5px;
751
            position: relative;
755
            position: relative;
752
            text-decoration: none;
756
            text-decoration: none;
753
		}
757
		}
754
		.network-configurator > .alcasar .actions-internals {
758
		.network-configurator > .alcasar .actions-internals {
755
			bottom: 0;
759
			bottom: 0;
756
			right: 0;
760
			right: 0;
757
			border-radius: 5px 0;
761
			border-radius: 5px 0;
758
		}
762
		}
759
		.network-configurator .actions-network {
763
		.network-configurator .actions-network {
760
			right: 0;
764
			right: 0;
761
			border-radius: 5px;
765
			border-radius: 5px;
762
            position: relative;
766
            position: relative;
763
            text-decoration: none;
767
            text-decoration: none;
764
		}
768
		}
765
		.network-configurator .network-box {
769
		.network-configurator .network-box {
766
			display: inline-block;
770
			display: inline-block;
767
			min-height: 100px;
771
			min-height: 100px;
768
			margin: 5px;
772
			margin: 5px;
769
			padding: 3px;
773
			padding: 3px;
770
			text-align: left;
774
			text-align: left;
771
			background-color: #f7f3ef;
775
			background-color: #f7f3ef;
772
			position: relative;
776
			position: relative;
773
			border-radius: 5px;
777
			border-radius: 5px;
774
			border: 2px solid grey;
778
			border: 2px solid grey;
775
		}
779
		}
776
		.network-configurator .network-connector {
780
		.network-configurator .network-connector {
777
			display: inline-block;
781
			display: inline-block;
778
			position: absolute;
782
			position: absolute;
779
			top: 50%;
783
			top: 50%;
780
			margin-top: -5px;
784
			margin-top: -5px;
781
			margin-left: -5px;
785
			margin-left: -5px;
782
			width: 10px;
786
			width: 10px;
783
			height: 10px;
787
			height: 10px;
784
			border-radius: 5px;
788
			border-radius: 5px;
785
			background-color: black;
789
			background-color: black;
786
		}
790
		}
787
		.network-configurator .network-connector[data-connector-direction="left"] {
791
		.network-configurator .network-connector[data-connector-direction="left"] {
788
			border-radius: 5px 0 0 5px;
792
			border-radius: 5px 0 0 5px;
789
		}
793
		}
790
		.network-configurator .network-connector[data-connector-direction="right"] {
794
		.network-configurator .network-connector[data-connector-direction="right"] {
791
			border-radius: 0 5px 5px 0;
795
			border-radius: 0 5px 5px 0;
792
		}
796
		}
793
		.network-configurator div[data-network-type] {
797
		.network-configurator div[data-network-type] {
794
			position: relative;
798
			position: relative;
795
		}
799
		}
796
	</style>
800
	</style>
797
	<script>
801
	<script>
798
	$(document).ready(function () {
802
	$(document).ready(function () {
799
 
803
 
800
        setTimeout(function(){$("#change_success").fadeOut('normal');}, 10000);
804
        setTimeout(function(){$("#change_success").fadeOut('normal');}, 10000);
801
 
805
 
802
	    //Will be used later for multiple LAN interfaces
806
	    //Will be used later for multiple LAN interfaces
803
		let interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
807
		let interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
804
		const wireStyles = { available: { border: '5px double green' } };
808
		const wireStyles = { available: { border: '5px double green' } };
805
 
809
 
806
		// Add gateway
810
		// Add gateway
807
		$('.network-configurator').on('click', '.add-external-network', function (event) {
811
		$('.network-configurator').on('click', '.add-external-network', function (event) {
808
			event.preventDefault();
812
			event.preventDefault();
809
			ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
813
			ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
810
			$('.network-configurator .externals .network-box #ext_gateways').append(' \
814
			$('.network-configurator .externals .network-box #ext_gateways').append(' \
811
			            <div id="ip_routeur_' + ifaces_count + '" data-info_type="gateway" data-number="'+ ifaces_count +'">\
815
			            <div id="ip_routeur_' + ifaces_count + '" data-info_type="gateway" data-number="'+ ifaces_count +'">\
812
                        <label for="ext_gateway_' + ifaces_count + '"><?= $l_ip_router.' ' ?></label><span class="gw_number">'+ (ifaces_count + 1) +'</span> <input style="width:100px" type="text" name="ip_gw_' + ifaces_count + '" id="ext_gateway_' + ifaces_count + '" value="" /> \
816
                        <label for="ext_gateway_' + ifaces_count + '"><?= $l_ip_router.' ' ?></label><span class="gw_number">'+ (ifaces_count + 1) +'</span> <input style="width:100px" type="text" name="ip_gw_' + ifaces_count + '" id="ext_gateway_' + ifaces_count + '" value="" /> \
813
                        <label for="ext_weight_'+ ifaces_count +'"><?= $l_gw_weight ?></label> <input style="width:20px" type="text" name="weight_' + ifaces_count + '" id="ext_weight_'+ ifaces_count +'" value="0"/> \
817
                        <label for="ext_weight_'+ ifaces_count +'"><?= $l_gw_weight ?></label> <input style="width:20px" type="text" name="weight_' + ifaces_count + '" id="ext_weight_'+ ifaces_count +'" value="0"/> \
814
                        <div class="actions actions-network" style="display:inline-block; width:11px"><a href="#" style="display:block; text-align:center" class="remove-network" title="Supprimer ce réseau">-</a></div><br></div> ');
818
                        <div class="actions actions-network" style="display:inline-block; width:11px"><a href="#" style="display:block; text-align:center" class="remove-network" title="Supprimer ce réseau">-</a></div><br></div> ');
815
            ifaces_count++;
819
            ifaces_count++;
816
            document.getElementById("gw_count").setAttribute('value', ifaces_count);
820
            document.getElementById("gw_count").setAttribute('value', ifaces_count);
817
            updateGatewayView();
821
            updateGatewayView();
818
            $('div.network-connector[data-connector-network]').connections('update');
822
            $('div.network-connector[data-connector-network]').connections('update');
819
		});
823
		});
820
 
824
 
821
		// Add internal network
825
		// Add internal network
822
		$('.network-configurator').on('click', '.add-internal-network', function (event) {
826
		$('.network-configurator').on('click', '.add-internal-network', function (event) {
823
			event.preventDefault();
827
			event.preventDefault();
824
			$('.network-configurator .internals').append(' \
828
			$('.network-configurator .internals').append(' \
825
					<div data-network-type="internal"> \
829
					<div data-network-type="internal"> \
826
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
830
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
827
						<div class="network-box"> \
831
						<div class="network-box"> \
828
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
832
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
829
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><br> \
833
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><br> \
830
							<label for="int_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_X" value="" /><br> \
834
							<label for="int_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_X" value="" /><br> \
831
						</div> \
835
						</div> \
832
					</div>');
836
					</div>');
833
			addWire($('div[data-network-type="internal"]:last'));
837
			addWire($('div[data-network-type="internal"]:last'));
834
		});
838
		});
835
 
839
 
836
		// Remove gateway
840
		// Remove gateway
837
		$('.network-box').on('click', '.remove-network', function (event) {
841
		$('.network-box').on('click', '.remove-network', function (event) {
838
			event.preventDefault();
842
			event.preventDefault();
839
			$(this).parent().parent().fadeOut(200, function() {
843
			$(this).parent().parent().fadeOut(200, function() {
840
 
844
 
841
			    $(this).remove();
845
			    $(this).remove();
842
				//update network numbers
846
				//update network numbers
843
                $('div[data-info_type="gateway"]').each(function (index, value) {
847
                $('div[data-info_type="gateway"]').each(function (index, value) {
844
                    updateGatewayNumbers($(this), index);
848
                    updateGatewayNumbers($(this), index);
845
                });
849
                });
846
                ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
850
                ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
847
                document.getElementById("gw_count").setAttribute('value', (ifaces_count - 1));
851
                document.getElementById("gw_count").setAttribute('value', (ifaces_count - 1));
848
                updateGatewayView();
852
                updateGatewayView();
849
 
853
 
850
                $('div.network-connector[data-connector-network]').connections('update');
854
                $('div.network-connector[data-connector-network]').connections('update');
851
			});
855
			});
852
		});
856
		});
853
 
857
 
854
		//proxy enabled or disabled
858
		//proxy enabled or disabled
855
		$('.network-configurator').on('click', '.enable_proxy', function(event){
859
		$('.network-configurator').on('click', '.enable_proxy', function(event){
856
		    if ($(this).is(':checked'))
860
		    if ($(this).is(':checked'))
857
            {
861
            {
858
                document.getElementById("add_external").setAttribute('hidden', 'true');
862
                document.getElementById("add_external").setAttribute('hidden', 'true');
859
                document.getElementById("ext_proxy").removeAttribute('disabled');
863
                document.getElementById("ext_proxy").removeAttribute('disabled');
860
                $('div[id="ip_routeur_0"]').children('span').html('');
864
                $('div[id="ip_routeur_0"]').children('span').html('');
861
                $('div[data-info_type="gateway"]').each(function(index, value) {
865
                $('div[data-info_type="gateway"]').each(function(index, value) {
862
                    if ($(this).attr('data-number') !== "0")
866
                    if ($(this).attr('data-number') !== "0")
863
                    {
867
                    {
864
                        $(this).attr('hidden', 'true');
868
                        $(this).attr('hidden', 'true');
865
                    }
869
                    }
866
                    else
870
                    else
867
                    {
871
                    {
868
                        $(this).children('input[id="ext_weight_0"]').attr('hidden', 'true');
872
                        $(this).children('input[id="ext_weight_0"]').attr('hidden', 'true');
869
                        $(this).children('label[for="ext_weight_0"]').attr('hidden', 'true');
873
                        $(this).children('label[for="ext_weight_0"]').attr('hidden', 'true');
870
                        $(this).children('div[class="actions actions-network"]').css('display', 'none');
874
                        $(this).children('div[class="actions actions-network"]').css('display', 'none');
871
                    }
875
                    }
872
                });
876
                });
873
            }
877
            }
874
            else
878
            else
875
            {
879
            {
876
                document.getElementById("add_external").removeAttribute('hidden');
880
                document.getElementById("add_external").removeAttribute('hidden');
877
                document.getElementById("ext_proxy").setAttribute('disabled', 'true');
881
                document.getElementById("ext_proxy").setAttribute('disabled', 'true');
878
                $('div[id="ip_routeur_0"]').children('span').html('1');
882
                $('div[id="ip_routeur_0"]').children('span').html('1');
879
                $('div[data-info_type="gateway"]').each(function(index, value) {
883
                $('div[data-info_type="gateway"]').each(function(index, value) {
880
                    if ($(this).attr('data-number') !== "0")
884
                    if ($(this).attr('data-number') !== "0")
881
                    {
885
                    {
882
                        $(this).removeAttr('hidden');
886
                        $(this).removeAttr('hidden');
883
                    }
887
                    }
884
                    else
888
                    else
885
                    {
889
                    {
886
                        $(this).children('input[id="ext_weight_0"]').removeAttr('hidden');
890
                        $(this).children('input[id="ext_weight_0"]').removeAttr('hidden');
887
                        $(this).children('label[for="ext_weight_0"]').removeAttr('hidden');
891
                        $(this).children('label[for="ext_weight_0"]').removeAttr('hidden');
888
                        $(this).children('div[class="actions actions-network"]').css('display', 'inline-block');
892
                        $(this).children('div[class="actions actions-network"]').css('display', 'inline-block');
889
                    }
893
                    }
890
                });
894
                });
891
                updateGatewayView();
895
                updateGatewayView();
892
            }
896
            }
893
            $('div.network-connector[data-connector-network]').connections('update');
897
            $('div.network-connector[data-connector-network]').connections('update');
894
        });
898
        });
895
 
899
 
896
		//Add a wire between two connectors
900
		//Add a wire between two connectors
897
		const addWire = function (network) {
901
		const addWire = function (network) {
898
			const networkType = network.data('networkType');
902
			const networkType = network.data('networkType');
899
			if (networkType === 'external') {
903
			if (networkType === 'external') {
900
                $().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: network.children('div.network-connector[data-connector-network="internet"]'), css: wireStyles.available, within: network });
904
                $().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: network.children('div.network-connector[data-connector-network="internet"]'), css: wireStyles.available, within: network });
901
                $().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: network.children('div.network-connector[data-connector-network="external"]'), css: wireStyles.available, within: network });
905
                $().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: network.children('div.network-connector[data-connector-network="external"]'), css: wireStyles.available, within: network });
902
            } else if (networkType === 'internal') {
906
            } else if (networkType === 'internal') {
903
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: network.children('div.network-connector[data-connector-network="internal"]'), css: wireStyles.available, within: network });
907
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: network.children('div.network-connector[data-connector-network="internal"]'), css: wireStyles.available, within: network });
904
			}
908
			}
905
		};
909
		};
906
 
910
 
907
		//reindex the gateway numbers when a gateway is deleted
911
		//reindex the gateway numbers when a gateway is deleted
908
		const updateGatewayNumbers = function(gateway, number) {
912
		const updateGatewayNumbers = function(gateway, number) {
909
		    old_number = gateway.attr('data-number');
913
		    old_number = gateway.attr('data-number');
910
            gateway.attr('data-number', number);
914
            gateway.attr('data-number', number);
911
            gateway.attr('id', 'ip_routeur_'+number);
915
            gateway.attr('id', 'ip_routeur_'+number);
912
            if (number === 0)
916
            if (number === 0)
913
            {
917
            {
914
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw');
918
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw');
915
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight');
919
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight');
916
            }
920
            }
917
            else
921
            else
918
            {
922
            {
919
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw_'+number);
923
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw_'+number);
920
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight_'+number);
924
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight_'+number);
921
            }
925
            }
922
            gateway.children('label[for="ext_gateway_'+old_number+'"]').attr('for', 'ext_gateway_'+number);
926
            gateway.children('label[for="ext_gateway_'+old_number+'"]').attr('for', 'ext_gateway_'+number);
923
            gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('id', 'ext_gateway_'+number);
927
            gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('id', 'ext_gateway_'+number);
924
            gateway.children('label[for="ext_weight_'+old_number+'"]').attr('for', 'ext_weight_'+number);
928
            gateway.children('label[for="ext_weight_'+old_number+'"]').attr('for', 'ext_weight_'+number);
925
            gateway.children('input[id="ext_weight_'+old_number+'"]').attr('id', 'ext_weight_'+number);
929
            gateway.children('input[id="ext_weight_'+old_number+'"]').attr('id', 'ext_weight_'+number);
926
            gateway.children('span[class="gw_number"]').html((number+1)+' ');
930
            gateway.children('span[class="gw_number"]').html((number+1)+' ');
927
 
931
 
928
        };
932
        };
929
 
933
 
930
		//hide the delete button and the weight field when there is only one gateway (or when there is a proxy)
934
		//hide the delete button and the weight field when there is only one gateway (or when there is a proxy)
931
		const updateGatewayView = function() {
935
		const updateGatewayView = function() {
932
            ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
936
            ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
933
            if (ifaces_count === 1)
937
            if (ifaces_count === 1)
934
            {
938
            {
935
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').attr('hidden', 'true');
939
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').attr('hidden', 'true');
936
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').attr('hidden', 'true');
940
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').attr('hidden', 'true');
937
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'none');
941
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'none');
938
            }
942
            }
939
            else
943
            else
940
            {
944
            {
941
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').removeAttr('hidden');
945
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').removeAttr('hidden');
942
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').removeAttr('hidden');
946
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').removeAttr('hidden');
943
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'inline-block');
947
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'inline-block');
944
            }
948
            }
945
        };
949
        };
946
 
950
 
947
		//resize the connections to fit the window
951
		//resize the connections to fit the window
948
		window.addEventListener('resize', function () {
952
		window.addEventListener('resize', function () {
949
			$('div.network-connector[data-connector-network]').connections('update');
953
			$('div.network-connector[data-connector-network]').connections('update');
950
		});
954
		});
951
 
955
 
952
		// Add wires to existing networks at page first render
956
		// Add wires to existing networks at page first render
953
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
957
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
954
			addWire($(this));
958
			addWire($(this));
955
		});
959
		});
956
	});
960
	});
957
	</script>
961
	</script>
958
</head>
962
</head>
959
<body>
963
<body>
960
<div id="ldoverlay" class="overlay">
964
<div id="ldoverlay" class="overlay">
961
	<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
965
	<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
962
</div>
966
</div>
963
<div class="panel">
967
<div class="panel">
964
	<div class="panel-header"><?= $l_network_title ?></div>
968
	<div class="panel-header"><?= $l_network_title ?></div>
965
	<div class="panel-row">
969
	<div class="panel-row">
966
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
970
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
967
			<div class="network-configurator">
971
			<div class="network-configurator">
968
				<div class="internet">
972
				<div class="internet">
969
					<div data-network-type="internet">
973
					<div data-network-type="internet">
970
						<div class="network-box">
974
						<div class="network-box">
971
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
975
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
972
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
976
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
973
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
977
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
974
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
978
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
975
						</div>
979
						</div>
976
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
980
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
977
					</div>
981
					</div>
978
				</div><div id="externals_id" class="externals">
982
				</div><div id="externals_id" class="externals">
979
						<div data-network-type="external">
983
						<div data-network-type="external">
980
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
984
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
981
							<div class="network-box">
985
							<div class="network-box">
982
								<label for="ext_interface">Interface</label> <input name="ext_interface" id="ext_interface" value="<?= $conf['EXTIF'] ?>" disabled="disabled"/><br>
986
								<label for="ext_interface">Interface</label> <input name="ext_interface" id="ext_interface" value="<?= $conf['EXTIF'] ?>" disabled="disabled"/><br>
983
								<label for="ext_ip"><?= $l_ip_address ?></label> <input style="width:130px" type="text" name="ip_public" id="ext_ip" value="<?= $conf['PUBLIC_IP'] ?>" /><br>
987
								<label for="ext_ip"><?= $l_ip_address ?></label> <input style="width:130px" type="text" name="ip_public" id="ext_ip" value="<?= $conf['PUBLIC_IP'] ?>" /><br>
984
                                <input class="enable_proxy" type="checkbox" name="enable_proxy" value="P_Enabled" <?php if($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On') { echo 'checked'; }?>/>
988
                                <input class="enable_proxy" type="checkbox" name="enable_proxy" value="P_Enabled" <?php if($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On') { echo 'checked'; }?>/>
985
                                <label for="proxy">Proxy</label> <input style="width:140px" type="text" name="proxy" id="ext_proxy" value=<?= $conf['PROXY_IP']?> <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? '' : 'disabled'?>/><br>
989
                                <label for="proxy">Proxy</label> <input style="width:140px" type="text" name="proxy" id="ext_proxy" value=<?= $conf['PROXY_IP']?> <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? '' : 'disabled'?>/><br>
986
                                <div id="ext_gateways" >
990
                                <div id="ext_gateways" >
987
                                    <input type="text" name="gw_count" id="gw_count" value="<?=count($gateways)?>" hidden="hidden"/>
991
                                    <input type="text" name="gw_count" id="gw_count" value="<?=count($gateways)?>" hidden="hidden"/>
988
                                    <?php foreach ($gateways as $index => $network):
992
                                    <?php foreach ($gateways as $index => $network):
989
                                        if ($index == 0) {?>
993
                                        if ($index == 0) {?>
990
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>">
994
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>">
991
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
995
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
992
                                                <span class="gw_number"><?= ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')?'':($index+1) ?> </span>
996
                                                <span class="gw_number"><?= ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')?'':($index+1) ?> </span>
993
                                                <input style="width:100px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
997
                                                <input style="width:100px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
994
                                                <label for="ext_weight_<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>><?= $l_gw_weight ?></label>
998
                                                <label for="ext_weight_<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>><?= $l_gw_weight ?></label>
995
                                                <input style="width:20px" type="text" name="weight" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On' || $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>/>
999
                                                <input style="width:20px" type="text" name="weight" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On' || $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>/>
996
                                                <div class="actions actions-network" style="display: <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'none' : 'inline-block' ?>; width:11px">
1000
                                                <div class="actions actions-network" style="display: <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'none' : 'inline-block' ?>; width:11px">
997
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
1001
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
998
                                                </div><br>
1002
                                                </div><br>
999
                                            </div>
1003
                                            </div>
1000
                                        <?php } else {?>
1004
                                        <?php } else {?>
1001
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>
1005
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>
1002
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
1006
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
1003
                                                <span class="gw_number"><?= ($index+1) ?> </span>
1007
                                                <span class="gw_number"><?= ($index+1) ?> </span>
1004
                                                <input style="width:100px" type="text" name="ip_gw_<?= $index ?>" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>"/>
1008
                                                <input style="width:100px" type="text" name="ip_gw_<?= $index ?>" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>"/>
1005
                                                <label for="ext_weight_<?= $index ?>"><?= $l_gw_weight ?></label>
1009
                                                <label for="ext_weight_<?= $index ?>"><?= $l_gw_weight ?></label>
1006
                                                <input style="width:20px" type="text" name="weight_<?= $index ?>" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>"/>
1010
                                                <input style="width:20px" type="text" name="weight_<?= $index ?>" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>"/>
1007
                                                <div class="actions actions-network" style="display:inline-block; width:11px">
1011
                                                <div class="actions actions-network" style="display:inline-block; width:11px">
1008
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
1012
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
1009
                                                </div><br>
1013
                                                </div><br>
1010
                                            </div>
1014
                                            </div>
1011
                                    <?php } endforeach; ?>
1015
                                    <?php } endforeach; ?>
1012
                                </div>
1016
                                </div>
1013
                                <div class="actions actions-externals" style="margin: 0 auto; width:11px"><a id="add_external" href="#" class="add-external-network" title="Ajouter un réseau externe" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>+</a></div>
1017
                                <div class="actions actions-externals" style="margin: 0 auto; width:11px"><a id="add_external" href="#" class="add-external-network" title="Ajouter un réseau externe" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>+</a></div>
1014
                            </div>
1018
                            </div>
1015
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
1019
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
1016
						</div>
1020
						</div>
1017
				</div><div class="alcasar">
1021
				</div><div class="alcasar">
1018
					<div data-network-type="alcasar">
1022
					<div data-network-type="alcasar">
1019
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
1023
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
1020
						<div class="network-box">
1024
						<div class="network-box">
1021
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
1025
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
1022
							<!-- <div class="actions actions-internals">
1026
							<!-- <div class="actions actions-internals">
1023
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
1027
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
1024
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
1028
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
1025
							</div> -->
1029
							</div> -->
1026
						</div>
1030
						</div>
1027
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
1031
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
1028
					</div>
1032
					</div>
1029
				</div><div id="internals_id" class="internals" data-count="1">
1033
				</div><div id="internals_id" class="internals" data-count="1">
1030
					<?php foreach ($internalNetworks as $network): ?>
1034
					<?php foreach ($internalNetworks as $network): ?>
1031
						<div data-network-type="internal">
1035
						<div data-network-type="internal">
1032
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
1036
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
1033
							<div class="network-box">
1037
							<div class="network-box">
1034
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
1038
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
1035
								<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>
1039
								<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>
1036
								<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>
1040
								<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>
1037
							</div>
1041
							</div>
1038
						</div>
1042
						</div>
1039
					<? endforeach; ?>
1043
					<? endforeach; ?>
1040
				</div>
1044
				</div>
1041
			</div>
1045
			</div>
1042
            <?php if ($ext_conf_error == true) {
1046
            <?php if ($ext_conf_error == true) {
1043
                echo '<span style="color:red">';
1047
                echo '<span style="color:red">';
1044
                $temp = 0;
1048
                $temp = 0;
1045
                while (isset($ext_conf_error_list[$temp])) {
1049
                while (isset($ext_conf_error_list[$temp])) {
1046
                    echo $ext_conf_error_list[$temp].'<br>';
1050
                    echo $ext_conf_error_list[$temp].'<br>';
1047
                    $temp++;
1051
                    $temp++;
1048
                }
1052
                }
1049
                echo '</span>';
1053
                echo '</span>';
1050
            }
1054
            }
1051
            else if (($choix === 'network_change') && ($modification_proxy || $modification_dns || $modification_network)) {
1055
            else if (($choix === 'network_change') && ($modification_proxy || $modification_dns || $modification_network)) {
1052
                echo '<span id="change_success" style="color:green">'.$l_change_successful.'</span>';
1056
                echo '<span id="change_success" style="color:green">'.$l_change_successful.'</span>';
1053
            }?>
1057
            }?>
1054
			<hr>
1058
			<hr>
1055
			<div style="text-align: center; margin: 5px">
1059
			<div style="text-align: center; margin: 5px">
1056
				<input type="hidden" name="choix" value="network_change">
1060
				<input type="hidden" name="choix" value="network_change">
1057
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1061
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1058
			</div>
1062
			</div>
1059
		</form>
1063
		</form>
1060
	</div>
1064
	</div>
1061
</div>
1065
</div>
1062
<br>
1066
<br>
1063
<div class="panel">
1067
<div class="panel">
1064
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
1068
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
1065
</div>
1069
</div>
1066
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1070
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1067
	<tr><td width="50%" align="center" valign="middle">
1071
	<tr><td width="50%" align="center" valign="middle">
1068
		<form action="network.php" method="POST">
1072
		<form action="network.php" method="POST">
1069
		<table cellspacing="2" cellpadding="3" border="1">
1073
		<table cellspacing="2" cellpadding="3" border="1">
1070
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
1074
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
1071
		<?php
1075
		<?php
1072
		// Read the "ether" file
1076
		// Read the "ether" file
1073
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
1077
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
1074
		$detail = explode(' ', $output[1]);
1078
		$detail = explode(' ', $output[1]);
1075
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
1079
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
1076
		unset($output); unset($detail);
1080
		unset($output); unset($detail);
1077
		$line_exist = false;
1081
		$line_exist = false;
1078
		$tab = file(ETHERS_INFO_FILE);
1082
		$tab = file(ETHERS_INFO_FILE);
1079
		if ($tab) { // le fichier n'est pas vide
1083
		if ($tab) { // le fichier n'est pas vide
1080
			foreach ($tab as $line) {
1084
			foreach ($tab as $line) {
1081
				$fields = explode(' ', $line);
1085
				$fields = explode(' ', $line);
1082
				$mac_addr = $fields[0];
1086
				$mac_addr = $fields[0];
1083
				$ip_addr  = $fields[1];
1087
				$ip_addr  = $fields[1];
1084
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
1088
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
1085
 
1089
 
1086
				echo '<tr>';
1090
				echo '<tr>';
1087
				echo "<td>$mac_addr</td>";
1091
				echo "<td>$mac_addr</td>";
1088
				echo "<td>$ip_addr</td>";
1092
				echo "<td>$ip_addr</td>";
1089
				if ($mac_addr !== $intif_mac_addr) {
1093
				if ($mac_addr !== $intif_mac_addr) {
1090
					echo '<td>'.ltrim($info, '#').'</td>';
1094
					echo '<td>'.ltrim($info, '#').'</td>';
1091
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
1095
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
1092
					$line_exist=True;
1096
					$line_exist=True;
1093
				} else {
1097
				} else {
1094
					echo '<td>ALCASAR</td>';
1098
					echo '<td>ALCASAR</td>';
1095
					echo '<td></td>';
1099
					echo '<td></td>';
1096
				}
1100
				}
1097
				echo '</tr>';
1101
				echo '</tr>';
1098
			}
1102
			}
1099
		}
1103
		}
1100
		?>
1104
		?>
1101
		</table>
1105
		</table>
1102
		<?php if ($line_exist): ?>
1106
		<?php if ($line_exist): ?>
1103
			<input type="hidden" name="choix" value="del_mac">
1107
			<input type="hidden" name="choix" value="del_mac">
1104
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1108
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1105
		<?php endif; ?>
1109
		<?php endif; ?>
1106
		</form>
1110
		</form>
1107
	</td><td width="50%" valign="middle" align="center">
1111
	</td><td width="50%" valign="middle" align="center">
1108
		<form name="new_mac" action="network.php" method="POST">
1112
		<form name="new_mac" action="network.php" method="POST">
1109
			<table cellspacing="2" cellpadding="3" border="1">
1113
			<table cellspacing="2" cellpadding="3" border="1">
1110
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
1114
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
1111
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
1115
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
1112
				<tr><td><input type="text" name="add_mac" size="17"></td>
1116
				<tr><td><input type="text" name="add_mac" size="17"></td>
1113
				<td><input type="text" name="add_ip" size="10"></td>
1117
				<td><input type="text" name="add_ip" size="10"></td>
1114
				<td><input type="text" name="info" size="10"></td>
1118
				<td><input type="text" name="info" size="10"></td>
1115
				<td>
1119
				<td>
1116
					<input type="hidden" name="choix" value="new_mac">
1120
					<input type="hidden" name="choix" value="new_mac">
1117
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
1121
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
1118
				</td>
1122
				</td>
1119
			</tr></table>
1123
			</tr></table>
1120
		</form>
1124
		</form>
1121
	</td></tr>
1125
	</td></tr>
1122
</table>
1126
</table>
1123
<br>
1127
<br>
1124
<div class="panel">
1128
<div class="panel">
1125
	<div class="panel-header"><?= $l_local_dns ?></div>
1129
	<div class="panel-header"><?= $l_local_dns ?></div>
1126
</div>
1130
</div>
1127
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1131
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1128
	<tr>
1132
	<tr>
1129
		<td width="50%" align="center">
1133
		<td width="50%" align="center">
1130
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1134
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1131
			<table cellspacing="2" cellpadding="3" border="1">
1135
			<table cellspacing="2" cellpadding="3" border="1">
1132
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
1136
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
1133
			<?php
1137
			<?php
1134
			// Read the "dns_local" file
1138
			// Read the "dns_local" file
1135
			$line_exist = false;
1139
			$line_exist = false;
1136
			$tab = file(DNS_LOCAL_FILE);
1140
			$tab = file(DNS_LOCAL_FILE);
1137
			if ($tab) { // not empty
1141
			if ($tab) { // not empty
1138
				foreach ($tab as $line) {
1142
				foreach ($tab as $line) {
1139
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
1143
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
1140
						$line_exist = true;
1144
						$line_exist = true;
1141
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
1145
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
1142
						$ip_addr   = $field[0];
1146
						$ip_addr   = $field[0];
1143
						$host_name = $field[1];
1147
						$host_name = $field[1];
1144
						echo "<tr><td>$ip_addr</td>";
1148
						echo "<tr><td>$ip_addr</td>";
1145
						echo "<td>$host_name</td>";
1149
						echo "<td>$host_name</td>";
1146
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
1150
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
1147
							echo "<td>";}
1151
							echo "<td>";}
1148
						else {
1152
						else {
1149
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
1153
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
1150
						}
1154
						}
1151
						echo "</td></tr>";
1155
						echo "</td></tr>";
1152
					}
1156
					}
1153
				}
1157
				}
1154
			}
1158
			}
1155
			if (!$line_exist) {
1159
			if (!$line_exist) {
1156
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
1160
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
1157
			}
1161
			}
1158
			?>
1162
			?>
1159
			</table>
1163
			</table>
1160
			<?php if ($line_exist): ?>
1164
			<?php if ($line_exist): ?>
1161
				<input type="hidden" name="choix" value="del_host">
1165
				<input type="hidden" name="choix" value="del_host">
1162
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1166
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1163
			<?php endif; ?>
1167
			<?php endif; ?>
1164
			</form>
1168
			</form>
1165
		</td>
1169
		</td>
1166
		<td width="50%" valign="middle" align="center">
1170
		<td width="50%" valign="middle" align="center">
1167
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1171
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1168
			<table cellspacing="2" cellpadding="3" border="1">
1172
			<table cellspacing="2" cellpadding="3" border="1">
1169
			<tr>
1173
			<tr>
1170
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
1174
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
1171
			</tr>
1175
			</tr>
1172
			<tr>
1176
			<tr>
1173
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
1177
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
1174
			</tr>
1178
			</tr>
1175
			<tr>
1179
			<tr>
1176
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
1180
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
1177
				<td><input type="text" name="add_host" size="17"></td>
1181
				<td><input type="text" name="add_host" size="17"></td>
1178
				<td><input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>"></td>
1182
				<td><input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>"></td>
1179
			</tr>
1183
			</tr>
1180
			</table>
1184
			</table>
1181
			</form>
1185
			</form>
1182
		</td>
1186
		</td>
1183
	</tr>
1187
	</tr>
1184
</table>
1188
</table>
1185
<br>
1189
<br>
1186
<div class="panel">
1190
<div class="panel">
1187
	<div class="panel-header"><?= $l_ssl_title ?></div>
1191
	<div class="panel-header"><?= $l_ssl_title ?></div>
1188
	<div class="panel-row">
1192
	<div class="panel-row">
1189
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1193
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1190
			<input type="hidden" name="choix" value="https_login">
1194
			<input type="hidden" name="choix" value="https_login">
1191
			<input type="checkbox" name="https_login" id="https_login" <?= ($conf['HTTPS_LOGIN'] === 'on')? "checked": "" ?>><b><?= $l_ssl_title ?></b><br>
1195
			<input type="checkbox" name="https_login" id="https_login" <?= ($conf['HTTPS_LOGIN'] === 'on')? "checked": "" ?>><b><?= $l_ssl_title ?></b><br>
1192
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1196
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1193
		</form>
1197
		</form>
1194
	</div>
1198
	</div>
1195
</div>
1199
</div>
1196
<br>
1200
<br>
1197
<div class="panel">
1201
<div class="panel">
1198
	<div class="panel-header"><?= $l_ssh_title ?></div>
1202
	<div class="panel-header"><?= $l_ssh_title ?></div>
1199
	<table width="100%" cellspacing="0" cellpadding="5" border="1">
1203
	<table width="100%" cellspacing="0" cellpadding="5" border="1">
1200
	<tr>
1204
	<tr>
1201
		<td width="50%" align="center">
1205
		<td width="50%" align="center">
1202
			<div class="panel-row">
1206
			<div class="panel-row">
1203
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1207
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1204
					<input type="hidden" name="choix" value="enable_lan_ssh">
1208
					<input type="hidden" name="choix" value="enable_lan_ssh">
1205
					<input type="checkbox" name="sshlan" id="sshlan" <?= $conf['SSH_LAN'] === 'on' ? "checked": "" ?>> <b><?= $l_ssh_lan_activate ?></b><br><br>
1209
					<input type="checkbox" name="sshlan" id="sshlan" <?= $conf['SSH_LAN'] !== '0' ? "checked": "" ?> onchange="document.getElementById('sshtablelan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_lan_activate ?></b><br><br>
-
 
1210
					<div id="sshtablelan" style="display:<?= $conf['SSH_LAN'] !== '0'? "block": "none" ?>">
-
 
1211
					<table cellspacing="2" cellpadding="3" border="1">
-
 
1212
						<tr>
-
 
1213
							<th><?= $l_ssh_port ?></th><th><?= $l_ssh_from ?></th>
-
 
1214
						</tr>
-
 
1215
						<tr>
-
 
1216
							<td><input style="width:120px" type="text" id="ssh_port" name="ssh_port" value="<?= $conf['SSH_LAN'] !== '0' ? $conf['SSH_LAN']:22 ?>" /></td>
-
 
1217
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[0] ?>" /></td>		
-
 
1218
						</tr>
-
 
1219
					</table>
-
 
1220
					<p>Activer sur tout le LAN : 0.0.0.0</p>
-
 
1221
				</div>
1206
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1222
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1207
				</form>
1223
				</form>
1208
			</div>
1224
			</div>
1209
		</td>
1225
		</td>
1210
		<td width="50%" align="center">
1226
		<td width="50%" align="center">
1211
			<div class="panel-row">
1227
			<div class="panel-row">
1212
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1228
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1213
				<input type="hidden" name="choix" value="enable_wan_ssh">
1229
				<input type="hidden" name="choix" value="enable_wan_ssh">
1214
				<input type="checkbox" name="togglessh" id="togglessh" <?= is_numeric($conf['SSH_WAN'])? "checked": "" ?> onchange="document.getElementById('sshtable').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_wan_activate ?></b><br><br>
1230
				<input type="checkbox" name="togglessh" id="togglessh" <?= $conf['SSH_WAN'] !== '0'? "checked": "" ?> onchange="document.getElementById('sshtablewan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_wan_activate ?></b><br><br>
1215
				<div id="sshtable" style="display:<?= is_numeric($conf['SSH_WAN'])? "block": "none" ?>">
1231
				<div id="sshtablewan" style="display:<?= $conf['SSH_WAN'] !== '0'? "block": "none" ?>">
1216
					<table cellspacing="2" cellpadding="3" border="1">
1232
					<table cellspacing="2" cellpadding="3" border="1">
1217
						<tr>
1233
						<tr>
1218
							<th><?= $l_ssh_port ?></th><th><?= $l_ssh_from ?></th>
1234
							<th><?= $l_ssh_port ?></th><th><?= $l_ssh_from ?></th>
1219
						</tr>
1235
						</tr>
1220
						<tr>
1236
						<tr>
1221
							<td><input style="width:120px" type="text" id="ssh_port" name="ssh_port" value="<?= is_numeric($conf['SSH_WAN']) ? $conf['SSH_WAN']:22 ?>" /></td>
1237
							<td><input style="width:120px" type="text" id="ssh_port" name="ssh_port" value="<?= $conf['SSH_WAN'] !== '0' ? $conf['SSH_WAN']:22 ?>" /></td>
1222
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= $conf['SSH_ADMIN_FROM'] ?>" /></td>		
1238
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[1] ?>" /></td>		
1223
						</tr>
1239
						</tr>
1224
					</table>
1240
					</table>
1225
					<p>Activer sur tout réseau : 0.0.0.0/0</p>
1241
					<p>Activer sur tout réseau : 0.0.0.0</p>
1226
				</div>
1242
				</div>
1227
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1243
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1228
				</form>
1244
				</form>
1229
			</div>
1245
			</div>
1230
		</td>
1246
		</td>
1231
	</tr>
1247
	</tr>
1232
	</table>
1248
	</table>
1233
</div>
1249
</div>
1234
<br>
1250
<br>
1235
<div class="panel">
1251
<div class="panel">
1236
	<div class="panel-header"><?= $l_import_cert ?></div>
1252
	<div class="panel-header"><?= $l_import_cert ?></div>
1237
	<div class="panel-row">
1253
	<div class="panel-row">
1238
		<div class="panel-cell">
1254
		<div class="panel-cell">
1239
			<?php
1255
			<?php
1240
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
1256
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
1241
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
1257
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
1242
			$domain               = $certificateInfos['subject']['CN'];
1258
			$domain               = $certificateInfos['subject']['CN'];
1243
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
1259
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
1244
			$CAdomain             = $certificateInfos['issuer']['CN'];
1260
			$CAdomain             = $certificateInfos['issuer']['CN'];
1245
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
1261
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
1246
			?>
1262
			?>
1247
			<h3><?= $l_current_certificate ?></h3>
1263
			<h3><?= $l_current_certificate ?></h3>
1248
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
1264
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
1249
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
1265
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
1250
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
1266
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
1251
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
1267
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
1252
		</div>
1268
		</div>
1253
		<div class="panel-cell">
1269
		<div class="panel-cell">
1254
			<?
1270
			<?
1255
			if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
1271
			if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
1256
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1272
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1257
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
1273
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
1258
				echo "\t\t\t\t<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
1274
				echo "\t\t\t\t<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
1259
				echo "\t\t\t</form>\n";}
1275
				echo "\t\t\t</form>\n";}
1260
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
1276
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
1261
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1277
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1262
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
1278
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
1263
				echo "\t\t\t\t<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
1279
				echo "\t\t\t\t<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
1264
				echo "\t\t\t</form>\n";}
1280
				echo "\t\t\t</form>\n";}
1265
			?>
1281
			?>
1266
		</div>
1282
		</div>
1267
	</div>
1283
	</div>
1268
	<div class="panel-row">
1284
	<div class="panel-row">
1269
		<div class="panel-cell">
1285
		<div class="panel-cell">
1270
			<h3><?= $l_upload_certificate ?></h3>
1286
			<h3><?= $l_upload_certificate ?></h3>
1271
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
1287
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
1272
				<?= $l_private_key;?> <input type="file" name="key"><br>
1288
				<?= $l_private_key;?> <input type="file" name="key"><br>
1273
				<?= $l_certificate;?> <input type="file" name="crt"><br>
1289
				<?= $l_certificate;?> <input type="file" name="crt"><br>
1274
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
1290
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
1275
				<input type="hidden" name="choix" value="import_cert">
1291
				<input type="hidden" name="choix" value="import_cert">
1276
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_import ?>">
1292
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_import ?>">
1277
			</form>
1293
			</form>
1278
		</div>
1294
		</div>
1279
		<div class="panel-cell">
1295
		<div class="panel-cell">
1280
			<?php
1296
			<?php
1281
			// Get step
1297
			// Get step
1282
			if (empty($LE_conf['domainRequest'])) {
1298
			if (empty($LE_conf['domainRequest'])) {
1283
				$step = 1;
1299
				$step = 1;
1284
			} else if (!empty($LE_conf['challenge'])) {
1300
			} else if (!empty($LE_conf['challenge'])) {
1285
				$step = 2;
1301
				$step = 2;
1286
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
1302
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
1287
				$step = 3;
1303
				$step = 3;
1288
			} else {
1304
			} else {
1289
				$step = 1;
1305
				$step = 1;
1290
			}
1306
			}
1291
			?>
1307
			?>
1292
			<h3><?= $l_le_integration ?></h3>
1308
			<h3><?= $l_le_integration ?></h3>
1293
			<?php if ($step === 1): ?>
1309
			<?php if ($step === 1): ?>
1294
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1310
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1295
					<input type="hidden" name="choix" value="le_issueCert">
1311
					<input type="hidden" name="choix" value="le_issueCert">
1296
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1312
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1297
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1313
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1298
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
1314
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
1299
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="issue" value="<?= $l_send ?>"><br>
1315
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="issue" value="<?= $l_send ?>"><br>
1300
				</form>
1316
				</form>
1301
			<?php elseif ($step === 2): ?>
1317
			<?php elseif ($step === 2): ?>
1302
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1318
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1303
					<input type="hidden" name="choix" value="le_renewCert">
1319
					<input type="hidden" name="choix" value="le_renewCert">
1304
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1320
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1305
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1321
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1306
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
1322
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
1307
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
1323
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
1308
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
1324
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
1309
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="cancel" value="<?= $l_cancel ?>"><br>
1325
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="cancel" value="<?= $l_cancel ?>"><br>
1310
				</form>
1326
				</form>
1311
			<?php elseif ($step === 3): ?>
1327
			<?php elseif ($step === 3): ?>
1312
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1328
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1313
					<input type="hidden" name="choix" value="le_renewCert">
1329
					<input type="hidden" name="choix" value="le_renewCert">
1314
					<?= $l_le_status ?> <?= $l_enabled ?><br>
1330
					<?= $l_le_status ?> <?= $l_enabled ?><br>
1315
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1331
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1316
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
1332
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
1317
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
1333
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
1318
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
1334
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
1319
						<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_renew ?>"><br>
1335
						<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_renew ?>"><br>
1320
					<?php else: ?>
1336
					<?php else: ?>
1321
						<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck_force" value="<?= $l_renew_force ?>"><br>
1337
						<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck_force" value="<?= $l_renew_force ?>"><br>
1322
					<?php endif; ?>
1338
					<?php endif; ?>
1323
				</form>
1339
				</form>
1324
			<?php endif; ?>
1340
			<?php endif; ?>
1325
			<?php if (isset($cmdResponse)): ?>
1341
			<?php if (isset($cmdResponse)): ?>
1326
				<p><?= $cmdResponse ?></p>
1342
				<p><?= $cmdResponse ?></p>
1327
			<?php endif; ?>
1343
			<?php endif; ?>
1328
		</div>
1344
		</div>
1329
	</div>
1345
	</div>
1330
</div>
1346
</div>
1331
</body>
1347
</body>
1332
</html>
1348
</html>
1333
 
1349