Subversion Repositories ALCASAR

Rev

Rev 2809 | Rev 2817 | 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 2813 2020-04-26 21:26:32Z rexy $
3
 
2316 tom.houday 4
// written by steweb57, Rexy & Tom HOUDAYER
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');
2316 tom.houday 14
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
15
 
16
// Files reading test
17
foreach ($conf_files as $file) {
18
	if (!file_exists($file)) {
19
		exit("Requested file $file isn't present");
20
	}
21
	if (!is_readable($file)) {
22
		exit("Can't read the file $file");
23
	}
841 richard 24
}
2316 tom.houday 25
 
26
// Read ALCASAR CONF_FILE
27
$file_conf = fopen(CONF_FILE, 'r');
28
if (!$file_conf) {
29
	exit('Error opening the file '.CONF_FILE);
30
}
31
while (!feof($file_conf)) {
32
	$buffer = fgets($file_conf, 4096);
33
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 34
		$tmp = explode('=', $buffer, 2);
2316 tom.houday 35
		$conf[trim($tmp[0])] = trim($tmp[1]);
36
	}
37
}
38
fclose($file_conf);
39
 
40
// Choice of language
318 richard 41
$Language = 'en';
2316 tom.houday 42
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
43
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
44
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
45
}
46
if ($Language === 'fr') {	// French
318 richard 47
	$l_network_title	= "Configuration réseau";
48
	$l_internet_legend	= "INTERNET";
1733 richard 49
	$l_ip_mask		= "Masque";
318 richard 50
	$l_ip_router		= "Passerelle";
736 franck 51
	$l_ip_public		= "Adresse IP publique";
2316 tom.houday 52
	$l_ip_dns1		= "DNS n°1";
53
	$l_ip_dns2		= "DNS n°2";
861 richard 54
	$l_dhcp_title		= "Service DHCP";
862 richard 55
	$l_dhcp_state		= "Mode actuel";
1484 richard 56
	$l_DHCP_on		= "actif";
57
	$l_DHCP_off		= "inactif";
2304 tom.houday 58
	$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 59
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
841 richard 60
	$l_mac_address		= "Adresse MAC";
61
	$l_ip_address		= "Adresse IP";
1959 richard 62
	$l_host_name		= "Nom d'hôte";
63
	$l_del			= "Supprimer de la liste";
841 richard 64
	$l_add_to_list		= "Ajouter";
1733 richard 65
	$l_apply		= "Appliquer les changements";
2717 tom.houday 66
	$l_local_dns		= "Résolution local de nom (DNS)";
1733 richard 67
	$l_import_cert		= "Import de certificat";
68
	$l_private_key		= "Clé privée (.key) :";
2813 rexy 69
	$l_certificate		= "Certificat (.crt ou .cer) :";
70
	$l_server_chain		= "Chaîne de certification (.crt, .cer ou .pem) :";
71
	$l_default_cert		= "Revenir au certificat d'origine :";
1740 richard 72
	$l_import		= "Importer";
1743 clement.si 73
	$l_current_certificate  = "Certificat actuel";
74
	$l_validated		= "Validé par :";
2316 tom.houday 75
	$l_empty		= "Vide";
2326 tom.houday 76
	$l_yes			= "Oui";
77
	$l_no			= "Non";
2736 rexy 78
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
2326 tom.houday 79
	$l_cert_expiration	= "Date d'expiration :";
2380 tom.houday 80
	$l_cert_commonname	= "Nom commun :";
81
	$l_cert_organization	= "Organisation :";
2813 rexy 82
	$l_upload_certificate	= "Importer un certificat officiel";
83
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
2326 tom.houday 84
	$l_le_status		= "Status :";
85
	$l_disabled		= "Inactif";
86
	$l_pending_validation	= "En attente de validation";
87
	$l_enabled		= "Actif";
88
	$l_le_email		= "Email :";
89
	$l_le_domain_name	= "Nom de domaine :";
90
	$l_send			= "Envoyer";
91
	$l_le_ask_on		= "Demandé le :";
92
	$l_le_dns_entry_txt	= "Entrée DNS TXT :";
93
	$l_le_challenge		= "Challenge :";
94
	$l_recheck		= "Revérifier";
95
	$l_cancel		= "Annuler";
96
	$l_le_api		= "API :";
97
	$l_le_next_renewal	= "Prochain renouvellement :";
98
	$l_renew		= "Renouveller";
99
	$l_renew_force		= "Renouveller (forcer)";
2813 rexy 100
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
2316 tom.houday 101
} else {			// English
318 richard 102
	$l_network_title	= "Network configuration";
103
	$l_internet_legend	= "INTERNET";
1733 richard 104
	$l_ip_mask		= "Mask";
841 richard 105
	$l_ip_router		= "Gateway";
318 richard 106
	$l_ip_public		= "Public IP address";
2316 tom.houday 107
	$l_ip_dns1		= "DNS n°1";
108
	$l_ip_dns2		= "DNS n°2";
861 richard 109
	$l_dhcp_title		= "DHCP service";
862 richard 110
	$l_dhcp_state		= "Current mode";
1484 richard 111
	$l_DHCP_on		= "enabled";
112
	$l_DHCP_off		= "disabled";
2304 tom.houday 113
	$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 114
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
2708 tom.houday 115
	$l_mac_address		= "MAC address";
116
	$l_ip_address		= "IP address";
117
	$l_port			= "Port";
1959 richard 118
	$l_host_name		= "Host name";
119
	$l_del			= "Delete from list";
841 richard 120
	$l_add_to_list		= "Add";
1733 richard 121
	$l_apply		= "Apply changes";
2717 tom.houday 122
	$l_local_dns		= "Local name resolution (DNS";
1733 richard 123
	$l_import_cert		= "Certificate import";
124
	$l_private_key		= "Private key (.key) :";
2813 rexy 125
	$l_certificate		= "Certificate (.crt or .cer) :";
126
	$l_server_chain		= "Server-chain (.crt, .cer or .pem) :";
127
	$l_default_cert		= "Back to default certificate :";
1740 richard 128
	$l_import		= "Import";
1743 clement.si 129
	$l_current_certificate  = "Current certificate";
130
	$l_validated		= "Validated by :";
2316 tom.houday 131
	$l_empty		= "Empty";
2326 tom.houday 132
	$l_yes			= "Yes";
133
	$l_no			= "No";
2736 rexy 134
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
2326 tom.houday 135
	$l_cert_expiration	= "Expiration date:";
136
	$l_cert_commonname	= "Common name:";
137
	$l_cert_organization	= "Organization:";
2813 rexy 138
	$l_upload_certificate	= "Import an officlal certificate";
139
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
2326 tom.houday 140
	$l_le_status		= "Status:";
141
	$l_disabled		= "Disabled";
142
	$l_pending_validation	= "Pending validation";
143
	$l_enabled		= "Enabled";
144
	$l_le_email		= "Email:";
145
	$l_le_domain_name	= "Domain name:";
146
	$l_send			= "Send";
147
	$l_le_ask_on		= "Ask on:";
148
	$l_le_dns_entry_txt	= "DNS TXT entry:";
149
	$l_le_challenge		= "Challenge:";
150
	$l_recheck		= "Recheck";
151
	$l_cancel		= "Cancel";
152
	$l_le_api		= "API:";
153
	$l_le_next_renewal	= "Next renewal:";
154
	$l_renew		= "Renew";
155
	$l_renew_force		= "Renew (force)";
2813 rexy 156
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
318 richard 157
}
2316 tom.houday 158
 
