318 |
richard |
1 |
<?php
|
2304 |
tom.houday |
2 |
# $Id: network.php 2613 2018-08-22 21:26:27Z 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";
|
|
|
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";
|
1959 |
richard |
66 |
$l_local_dns = "Résolution local de nom";
|
1733 |
richard |
67 |
$l_import_cert = "Import de certificat";
|
|
|
68 |
$l_private_key = "Clé privée (.key) :";
|
|
|
69 |
$l_certificate = "Certificat (.crt) :";
|
1740 |
richard |
70 |
$l_server_chain = "Chaîne de certification (si nécéssaire : .crt) :";
|
|
|
71 |
$l_default_cert = "Revenir au certificat d'origine";
|
|
|
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";
|
2609 |
rexy |
78 |
$l_ssl_title = "Chiffrer les flux réseau 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 :";
|
2326 |
tom.houday |
82 |
$l_upload_certificate = "Importer un certificat";
|
|
|
83 |
$l_le_integration = "Intégration Let's Encrypt";
|
|
|
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)";
|
2316 |
tom.houday |
100 |
} else { // English
|
318 |
richard |
101 |
$l_network_title = "Network configuration";
|
|
|
102 |
$l_internet_legend = "INTERNET";
|
1733 |
richard |
103 |
$l_ip_mask = "Mask";
|
841 |
richard |
104 |
$l_ip_router = "Gateway";
|
318 |
richard |
105 |
$l_ip_public = "Public IP address";
|
2316 |
tom.houday |
106 |
$l_ip_dns1 = "DNS n°1";
|
|
|
107 |
$l_ip_dns2 = "DNS n°2";
|
861 |
richard |
108 |
$l_dhcp_title = "DHCP service";
|
862 |
richard |
109 |
$l_dhcp_state = "Current mode";
|
1484 |
richard |
110 |
$l_DHCP_on = "enabled";
|
|
|
111 |
$l_DHCP_off = "disabled";
|
2304 |
tom.houday |
112 |
$l_DHCP_off_explain = "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
|
841 |
richard |
113 |
$l_static_dhcp_title = "Static IP addresses reservation";
|
|
|
114 |
$l_mac_address = "MAC Address";
|
|
|
115 |
$l_ip_address = "IP Address";
|
1959 |
richard |
116 |
$l_host_name = "Host name";
|
|
|
117 |
$l_del = "Delete from list";
|
841 |
richard |
118 |
$l_add_to_list = "Add";
|
1733 |
richard |
119 |
$l_apply = "Apply changes";
|
1959 |
richard |
120 |
$l_local_dns = "Local name resolution";
|
1733 |
richard |
121 |
$l_import_cert = "Certificate import";
|
|
|
122 |
$l_private_key = "Private key (.key) :";
|
|
|
123 |
$l_certificate = "Certificate (.crt) :";
|
1740 |
richard |
124 |
$l_server_chain = "Server-chain (if necessary : .crt) :";
|
1733 |
richard |
125 |
$l_default_cert = "Back to default certificate";
|
1740 |
richard |
126 |
$l_import = "Import";
|
1743 |
clement.si |
127 |
$l_current_certificate = "Current certificate";
|
|
|
128 |
$l_validated = "Validated by :";
|
2316 |
tom.houday |
129 |
$l_empty = "Empty";
|
2326 |
tom.houday |
130 |
$l_yes = "Yes";
|
|
|
131 |
$l_no = "No";
|
2613 |
tom.houday |
132 |
$l_ssl_title = "Cipher the network flows between users and ALCASAR";
|
2326 |
tom.houday |
133 |
$l_cert_expiration = "Expiration date:";
|
|
|
134 |
$l_cert_commonname = "Common name:";
|
|
|
135 |
$l_cert_organization = "Organization:";
|
|
|
136 |
$l_upload_certificate = "Importer un certificat";
|
|
|
137 |
$l_le_integration = "Let's Encrypt integration";
|
|
|
138 |
$l_le_status = "Status:";
|
|
|
139 |
$l_disabled = "Disabled";
|
|
|
140 |
$l_pending_validation = "Pending validation";
|
|
|
141 |
$l_enabled = "Enabled";
|
|
|
142 |
$l_le_email = "Email:";
|
|
|
143 |
$l_le_domain_name = "Domain name:";
|
|
|
144 |
$l_send = "Send";
|
|
|
145 |
$l_le_ask_on = "Ask on:";
|
|
|
146 |
$l_le_dns_entry_txt = "DNS TXT entry:";
|
|
|
147 |
$l_le_challenge = "Challenge:";
|
|
|
148 |
$l_recheck = "Recheck";
|
|
|
149 |
$l_cancel = "Cancel";
|
|
|
150 |
$l_le_api = "API:";
|
|
|
151 |
$l_le_next_renewal = "Next renewal:";
|
|
|
152 |
$l_renew = "Renew";
|
|
|
153 |
$l_renew_force = "Renew (force)";
|
318 |
richard |
154 |
}
|
2316 |
tom.houday |
155 |
|
|
|
156 |
$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])$/';
|
|
|
157 |
$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 |
158 |
$reg_mac = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
|
|
|
159 |
$reg_host = '/^[a-zA-Z0-9-_]+$/';
|
2316 |
tom.houday |
160 |
|
|
|
161 |
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
|
|
|
162 |
|
|
|
163 |
switch ($choix) {
|
|
|
164 |
case 'DHCP_On':
|
|
|
165 |
exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
|
|
|
166 |
break;
|
|
|
167 |
case 'DHCP_Off':
|
|
|
168 |
exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
|
|
|
169 |
break;
|
|
|
170 |
|
|
|
171 |
case 'new_mac':
|
2380 |
tom.houday |
172 |
$new_mac_addr = trim($_POST['add_mac']);
|
|
|
173 |
$new_ip_addr = trim($_POST['add_ip']);
|
|
|
174 |
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 |
175 |
$tab = file(ETHERS_FILE);
|
|
|
176 |
if ($tab) { // the file isn't empty
|
|
|
177 |
$insert = true;
|
|
|
178 |
foreach ($tab as $line) { // verify that MAC or IP address doesn't exist
|
|
|
179 |
$field = explode(' ', $line);
|
|
|
180 |
$mac_addr = trim($field[0]);
|
|
|
181 |
$ip_addr = trim($field[1]);
|
|
|
182 |
if (strcasecmp($new_mac_addr, $mac_addr) === 0) {
|
|
|
183 |
$insert = false;
|
|
|
184 |
break;
|
841 |
richard |
185 |
}
|
2316 |
tom.houday |
186 |
if (strcasecmp($new_ip_addr, $ip_addr) === 0) {
|
|
|
187 |
$insert = false;
|
|
|
188 |
break;
|
841 |
richard |
189 |
}
|
|
|
190 |
}
|
2316 |
tom.houday |
191 |
if ($insert) {
|
|
|
192 |
$line = $new_mac_addr . ' ' . $new_ip_addr . "\n";
|
|
|
193 |
$pointeur = fopen(ETHERS_FILE, 'a');
|
|
|
194 |
fwrite($pointeur, $line);
|
|
|
195 |
fclose($pointeur);
|
|
|
196 |
$pointeur = fopen(ETHERS_INFO_FILE, 'a');
|
|
|
197 |
$line = "$new_mac_addr $new_ip_addr #" . trim($_POST['info'],"\x00..\x20") . "\n";
|
|
|
198 |
fwrite($pointeur, $line);
|
|
|
199 |
fclose($pointeur);
|
|
|
200 |
exec('sudo /usr/bin/systemctl reload chilli');
|
1959 |
richard |
201 |
}
|
841 |
richard |
202 |
}
|
1959 |
richard |
203 |
}
|
2316 |
tom.houday |
204 |
break;
|
|
|
205 |
case 'del_mac':
|
|
|
206 |
foreach ($_POST as $key => $value) {
|
|
|
207 |
if ($value == 'on') {
|
|
|
208 |
$ether_file = ETHERS_FILE;
|
|
|
209 |
$ether_file_info = ETHERS_INFO_FILE;
|
2559 |
rexy |
210 |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file");
|
|
|
211 |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info");
|
2316 |
tom.houday |
212 |
exec('sudo /usr/bin/systemctl reload chilli');
|
841 |
richard |
213 |
}
|
|
|
214 |
}
|
2316 |
tom.houday |
215 |
break;
|
|
|
216 |
|
|
|
217 |
case 'new_host':
|
2380 |
tom.houday |
218 |
$add_host = trim($_POST['add_host']);
|
|
|
219 |
$add_ip = trim($_POST['add_ip']);
|
|
|
220 |
if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
|
2316 |
tom.houday |
221 |
$tab = file(DNS_LOCAL_FILE);
|
|
|
222 |
if ($tab) { // the file isn't empty
|
|
|
223 |
$insert = true;
|
2559 |
rexy |
224 |
foreach ($tab as $line) { // verify that host or IP address doesn't exist
|
|
|
225 |
if (preg_match('/^\d+/', $line)) {
|
|
|
226 |
$field = preg_split("/\s+/",$line);
|
|
|
227 |
$ip_addr = $field[0];
|
|
|
228 |
$host_name = trim($field[1]);
|
|
|
229 |
if (strcmp($add_ip, $ip_addr) === 0) {
|
|
|
230 |
$insert = false;
|
|
|
231 |
break;
|
|
|
232 |
}
|
|
|
233 |
if (strcasecmp($add_host, $host_name) === 0) {
|
|
|
234 |
$insert = false;
|
|
|
235 |
break;
|
|
|
236 |
}
|
841 |
richard |
237 |
}
|
2559 |
rexy |
238 |
}
|
2316 |
tom.houday |
239 |
if ($insert) {
|
2559 |
rexy |
240 |
exec("sudo /usr/local/bin/alcasar-dns-local.sh -add $add_ip $add_host");
|
1959 |
richard |
241 |
}
|
841 |
richard |
242 |
}
|
2380 |
tom.houday |
243 |
}
|
2316 |
tom.houday |
244 |
break;
|
|
|
245 |
case 'del_host':
|
|
|
246 |
foreach ($_POST as $key => $value) {
|
|
|
247 |
if ($value == 'on') {
|
2559 |
rexy |
248 |
$del_host = explode ("|", $key);
|
|
|
249 |
$del_ip = str_replace("_",".",$del_host[0]);
|
|
|
250 |
exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]");
|
2316 |
tom.houday |
251 |
}
|
841 |
richard |
252 |
}
|
2316 |
tom.houday |
253 |
break;
|
|
|
254 |
|
|
|
255 |
case 'default_cert': // Restore default certificate
|
|
|
256 |
exec('sudo alcasar-importcert.sh -d');
|
|
|
257 |
break;
|
|
|
258 |
|
|
|
259 |
case 'import_cert': // Import certificate
|
2479 |
tom.houday |
260 |
$maxsize = 100000;
|
2316 |
tom.houday |
261 |
if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
|
|
|
262 |
if ($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize) {
|
2479 |
tom.houday |
263 |
if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
|
2316 |
tom.houday |
264 |
$dest = '/tmp/';
|
2380 |
tom.houday |
265 |
$scpath = '';
|
2479 |
tom.houday |
266 |
if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer'))) {
|
2316 |
tom.houday |
267 |
$scpath = $dest.'server-chain.crt';
|
|
|
268 |
move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
|
|
|
269 |
}
|
2380 |
tom.houday |
270 |
$keypath = $dest.'alcasar.key';
|
|
|
271 |
$crtpath = $dest.'alcasar.crt';
|
2316 |
tom.houday |
272 |
move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
|
|
|
273 |
move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
|
|
|
274 |
exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
|
|
|
275 |
if (file_exists($crtpath)) unlink($crtpath);
|
|
|
276 |
if (file_exists($keypath)) unlink($keypath);
|
2610 |
tom.houday |
277 |
if (file_exists($scpath)) unlink($scpath);
|
2316 |
tom.houday |
278 |
}
|
1959 |
richard |
279 |
}
|
|
|
280 |
}
|
2316 |
tom.houday |
281 |
break;
|
2324 |
tom.houday |
282 |
|
|
|
283 |
case 'https_login': // Set HTTPS login status
|
|
|
284 |
if ($_POST['https_login'] === 'on') {
|
|
|
285 |
exec('sudo /usr/local/bin/alcasar-https.sh --on');
|
|
|
286 |
} else {
|
|
|
287 |
exec('sudo /usr/local/bin/alcasar-https.sh --off');
|
|
|
288 |
}
|
|
|
289 |
header('Location: '.$_SERVER['PHP_SELF']);
|
|
|
290 |
exit();
|
318 |
richard |
291 |
}
|
|
|
292 |
|
2316 |
tom.houday |
293 |
// Network changes
|
|
|
294 |
if ($choix === 'network_change') {
|
|
|
295 |
$network_modification = false;
|
1733 |
richard |
296 |
|
2316 |
tom.houday |
297 |
if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1']) && preg_match($reg_ip, $_POST['dns1'])) {
|
|
|
298 |
file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(CONF_FILE)));
|
|
|
299 |
$network_modification = true;
|
318 |
richard |
300 |
}
|
2316 |
tom.houday |
301 |
if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2']) && preg_match($reg_ip, $_POST['dns2'])) {
|
|
|
302 |
file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(CONF_FILE)));
|
|
|
303 |
$network_modification = true;
|
318 |
richard |
304 |
}
|
2316 |
tom.houday |
305 |
if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP']) && preg_match($reg_ip_cidr, $_POST['ip_public'])) {
|
|
|
306 |
file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(CONF_FILE)));
|
|
|
307 |
$network_modification = true;
|
|
|
308 |
}
|
|
|
309 |
if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW']) && preg_match($reg_ip, $_POST['ip_gw'])) {
|
|
|
310 |
file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(CONF_FILE)));
|
|
|
311 |
$network_modification = true;
|
|
|
312 |
}
|
|
|
313 |
if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP']) && preg_match($reg_ip_cidr, $_POST['ip_private'])) {
|
|
|
314 |
file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(CONF_FILE)));
|
|
|
315 |
$network_modification = true;
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
if ($network_modification) {
|
|
|
319 |
exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
// Read CONF_FILE updated
|
|
|
323 |
$file_conf = fopen(CONF_FILE, 'r');
|
|
|
324 |
if (!$file_conf) {
|
|
|
325 |
exit('Error opening the file '.CONF_FILE);
|
|
|
326 |
}
|
|
|
327 |
while (!feof($file_conf)) {
|
|
|
328 |
$buffer = fgets($file_conf, 4096);
|
|
|
329 |
if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
|
2450 |
tom.houday |
330 |
$tmp = explode('=', $buffer, 2);
|
2316 |
tom.houday |
331 |
$conf[trim($tmp[0])] = trim($tmp[1]);
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
fclose($file_conf);
|
318 |
richard |
335 |
}
|
2316 |
tom.houday |
336 |
|
|
|
337 |
// Let's Encrypt actions
|
|
|
338 |
if ($choix === 'le_issueCert') {
|
|
|
339 |
// TODO: check ndd & mail format
|
|
|
340 |
|
|
|
341 |
$email = $_POST['email'];
|
|
|
342 |
$domainName = $_POST['domainname'];
|
|
|
343 |
|
|
|
344 |
exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
|
1822 |
raphael.pi |
345 |
|
2316 |
tom.houday |
346 |
$cmdResponse = implode("<br>\n", $output);
|
1822 |
raphael.pi |
347 |
}
|
2316 |
tom.houday |
348 |
if ($choix === 'le_renewCert') {
|
|
|
349 |
if ((isset($_POST['recheck'])) && ((!empty($_POST['recheck'])) || (!empty($_POST['recheck_force'])))) {
|
|
|
350 |
$forceOpt = (!empty($_POST['recheck_force'])) ? ' --force' : '';
|
318 |
richard |
351 |
|
2316 |
tom.houday |
352 |
exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --renew' . $forceOpt, $output, $exitCode);
|
1822 |
raphael.pi |
353 |
|
2316 |
tom.houday |
354 |
$cmdResponse = implode("<br>\n", $output);
|
|
|
355 |
} else if ((isset($_POST['cancel'])) && (!empty($_POST['cancel']))) {
|
|
|
356 |
file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/challenge=.*/','challenge=', file_get_contents(LETS_ENCRYPT_FILE)));
|
|
|
357 |
file_put_contents(LETS_ENCRYPT_FILE, preg_replace('/domainRequest=.*/','domainRequest=', file_get_contents(LETS_ENCRYPT_FILE)));
|
|
|
358 |
}
|
1822 |
raphael.pi |
359 |
}
|
|
|
360 |
|
|
|
361 |
|
2316 |
tom.houday |
362 |
// Read Let's Encrypt configuration file
|
|
|
363 |
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
|
|
|
364 |
if (!$file_conf_LE) {
|
|
|
365 |
exit('Error opening the file '.LETS_ENCRYPT_FILE);
|
2299 |
tom.houday |
366 |
}
|
2316 |
tom.houday |
367 |
while (!feof($file_conf_LE)) {
|
|
|
368 |
$buffer = fgets($file_conf_LE, 4096);
|
2299 |
tom.houday |
369 |
if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
|
2450 |
tom.houday |
370 |
$tmp = explode('=', $buffer, 2);
|
2316 |
tom.houday |
371 |
$LE_conf[trim($tmp[0])] = trim($tmp[1]);
|
1822 |
raphael.pi |
372 |
}
|
|
|
373 |
}
|
2316 |
tom.houday |
374 |
fclose($file_conf_LE);
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
// Fonction de test de connectivité internet
|
|
|
378 |
function internetTest() {
|
|
|
379 |
$host = 'www.google.fr'; # Google Test
|
|
|
380 |
$port = '80';
|
|
|
381 |
|
|
|
382 |
if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
|
|
|
383 |
return false;
|
|
|
384 |
} else {
|
|
|
385 |
fclose($sock);
|
|
|
386 |
return true;
|
|
|
387 |
}
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
$internet_connected = InternetTest();
|
|
|
391 |
if ($internet_connected) {
|
2404 |
tom.houday |
392 |
$ch = curl_init('https://api.ipify.org/');
|
|
|
393 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
394 |
$internet_publicIP = curl_exec($ch);
|
|
|
395 |
curl_close($ch);
|
2316 |
tom.houday |
396 |
} else {
|
|
|
397 |
$internet_publicIP = '-.-.-.-';
|
|
|
398 |
}
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
// Network interfaces
|
|
|
402 |
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
|
|
|
403 |
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
|
|
|
404 |
|
|
|
405 |
// TODO: Pending the next version
|
|
|
406 |
$externalNetworks = [
|
|
|
407 |
(object) [
|
|
|
408 |
'interface' => $conf['EXTIF'],
|
|
|
409 |
'ip' => $conf['PUBLIC_IP'],
|
|
|
410 |
'gateway' => $conf['GW']
|
|
|
411 |
]
|
|
|
412 |
];
|
|
|
413 |
$internalNetworks = [
|
|
|
414 |
(object) [
|
|
|
415 |
'interface' => $conf['INTIF'],
|
|
|
416 |
'ip' => $conf['PRIVATE_IP']
|
|
|
417 |
]
|
|
|
418 |
];
|
|
|
419 |
|
1740 |
richard |
420 |
?>
|
|
|
421 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
2316 |
tom.houday |
422 |
<html>
|
318 |
richard |
423 |
<head>
|
2316 |
tom.houday |
424 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
425 |
<title><?= $l_network_title ?></title>
|
|
|
426 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
|
|
427 |
<link rel="stylesheet" href="/css/acc.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>
|
|
|
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 |
}
|
|
|
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>
|
2316 |
tom.houday |
603 |
<div class="panel">
|
|
|
604 |
<div class="panel-header"><?= $l_network_title ?></div>
|
|
|
605 |
<div class="panel-body">
|
|
|
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>
|
|
|
622 |
<div class="network-box">
|
|
|
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 ?>" />
|
|
|
627 |
</div>
|
|
|
628 |
<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
|
|
|
629 |
</div>
|
|
|
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>
|
|
|
650 |
<div class="network-box">
|
|
|
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>
|
|
|
654 |
</div>
|
|
|
655 |
</div>
|
|
|
656 |
<? endforeach; ?>
|
|
|
657 |
</div>
|
|
|
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>
|
|
|
665 |
</div>
|
|
|
666 |
</div>
|
|
|
667 |
<br>
|
|
|
668 |
|
2304 |
tom.houday |
669 |
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
2316 |
tom.houday |
670 |
<tr><th><?= $l_dhcp_title?></th></tr>
|
318 |
richard |
671 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
672 |
</table>
|
2304 |
tom.houday |
673 |
<table width="100%" cellspacing="0" cellpadding="5" border="1">
|
2316 |
tom.houday |
674 |
<tr><td colspan="2" valign="middle" align="left">
|
|
|
675 |
<center><h3><?= $l_dhcp_state ?> : <?= ${'l_DHCP_'.$conf['DHCP']} ?></h3></center>
|
|
|
676 |
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
|
2324 |
tom.houday |
677 |
<select name="choix">
|
2316 |
tom.houday |
678 |
<option value="DHCP_Off"<?= ((!strcmp($conf['DHCP'], 'off')) ? ' selected' : '') ?>><?= $l_DHCP_off ?></option>
|
|
|
679 |
<option value="DHCP_On"<?= ((!strcmp($conf['DHCP'], 'on')) ? ' selected' : '') ?>><?= $l_DHCP_on ?></option>
|
|
|
680 |
</select>
|
|
|
681 |
<input type="submit" value="<?= $l_apply ?>">
|
|
|
682 |
<br><?= $l_DHCP_off_explain ?>
|
|
|
683 |
</form>
|
|
|
684 |
</td></tr>
|
|
|
685 |
|
1822 |
raphael.pi |
686 |
<?php
|
2316 |
tom.houday |
687 |
if ($conf['DHCP'] === 'on') {
|
|
|
688 |
require('network2.php');
|
|
|
689 |
}
|
1822 |
raphael.pi |
690 |
?>
|
318 |
richard |
691 |
</table>
|
2316 |
tom.houday |
692 |
<br>
|
2013 |
raphael.pi |
693 |
|
2304 |
tom.houday |
694 |
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
2316 |
tom.houday |
695 |
<tr><th><?= $l_local_dns?></th></tr>
|
1959 |
richard |
696 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
697 |
</table>
|
2304 |
tom.houday |
698 |
<table width="100%" cellspacing="0" cellpadding="5" border="1">
|
2316 |
tom.houday |
699 |
<tr>
|
|
|
700 |
<td width="50%" align="center">
|
|
|
701 |
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
|
|
|
702 |
<table cellspacing="2" cellpadding="3" border="1">
|
2559 |
rexy |
703 |
<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
|
2316 |
tom.houday |
704 |
<?php
|
|
|
705 |
// Read the "dns_local" file
|
|
|
706 |
$line_exist = false;
|
|
|
707 |
$tab = file(DNS_LOCAL_FILE);
|
|
|
708 |
if ($tab) { // not empty
|
|
|
709 |
foreach ($tab as $line) {
|
2559 |
rexy |
710 |
if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
|
2316 |
tom.houday |
711 |
$line_exist = true;
|
2559 |
rexy |
712 |
$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
|
|
|
713 |
$ip_addr = $field[0];
|
2316 |
tom.houday |
714 |
$host_name = $field[1];
|
2559 |
rexy |
715 |
echo "<tr><td>$ip_addr</td>";
|
|
|
716 |
echo "<td>$host_name</td>";
|
|
|
717 |
if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
|
|
|
718 |
echo "<td>";}
|
|
|
719 |
else {
|
|
|
720 |
echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
|
|
|
721 |
}
|
|
|
722 |
echo "</td></tr>";
|
2316 |
tom.houday |
723 |
}
|
1959 |
richard |
724 |
}
|
|
|
725 |
}
|
2316 |
tom.houday |
726 |
if (!$line_exist) {
|
|
|
727 |
echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
|
|
|
728 |
}
|
|
|
729 |
?>
|
|
|
730 |
</table>
|
|
|
731 |
<?php if ($line_exist): ?>
|
|
|
732 |
<input type="hidden" name="choix" value="del_host">
|
|
|
733 |
<input type="submit" value="<?= $l_apply ?>">
|
|
|
734 |
<?php endif; ?>
|
|
|
735 |
</form>
|
|
|
736 |
</td>
|
|
|
737 |
<td width="50%" valign="middle" align="center">
|
|
|
738 |
<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
|
|
|
739 |
<table cellspacing="2" cellpadding="3" border="1">
|
|
|
740 |
<tr>
|
2559 |
rexy |
741 |
<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
|
2316 |
tom.houday |
742 |
</tr>
|
|
|
743 |
<tr>
|
2559 |
rexy |
744 |
<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
|
2316 |
tom.houday |
745 |
</tr>
|
|
|
746 |
<tr>
|
2559 |
rexy |
747 |
<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
|
2316 |
tom.houday |
748 |
<td><input type="text" name="add_host" size="17"></td>
|
|
|
749 |
<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
|
|
|
750 |
</tr>
|
|
|
751 |
</table>
|
|
|
752 |
</form>
|
|
|
753 |
</td>
|
|
|
754 |
</tr>
|
1959 |
richard |
755 |
</table>
|
2316 |
tom.houday |
756 |
<br>
|
|
|
757 |
|
2304 |
tom.houday |
758 |
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
2610 |
tom.houday |
759 |
<tr><th><?= $l_ssl_title ?></th></tr>
|
2609 |
rexy |
760 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
761 |
</table>
|
|
|
762 |
<table width="100%" cellspacing="0" cellpadding="5" border="1">
|
|
|
763 |
<tr><td valign="middle" align="left">
|
|
|
764 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
|
|
|
765 |
<input type="hidden" name="choix" value="https_login">
|
|
|
766 |
<select name="https_login">
|
|
|
767 |
<option value="on"<?= (($conf['HTTPS_LOGIN'] === 'on') ? ' selected' : '') ?>><?= $l_yes ?></option>
|
|
|
768 |
<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
|
|
|
769 |
</select>
|
|
|
770 |
<input type="submit" value="<?= $l_apply ?>"><br>
|
|
|
771 |
</form>
|
|
|
772 |
<br>
|
|
|
773 |
</td></tr>
|
|
|
774 |
</table>
|
|
|
775 |
<br>
|
|
|
776 |
|
|
|
777 |
<table width="100%" cellspacing="0" cellpadding="0" border="0">
|
2316 |
tom.houday |
778 |
<tr><th><?= $l_import_cert ?></th></tr>
|
1710 |
richard |
779 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
780 |
</table>
|
2304 |
tom.houday |
781 |
<table width="100%" cellspacing="0" cellpadding="5" border="1">
|
|
|
782 |
<tr>
|
2324 |
tom.houday |
783 |
<td width="50%" valign="top">
|
2297 |
tom.houday |
784 |
<?php
|
|
|
785 |
$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
|
|
|
786 |
|
|
|
787 |
$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
|
|
|
788 |
$domain = $certificateInfos['subject']['CN'];
|
|
|
789 |
$organization = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
|
|
|
790 |
$CAdomain = $certificateInfos['issuer']['CN'];
|
|
|
791 |
$CAorganization = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
|
|
|
792 |
?>
|
|
|
793 |
<h3><?= $l_current_certificate ?></h3>
|
2326 |
tom.houday |
794 |
<?= $l_cert_expiration ?> <?= $cert_expiration_date ?><br>
|
|
|
795 |
<?= $l_cert_commonname ?> <?= $domain ?><br>
|
|
|
796 |
<?= $l_cert_organization ?> <?= $organization ?><br/>
|
2297 |
tom.houday |
797 |
<h4><?= $l_validated ?></h4>
|
2326 |
tom.houday |
798 |
<?= $l_cert_commonname ?> <?= $CAdomain ?><br>
|
|
|
799 |
<?= $l_cert_organization ?> <?= $CAorganization ?><br>
|
2324 |
tom.houday |
800 |
</td>
|
2609 |
rexy |
801 |
<td width="50%" valign="center">
|
|
|
802 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
|
|
|
803 |
<input type="hidden" name="choix" value="default_cert">
|
|
|
804 |
<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' : '' ?>>
|
|
|
805 |
</form>
|
|
|
806 |
</td>
|
2324 |
tom.houday |
807 |
</tr>
|
|
|
808 |
<tr>
|
|
|
809 |
<td width="50%" valign="top">
|
2326 |
tom.houday |
810 |
<h3><?= $l_upload_certificate ?></h3>
|
2324 |
tom.houday |
811 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
|
|
|
812 |
<?= $l_private_key;?> <input type="file" name="key"><br>
|
|
|
813 |
<?= $l_certificate;?> <input type="file" name="crt"><br>
|
|
|
814 |
<?= $l_server_chain;?> <input type="file" name="sc"><br>
|
|
|
815 |
<input type="hidden" name="choix" value="import_cert">
|
|
|
816 |
<input type="submit" value="<?= $l_import ?>">
|
2297 |
tom.houday |
817 |
</form>
|
|
|
818 |
</td>
|
2304 |
tom.houday |
819 |
<td width="50%" valign="top">
|
|
|
820 |
<?php
|
|
|
821 |
// Get step
|
|
|
822 |
if (empty($LE_conf['domainRequest'])) {
|
|
|
823 |
$step = 1;
|
|
|
824 |
} else if (!empty($LE_conf['challenge'])) {
|
|
|
825 |
$step = 2;
|
|
|
826 |
} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
|
|
|
827 |
$step = 3;
|
|
|
828 |
} else {
|
|
|
829 |
$step = 1;
|
|
|
830 |
}
|
|
|
831 |
?>
|
2326 |
tom.houday |
832 |
<h3><?= $l_le_integration ?></h3>
|
2324 |
tom.houday |
833 |
<?php if ($step === 1): ?>
|
2316 |
tom.houday |
834 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
|
|
|
835 |
<input type="hidden" name="choix" value="le_issueCert">
|
2326 |
tom.houday |
836 |
<?= $l_le_status ?> <?= $l_disabled ?><br>
|
|
|
837 |
<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
|
|
|
838 |
<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
|
|
|
839 |
<input type="submit" name="issue" value="<?= $l_send ?>"><br>
|
2304 |
tom.houday |
840 |
</form>
|
|
|
841 |
<?php elseif ($step === 2): ?>
|
2316 |
tom.houday |
842 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
|
|
|
843 |
<input type="hidden" name="choix" value="le_renewCert">
|
2326 |
tom.houday |
844 |
<?= $l_le_status ?> <?= $l_pending_validation ?><br>
|
|
|
845 |
<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
|
|
|
846 |
<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
|
|
|
847 |
<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
|
|
|
848 |
<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
|
|
|
849 |
<input type="submit" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" name="cancel" value="<?= $l_cancel ?>"><br>
|
2304 |
tom.houday |
850 |
</form>
|
|
|
851 |
<?php elseif ($step === 3): ?>
|
2316 |
tom.houday |
852 |
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
|
|
|
853 |
<input type="hidden" name="choix" value="le_renewCert">
|
2326 |
tom.houday |
854 |
<?= $l_le_status ?> <?= $l_enabled ?><br>
|
|
|
855 |
<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
|
|
|
856 |
<?= $l_le_api ?> <?= $LE_conf['dnsapi'] ?><br>
|
|
|
857 |
<?= $l_le_next_renewal ?> <?= date('d-m-Y', $LE_conf['dateNextRenewal']) ?><br>
|
2304 |
tom.houday |
858 |
<?php if ($LE_conf['dateNextRenewal'] <= date('U')): ?>
|
2326 |
tom.houday |
859 |
<input type="submit" name="recheck" value="<?= $l_renew ?>"><br>
|
2304 |
tom.houday |
860 |
<?php else: ?>
|
2326 |
tom.houday |
861 |
<input type="submit" name="recheck_force" value="<?= $l_renew_force ?>"><br>
|
2304 |
tom.houday |
862 |
<?php endif; ?>
|
|
|
863 |
</form>
|
|
|
864 |
<?php endif; ?>
|
|
|
865 |
<?php if (isset($cmdResponse)): ?>
|
|
|
866 |
<p><?= $cmdResponse ?></p>
|
|
|
867 |
<?php endif; ?>
|
|
|
868 |
</td>
|
1710 |
richard |
869 |
</tr>
|
|
|
870 |
</table>
|
318 |
richard |
871 |
</body>
|
|
|
872 |
</html>
|