Subversion Repositories ALCASAR

Rev

Rev 2874 | Rev 2971 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2874 Rev 2956
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 2874 2020-10-31 13:54:28Z rexy $
2
# $Id: network.php 2956 2021-05-24 19:57:17Z rexy $
3
 
3
 
4
// written by steweb57, Rexy & Tom HOUDAYER
4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
5
 
5
 
6
/********************
6
/********************
7
*  READ CONF FILES  *
7
*  READ CONF FILES  *
8
*********************/
8
*********************/
9
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
9
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
10
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
10
define('ETHERS_FILE', '/usr/local/etc/alcasar-ethers');
11
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
11
define('ETHERS_INFO_FILE', '/usr/local/etc/alcasar-ethers-info');
12
define('DNS_LOCAL_FILE', '/etc/hosts');
12
define('DNS_LOCAL_FILE', '/etc/hosts');
13
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
13
define('LETS_ENCRYPT_FILE', '/usr/local/etc/alcasar-letsencrypt');
-
 
14
define('TEMP_FILE', '/tmp/alcasar.conf.temp');
-
 
15
 
14
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
16
$conf_files = [CONF_FILE, ETHERS_FILE, ETHERS_INFO_FILE, DNS_LOCAL_FILE, LETS_ENCRYPT_FILE];
15
 
17
 
16
// Files reading test
18
// Files reading test
17
foreach ($conf_files as $file) {
19
foreach ($conf_files as $file) {
18
	if (!file_exists($file)) {
20
	if (!file_exists($file)) {
Line 96... Line 98...
96
	$l_le_api		= "API :";
98
	$l_le_api		= "API :";
97
	$l_le_next_renewal	= "Prochain renouvellement :";
99
	$l_le_next_renewal	= "Prochain renouvellement :";
98
	$l_renew		= "Renouveller";
100
	$l_renew		= "Renouveller";
99
	$l_renew_force		= "Renouveller (forcer)";
101
	$l_renew_force		= "Renouveller (forcer)";
100
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
102
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
-
 
103
	$l_gw_weight    = "Poids";
-
 
104
	$l_error        = "Erreur";
-
 
105
	$l_error_bad_ip = "Ceci n'est pas une adresse IP valide";
-
 
106
	$l_error_bad_ip_CIDR = "Ceci n'est pas une adresse CIDR valide";
-
 
107
	$l_error_bad_ip_port = "Ceci n'est pas une adresse IP + port valide";
-
 
108
	$l_error_weight = "Ceci n'est pas un poids valide";
-
 
109
    $l_change_successful = "Changement effectué avec succès";
-
 
110
 
101
} else if ($Language === 'es') {
111
} else if ($Language === 'es') {
102
	$l_network_title	= "Configuración de Red";
112
	$l_network_title	= "Configuración de Red";
103
	$l_internet_legend	= "INTERNET";
113
	$l_internet_legend	= "INTERNET";
104
	$l_ip_mask		= "Máscara";
114
	$l_ip_mask		= "Máscara";
105
	$l_ip_router		= "Puerta de enlace";
115
	$l_ip_router		= "Puerta de enlace";
Line 151... Line 161...
151
	$l_le_api		= "API:";
161
	$l_le_api		= "API:";
152
	$l_le_next_renewal	= "Siguiente renovación:";
162
	$l_le_next_renewal	= "Siguiente renovación:";
153
	$l_renew		= "Renovar";
163
	$l_renew		= "Renovar";
154
	$l_renew_force		= "Renovar (forzado)";
164
	$l_renew_force		= "Renovar (forzado)";
155
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
165
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
-
 
166
    $l_gw_weight = "";/*TODO Traduction espagnole*/
-
 
167
    $l_error        = "";/*TODO Traduction espagnole*/
-
 
168
    $l_error_bad_ip = "";/*TODO Traduction espagnole*/
-
 
169
    $l_error_bad_ip_CIDR = "";/*TODO Traduction espagnole*/
-
 
170
    $l_error_bad_ip_port = "";/*TODO Traduction espagnole*/
-
 
171
    $l_error_weight = "";/*TODO Traduction espagnole*/
-
 
172
    $l_change_successful = "";/*TODO Traduction espagnole*/
156
} else {
173
} else {
157
	$l_network_title	= "Network configuration";
174
	$l_network_title	= "Network configuration";
158
	$l_internet_legend	= "INTERNET";
175
	$l_internet_legend	= "INTERNET";
159
	$l_ip_mask		= "Mask";
176
	$l_ip_mask		= "Mask";
160
	$l_ip_router		= "Gateway";
177
	$l_ip_router		= "Gateway";
Line 206... Line 223...
206
	$l_le_api		= "API:";
223
	$l_le_api		= "API:";
207
	$l_le_next_renewal	= "Next renewal:";
224
	$l_le_next_renewal	= "Next renewal:";
208
	$l_renew		= "Renew";
225
	$l_renew		= "Renew";
209
	$l_renew_force		= "Renew (force)";
226
	$l_renew_force		= "Renew (force)";
210
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
227
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
-
 
228
    $l_gw_weight = "Weight";
-
 
229
    $l_error        = "Error";
-
 
230
    $l_error_bad_ip = "This is not a valid IP";
-
 
231
    $l_error_bad_ip_CIDR = "This is not a valid CIDR IP";
-
 
232
    $l_error_bad_ip_port = "This is not a valid IP + port";
-
 
233
    $l_error_weight = "This is not a valid weight";
-
 
234
    $l_change_successful = "Network updated successfully";
211
}
235
}
212
 
236
 
213
$reg_ip      = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
237
$reg_ip      = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
214
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
238
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
-
 
239
$reg_ip_port = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\:([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))$/';
215
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
240
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
216
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
241
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
-
 
242
$reg_weight  = '/^[0-9]*$/';
-
 
243
$ext_conf_error = false;
217
 
244
 
218
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
245
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
219
 
-
 
220
switch ($choix) {
246
switch ($choix) {
221
	case 'DHCP_On':
247
	case 'DHCP_On':
222
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
248
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -on');
223
		header('Location: '.$_SERVER['PHP_SELF']);
249
		header('Location: '.$_SERVER['PHP_SELF']);
224
		exit();
250
		exit();
225
	case 'DHCP_Off':
251
	case 'DHCP_Off':
226
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
252
		exec('sudo /usr/local/bin/alcasar-dhcp.sh -off');
227
		header('Location: '.$_SERVER['PHP_SELF']);
253
		header('Location: '.$_SERVER['PHP_SELF']);
228
		exit();
254
		exit();
229
 
-
 
230
	case 'new_mac':
255
	case 'new_mac':
231
		$new_mac_addr = trim($_POST['add_mac']);
256
		$new_mac_addr = trim($_POST['add_mac']);
232
		$new_ip_addr  = trim($_POST['add_ip']);
257
		$new_ip_addr  = trim($_POST['add_ip']);
233
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
258
		if (((!empty($new_mac_addr)) && (preg_match($reg_mac, $new_mac_addr))) && ((!empty($new_ip_addr)) && (preg_match($reg_ip, $new_ip_addr)))) {
234
			$tab = file(ETHERS_FILE);
259
			$tab = file(ETHERS_FILE);
Line 272... Line 297...
272
				exec('sudo /usr/bin/systemctl reload chilli');
297
				exec('sudo /usr/bin/systemctl reload chilli');
273
			}
298
			}
274
		}
299
		}
275
		header('Location: '.$_SERVER['PHP_SELF']);
300
		header('Location: '.$_SERVER['PHP_SELF']);
276
		exit();
301
		exit();
277
 
-
 
278
	case 'new_host':
302
	case 'new_host':
279
		$add_host = trim($_POST['add_host']);
303
		$add_host = trim($_POST['add_host']);
280
		$add_ip   = trim($_POST['add_ip']);
304
		$add_ip   = trim($_POST['add_ip']);
281
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
305
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
282
			$tab = file(DNS_LOCAL_FILE);
306
			$tab = file(DNS_LOCAL_FILE);
Line 338... Line 362...
338
					if (file_exists($scpath))  unlink($scpath);
362
					if (file_exists($scpath))  unlink($scpath);
339
				}