159
$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])$/';
160
$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]))$/';
2380 tom.houday 161
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
162
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
2316 tom.houday 163
 
164
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
165
 
166
switch ($choix) {
167
	case 'DHCP_On':
168
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
2708 tom.houday 169
		header('Location: '.$_SERVER['PHP_SELF']);
170
		exit();
2316 tom.houday 171
	case 'DHCP_Off':
172
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
2708 tom.houday 173
		header('Location: '.$_SERVER['PHP_SELF']);
174
		exit();
2316 tom.houday 175
 
176
	case 'new_mac':
2380 tom.houday 177
		$new_mac_addr = trim($_POST['add_mac']);
178
		$new_ip_addr  = trim($_POST['add_ip']);
179
		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 180
			$tab = file(ETHERS_FILE);
181
			if ($tab) { // the file isn't empty
182
				$insert = true;
183
				foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
184
					$field = explode(' ', $line);
185
					$mac_addr = trim($field[0]);
186
					$ip_addr  = trim($field[1]);
187
					if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
188
						$insert = false;
189
						break;
841 richard 190
					}
2316 tom.houday 191
					if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
192
						$insert = false;
193
						break;
841 richard 194
					}
195
				}
2316 tom.houday 196
				if ($insert) {
197
					$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
198
					$pointeur = fopen(ETHERS_FILE, 'a');
199
					fwrite($pointeur, $line);
200
					fclose($pointeur);
201
					$pointeur = fopen(ETHERS_INFO_FILE, 'a');
202
					$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
203
					fwrite($pointeur, $line);
204
					fclose($pointeur);
205
					exec('sudo /usr/bin/systemctl reload chilli');
1959 richard 206
				}
