Subversion Repositories ALCASAR

Rev

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

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