Subversion Repositories ALCASAR

Rev

Rev 2971 | Rev 2979 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 richard 1
<?php
2304 tom.houday 2
# $Id: network.php 2972 2021-07-14 22:39:09Z rexy $
3
 
2956 rexy 4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
318 richard 5
 
861 richard 6
/********************
2316 tom.houday 7
*  READ CONF FILES  *
861 richard 8
*********************/
2316 tom.houday 9
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
10
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
11
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
2558 rexy 12
define('DNS_LOCAL_FILE', '/etc/hosts');
2304 tom.houday 13
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
2956 rexy 14
define('TEMP_FILE', '/tmp/alcasar.conf.temp');
15
 
2316 tom.houday 16
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
17
 
18
// Files reading test
19
foreach ($conf_files as $file) {
20
	if (!file_exists($file)) {
21
		exit("Requested file $file isn't present");
22
	}
23
	if (!is_readable($file)) {
24
		exit("Can't read the file $file");
25
	}
841 richard 26
}
2316 tom.houday 27
 
28
// Read ALCASAR CONF_FILE
29
$file_conf = fopen(CONF_FILE, 'r');
30
if (!$file_conf) {
31
	exit('Error opening the file '.CONF_FILE);
32
}
33
while (!feof($file_conf)) {
34
	$buffer = fgets($file_conf, 4096);
35
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 36
		$tmp = explode('=', $buffer, 2);
2316 tom.houday 37
		$conf[trim($tmp[0])] = trim($tmp[1]);
38
	}
39
}
40
fclose($file_conf);
41
 