841 richard 207
			}
1959 richard 208
		}
2708 tom.houday 209
		header('Location: '.$_SERVER['PHP_SELF']);
210
		exit();
2316 tom.houday 211
	case 'del_mac':
212
		foreach ($_POST as $key => $value) {
213
			if ($value == 'on') {
214
				$ether_file = ETHERS_FILE;
215
				$ether_file_info = ETHERS_INFO_FILE;
2559 rexy 216
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
217
				exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
2316 tom.houday 218
				exec('sudo /usr/bin/systemctl reload chilli');
841 richard 219
			}
220
		}
2708 tom.houday 221
		header('Location: '.$_SERVER['PHP_SELF']);
222
		exit();
2316 tom.houday 223
 
224
	case 'new_host':
2380 tom.houday 225
		$add_host = trim($_POST['add_host']);
226
		$add_ip   = trim($_POST['add_ip']);
227
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
2316 tom.houday 228
			$tab = file(DNS_LOCAL_FILE);
229
			if ($tab) { // the file isn't empty
230
				$insert = true;
2559 rexy 231
				foreach ($tab as $line) { // verify that host or IP address doesn't exist
232
					if (preg_match('/^\d+/', $line)) {
233
						$field = preg_split("/\s+/",$line);
234
						$ip_addr = $field[0];
235
						$host_name = trim($field[1]);
236
						if (strcasecmp($add_host, $host_name) === 0) {
237
							$insert = false;
238
							break;
239
						}
841 richard 240
					}
2559 rexy 241
				}
2316 tom.houday 242
				if ($insert) {
2688 lucas.echa 243
					exec("sudo /usr/local/bin/alcasar-dns-local.sh --add $add_ip $add_host");
1959 richard 244
				}
841 richard 245
			}
2380 tom.houday 246
		}
2708 tom.houday 247
		header('Location: '.$_SERVER['PHP_SELF']);
248
		exit();
2316 tom.houday 249
	case 'del_host':
250
		foreach ($_POST as $key => $value) {
251
			if ($value == 'on') {
2559 rexy 252
				$del_host = explode ("|", $key);
253
				$del_ip = str_replace("_",".",$del_host[0]);
254
				exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
2316 tom.houday 255
			}
841 richard 256
		}
2708 tom.houday 257
		header('Location: '.$_SERVER['PHP_SELF']);
258
		exit();
2316 tom.houday 259
 
2813 rexy 260
	case 'set_default_cert':
2316 tom.houday 261
		exec('sudo alcasar-importcert.sh -d');
262
		break;
2813 rexy 263
	case 'set_last_LE_cert':
264
		exec('sudo alcasar-letsencrypt.sh --install-cert');
265
		break;
2316 tom.houday 266
	case 'import_cert':	// Import certificate
2479 tom.houday 267
		$maxsize = 100000;
2316 tom.houday 268
		if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
269
			if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
2479 tom.houday 270
				if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
2316 tom.houday 271
					$dest = '/tmp/';
2380 tom.houday 272
					$scpath = '';
2813 rexy 273
					if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
274
						$scpath = $dest.'server-chain.pem';
2316 tom.houday 275
						move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
276
					}
2380 tom.houday 277
					$keypath = $dest.'alcasar.key';
278
					$crtpath = $dest.'alcasar.crt';
2316 tom.houday 279
					move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
280
					move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
281
					exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
2688 lucas.echa 282
					if (file_exists($crtpath)) unlink($crtpath);
283
					if (file_exists($keypath)) unlink($keypath);
2610 tom.houday 284
					if (file_exists($scpath))  unlink($scpath);
2316 tom.houday 285
				}