363
				}
340
			}
364
			}
341
		}
365
		}
342
		break;
366
		break;
343
 
-
 
344
	case 'https_login':	// Set HTTPS login status
367
	case 'https_login':	// Set HTTPS login status
345
		if ($_POST['https_login'] === 'on') {
368
		if ($_POST['https_login'] === 'on') {
346
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
369
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
347
		} else {
370
		} else {
348
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
371
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
Line 351... Line 374...
351
		exit();
374
		exit();
352
}
375
}
353
 
376
 
354
// Network changes
377
// Network changes
355
if ($choix === 'network_change') {
378
if ($choix === 'network_change') {
-
 
379
    exec('sudo /usr/local/bin/alcasar-network.sh --save');
-
 
380
	$modification_network = false;
356
	$network_modification = false;
381
	$modification_dns = false;
-
 
382
	$modification_proxy = false;
-
 
383
	$ext_conf_error_list = [];
-
 
384
	copy(CONF_FILE, TEMP_FILE);
357
 
385
 
358
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1']) && preg_match($reg_ip, $_POST['dns1'])) {
386
	if (isset($_POST['dns1']) && (trim($_POST['dns1']) !== $conf['DNS1'])) {
359
		file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(CONF_FILE)));
387
	    if (!preg_match($reg_ip, $_POST['dns1'])) {
360
		$network_modification = true;
388
            $ext_conf_error = true;
361
	}
-
 
362
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2']) && preg_match($reg_ip, $_POST['dns2'])) {
389
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns1.': '.$l_error_bad_ip;
-
 
390
        }
363
		file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(CONF_FILE)));
391
		file_put_contents(TEMP_FILE, str_replace('DNS1='.$conf['DNS1'], 'DNS1='.trim($_POST['dns1']), file_get_contents(TEMP_FILE)));
364
		$network_modification = true;
392
		$modification_dns = true;
365
	}
393
	}
366
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP']) && preg_match($reg_ip_cidr, $_POST['ip_public'])) {
394
	if (isset($_POST['dns2']) && (trim($_POST['dns2']) !== $conf['DNS2'])) {
-
 
395
	    if (!preg_match($reg_ip, $_POST['dns2'])) {
-
 
396
            $ext_conf_error = true;
-
 
397
            $ext_conf_error_list[] = $l_error.': '.$l_ip_dns2.': '.$l_error_bad_ip;
-
 
398
        }
367
		file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(CONF_FILE)));
399
		file_put_contents(TEMP_FILE, str_replace('DNS2='.$conf['DNS2'], 'DNS2='.trim($_POST['dns2']), file_get_contents(TEMP_FILE)));
368
		$network_modification = true;
400
		$modification_dns = true;
369
	}
401
	}
370
	if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW']) && preg_match($reg_ip, $_POST['ip_gw'])) {
402
    if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP'])) {
-
 
403
        if (!preg_match($reg_ip_cidr, $_POST['ip_private'])) {
-
 
404
            $ext_conf_error = true;
-
 
405
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' LAN: '.$l_error_bad_ip_CIDR;
-
 
406
        }
371
		file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(CONF_FILE)));
407
        file_put_contents(TEMP_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(TEMP_FILE)));
372
		$network_modification = true;
408
        $modification_network = true;
373
	}
409
    }