42
// Choice of language
318 richard 43
$Language = 'en';
2316 tom.houday 44
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
45
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
46
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
47
}
2853 rexy 48
if ($Language === 'fr') {
318 richard 49
	$l_network_title	= "Configuration réseau";
50
	$l_internet_legend	= "INTERNET";
1733 richard 51
	$l_ip_mask		= "Masque";
318 richard 52
	$l_ip_router		= "Passerelle";
736 franck 53
	$l_ip_public		= "Adresse IP publique";
2316 tom.houday 54
	$l_ip_dns1		= "DNS n°1";
55
	$l_ip_dns2		= "DNS n°2";
861 richard 56
	$l_dhcp_title		= "Service DHCP";
862 richard 57
	$l_dhcp_state		= "Mode actuel";
1484 richard 58
	$l_DHCP_on		= "actif";
59
	$l_DHCP_off		= "inactif";
2304 tom.houday 60
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
2717 tom.houday 61
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
841 richard 62
	$l_mac_address		= "Adresse MAC";
63
	$l_ip_address		= "Adresse IP";
1959 richard 64
	$l_host_name		= "Nom d'hôte";
65
	$l_del			= "Supprimer de la liste";
841 richard 66
	$l_add_to_list		= "Ajouter";
1733 richard 67
	$l_apply		= "Appliquer les changements";
2717 tom.houday 68
	$l_local_dns		= "Résolution local de nom (DNS)";
1733 richard 69
	$l_import_cert		= "Import de certificat";
70
	$l_private_key		= "Clé privée (.key) :";
2813 rexy 71
	$l_certificate		= "Certificat (.crt ou .cer) :";
72
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
73
	$l_default_cert		= "Revenir au certificat d'origine :";
1740 richard 74
	$l_import		= "Importer";
1743 clement.si 75
	$l_current_certificate  = "Certificat actuel";
76
	$l_validated		= "Validé par :";
2316 tom.houday 77
	$l_empty		= "Vide";
2326 tom.houday 78
	$l_yes			= "Oui";
79
	$l_no			= "Non";
2736 rexy 80
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
2326 tom.houday 81
	$l_cert_expiration	= "Date d'expiration :";
2380 tom.houday 82
	$l_cert_commonname	= "Nom commun :";
83
	$l_cert_organization	= "Organisation :";
2813 rexy 84
	$l_upload_certificate	= "Importer un certificat officiel";
85
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
2326 tom.houday 86
	$l_le_status		= "Status :";
87
	$l_disabled		= "Inactif";
88
	$l_pending_validation	= "En attente de validation";
89
	$l_enabled		= "Actif";
90
	$l_le_email		= "Email :";
91
	$l_le_domain_name	= "Nom de domaine :";
92
	$l_send			= "Envoyer";
93
	$l_le_ask_on		= "Demandé le :";
94
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
95
	$l_le_challenge		= "Challenge :";
96
	$l_recheck		= "Revérifier";
97
	$l_cancel		= "Annuler";
98
	$l_le_api		= "API :";
99
	$l_le_next_renewal	= "Prochain renouvellement :";
100
	$l_renew		= "Renouveller";
101
	$l_renew_force		= "Renouveller (forcer)";
2813 rexy 102
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
2956 rexy 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
 
2853 rexy 111
} else if ($Language === 'es') {
112
	$l_network_title	= "Configuración de Red";
113
	$l_internet_legend	= "INTERNET";
114
	$l_ip_mask		= "Máscara";
115
	$l_ip_router		= "Puerta de enlace";
116
	$l_ip_public		= "IP Pública";
117
	$l_ip_dns1		= "DNS n°1";
118
	$l_ip_dns2		= "DNS n°2";
119
	$l_dhcp_title		= "Servicio DHCP";
120
	$l_dhcp_state		= "Modo actual";
121
	$l_DHCP_on		= "activado";
122
	$l_DHCP_off		= "desactivado";
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";
124
	$l_static_dhcp_title	= "Reserva de direcciones IP estáticas (DHCP)";
125
	$l_mac_address		= "Dirección MAC";
126
	$l_ip_address		= "Dirección IP";
127
	$l_host_name		= "Nombre de Host";
128
	$l_del			= "Borrar de la lista";
129
	$l_add_to_list		= "Agregar";
130
	$l_apply		= "Aplicar cambios";
131
	$l_local_dns		= "Resolución de Nombres Local (DNS)";
132
	$l_import_cert		= "Importar Certificado";
133
	$l_private_key		= "Clave Privada (.key) :";
134
	$l_certificate		= "Certificado (.crt) :";
135
	$l_server_chain		= "Cadena completa (de ser necesario: .crt) :";
136
	$l_default_cert		= "Volverl al certificado por defecto";
137
	$l_import		= "Importar";
138
	$l_current_certificate  = "Certificado en uso";
139
	$l_validated		= "Validado por :";
140
	$l_empty		= "Vacío";
141
	$l_yes			= "Si";
142
	$l_no			= "No";
143
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
144
	$l_cert_expiration	= "Fecha de vencimiento:";
145
	$l_cert_commonname	= "Common name:";
146
	$l_cert_organization	= "Organización:";
147
	$l_upload_certificate	= "Importar un certificado";
148
	$l_le_integration	= "Integración con Let's Encrypt";
149
	$l_le_status		= "Estado:";
150
	$l_disabled		= "Desactivado";
151
	$l_pending_validation	= "Validación pendiente";
152
	$l_enabled		= "Activado";
153
	$l_le_email		= "Email:";
154
	$l_le_domain_name	= "Nombre de dominio:";
155
	$l_send			= "Enviar";
156
	$l_le_ask_on		= "Preguntar el:";
157
	$l_le_dns_entry_txt	= "Entrada DNS TXT:";
158
	$l_le_challenge		= "Desafío:";
159
	$l_recheck		= "Verificar";
160
	$l_cancel		= "Cancelar";
161
	$l_le_api		= "API:";
162
	$l_le_next_renewal	= "Siguiente renovación:";
163
	$l_renew		= "Renovar";
164
	$l_renew_force		= "Renovar (forzado)";
165
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
2971 rexy 166
    $l_gw_weight	= "Peso";
167
    $l_error		= "Error";
168
    $l_error_bad_ip	= "Esta no es una dirección IP válida";
2972 rexy 169
    $l_error_bad_ip_CIDR	= "Esta no es una dirección CIDR válida";
2971 rexy 170
    $l_error_bad_ip_port	= "Esto no es una dirección IP + puerto válidos";
171
    $l_error_weight	= "Esto no es un peso válido";
172
    $l_change_successful	= "Cambio completado con éxito";
2853 rexy 173
} else {
318 richard 174
	$l_network_title	= "Network configuration";
175
	$l_internet_legend	= "INTERNET";
1733 richard 176
	$l_ip_mask		= "Mask";
841 richard 177
	$l_ip_router		= "Gateway";
318 richard 178
	$l_ip_public		= "Public IP address";
2316 tom.houday 179
	$l_ip_dns1		= "DNS n°1";
180
	$l_ip_dns2		= "DNS n°2";
861 richard 181
	$l_dhcp_title		= "DHCP service";
862 richard 182
	$l_dhcp_state		= "Current mode";
1484 richard 183
	$l_DHCP_on		= "enabled";
184
	$l_DHCP_off		= "disabled";
2304 tom.houday 185
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
2717 tom.houday 186
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
2708 tom.houday 187
	$l_mac_address		= "MAC address";
188
	$l_ip_address		= "IP address";
1959 richard 189
	$l_host_name		= "Host name";
190
	$l_del			= "Delete from list";
841 richard 191
	$l_add_to_list		= "Add";
1733 richard 192
	$l_apply		= "Apply changes";
2717 tom.houday 193
	$l_local_dns		= "Local name resolution (DNS";
1733 richard 194
	$l_import_cert		= "Certificate import";
195
	$l_private_key		= "Private key (.key) :";
2813 rexy 196
	$l_certificate		= "Certificate (.crt or .cer) :";
197
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
198
	$l_default_cert		= "Back to default certificate :";
1740 richard 199
	$l_import		= "Import";
1743 clement.si 200
	$l_current_certificate  = "Current certificate";
201
	$l_validated		= "Validated by :";
2316 tom.houday 202
	$l_empty		= "Empty";
2326 tom.houday 203
	$l_yes			= "Yes";
204
	$l_no			= "No";
2736 rexy 205
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
2326 tom.houday 206
	$l_cert_expiration	= "Expiration date:";
207
	$l_cert_commonname	= "Common name:";
208
	$l_cert_organization	= "Organization:";
2813 rexy 209
	$l_upload_certificate	= "Import an officlal certificate";
210
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
2326 tom.houday 211
	$l_le_status		= "Status:";
212
	$l_disabled		= "Disabled";
213
	$l_pending_validation	= "Pending validation";
214
	$l_enabled		= "Enabled";
215
	$l_le_email		= "Email:";
216
	$l_le_domain_name	= "Domain name:";
217
	$l_send			= "Send";
218
	$l_le_ask_on		= "Ask on:";
219
	$l_le_dns_entry_txt	= "DNS TXT entry:";
220
	$l_le_challenge		= "Challenge:";
221
	$l_recheck		= "Recheck";
222
	$l_cancel		= "Cancel";
223
	$l_le_api		= "API:";
224
	$l_le_next_renewal	= "Next renewal:";
225
	$l_renew		= "Renew";
226
	$l_renew_force		= "Renew (force)";
2813 rexy 227
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
2956 rexy 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";
318 richard 235
}
2316 tom.houday 236
 
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])$/';
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]))$/';
2956 rexy 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]))$/';
2380 tom.houday 240
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
241
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
2956 rexy 242
$reg_weight  = '/^[0-9]*$/';
243
$ext_conf_error = false;
2316 tom.houday 244
 