1959 richard 286
			}
287
		}
2316 tom.houday 288
		break;
2324 tom.houday 289
 
290
	case 'https_login':	// Set HTTPS login status
291
		if ($_POST['https_login'] === 'on') {
292
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
293
		} else {
294
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
295
		}
296
		header('Location: '.$_SERVER['PHP_SELF']);
297
		exit();
318 richard 298
}
299
 
2316 tom.houday 300
// Network changes
301
if ($choix === 'network_change') {
302
	$network_modification = false;
1733 richard 303
 
2316 tom.houday 304
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1']) && preg_match($reg_ip, $_POST['dns1'])) {
305
		file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(CONF_FILE)));
306
		$network_modification = true;
318 richard 307
	}
2316 tom.houday 308
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2']) && preg_match($reg_ip, $_POST['dns2'])) {
309
		file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(CONF_FILE)));
310
		$network_modification = true;
318 richard 311
	}
2316 tom.houday 312
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP']) && preg_match($reg_ip_cidr, $_POST['ip_public'])) {
313
		file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(CONF_FILE)));
314
		$network_modification = true;
315
	}
316
	if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW']) && preg_match($reg_ip, $_POST['ip_gw'])) {
317
		file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(CONF_FILE)));
318
		$network_modification = true;
319
	}
320
	if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP']) && preg_match($reg_ip_cidr, $_POST['ip_private'])) {
321
		file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(CONF_FILE)));
322
		$network_modification = true;
323
	}
324
 
325
	if ($network_modification) {
326
		exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
327
	}
328
 
329
	// Read CONF_FILE updated
330
	$file_conf = fopen(CONF_FILE, 'r');
331
	if (!$file_conf) {
332
		exit('Error opening the file '.CONF_FILE);
333
	}
334
	while (!feof($file_conf)) {
335
		$buffer = fgets($file_conf, 4096);
336
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 337
			$tmp = explode('=', $buffer, 2);
2316 tom.houday 338
			$conf[trim($tmp[0])] = trim($tmp[1]);
339
		}
340
	}
341
	fclose($file_conf);
318 richard 342
}
2316 tom.houday 343
 
344
// Let's Encrypt actions
345
if ($choix === 'le_issueCert') {
346
	// TODO: check ndd & mail format
347
	$email      = $_POST['email'];
348
	$domainName = $_POST['domainname'];
349
	exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
350
	$cmdResponse = implode("<br>\n", $output);
1822 raphael.pi 351
}
2316 tom.houday 352
if ($choix === 'le_renewCert') {
353
	if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
354
		$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
318 richard 355
 
2316 tom.houday 356
		exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
1822 raphael.pi 357
 
2316 tom.houday 358
		$cmdResponse = implode("<br>\n", $output);
359
	} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
360
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
361
		file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
362
	}
1822 raphael.pi 363
}
364
 
2316 tom.houday 365
// Read Let's Encrypt configuration file
366
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
367
if (!$file_conf_LE) {
368
	exit('Error opening the file '.LETS_ENCRYPT_FILE);
2299 tom.houday 369
}
2316 tom.houday 370
while (!feof($file_conf_LE)) {
371
	$buffer = fgets($file_conf_LE, 4096);
2299 tom.houday 372
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 373
		$tmp = explode('=', $buffer, 2);
2316 tom.houday 374
		$LE_conf[trim($tmp[0])] = trim($tmp[1]);
1822 raphael.pi 375
	}
376
}
2316 tom.houday 377
fclose($file_conf_LE);
378
 
379
// Fonction de test de connectivité internet
380
function internetTest() {
381
	$host = 'www.google.fr'; # Google Test
382
	$port = '80';
383
 
384
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
385
		return false;
386
	} else {
387
		fclose($sock);
388
		return true;
389
	}
390
}
391
 
392
$internet_connected = InternetTest();
393
if ($internet_connected) {
2404 tom.houday 394
	$ch = curl_init('https://api.ipify.org/');
395
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
396
	$internet_publicIP = curl_exec($ch);
397
	curl_close($ch);
2316 tom.houday 398
} else {
399
	$internet_publicIP = '-.-.-.-';
400
}
401
 
402
// Network interfaces
403
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
404
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
405
 
