Subversion Repositories ALCASAR

Rev

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

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