245
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
246
switch ($choix) {
247
	case 'DHCP_On':
248
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
2708 tom.houday 249
		header('Location: '.$_SERVER['PHP_SELF']);
250
		exit();
2316 tom.houday 251
	case 'DHCP_Off':
252
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
2708 tom.houday 253
		header('Location: '.$_SERVER['PHP_SELF']);
254
		exit();
2316 tom.houday 255
	case 'new_mac':
2380 tom.houday 256
		$new_mac_addr = trim($_POST['add_mac']);
257
		$new_ip_addr  = trim($_POST['add_ip']);
258
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
2316 tom.houday 259
			$tab = file(ETHERS_FILE);
260
			if ($tab) { // the file isn't empty
261
				$insert = true;
262
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
263
					$field = explode(' ', $line);
264
					$mac_addr = trim($field[0]);
265
					$ip_addr  = trim($field[1]);
266
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
267
						$insert = false;
268
						break;
841 richard 269
					}
2316 tom.houday 270
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
271
						$insert = false;
272
						break;
841 richard 273
					}
274
				}
2316 tom.houday 275
				if ($insert) {
276
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
277
					$pointeur = fopen(ETHERS_FILE, 'a');
278
					fwrite($pointeur, $line);
279
					fclose($pointeur);
280
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
281
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
282
					fwrite($pointeur, $line);
283
					fclose($pointeur);
284
					exec('sudo /usr/bin/systemctl reload chilli');
1959 richard 285
				}
841 richard 286
			}
1959 richard 287
		}
2708 tom.houday 288
		header('Location: '.$_SERVER['PHP_SELF']);
289
		exit();
2316 tom.houday 290
	case 'del_mac':
291
		foreach ($_POST as $key => $value) {
292
			if ($value == 'on') {
293
				$ether_file = ETHERS_FILE;
294
				$ether_file_info = ETHERS_INFO_FILE;
2559 rexy 295
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
296
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
2316 tom.houday 297
				exec('sudo /usr/bin/systemctl reload chilli');
841 richard 298
			}
299
		}
2708 tom.houday 300
		header('Location: '.$_SERVER['PHP_SELF']);
301
		exit();
2316 tom.houday 302
	case 'new_host':
2380 tom.houday 303
		$add_host = trim($_POST['add_host']);
304
		$add_ip   = trim($_POST['add_ip']);
305
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
2316 tom.houday 306
			$tab = file(DNS_LOCAL_FILE);
307
			if ($tab) { // the file isn't empty
308
				$insert = true;
2559 rexy 309
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
310
					if (preg_match('/^\d+/', $line)) {
311
						$field = preg_split("/\s+/",$line);
312
						$ip_addr = $field[0];
313
						$host_name = trim($field[1]);
314
						if (strcasecmp($add_host, $host_name) === 0) {
315
							$insert = false;
316
							break;
317
						}
841 richard 318
					}
2559 rexy 319
				}
2316 tom.houday 320
				if ($insert) {
2688 lucas.echa 321
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
1959 richard 322
				}
