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