406
// TODO: Pending the next version
407
$externalNetworks = [
408
	(object) [
409
		'interface' => $conf['EXTIF'],
410
		'ip'        => $conf['PUBLIC_IP'],
411
		'gateway'   => $conf['GW']
412
	]
413
];
414
$internalNetworks = [
415
	(object) [
416
		'interface' => $conf['INTIF'],
417
		'ip'        => $conf['PRIVATE_IP']
418
	]
419
];
420
 
1740 richard 421
?>
2813 rexy 422
<!DOCTYPE HTML>
2316 tom.houday 423
<html>
318 richard 424
<head>
2316 tom.houday 425
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
426
	<title><?= $l_network_title ?></title>
427
	<link rel="stylesheet" href="/css/style.css" type="text/css">
428
	<script src="/js/jquery.min.js"></script>
429
	<script src="/js/jquery.connections.js"></script>
430
	<script type="text/javascript">
431
	function MAC_Control(formulaire){
432
		// MAC control (upper case and '-' separator)
433
		var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
434
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
435
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
436
			return true;
437
		} else {
438
			alert('Invalid MAC address');
439
			return false;
440
		}
1578 richard 441
	}
2316 tom.houday 442
	</script>
443
	<style>
2813 rexy 444
		.network-configurator {
445
			width: 100%;
446
		}
447
		.network-configurator > * {
448
			display: inline-block;
449
			vertical-align: top;
450
			text-align: center;
451
		}
452
		.network-configurator > .internet, .network-configurator > .alcasar {
453
			width: 20%;
454
		}
455
		.network-configurator > .externals, .network-configurator > .internals {
456
			width: 30%;
457
		}
458
		.network-configurator .actions {
459
			position: absolute;
460
			background-color: #ddd;
461
			padding: 0 2px;
462
		}
463
		.network-configurator .actions a {
464
			text-decoration: none;
465
		}
466
		.network-configurator .actions a:hover {
467
			font-weight: bold;
468
		}
469
		.network-configurator > .alcasar .actions-externals {
470
			bottom: 0;
471
			left: 0;
472
			border-radius: 0 5px;
473
		}
474
		.network-configurator > .alcasar .actions-internals {
475
			bottom: 0;
476
			right: 0;
477
			border-radius: 5px 0;
478
		}
479
		.network-configurator .actions-network {
480
			top: 0;
481
			right: 0;
482
			border-radius: 0 5px;
483
		}
484
		.network-configurator .network-box {
485
			display: inline-block;
486
			min-height: 100px;
487
			margin: 5px;
488
			padding: 3px;
489
			text-align: left;
490
			background-color: #f7f3ef;
491
			position: relative;
492
			border-radius: 5px;
493
			border: 2px solid grey;
494
		}
495
		.network-configurator .network-connector {
496
			display: inline-block;
497
			position: absolute;
498
			top: 50%;
499
			margin-top: -5px;
500
			margin-left: -5px;
501
			width: 10px;
502
			height: 10px;
503
			border-radius: 5px;
504
			background-color: black;
505
		}
506
		.network-configurator .network-connector[data-connector-direction="left"] {
507
			border-radius: 5px 0px 0px 5px;
508
		}
509
		.network-configurator .network-connector[data-connector-direction="right"] {
510
			border-radius: 0px 5px 5px 0px;
511
		}
512
		.network-configurator div[data-network-type] {
513
			position: relative;
514
		}
2316 tom.houday 515
	</style>
516
	<script>