841 richard 323
			}
2380 tom.houday 324
		}
2708 tom.houday 325
		header('Location: '.$_SERVER['PHP_SELF']);
326
		exit();
2316 tom.houday 327
	case 'del_host':
328
		foreach ($_POST as $key => $value) {
329
			if ($value == 'on') {
2559 rexy 330
				$del_host = explode ("|", $key);
331
				$del_ip = str_replace("_",".",$del_host[0]);
332
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
2316 tom.houday 333
			}
841 richard 334
		}
2708 tom.houday 335
		header('Location: '.$_SERVER['PHP_SELF']);
336
		exit();
2316 tom.houday 337
 
2813 rexy 338
	case 'set_default_cert':
2316 tom.houday 339
		exec('sudo alcasar-importcert.sh -d');
340
		break;
2813 rexy 341
	case 'set_last_LE_cert':
342
		exec('sudo alcasar-letsencrypt.sh --install-cert');
343
		break;
2316 tom.houday 344
	case 'import_cert':	// Import certificate
2479 tom.houday 345
		$maxsize = 100000;
2316 tom.houday 346
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
347
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
2479 tom.houday 348
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
2316 tom.houday 349
					$dest = '/tmp/';
2380 tom.houday 350
					$scpath = '';
2813 rexy 351
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
352
						$scpath = $dest.'server-chain.pem';
2316 tom.houday 353
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
354
					}
2380 tom.houday 355
					$keypath = $dest.'alcasar.key';
356
					$crtpath = $dest.'alcasar.crt';
2316 tom.houday 357
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
358
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
359
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
2688 lucas.echa 360
					if (file_exists($crtpath)) unlink($crtpath);
361
					if (file_exists($keypath)) unlink($keypath);
2610 tom.houday 362
					if (file_exists($scpath))  unlink($scpath);
2316 tom.houday 363
				}
1959 richard 364
			}
365
		}
2316 tom.houday 366
		break;
2324 tom.houday 367
	case 'https_login':	// Set HTTPS login status
368
		if ($_POST['https_login'] === 'on') {
369
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
370
		} else {
371
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
372
		}
373
		header('Location: '.$_SERVER['PHP_SELF']);
374
		exit();
318 richard 375
}
376
 
2316 tom.houday 377
// Network changes
378
if ($choix === 'network_change') {
2956 rexy 379
    exec('sudo /usr/local/bin/alcasar-network.sh --save');
380
	$modification_network = false;
381
	$modification_dns = false;
382
	$modification_proxy = false;
383
	$ext_conf_error_list = [];
384
	copy(CONF_FILE, TEMP_FILE);
1733 richard 385
 
2956 rexy 386
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1'])) {
387
	    if (!preg_match($reg_ip, $_POST['dns1'])) {
388
            $ext_conf_error = true;
389
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns1.': '.$l_error_bad_ip;
390
        }
391
		file_put_contents(TEMP_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(TEMP_FILE)));
392
		$modification_dns = true;
318 richard 393
	}
2956 rexy 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
        }
399
		file_put_contents(TEMP_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(TEMP_FILE)));
400
		$modification_dns = true;
318 richard 401
	}
2956 rexy 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
        }
407
        file_put_contents(TEMP_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(TEMP_FILE)));
408
        $modification_network = true;
409
    }
410
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP'])) {
411
	    if (!preg_match($reg_ip_cidr, $_POST['ip_public'])) {
412
            $ext_conf_error = true;
413
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' WAN: '.$l_error_bad_ip_CIDR;
414
        }
415
		file_put_contents(TEMP_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(TEMP_FILE)));
416
		$modification_network = true;
2316 tom.houday 417
	}
2956 rexy 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
            }
2316 tom.houday 486
 
2956 rexy 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
    }
2316 tom.houday 536
 
2956 rexy 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);
555
 
2316 tom.houday 556
	// Read CONF_FILE updated
557
	$file_conf = fopen(CONF_FILE, 'r');
558
	if (!$file_conf) {
559
		exit('Error opening the file '.CONF_FILE);
560
	}
561
	while (!feof($file_conf)) {
562
		$buffer = fgets($file_conf, 4096);
563
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 564
			$tmp = explode('=', $buffer, 2);
2316 tom.houday 565
			$conf[trim($tmp[0])] = trim($tmp[1]);
566
		}
567
	}
568
	fclose($file_conf);
318 richard 569
}
2316 tom.houday 570
 
571
// Let's Encrypt actions
572
if ($choix === 'le_issueCert') {
573
	// TODO: check ndd & mail format
574
	$email      = $_POST['email'];
575
	$domainName = $_POST['domainname'];
576
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
577
	$cmdResponse = implode("<br>\n", $output);
1822 raphael.pi 578
}
2316 tom.houday 579
if ($choix === 'le_renewCert') {
580
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
581
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
318 richard 582
 
2316 tom.houday 583
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
1822 raphael.pi 584
 
2316 tom.houday 585
		$cmdResponse = implode("<br>\n", $output);
586
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
587
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
588
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
589
	}