374
	if (isset($_POST['ip_private']) && (trim($_POST['ip_private']) !== $conf['PRIVATE_IP']) && preg_match($reg_ip_cidr, $_POST['ip_private'])) {
410
	if (isset($_POST['ip_public']) && (trim($_POST['ip_public']) !== $conf['PUBLIC_IP'])) {
375
		file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'], 'PRIVATE_IP='.trim($_POST['ip_private']), file_get_contents(CONF_FILE)));
411
	    if (!preg_match($reg_ip_cidr, $_POST['ip_public'])) {
376
		$network_modification = true;
412
            $ext_conf_error = true;
-
 
413
            $ext_conf_error_list[] = $l_error.': '.$l_ip_address.' WAN: '.$l_error_bad_ip_CIDR;
377
	}
414
        }
378
 
-
 
-
 
415
		file_put_contents(TEMP_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'], 'PUBLIC_IP='.trim($_POST['ip_public']), file_get_contents(TEMP_FILE)));
379
	if ($network_modification) {
416
		$modification_network = true;
380
		exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
-
 
381
	}
417
	}
-
 
418
    if (isset($_POST['ip_gw']) && (trim($_POST['ip_gw']) !== $conf['GW'])) {
-
 
419
        if (!preg_match($reg_ip, $_POST['ip_gw'])) {
-
 
420
            $ext_conf_error = true;
-
 
421
            $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' 1: '.$l_error_bad_ip;
-
 
422
        }
-
 
423
        file_put_contents(TEMP_FILE, str_replace('GW='.$conf['GW'], 'GW='.trim($_POST['ip_gw']), file_get_contents(TEMP_FILE)));
-
 
424
        $modification_network = true;
-
 
425
    }
-
 
426
    if (isset($_POST['enable_proxy']) && $_POST['enable_proxy'] == 'P_Enabled')
-
 
427
    {
-
 
428
        if ($conf['PROXY'] !== 'On')
-
 
429
        {
-
 
430
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=On', file_get_contents(TEMP_FILE)));
-
 
431
            $modification_proxy = true;
-
 
432
        }
-
 
433
        if (isset($_POST['proxy']) && (trim($_POST['proxy']) !== $conf['PROXY_IP'])) {
-
 
434
            if (!preg_match($reg_ip_port, $_POST['proxy'])) {
-
 
435
                $ext_conf_error = true;
-
 
436
                $ext_conf_error_list[] = $l_error.': Proxy: '.$l_error_bad_ip_port;
-
 
437
            }
-
 
438
            file_put_contents(TEMP_FILE, str_replace('PROXY_IP='.$conf['PROXY_IP'], 'PROXY_IP='.trim($_POST['proxy']), file_get_contents(TEMP_FILE)));
-
 
439
            $modification_proxy = true;
-
 
440
        }
-
 
441
        if ($conf['MULTIWAN'] !== 'Off')
-
 
442
        {
-
 
443
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=Off', file_get_contents(TEMP_FILE)));
-
 
444
            $modification_network = true;
-
 
445
        }
-
 
446
    }
-
 
447
    else
-
 
448
    {
-
 
449
        //set multiwan value to off and delete every "WANx=" line
-
 
450
        if ($_POST['gw_count'] === "1" && $conf['MULTIWAN'] !== 'Off')
-
 
451
        {
-
 
452
            file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=Off', file_get_contents(TEMP_FILE)));
-
 
453
            $temp = 1;
-
 
454
            while (isset($conf['WAN'.$temp]))
-
 
455
            {
-
 
456
                file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
-
 
457
                $temp++;
-
 
458
            }
-
 
459
            $modification_network = true;
-
 
460
        }
-
 
461
        if ($_POST['gw_count'] !== "1")
-
 
462
        {
-
 
463
            $changed = false;
-
 
464
            //testing the existence of a change in the routing configuration
-
 
465
            exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nb_gw);
-
 
466
            if ($_POST['gw_count'] == ($nb_gw[0] + 1))
-
 
467
            {
-
 
468
                if ($_POST['weight'] !== $conf['PUBLIC_WEIGHT']) {
-
 
469
                    $changed = true;
-
 
470
                }
-
 
471
                else {
-
 
472
                    for($i=1;$i<$_POST['gw_count'];$i++)
-
 
473
                    {
-
 
474
                        if( '"'.$_POST['ip_gw_'.$i].','.$_POST['weight_'.$i].'"' != $conf['WAN'.$i])
-
 
475
                        {
-
 
476
                            $changed = true;
-
 
477
                            break;
-
 
478
                        }
-
 
479
                    }
-
 
480
                }
-
 
481
            }
-
 
482
            else
-
 
483
            {
-
 
484
                $changed = true;
-
 
485
            }
-
 
486
 
-
 
487
            if ($changed == true)
-
 
488
            {
-
 
489
                //deleting all the old lines containing "WANx="
-
 
490
                $temp = 1;
-
 
491
                while (isset($conf['WAN'.$temp]))
-
 
492
                {
-
 
493
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$temp.'='.$conf['WAN'.$temp]."\n", '', file_get_contents(TEMP_FILE)));
-
 
494
                    $temp++;
-
 
495
                }
-
 
496
                //setting back the line "WAN1=" which will be our base
-
 
497
                if (!preg_match($reg_weight, $_POST['weight'])) {
-
 
498
                    $ext_conf_error = true;
-
 
499
                    $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' 1: '.$l_error_weight;
-
 
500
                }
-
 
501
                file_put_contents(TEMP_FILE, str_replace('PUBLIC_WEIGHT='.$conf['PUBLIC_WEIGHT'], 'PUBLIC_WEIGHT='.(($_POST['weight'] !== '')?$_POST['weight']:1), file_get_contents(TEMP_FILE)));
-
 
502
                //Set Multiwan status
-
 
503
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], "MULTIWAN=On\nWAN1=", file_get_contents(TEMP_FILE)));
-
 