517
	$(document).ready(function () {
518
		const interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
519
 
520
		const wireStyles = {
521
			available: { border: '5px double green' }
2325 tom.houday 522
		};
2316 tom.houday 523
 
524
		// Add external network
525
		$('.network-configurator .add-external-network').click(function (event) {
526
			event.preventDefault();
527
			let options = '';
528
			if (interfacesAvailable.length === 0) {
529
				options = '<option value=""></option>';
530
			} else {
531
				for (let i = 0; i < interfacesAvailable.length; i++) {
532
					options += '<option value="' + interfacesAvailable[i] + '">' + interfacesAvailable[i] + '</option>';
533
				}
534
			}
535
			$('.network-configurator .externals').append(' \
536
				<div data-network-type="external"> \
537
					<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div> \
538
					<div class="network-box"> \
539
						<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
540
						<label for="ext_interface_X"><?= 'Interface' ?></label> <select name="interface" id="ext_interface_X">' + options + '</select><br> \
541
						<label for="ext_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_X" value="" /><br> \
542
						<label for="ext_gateway_X"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_X" value="" /> \
543
					</div> \
544
					<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div> \
545
				</div>');
546
			addWire($('div[data-network-type="external"]:last'));
547
		});
548
 
549
		// Add internal network
550
		$('.network-configurator .add-internal-network').click(function (event) {
551
			event.preventDefault();
552
			$('.network-configurator .internals').append(' \
553
					<div data-network-type="internal"> \
554
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
555
						<div class="network-box"> \
556
							<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
557
							<label for="int_interface_X"><?= 'Interface' ?></label> <select name="interface" id="int_interface_X" disabled><option value=""></option></select><br> \
558
							<label for="int_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_X" value="" /><br> \
559
						</div> \
560
					</div>');
561
			addWire($('div[data-network-type="internal"]:last'));
562
		});
563
 
564
		// Remove network
565
		$('.network-configurator').on('click', '.remove-network', function (event) {
566
			event.preventDefault();
567
			$(this).parent().parent().parent().fadeOut(200, function() {
568
				const networkType = $(this).data('networkType');
569
				$(this).remove();
570
 
571
				// Update wires
572
				if (networkType === 'external') {
573
					$('div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]').connections('update');
574
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]').connections('update');
575
				} else if (networkType === 'internal') {
576
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]').connections('update');
577
				}
578
			});
579
		});
580
 
581
		const addWire = function (network) {
582
			const networkType = network.data('networkType');
583
			if (networkType === 'external') {
584
				$().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' });
585
				$().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' });
586
			} else if (networkType === 'internal') {
587
				$().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' });
588
			}
2325 tom.houday 589
		};
2316 tom.houday 590
 
2325 tom.houday 591
		window.addEventListener('resize', function () {
592
			$('div.network-connector[data-connector-network]').connections('update');
593
		});
594
 
2316 tom.houday 595
		// Add wires to existing networks
596
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
597
			addWire($(this));
2325 tom.houday 598
		});
2316 tom.houday 599
	});
600
	</script>
318 richard 601
</head>
602
<body>
2813 rexy 603
<div class="panel">
604
	<div class="panel-header"><?= $l_network_title ?></div>
605
	<div class="panel-row">
606
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
607
			<div class="network-configurator">
608
				<div class="internet">
609
					<div data-network-type="internet">
610
						<div class="network-box">
611
							<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
612
							<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
613
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
614
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
615
						</div>
616
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
617
					</div>
618
				</div><div class="externals">
619
					<?php foreach ($externalNetworks as $index => $network): ?>
620
						<div data-network-type="external">
621
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
2316 tom.houday 622
							<div class="network-box">
2813 rexy 623
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
624
								<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>
625
								<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>
626
								<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 ?>" />
2316 tom.houday 627
							</div>
2813 rexy 628
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
2316 tom.houday 629
						</div>
2813 rexy 630
					<? endforeach; ?>
631
				</div><div class="alcasar">
632
					<div data-network-type="alcasar">
633
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
634
						<div class="network-box">
635
							<!-- <div class="actions actions-externals">
636
								<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
637
							</div> -->
638
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
639
							<!-- <div class="actions actions-internals">
640
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
641
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
642
							</div> -->
643
						</div>
644
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
645
					</div>
646
				</div><div class="internals">
647
					<?php foreach ($internalNetworks as $network): ?>
648
						<div data-network-type="internal">
649
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
2316 tom.houday 650
							<div class="network-box">
2813 rexy 651
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
652
								<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>
653
								<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 654
							</div>
655
						</div>
2813 rexy 656
					<? endforeach; ?>
2316 tom.houday 657
				</div>
2813 rexy 658
			</div>
659
			<hr>
660
			<div style="text-align: center; margin: 5px">
661
				<input type="hidden" name="choix" value="network_change">
662
				<input type="submit" value="<?= $l_apply ?>">
663
			</div>
664
		</form>
2316 tom.houday 665
	</div>
2813 rexy 666
</div>
667
<br>
668
<div class="panel">
669
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
670
</div>
2304 tom.houday 671
<table width="100%" cellspacing="0" cellpadding="5" border="1">
2708 tom.houday 672
	<tr><td width="50%" align="center" valign="middle">