1822 raphael.pi 590
}
591
 
2316 tom.houday 592
// Read Let's Encrypt configuration file
593
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
594
if (!$file_conf_LE) {
595
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
2299 tom.houday 596
}
2316 tom.houday 597
while (!feof($file_conf_LE)) {
598
	$buffer = fgets($file_conf_LE, 4096);
2299 tom.houday 599
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 600
		$tmp = explode('=', $buffer, 2);
2316 tom.houday 601
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
1822 raphael.pi 602
	}
603
}
2316 tom.houday 604
fclose($file_conf_LE);
605
 
606
// Fonction de test de connectivité internet
607
function internetTest() {
608
	$host = 'www.google.fr'; # Google Test
609
	$port = '80';
610
 
611
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
612
		return false;
613
	} else {
614
		fclose($sock);
615
		return true;
616
	}
617
}
618
 
619
$internet_connected = InternetTest();
620
if ($internet_connected) {
2404 tom.houday 621
	$ch = curl_init('https://api.ipify.org/');
622
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
623
	$internet_publicIP = curl_exec($ch);
624
	curl_close($ch);
2316 tom.houday 625
} else {
626
	$internet_publicIP = '-.-.-.-';
627
}
628
 
2956 rexy 629
// Network interfaces, will be use later for multiple LAN interfaces
630
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['INTIF']];
2316 tom.houday 631
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
632
 
2956 rexy 633
//retreive gateway(s) parameters
634
$gateways = [
2316 tom.houday 635
	(object) [
2956 rexy 636
		'gateway'   => $conf['GW'],
637
        'weight'    => $conf['PUBLIC_WEIGHT']
2316 tom.houday 638
	]
639
];
2956 rexy 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
2316 tom.houday 656
$internalNetworks = [
657
	(object) [
658
		'interface' => $conf['INTIF'],
659
		'ip'        => $conf['PRIVATE_IP']
660
	]
661
];
662
 
1740 richard 663
?>
2813 rexy 664
<!DOCTYPE HTML>
2316 tom.houday 665
<html>
318 richard 666
<head>
2316 tom.houday 667
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
668
	<title><?= $l_network_title ?></title>
2817 rexy 669
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
2316 tom.houday 670
	<script src="/js/jquery.min.js"></script>
671
	<script src="/js/jquery.connections.js"></script>
672
	<script type="text/javascript">
673
	function MAC_Control(formulaire){
674
		// MAC control (upper case and '-' separator)
675
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
676
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
677
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
678
			return true;
679
		} else {
680
			alert('Invalid MAC address');
681
			return false;
682
		}
1578 richard 683
	}
2316 tom.houday 684
	</script>
685
	<style>
2813 rexy 686
		.network-configurator {
687
			width: 100%;
688
		}
689
		.network-configurator > * {
690
			display: inline-block;
691
			vertical-align: top;
692
			text-align: center;
693
		}
694
		.network-configurator > .internet, .network-configurator > .alcasar {
695
			width: 20%;
696
		}
697
		.network-configurator > .externals, .network-configurator > .internals {
698
			width: 30%;
699
		}
700
		.network-configurator .actions {
2956 rexy 701
            position: absolute;
2813 rexy 702
			background-color: #ddd;
703
			padding: 0 2px;
704
		}
705
		.network-configurator .actions a {
706
			text-decoration: none;
707
		}
708
		.network-configurator .actions a:hover {
709
			font-weight: bold;
710
		}
2956 rexy 711
		.network-configurator .actions-externals {
712
			right: 0;
713
			border-radius: 5px;
714
            position: relative;
715
            text-decoration: none;
2813 rexy 716
		}
717
		.network-configurator > .alcasar .actions-internals {
718
			bottom: 0;
719
			right: 0;
720
			border-radius: 5px 0;
721
		}
722
		.network-configurator .actions-network {
723
			right: 0;
2956 rexy 724
			border-radius: 5px;
725
            position: relative;
726
            text-decoration: none;
2813 rexy 727
		}
728
		.network-configurator .network-box {
729
			display: inline-block;
730
			min-height: 100px;
731
			margin: 5px;
732
			padding: 3px;
733
			text-align: left;
734
			background-color: #f7f3ef;
735
			position: relative;
736
			border-radius: 5px;
737
			border: 2px solid grey;
738
		}
739
		.network-configurator .network-connector {
740
			display: inline-block;
741
			position: absolute;
742
			top: 50%;
743
			margin-top: -5px;
744
			margin-left: -5px;
745
			width: 10px;
746
			height: 10px;
747
			border-radius: 5px;
748
			background-color: black;
749
		}