504
                //Adding the correct number of "WANx=" lines, numbered
-
 
505
                for($i=2;$i<$_POST['gw_count'];$i++)
-
 
506
                {
-
 
507
                    file_put_contents(TEMP_FILE, str_replace('WAN'.($i-1).'=', 'WAN'.($i-1)."=\nWAN".$i.'=', file_get_contents(TEMP_FILE)));
-
 
508
                }
-
 
509
                //Adding the content
-
 
510
                for($i=1;$i<$_POST['gw_count'];$i++)
-
 
511
                {
-
 
512
                    if (!preg_match($reg_ip, $_POST['ip_gw_'.$i])) {
-
 
513
                        $ext_conf_error = true;
-
 
514
                        $ext_conf_error_list[] = $l_error.': '.$l_ip_router.' '.($i+1).': '.$l_error_bad_ip;
-
 
515
                    }
-
 
516
                    if (!preg_match($reg_weight, $_POST['weight_'.$i])) {
-
 
517
                        $ext_conf_error = true;
-
 
518
                        $ext_conf_error_list[] = $l_error.': '.$l_gw_weight.' '.($i+1).': '.$l_error_weight;
-
 
519
                    }
-
 
520
                    file_put_contents(TEMP_FILE, str_replace('WAN'.$i.'=', 'WAN'.$i.'="'.$_POST['ip_gw_'.$i].','.(($_POST['weight_'.$i] === "0" || $_POST['weight_'.$i] === "")?"1":$_POST['weight_'.$i]).'"', file_get_contents(TEMP_FILE)));
-
 
521
                }
-
 
522
                $modification_network = true;
-
 
523
            }
-
 
524
        }
-
 
525
        //set proxy value to off
-
 
526
        if ($conf['PROXY'] !== 'Off')
-
 
527
        {
-
 
528
            file_put_contents(TEMP_FILE, str_replace('PROXY='.$conf['PROXY'], 'PROXY=Off', file_get_contents(TEMP_FILE)));
-
 
529
            if($_POST['gw_count'] !== "1" && $conf['MULTIWAN'] !== 'On') {
-
 
530
                file_put_contents(TEMP_FILE, str_replace('MULTIWAN='.$conf['MULTIWAN'], 'MULTIWAN=On', file_get_contents(TEMP_FILE)));
-
 
531
                $modification_network = true;
-
 
532
            }
-
 
533
            $modification_proxy = true;
-
 
534
        }
-
 
535
    }
-
 
536
 
-
 
537
    //if no errors are detected
-
 
538
    if ($ext_conf_error == false) {
-
 
539
        copy(TEMP_FILE, CONF_FILE);
-
 
540
        //DNS values modification, several services needs to be reloading, reloads the full server.
-
 
541
        if ($modification_dns) {
-
 
542
            exec('sudo /usr/local/bin/alcasar-conf.sh -apply');
-
 
543
        }
-
 
544
        //External network modifications, no service reloading
-
 
545
        if ($modification_network) {
-
 
546
            exec('sudo /usr/local/bin/alcasar-network.sh');
-
 
547
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
-
 
548
        }
-
 
549
        //If only the proxy has been modified, only the firewall needs a change
-
 
550
        else if ($modification_proxy) {
-
 
551
            exec('sudo /usr/local/bin/alcasar-iptables.sh');
-
 
552
        }
-
 
553
    }
-
 
554
    unlink(TEMP_FILE);
382
 
555
 
383
	// Read CONF_FILE updated
556
	// Read CONF_FILE updated
384
	$file_conf = fopen(CONF_FILE, 'r');
557
	$file_conf = fopen(CONF_FILE, 'r');
385
	if (!$file_conf) {
558
	if (!$file_conf) {
386
		exit('Error opening the file '.CONF_FILE);
559
		exit('Error opening the file '.CONF_FILE);
Line 451... Line 624...
451
	curl_close($ch);
624
	curl_close($ch);
452
} else {
625
} else {
453
	$internet_publicIP = '-.-.-.-';
626
	$internet_publicIP = '-.-.-.-';
454
}
627
}
455
 
628
 
456
// Network interfaces
629
// Network interfaces, will be use later for multiple LAN interfaces
457
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
630
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['INTIF']];
458
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
631
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
459
 
632
 
460
// TODO: Pending the next version
633
//retreive gateway(s) parameters
461
$externalNetworks = [
634
$gateways = [
462
	(object) [
635
	(object) [
463
		'interface' => $conf['EXTIF'],
636
		'gateway'   => $conf['GW'],
464
		'ip'        => $conf['PUBLIC_IP'],
637
        'weight'    => $conf['PUBLIC_WEIGHT']
465
		'gateway'   => $conf['GW']
-
 
466
	]
638
	]
467
];
639
];
-
 
640
exec("grep \"^WAN\" " . CONF_FILE . " | wc -l", $nbIfaces);
-
 
641
if ($nbIfaces > 0)
-
 
642
{
-
 
643
    for ($i = 1; $i <= $nbIfaces[0]; $i++) {
-
 
644
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $1 }'", $temp_gw);
-
 
645
        exec("grep \"WAN" . $i . "=\" " . CONF_FILE . " | awk -F'\"' '{ print $2 }' | awk -F, '{ print $2 }'", $temp_weight);
-
 
646
        $gateways[] = (object) [
-
 
647
            'gateway'   => $temp_gw[0],
-
 
648
            'weight'    => $temp_weight[0]
-
 
649
        ];
-
 
650
        $temp_gw = "";
-
 
651
        $temp_weight = "";
-
 
652
    }
-
 
653
}
-
 