673
		<form action="network.php" method="POST">
2316 tom.houday 674
		<table cellspacing="2" cellpadding="3" border="1">
2708 tom.houday 675
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
2316 tom.houday 676
		<?php
2708 tom.houday 677
		// Read the "ether" file
678
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
679
		$detail = explode(' ', $output[1]);
680
		$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5]));
681
		unset($output); unset($detail);
2316 tom.houday 682
		$line_exist = false;
2708 tom.houday 683
		$tab = file(ETHERS_INFO_FILE);
684
		if ($tab) { // le fichier n'est pas vide
2316 tom.houday 685
			foreach ($tab as $line) {
2708 tom.houday 686
				$fields = explode(' ', $line);
687
				$mac_addr = $fields[0];
688
				$ip_addr  = $fields[1];
2713 tom.houday 689
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
2708 tom.houday 690
 
691
				echo '<tr>';
692
				echo "<td>$mac_addr</td>";
693
				echo "<td>$ip_addr</td>";
694
				if ($mac_addr !== $intif_mac_addr) {
695
					echo '<td>'.ltrim($info, '#').'</td>';
696
					echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>";
697
					$line_exist=True;
698
				} else {
699
					echo '<td>ALCASAR</td>';
700
					echo '<td></td>';
2316 tom.houday 701
				}
2708 tom.houday 702
				echo '</tr>';
1959 richard 703
			}
704
		}
2316 tom.houday 705
		?>
706
		</table>
707
		<?php if ($line_exist): ?>
2708 tom.houday 708
			<input type="hidden" name="choix" value="del_mac">
2316 tom.houday 709
			<input type="submit" value="<?= $l_apply ?>">
710
		<?php endif; ?>
711
		</form>
2708 tom.houday 712
	</td><td width="50%" valign="middle" align="center">
713
		<form name="new_mac" action="network.php" method="POST">
714
			<table cellspacing="2" cellpadding="3" border="1">
715
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
716
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
717
				<tr><td><input type="text" name="add_mac" size="17"></td>
718
				<td><input type="text" name="add_ip" size="10"></td>
719
				<td><input type="text" name="info" size="10"></td>
720
				<td>
721
					<input type="hidden" name="choix" value="new_mac">
722
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
723
				</td>
724
			</tr></table>
2316 tom.houday 725
		</form>
2708 tom.houday 726
	</td></tr>
1959 richard 727
</table>
2316 tom.houday 728
<br>
2813 rexy 729
<div class="panel">
730
	<div class="panel-header"><?= $l_local_dns ?></div>
731
</div>
2709 tom.houday 732
<table width="100%" cellspacing="0" cellpadding="5" border="1">
733
	<tr>
734
		<td width="50%" align="center">
735
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
736
			<table cellspacing="2" cellpadding="3" border="1">
737
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
738
			<?php
739
			// Read the "dns_local" file
740
			$line_exist = false;
741
			$tab = file(DNS_LOCAL_FILE);
742
			if ($tab) { // not empty
743
				foreach ($tab as $line) {
744
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
745
						$line_exist = true;
746
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
747
						$ip_addr   = $field[0];
748
						$host_name = $field[1];
749
						echo "<tr><td>$ip_addr</td>";
750
						echo "<td>$host_name</td>";
751
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
752
							echo "<td>";}
753
						else {
754
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
755
						}
756
						echo "</td></tr>";
757
					}
758
				}
759
			}
760
			if (!$line_exist) {
761
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
762
			}
763
			?>
764
			</table>
765
			<?php if ($line_exist): ?>
766
				<input type="hidden" name="choix" value="del_host">
767
				<input type="submit" value="<?= $l_apply ?>">
768
			<?php endif; ?>
769
			</form>
770
		</td>
771
		<td width="50%" valign="middle" align="center">
772
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
773
			<table cellspacing="2" cellpadding="3" border="1">
774
			<tr>
775
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
776
			</tr>
777
			<tr>
778
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
779
			</tr>
780
			<tr>
781
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
782
				<td><input type="text" name="add_host" size="17"></td>
783
				<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
784
			</tr>
785
			</table>
786
			</form>
787
		</td>
788
	</tr>
789
</table>
790
<br>
2813 rexy 791
<div class="panel">
792
	<div class="panel-header"><?= $l_ssl_title ?></div>