750
		.network-configurator .network-connector[data-connector-direction="left"] {
2956 rexy 751
			border-radius: 5px 0 0 5px;
2813 rexy 752
		}
753
		.network-configurator .network-connector[data-connector-direction="right"] {
2956 rexy 754
			border-radius: 0 5px 5px 0;
2813 rexy 755
		}
756
		.network-configurator div[data-network-type] {
757
			position: relative;
758
		}
2316 tom.houday 759
	</style>
760
	<script>
761
	$(document).ready(function () {
762
 
2956 rexy 763
        setTimeout(function(){$("#change_success").fadeOut('normal');}, 10000);
2316 tom.houday 764
 
2956 rexy 765
	    //Will be used later for multiple LAN interfaces
766
		let interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
767
		const wireStyles = { available: { border: '5px double green' } };
768
 
769
		// Add gateway
770
		$('.network-configurator').on('click', '.add-external-network', function (event) {
2316 tom.houday 771
			event.preventDefault();
2956 rexy 772
			ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
773
			$('.network-configurator .externals .network-box #ext_gateways').append(' \
774
			            <div id="ip_routeur_' + ifaces_count + '" data-info_type="gateway" data-number="'+ ifaces_count +'">\
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="" /> \
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"/> \
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> ');
778
            ifaces_count++;
779
            document.getElementById("gw_count").setAttribute('value', ifaces_count);
780
            updateGatewayView();
781
            $('div.network-connector[data-connector-network]').connections('update');
2316 tom.houday 782
		});
783
 
784
		// Add internal network
2956 rexy 785
		$('.network-configurator').on('click', '.add-internal-network', function (event) {
2316 tom.houday 786
			event.preventDefault();
787
			$('.network-configurator .internals').append(' \
788
					<div data-network-type="internal"> \
789
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
790
						<div class="network-box"> \
791
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
792
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><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> \
794
						</div> \
795
					</div>');
796
			addWire($('div[data-network-type="internal"]:last'));
797
		});
798
 
2956 rexy 799
		// Remove gateway
800
		$('.network-box').on('click', '.remove-network', function (event) {
2316 tom.houday 801
			event.preventDefault();
2956 rexy 802
			$(this).parent().parent().fadeOut(200, function() {
2316 tom.houday 803
 
2956 rexy 804
			    $(this).remove();
805
				//update network numbers
806
                $('div[data-info_type="gateway"]').each(function (index, value) {
807
                    updateGatewayNumbers($(this), index);
808
                });
809
                ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
810
                document.getElementById("gw_count").setAttribute('value', (ifaces_count - 1));
811
                updateGatewayView();
812
 
813
                $('div.network-connector[data-connector-network]').connections('update');
2316 tom.houday 814
			});
815
		});
816
 
2956 rexy 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
2316 tom.houday 860
		const addWire = function (network) {
861
			const networkType = network.data('networkType');
862
			if (networkType === 'external') {
2956 rexy 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 });
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 });
865
            } else if (networkType === 'internal') {
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 });
2316 tom.houday 867
			}
2325 tom.houday 868
		};
2316 tom.houday 869
 
2956 rexy 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
2325 tom.houday 911
		window.addEventListener('resize', function () {
912
			$('div.network-connector[data-connector-network]').connections('update');
913
		});
914
 
2956 rexy 915
		// Add wires to existing networks at page first render
2316 tom.houday 916
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
917
			addWire($(this));
2325 tom.houday 918
		});
2316 tom.houday 919
	});
920
	</script>
318 richard 921
</head>
922
<body>
2813 rexy 923
<div class="panel">
924
	<div class="panel-header"><?= $l_network_title ?></div>
925
	<div class="panel-row">
926
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
927
			<div class="network-configurator">
928
				<div class="internet">
929
					<div data-network-type="internet">
930
						<div class="network-box">
931
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
932
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
933
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
934
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
935
						</div>
936
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
937
					</div>
2956 rexy 938
				</div><div id="externals_id" class="externals">
2813 rexy 939
						<div data-network-type="external">
940
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
2316 tom.houday 941
							<div class="network-box">
2956 rexy 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 ?>" />
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>
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' : '' ?>/>
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>
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>
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>
2813 rexy 975
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
2316 tom.houday 976
						</div>
2813 rexy 977
				</div><div class="alcasar">
978
					<div data-network-type="alcasar">
979
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
980
						<div class="network-box">
981
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
982
							<!-- <div class="actions actions-internals">
983
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
984
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
985
							</div> -->
986
						</div>
987
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
988
					</div>
2956 rexy 989
				</div><div id="internals_id" class="internals" data-count="1">
2813 rexy 990
					<?php foreach ($internalNetworks as $network): ?>
991
						<div data-network-type="internal">
992
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
2316 tom.houday 993
							<div class="network-box">
2813 rexy 994
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
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>
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>
2316 tom.houday 997
							</div>