654
 
-
 
655
//retreive internal networks parameters
468
$internalNetworks = [
656
$internalNetworks = [
469
	(object) [
657
	(object) [
470
		'interface' => $conf['INTIF'],
658
		'interface' => $conf['INTIF'],
471
		'ip'        => $conf['PRIVATE_IP']
659
		'ip'        => $conf['PRIVATE_IP']
472
	]
660
	]
Line 508... Line 696...
508
		}
696
		}
509
		.network-configurator > .externals, .network-configurator > .internals {
697
		.network-configurator > .externals, .network-configurator > .internals {
510
			width: 30%;
698
			width: 30%;
511
		}
699
		}
512
		.network-configurator .actions {
700
		.network-configurator .actions {
513
			position: absolute;
701
            position: absolute;
514
			background-color: #ddd;
702
			background-color: #ddd;
515
			padding: 0 2px;
703
			padding: 0 2px;
516
		}
704
		}
517
		.network-configurator .actions a {
705
		.network-configurator .actions a {
518
			text-decoration: none;
706
			text-decoration: none;
519
		}
707
		}
520
		.network-configurator .actions a:hover {
708
		.network-configurator .actions a:hover {
521
			font-weight: bold;
709
			font-weight: bold;
522
		}
710
		}
523
		.network-configurator > .alcasar .actions-externals {
711
		.network-configurator .actions-externals {
524
			bottom: 0;
-
 
525
			left: 0;
712
			right: 0;
526
			border-radius: 0 5px;
713
			border-radius: 5px;
-
 
714
            position: relative;
-
 
715
            text-decoration: none;
527
		}
716
		}
528
		.network-configurator > .alcasar .actions-internals {
717
		.network-configurator > .alcasar .actions-internals {
529
			bottom: 0;
718
			bottom: 0;
530
			right: 0;
719
			right: 0;
531
			border-radius: 5px 0;
720
			border-radius: 5px 0;
532
		}
721
		}
533
		.network-configurator .actions-network {
722
		.network-configurator .actions-network {
534
			top: 0;
-
 
535
			right: 0;
723
			right: 0;
536
			border-radius: 0 5px;
724
			border-radius: 5px;
-
 
725
            position: relative;
-
 
726
            text-decoration: none;
537
		}
727
		}
538
		.network-configurator .network-box {
728
		.network-configurator .network-box {
539
			display: inline-block;
729
			display: inline-block;
540
			min-height: 100px;
730
			min-height: 100px;
541
			margin: 5px;
731
			margin: 5px;
Line 556... Line 746...
556
			height: 10px;
746
			height: 10px;
557
			border-radius: 5px;
747
			border-radius: 5px;
558
			background-color: black;
748
			background-color: black;
559
		}
749
		}
560
		.network-configurator .network-connector[data-connector-direction="left"] {
750
		.network-configurator .network-connector[data-connector-direction="left"] {
561
			border-radius: 5px 0px 0px 5px;
751
			border-radius: 5px 0 0 5px;
562
		}
752
		}
563
		.network-configurator .network-connector[data-connector-direction="right"] {
753
		.network-configurator .network-connector[data-connector-direction="right"] {
564
			border-radius: 0px 5px 5px 0px;
754
			border-radius: 0 5px 5px 0;
565
		}
755
		}
566
		.network-configurator div[data-network-type] {
756
		.network-configurator div[data-network-type] {
567
			position: relative;
757
			position: relative;
568
		}
758
		}
569
	</style>
759
	</style>
570
	<script>
760
	<script>
