Subversion Repositories ALCASAR

Rev

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

Rev 2134 Rev 2265
Line 5... Line 5...
5
* READ CONF FILES   *
5
* READ CONF FILES   *
6
*********************/
6
*********************/
7
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
7
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
8
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
8
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
9
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
9
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
10
$conf_files=array(CONF_FILE,ETHERS_FILE);
10
$conf_files=array(CONF_FILE,ETHERS_FILE,DNS_LOCAL_FILE);
11
$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])$/';
11
$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])$/';
12
$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]))$/';
12
$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]))$/';
13
$network_modification=0;
13
$network_modification=0;
14
foreach ($conf_files as $file){
14
foreach ($conf_files as $file){
15
if (!file_exists($file)){
15
if (!file_exists($file)){
Line 51... Line 51...
51
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
51
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
52
	$l_default_cert		= "Revenir au certificat d'origine";
52
	$l_default_cert		= "Revenir au certificat d'origine";
53
	$l_import		= "Importer";
53
	$l_import		= "Importer";
54
	$l_current_certificate  = "Certificat actuel";
54
	$l_current_certificate  = "Certificat actuel";
55
	$l_validated		= "Validé par :";
55
	$l_validated		= "Validé par :";
56
 
-
 
57
} else {
56
} else {
58
	$l_network_title	= "Network configuration";
57
	$l_network_title	= "Network configuration";
59
	$l_extif_legend		= " (Internet connected interface)";
58
	$l_extif_legend		= " (Internet connected interface)";
60
	$l_intif_legend		= " (Private network)";
59
	$l_intif_legend		= " (Private network)";
61
	$l_internet_legend	= "INTERNET";
60
	$l_internet_legend	= "INTERNET";
Line 83... Line 82...
83
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
82
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
84
	$l_default_cert		= "Back to default certificate";
83
	$l_default_cert		= "Back to default certificate";
85
	$l_import		= "Import";
84
	$l_import		= "Import";
86
	$l_current_certificate  = "Current certificate";
85
	$l_current_certificate  = "Current certificate";
87
	$l_validated		= "Validated by :";
86
	$l_validated		= "Validated by :";
88
 
-
 
89
}
87
}
90
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
88
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
91
switch ($choix)
89
switch ($choix)
92
{
90
{
93
case 'DHCP_On' :
91
case 'DHCP_On' :
Line 101... Line 99...
101
		{
99
		{
102
		$tab=file(ETHERS_FILE);
100
		$tab=file(ETHERS_FILE);
103
		if ($tab)  # the file isn't empty
101
		if ($tab)  # the file isn't empty
104
			{
102
			{
105
			$insert="True";
103
			$insert="True";
-
 
104
			$new_mac_addr=trim($_POST['add_mac'],"\x00..\x20");
-
 
105
			$new_ip_addr=trim($_POST['add_ip'],"\x00..\x20");
106
			foreach ($tab as $line)  # verify that MAC or IP address doesn't exist
106
			foreach ($tab as $line)  # verify that MAC or IP address doesn't exist
107
				{
107
				{
108
				$field=explode(" ", $line);
108
				$field=explode(" ", $line);
109
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
109
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
110
				if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
110
				if (strcasecmp($new_mac_addr, $mac_addr) == 0)
111
					{
111
					{
112
					$insert="False";
112
					$insert="False";
113
					break;
113
					break;
114
					}
114
					}
115
				if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
115
				if (strcasecmp($new_ip_addr, $ip_addr) == 0)
116
					{
116
					{
117
					$insert="False";
117
					$insert="False";
118
					break;
118
					break;
119
					}
119
					}
120
				}
120
				}
121
			if ($insert == "True")
121
			if ($insert == "True")
122
				{
122
				{
123
				$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
123
				$line = $new_mac_addr . " " . $new_ip_addr . " #" . trim($_POST['info'],"\x00..\x20") . "\n";
124
				$pointeur=fopen(ETHERS_FILE,"a");
124
				$pointeur=fopen(ETHERS_FILE,"a");
125
				fwrite ($pointeur, $line);
125
				fwrite ($pointeur, $line);
126
				fclose ($pointeur);
126
				fclose ($pointeur);
127
				exec ("sudo /usr/bin/systemctl reload chilli");
127
				exec ("sudo /usr/bin/systemctl reload chilli");
128
				}
128
				}
Line 413... Line 413...
413
echo "<FORM name='new_host' action='network.php' method='POST'>";
413
echo "<FORM name='new_host' action='network.php' method='POST'>";
414
echo "<table cellspacing=2 cellpadding=3 border=1>";
414
echo "<table cellspacing=2 cellpadding=3 border=1>";
415
echo "<tr><th>$l_host_name<th>$l_ip_address";
415
echo "<tr><th>$l_host_name<th>$l_ip_address";
416
?>
416
?>
417
<td></td></tr>
417
<td></td></tr>
418
<tr><td>exemple : my_nas</td><td>exemple : 192.168.182.10</td><td></td></tr>
418
<tr><td>Ex. : my_nas</td><td>Ex. : 192.168.182.10</td><td></td></tr>
419
<tr><td><input type='text' name='add_host' size='17'></td>
419
<tr><td><input type='text' name='add_host' size='17'></td>
420
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td>
420
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td>
421
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td>
421
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td>
422
</tr></table>
422
</tr></table>
423
</form>
423
</form>