793
	<div class="panel-row">
2609 rexy 794
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
795
		<input type="hidden" name="choix" value="https_login">
796
		<select name="https_login">
797
			<option value="on"<?=  (($conf['HTTPS_LOGIN'] === 'on')  ? ' selected' : '') ?>><?= $l_yes ?></option>
798
			<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
799
		</select>
800
		<input type="submit" value="<?= $l_apply ?>"><br>
801
		</form>
2813 rexy 802
	</div>
803
</div>
2609 rexy 804
<br>
2813 rexy 805
<div class="panel">
806
	<div class="panel-header"><?= $l_import_cert ?></div>
807
	<div class="panel-row">
808
		<div class="panel-cell">
2297 tom.houday 809
			<?php
810
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
811
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
812
			$domain               = $certificateInfos['subject']['CN'];
813
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
814
			$CAdomain             = $certificateInfos['issuer']['CN'];
815
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
816
			?>
817
			<h3><?= $l_current_certificate ?></h3>
2813 rexy 818
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
819
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
820
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
821
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
822
		</div>
823
		<div class="panel-cell">
824
			<?
825
			if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
826
				echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
827
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
828
				echo "\t\t\t\t<input type=\"submit\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
829
				echo "\t\t\t</form>\n";}
830
			if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
831
				echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
832
				echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
833
				echo "\t\t\t\t<input type=\"submit\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
834
				echo "\t\t\t</form>\n";}
835
			?>
836
		</div>
837
	</div>
838
	<div class="panel-row">
839
		<div class="panel-cell">
2326 tom.houday 840
			<h3><?= $l_upload_certificate ?></h3>
2324 tom.houday 841
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
842
				<?= $l_private_key;?> <input type="file" name="key"><br>
843
				<?= $l_certificate;?> <input type="file" name="crt"><br>
844
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
845
				<input type="hidden" name="choix" value="import_cert">
846
				<input type="submit" value="<?= $l_import ?>">
2297 tom.houday 847
			</form>
2813 rexy 848
		</div>
849
		<div class="panel-cell">
2304 tom.houday 850
			<?php
851
			// Get step
852
			if (empty($LE_conf['domainRequest'])) {
853
				$step = 1;
854
			} else if (!empty($LE_conf['challenge'])) {
855
				$step = 2;
856
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
857
				$step = 3;
858
			} else {
859
				$step = 1;
860
			}
861
			?>
2326 tom.houday 862
			<h3><?= $l_le_integration ?></h3>
2324 tom.houday 863
			<?php if ($step === 1): ?>
2316 tom.houday 864
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
865
					<input type="hidden" name="choix" value="le_issueCert">
2326 tom.houday 866
					<?= $l_le_status ?> <?= $l_disabled ?><br>
867
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
868
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
869
					<input type="submit" name="issue" value="<?= $l_send ?>"><br>
2304 tom.houday 870
				</form>
871
			<?php elseif ($step === 2): ?>
2316 tom.houday 872
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
873
					<input type="hidden" name="choix" value="le_renewCert">
2326 tom.houday 874
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
875
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
876
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
877
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
878
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
879
					<input type="submit" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" name="cancel" value="<?= $l_cancel ?>"><br>
2304 tom.houday 880
				</form>
881
			<?php elseif ($step === 3): ?>
2316 tom.houday 882
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
883
					<input type="hidden" name="choix" value="le_renewCert">
2326 tom.houday 884
					<?= $l_le_status ?> <?= $l_enabled ?><br>
885
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
886
					<?= $l_le_api ?>  <?= $LE_conf['dnsapi'] ?><br>
887
					<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
2304 tom.houday 888
					<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
2326 tom.houday 889
						<input type="submit" name="recheck" value="<?= $l_renew ?>"><br>
2304 tom.houday 890
					<?php else: ?>
2326 tom.houday 891
						<input type="submit" name="recheck_force" value="<?= $l_renew_force ?>"><br>
2304 tom.houday 892
					<?php endif; ?>
893
				</form>
894
			<?php endif; ?>
895
			<?php if (isset($cmdResponse)): ?>
896
				<p><?= $cmdResponse ?></p>
897
			<?php endif; ?>
2813 rexy 898
		</div>
899
	</div>
900
</div>
318 richard 901
</body>
902
</html>