571
	$(document).ready(function () {
761
	$(document).ready(function () {
572
		const interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
-
 
573
 
762
 
-
 
763
        setTimeout(function(){$("#change_success").fadeOut('normal');}, 10000);
-
 
764
 
574
		const wireStyles = {
765
	    //Will be used later for multiple LAN interfaces
-
 
766
		let interfacesAvailable = <?= ((!empty($interfacesAvailable)) ? "['".implode("', '", $interfacesAvailable)."']" : '[]') ?>;
575
			available: { border: '5px double green' }
767
		const wireStyles = { available: { border: '5px double green' } };
576
		};
-
 
577
 
768
 
578
		// Add external network
769
		// Add gateway
579
		$('.network-configurator .add-external-network').click(function (event) {
770
		$('.network-configurator').on('click', '.add-external-network', function (event) {
580
			event.preventDefault();
771
			event.preventDefault();
581
			let options = '';
-
 
582
			if (interfacesAvailable.length === 0) {
-
 
583
				options = '<option value=""></option>';
-
 
584
			} else {
-
 
585
				for (let i = 0; i < interfacesAvailable.length; i++) {
-
 
586
					options += '<option value="' + interfacesAvailable[i] + '">' + interfacesAvailable[i] + '</option>';
772
			ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
587
				}
-
 
588
			}
-
 
589
			$('.network-configurator .externals').append(' \
773
			$('.network-configurator .externals .network-box #ext_gateways').append(' \
590
				<div data-network-type="external"> \
-
 
591
					<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div> \
774
			            <div id="ip_routeur_' + ifaces_count + '" data-info_type="gateway" data-number="'+ ifaces_count +'">\
592
					<div class="network-box"> \
-
 
593
						<div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> \
-
 
594
						<label for="ext_interface_X"><?= 'Interface' ?></label> <select name="interface" id="ext_interface_X">' + options + '</select><br> \
775
                        <label for="ext_gateway_' + ifaces_count + '"><?= $l_ip_router.' ' ?></label><span class="gw_number">'+ (ifaces_count + 1) +'</span> <input style="width:100px" type="text" name="ip_gw_' + ifaces_count + '" id="ext_gateway_' + ifaces_count + '" value="" /> \
595
						<label for="ext_ip_X"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_X" value="" /><br> \
776
                        <label for="ext_weight_'+ ifaces_count +'"><?= $l_gw_weight ?></label> <input style="width:20px" type="text" name="weight_' + ifaces_count + '" id="ext_weight_'+ ifaces_count +'" value="0"/> \
596
						<label for="ext_gateway_X"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_X" value="" /> \
777
                        <div class="actions actions-network" style="display:inline-block; width:11px"><a href="#" style="display:block; text-align:center" class="remove-network" title="Supprimer ce réseau">-</a></div><br></div> ');
597
					</div> \
778
            ifaces_count++;
598
					<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div> \
779
            document.getElementById("gw_count").setAttribute('value', ifaces_count);
599
				</div>');
780
            updateGatewayView();
600
			addWire($('div[data-network-type="external"]:last'));
781
            $('div.network-connector[data-connector-network]').connections('update');
601
		});
782
		});
602
 
783
 
603
		// Add internal network
784
		// Add internal network
604
		$('.network-configurator .add-internal-network').click(function (event) {
785
		$('.network-configurator').on('click', '.add-internal-network', function (event) {
605
			event.preventDefault();
786
			event.preventDefault();
606
			$('.network-configurator .internals').append(' \
787
			$('.network-configurator .internals').append(' \
607
					<div data-network-type="internal"> \
788
					<div data-network-type="internal"> \
608
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
789
						<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div> \
609
						<div class="network-box"> \
790
						<div class="network-box"> \
Line 613... Line 794...
613
						</div> \
794
						</div> \
614
					</div>');
795
					</div>');
615
			addWire($('div[data-network-type="internal"]:last'));
796
			addWire($('div[data-network-type="internal"]:last'));
616
		});
797
		});
617
 
798
 
618
		// Remove network
799
		// Remove gateway
619
		$('.network-configurator').on('click', '.remove-network', function (event) {
800
		$('.network-box').on('click', '.remove-network', function (event) {
620
			event.preventDefault();
801
			event.preventDefault();
621
			$(this).parent().parent().parent().fadeOut(200, function() {
802
			$(this).parent().parent().fadeOut(200, function() {
622
				const networkType = $(this).data('networkType');
-
 
623
				$(this).remove();
-
 
624
 
803
 
-
 
804
			    $(this).remove();
625
				// Update wires
805
				//update network numbers
-
 
806
                $('div[data-info_type="gateway"]').each(function (index, value) {
626
				if (networkType === 'external') {
807
                    updateGatewayNumbers($(this), index);
-
 
808
                });
627
					$('div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]').connections('update');
809
                ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
628
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]').connections('update');
810
                document.getElementById("gw_count").setAttribute('value', (ifaces_count - 1));
629
				} else if (networkType === 'internal') {
811
                updateGatewayView();
-
 
812
 
630
					$('div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]').connections('update');
813
                $('div.network-connector[data-connector-network]').connections('update');
631
				}
-
 
632
			});
814
			});
633
		});
815
		});
634
 
816
 
-
 
817
		//proxy enabled or disabled
-
 
818
		$('.network-configurator').on('click', '.enable_proxy', function(event){
-
 
819
		    if ($(this).is(':checked'))
-
 
820
            {
-
 
821
                document.getElementById("add_external").setAttribute('hidden', 'true');
-
 
822
                document.getElementById("ext_proxy").removeAttribute('disabled');
-
 
823
                $('div[id="ip_routeur_0"]').children('span').html('');
-
 
824
                $('div[data-info_type="gateway"]').each(function(index, value) {
-
 
825
                    if ($(this).attr('data-number') !== "0")
-
 
826
                    {
-
 
827
                        $(this).attr('hidden', 'true');
-
 
828
                    }
-
 
829
                    else
-
 
830
                    {
-
 
831
                        $(this).children('input[id="ext_weight_0"]').attr('hidden', 'true');
-
 
832
                        $(this).children('label[for="ext_weight_0"]').attr('hidden', 'true');
-
 
833
                        $(this).children('div[class="actions actions-network"]').css('display', 'none');
-
 
834
                    }
-
 
835
                });
-
 
836
            }
-
 
837
            else
-
 
838
            {
-
 
839
                document.getElementById("add_external").removeAttribute('hidden');
-
 
840
                document.getElementById("ext_proxy").setAttribute('disabled', 'true');
-
 
841
                $('div[id="ip_routeur_0"]').children('span').html('1');
-
 
842
                $('div[data-info_type="gateway"]').each(function(index, value) {
-
 
843
                    if ($(this).attr('data-number') !== "0")
-
 
844
                    {
-
 
845
                        $(this).removeAttr('hidden');
-
 
846
                    }
-
 
847
                    else
-
 
848
                    {
-
 
849
                        $(this).children('input[id="ext_weight_0"]').removeAttr('hidden');
-
 
850
                        $(this).children('label[for="ext_weight_0"]').removeAttr('hidden');
-
 
851
                        $(this).children('div[class="actions actions-network"]').css('display', 'inline-block');
-
 
852
                    }
-
 
853
                });
-
 
854
                updateGatewayView();
-
 
855
            }
-
 
856
            $('div.network-connector[data-connector-network]').connections('update');
-
 
857
        });
-
 
858
 
-
 
859
		//Add a wire between two connectors
635
		const addWire = function (network) {
860
		const addWire = function (network) {
636
			const networkType = network.data('networkType');
861
			const networkType = network.data('networkType');
637
			if (networkType === 'external') {
862
			if (networkType === 'external') {
638
				$().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="internet"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
863
                $().connections({ from: 'div[data-network-type="internet"]>div.network-connector[data-connector-network="internet"]', to: network.children('div.network-connector[data-connector-network="internet"]'), css: wireStyles.available, within: network });
639
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: 'div[data-network-type="external"]>div.network-connector[data-connector-network="external"]:last', css: wireStyles.available, within: 'div[data-network-type="external"]:last' });
864
                $().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="external"]', to: network.children('div.network-connector[data-connector-network="external"]'), css: wireStyles.available, within: network });
640
			} else if (networkType === 'internal') {
865
            } else if (networkType === 'internal') {
641
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: 'div[data-network-type="internal"]>div.network-connector[data-connector-network="internal"]:last', css: wireStyles.available, within: 'div[data-network-type="internal"]:last' });
866
				$().connections({ from: 'div[data-network-type="alcasar"]>div.network-connector[data-connector-network="internal"]', to: network.children('div.network-connector[data-connector-network="internal"]'), css: wireStyles.available, within: network });
642
			}
867
			}
643
		};
868
		};
644
 
869
 
-
 
870
		//reindex the gateway numbers when a gateway is deleted
-
 
871
		const updateGatewayNumbers = function(gateway, number) {
-
 
872
		    old_number = gateway.attr('data-number');
-
 
873
            gateway.attr('data-number', number);
-
 
874
            gateway.attr('id', 'ip_routeur_'+number);
-
 
875
            if (number === 0)
-
 
876
            {
-
 
877
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw');
-
 
878
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight');
-
 
879
            }
-
 
880
            else
-
 
881
            {
-
 
882
                gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('name', 'ip_gw_'+number);
-
 
883
                gateway.children('input[id="ext_weight_'+old_number+'"]').attr('name', 'weight_'+number);
-
 
884
            }
-
 
885
            gateway.children('label[for="ext_gateway_'+old_number+'"]').attr('for', 'ext_gateway_'+number);
-
 
886
            gateway.children('input[id="ext_gateway_'+old_number+'"]').attr('id', 'ext_gateway_'+number);
-
 
887
            gateway.children('label[for="ext_weight_'+old_number+'"]').attr('for', 'ext_weight_'+number);
-
 
888
            gateway.children('input[id="ext_weight_'+old_number+'"]').attr('id', 'ext_weight_'+number);
-
 
889
            gateway.children('span[class="gw_number"]').html((number+1)+' ');
-
 
890
 
-
 
891
        };
-
 
892
 
-
 
893
		//hide the delete button and the weight field when there is only one gateway (or when there is a proxy)
-
 
894
		const updateGatewayView = function() {
-
 
895
            ifaces_count = parseInt(document.getElementById("gw_count").getAttribute('value'));
-
 
896
            if (ifaces_count === 1)
-
 
897
            {
-
 
898
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').attr('hidden', 'true');
-
 
899
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').attr('hidden', 'true');
-
 
900
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'none');
-
 
901
            }
-
 
902
            else
-
 
903
            {
-
 
904
                $('div#ip_routeur_0').children('input[id="ext_weight_0"]').removeAttr('hidden');
-
 
905
                $('div#ip_routeur_0').children('label[for="ext_weight_0"]').removeAttr('hidden');
-
 
906
                $('div#ip_routeur_0').children('div[class="actions actions-network"]').css('display', 'inline-block');
-
 
907
            }
-
 
908
        };
-
 
909
 
-
 
910
		//resize the connections to fit the window
645
		window.addEventListener('resize', function () {
911
		window.addEventListener('resize', function () {
646
			$('div.network-connector[data-connector-network]').connections('update');
912
			$('div.network-connector[data-connector-network]').connections('update');
647
		});
913
		});
648
 
914
 
649
		// Add wires to existing networks
915
		// Add wires to existing networks at page first render
650
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
916
		$('div[data-network-type="external"]').add('div[data-network-type="internal"]').each(function (index, element) {
651
			addWire($(this));
917
			addWire($(this));
652
		});
918
		});