998
						</div>
2813 rexy 999
					<? endforeach; ?>
2316 tom.houday 1000
				</div>
2813 rexy 1001
			</div>
2956 rexy 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
            }?>
2813 rexy 1014
			<hr>
1015
			<div style="text-align: center; margin: 5px">
1016
				<input type="hidden" name="choix" value="network_change">
1017
				<input type="submit" value="<?= $l_apply ?>">
1018
			</div>
1019
		</form>
2316 tom.houday 1020
	</div>
2813 rexy 1021
</div>
1022
<br>
1023
<div class="panel">
1024
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
1025
</div>
2304 tom.houday 1026
<table width="100%" cellspacing="0" cellpadding="5" border="1">
2708 tom.houday 1027
	<tr><td width="50%" align="center" valign="middle">
1028
		<form action="network.php" method="POST">
2316 tom.houday 1029
		<table cellspacing="2" cellpadding="3" border="1">
2708 tom.houday 1030
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
2316 tom.houday 1031
		<?php
2708 tom.houday 1032
		// Read the "ether" file
1033
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
1034
		$detail = explode(' ', $output[1]);
1035
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
1036
		unset($output); unset($detail);
2316 tom.houday 1037
		$line_exist = false;
2708 tom.houday 1038
		$tab = file(ETHERS_INFO_FILE);
1039
		if ($tab) { // le fichier n'est pas vide
2316 tom.houday 1040
			foreach ($tab as $line) {
2708 tom.houday 1041
				$fields = explode(' ', $line);
1042
				$mac_addr = $fields[0];
1043
				$ip_addr  = $fields[1];
2713 tom.houday 1044
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
2956 rexy 1045
 
2708 tom.houday 1046
				echo '<tr>';
1047
				echo "<td>$mac_addr</td>";
1048
				echo "<td>$ip_addr</td>";
1049
				if ($mac_addr !== $intif_mac_addr) {
1050
					echo '<td>'.ltrim($info, '#').'</td>';
1051
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
1052
					$line_exist=True;
1053
				} else {
1054
					echo '<td>ALCASAR</td>';
1055
					echo '<td></td>';
2316 tom.houday 1056
				}
2708 tom.houday 1057
				echo '</tr>';
1959 richard 1058
			}
1059
		}
2316 tom.houday 1060
		?>
1061
		</table>
1062
		<?php if ($line_exist): ?>
2708 tom.houday 1063
			<input type="hidden" name="choix" value="del_mac">
2316 tom.houday 1064
			<input type="submit" value="<?= $l_apply ?>">
1065
		<?php endif; ?>
1066
		</form>
2708 tom.houday 1067
	</td><td width="50%" valign="middle" align="center">
1068
		<form name="new_mac" action="network.php" method="POST">
1069
			<table cellspacing="2" cellpadding="3" border="1">
1070
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><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>
1072
				<tr><td><input type="text" name="add_mac" size="17"></td>
1073
				<td><input type="text" name="add_ip" size="10"></td>
1074
				<td><input type="text" name="info" size="10"></td>
1075
				<td>
1076
					<input type="hidden" name="choix" value="new_mac">
1077
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
1078
				</td>
1079
			</tr></table>
2316 tom.houday 1080
		</form>
2708 tom.houday 1081
	</td></tr>
1959 richard 1082
</table>
2316 tom.houday 1083
<br>
2813 rexy 1084
<div class="panel">
1085
	<div class="panel-header"><?= $l_local_dns ?></div>
1086
</div>
2709 tom.houday 1087
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1088
	<tr>
1089
		<td width="50%" align="center">
1090
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1091
			<table cellspacing="2" cellpadding="3" border="1">
1092
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
1093
			<?php
1094
			// Read the "dns_local" file
1095
			$line_exist = false;
1096
			$tab = file(DNS_LOCAL_FILE);
1097
			if ($tab) { // not empty
1098
				foreach ($tab as $line) {
1099
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
1100
						$line_exist = true;
1101
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
1102
						$ip_addr   = $field[0];
1103
						$host_name = $field[1];
1104
						echo "<tr><td>$ip_addr</td>";
1105
						echo "<td>$host_name</td>";
1106
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
1107
							echo "<td>";}
1108
						else {
1109
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
1110
						}
1111
						echo "</td></tr>";
1112
					}
1113
				}
1114
			}
1115
			if (!$line_exist) {
1116
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
1117
			}
1118
			?>
1119
			</table>
1120
			<?php if ($line_exist): ?>
1121
				<input type="hidden" name="choix" value="del_host">
1122
				<input type="submit" value="<?= $l_apply ?>">
1123
			<?php endif; ?>
1124
			</form>
1125
		</td>
1126
		<td width="50%" valign="middle" align="center">
1127
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1128
			<table cellspacing="2" cellpadding="3" border="1">
