Subversion Repositories ALCASAR

Rev

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