653
	});
919
	});
654
	</script>
920
	</script>
Line 667... Line 933...
667
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
933
							<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
668
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
934
							<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
669
						</div>
935
						</div>
670
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
936
						<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
671
					</div>
937
					</div>
672
				</div><div class="externals">
938
				</div><div id="externals_id" class="externals">
673
					<?php foreach ($externalNetworks as $index => $network): ?>
-
 
674
						<div data-network-type="external">
939
						<div data-network-type="external">
675
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
940
							<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
676
							<div class="network-box">
941
							<div class="network-box">
-
 
942
								<label for="ext_interface">Interface</label> <input name="ext_interface" id="ext_interface" value="<?= $conf['EXTIF'] ?>" disabled="disabled"/><br>
-
 
943
								<label for="ext_ip"><?= $l_ip_address ?></label> <input style="width:130px" type="text" name="ip_public" id="ext_ip" value="<?= $conf['PUBLIC_IP'] ?>" /><br>
-
 
944
                                <input class="enable_proxy" type="checkbox" name="enable_proxy" value="P_Enabled" <?php if($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On') { echo 'checked'; }?>/>
-
 
945
                                <label for="proxy">Proxy</label> <input style="width:140px" type="text" name="proxy" id="ext_proxy" value=<?= $conf['PROXY_IP']?> <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? '' : 'disabled'?>/><br>
-
 
946
                                <div id="ext_gateways" >
-
 
947
                                    <input type="text" name="gw_count" id="gw_count" value="<?=count($gateways)?>" hidden="hidden"/>
-
 
948
                                    <?php foreach ($gateways as $index => $network):
-
 
949
                                        if ($index == 0) {?>
-
 
950
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>">
-
 
951
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
-
 
952
                                                <span class="gw_number"><?= ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')?'':($index+1) ?> </span>
-
 
953
                                                <input style="width:100px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
677
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
954
                                                <label for="ext_weight_<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>><?= $l_gw_weight ?></label>
678
								<label for="ext_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="ext_interface[<?= $index ?>]" id="ext_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
955
                                                <input style="width:20px" type="text" name="weight" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On' || $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'hidden' : '' ?>/>
679
								<label for="ext_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
956
                                                <div class="actions actions-network" style="display: <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On'|| $conf['MULTIWAN'] === 'Off' || $conf['MULTIWAN'] === 'off')? 'none' : 'inline-block' ?>; width:11px">
-
 
957
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
-
 
958
                                                </div><br>
-
 
959
                                            </div>
-
 
960
                                        <?php } else {?>
-
 
961
                                            <div id="ip_routeur_<?= $index ?>" data-info_type="gateway" data-number="<?= $index ?>" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>
-
 
962
                                                <label for="ext_gateway_<?= $index ?>"><?= $l_ip_router.' ' ?></label>
-
 
963
                                                <span class="gw_number"><?= ($index+1) ?> </span>
680
								<label for="ext_gateway_<?= $index ?>"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
964
                                                <input style="width:100px" type="text" name="ip_gw_<?= $index ?>" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>"/>
-
 
965
                                                <label for="ext_weight_<?= $index ?>"><?= $l_gw_weight ?></label>
-
 
966
                                                <input style="width:20px" type="text" name="weight_<?= $index ?>" id="ext_weight_<?= $index ?>" value="<?= $network->weight ?>"/>
-
 
967
                                                <div class="actions actions-network" style="display:inline-block; width:11px">
-
 
968
                                                    <a style="display:block; text-align:center" href="#" class="remove-network" title="Supprimer ce réseau">-</a>
-
 
969
                                                </div><br>
-
 
970
                                            </div>
-
 
971
                                    <?php } endforeach; ?>
-
 
972
                                </div>
681
							</div>
973
                                <div class="actions actions-externals" style="margin: 0 auto; width:11px"><a id="add_external" href="#" class="add-external-network" title="Ajouter un réseau externe" <?php echo ($conf['PROXY'] === 'on' || $conf['PROXY'] === 'On')? 'hidden' : '' ?>>+</a></div>
-
 
974
                            </div>
682
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
975
							<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
683
						</div>
976
						</div>
684
					<? endforeach; ?>
-
 
685
				</div><div class="alcasar">
977
				</div><div class="alcasar">
686
					<div data-network-type="alcasar">
978
					<div data-network-type="alcasar">
687
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
979
						<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
688
						<div class="network-box">
980
						<div class="network-box">
689
							<!-- <div class="actions actions-externals">
-
 
690
								<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
-
 
691
							</div> -->
-
 
692
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
981
							<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
693
							<!-- <div class="actions actions-internals">
982
							<!-- <div class="actions actions-internals">
694
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
983
								<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
695
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
984
								<div><a href="#" class="add-internal-wifi-network">++</a></div>
696
							</div> -->
985
							</div> -->
697
						</div>
986
						</div>
698
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
987
						<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
699
					</div>
988
					</div>
700
				</div><div class="internals">
989
				</div><div id="internals_id" class="internals" data-count="1">
701
					<?php foreach ($internalNetworks as $network): ?>
990
					<?php foreach ($internalNetworks as $network): ?>
702
						<div data-network-type="internal">
991
						<div data-network-type="internal">
703
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
992
							<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
704
							<div class="network-box">
993
							<div class="network-box">
705
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
994
								<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
Line 708... Line 997...
708
							</div>
997
							</div>
709
						</div>
998
						</div>
710
					<? endforeach; ?>
999
					<? endforeach; ?>
711
				</div>
1000
				</div>
712
			</div>
1001
			</div>
-
 
1002
            <?php if ($ext_conf_error == true) {
-
 
1003
                echo '<span style="color:red">';
-
 
1004
                $temp = 0;
-
 
1005
                while (isset($ext_conf_error_list[$temp])) {
-
 
1006
                    echo $ext_conf_error_list[$temp].'<br>';
-
 
1007
                    $temp++;
-
 
1008
                }
-
 
1009
                echo '</span>';
-
 
1010
            }
-
 
1011
            else if (($choix === 'network_change') && ($modification_proxy || $modification_dns || $modification_network)) {
-
 
1012
                echo '<span id="change_success" style="color:green">'.$l_change_successful.'</span>';
-
 
1013
            }?>
713
			<hr>
1014
			<hr>
714
			<div style="text-align: center; margin: 5px">
1015
			<div style="text-align: center; margin: 5px">
715
				<input type="hidden" name="choix" value="network_change">
1016
				<input type="hidden" name="choix" value="network_change">
716
				<input type="submit" value="<?= $l_apply ?>">
1017
				<input type="submit" value="<?= $l_apply ?>">
717
			</div>
1018
			</div>
Line 739... Line 1040...
739
			foreach ($tab as $line) {
1040
			foreach ($tab as $line) {
740
				$fields = explode(' ', $line);
1041
				$fields = explode(' ', $line);
741
				$mac_addr = $fields[0];
1042
				$mac_addr = $fields[0];
742
				$ip_addr  = $fields[1];
1043
				$ip_addr  = $fields[1];
743
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
1044
				$info     = (isset($fields[2])) ? implode(' ', array_slice($fields, 2)) : ' ';
-
 
1045
 
744
				echo '<tr>';
1046
				echo '<tr>';
745
				echo "<td>$mac_addr</td>";
1047
				echo "<td>$mac_addr</td>";
746
				echo "<td>$ip_addr</td>";
1048
				echo "<td>$ip_addr</td>";
747
				if ($mac_addr !== $intif_mac_addr) {
1049
				if ($mac_addr !== $intif_mac_addr) {
748
					echo '<td>'.ltrim($info, '#').'</td>';
1050
					echo '<td>'.ltrim($info, '#').'</td>';