1129
			<tr>
1130
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
1131
			</tr>
1132
			<tr>
1133
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
1134
			</tr>
1135
			<tr>
1136
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
1137
				<td><input type="text" name="add_host" size="17"></td>
1138
				<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
1139
			</tr>
1140
			</table>
1141
			</form>
1142
		</td>
1143
	</tr>
1144
</table>
1145
<br>
2813 rexy 1146
<div class="panel">
1147
	<div class="panel-header"><?= $l_ssl_title ?></div>
1148
	<div class="panel-row">
2609 rexy 1149
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1150
		<input type="hidden" name="choix" value="https_login">
1151
		<select name="https_login">
1152
			<option value="on"<?=  (($conf['HTTPS_LOGIN'] === 'on')  ? ' selected' : '') ?>><?= $l_yes ?></option>
1153
			<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
1154
		</select>
1155
		<input type="submit" value="<?= $l_apply ?>"><br>
1156
		</form>
2813 rexy 1157
	</div>
1158
</div>
2609 rexy 1159
<br>
2813 rexy 1160
<div class="panel">
1161
	<div class="panel-header"><?= $l_import_cert ?></div>
1162
	<div class="panel-row">
1163
		<div class="panel-cell">
2297 tom.houday 1164
			<?php
1165
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
1166
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
1167
			$domain               = $certificateInfos['subject']['CN'];
1168
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
1169
			$CAdomain             = $certificateInfos['issuer']['CN'];
1170
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
1171
			?>
1172
			<h3><?= $l_current_certificate ?></h3>
2813 rexy 1173
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
1174
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
1175
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
1176
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
1177
		</div>
1178
		<div class="panel-cell">
1179
			<?
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 ?
1181
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1182
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
1183
				echo "\t\t\t\t<input type=\"submit\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
1184
				echo "\t\t\t</form>\n";}
1185
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
1186
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
1187
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
1188
				echo "\t\t\t\t<input type=\"submit\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
1189
				echo "\t\t\t</form>\n";}
1190
			?>
1191
		</div>
1192
	</div>
1193
	<div class="panel-row">
1194
		<div class="panel-cell">
2326 tom.houday 1195
			<h3><?= $l_upload_certificate ?></h3>
2324 tom.houday 1196
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
1197
				<?= $l_private_key;?> <input type="file" name="key"><br>
1198
				<?= $l_certificate;?> <input type="file" name="crt"><br>
1199
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
1200
				<input type="hidden" name="choix" value="import_cert">
1201
				<input type="submit" value="<?= $l_import ?>">
2297 tom.houday 1202
			</form>
2813 rexy 1203
		</div>
1204
		<div class="panel-cell">
2304 tom.houday 1205
			<?php
1206
			// Get step
1207
			if (empty($LE_conf['domainRequest'])) {
1208
				$step = 1;
1209
			} else if (!empty($LE_conf['challenge'])) {
1210
				$step = 2;
1211
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
1212
				$step = 3;
1213
			} else {
1214
				$step = 1;
1215
			}
1216
			?>
2326 tom.houday 1217
			<h3><?= $l_le_integration ?></h3>
2324 tom.houday 1218
			<?php if ($step === 1): ?>
2316 tom.houday 1219
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1220
					<input type="hidden" name="choix" value="le_issueCert">
2326 tom.houday 1221
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1222
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1223
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
1224
					<input type="submit" name="issue" value="<?= $l_send ?>"><br>
2304 tom.houday 1225
				</form>
1226
			<?php elseif ($step === 2): ?>
2316 tom.houday 1227
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1228
					<input type="hidden" name="choix" value="le_renewCert">
2326 tom.houday 1229
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1230
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1231
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
1232
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
1233
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
1234
					<input type="submit" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" name="cancel" value="<?= $l_cancel ?>"><br>
2304 tom.houday 1235
				</form>
1236
			<?php elseif ($step === 3): ?>
2316 tom.houday 1237
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1238
					<input type="hidden" name="choix" value="le_renewCert">
2326 tom.houday 1239
					<?= $l_le_status ?> <?= $l_enabled ?><br>
1240
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1241
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
1242
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
2304 tom.houday 1243
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
2326 tom.houday 1244
						<input type="submit" name="recheck" value="<?= $l_renew ?>"><br>
2304 tom.houday 1245
					<?php else: ?>
2326 tom.houday 1246
						<input type="submit" name="recheck_force" value="<?= $l_renew_force ?>"><br>
2304 tom.houday 1247
					<?php endif; ?>
1248
				</form>
1249
			<?php endif; ?>
1250
			<?php if (isset($cmdResponse)): ?>
1251
				<p><?= $cmdResponse ?></p>
1252
			<?php endif; ?>
2813 rexy 1253
		</div>
1254
	</div>
1255
</div>
318 richard 1256
</body>
1257
</html>