Subversion Repositories ALCASAR

Rev

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

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