Subversion Repositories ALCASAR

Rev

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

Rev 2265 Rev 2274
Line 4... Line 4...
4
/********************
4
/********************
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 ("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
9
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
10
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
10
$conf_files=array(CONF_FILE,ETHERS_FILE,DNS_LOCAL_FILE);
11
$conf_files=array(CONF_FILE,ETHERS_FILE,ETHERS_INFO_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])$/';
12
$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]))$/';
13
$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;
14
$network_modification=0;
14
foreach ($conf_files as $file){
15
foreach ($conf_files as $file){
15
if (!file_exists($file)){
16
if (!file_exists($file)){
Line 118... Line 119...
118
					break;
119
					break;
119
					}
120
					}
120
				}
121
				}
121
			if ($insert == "True")
122
			if ($insert == "True")
122
				{
123
				{
123
				$line = $new_mac_addr . " " . $new_ip_addr . " #" . trim($_POST['info'],"\x00..\x20") . "\n";
124
				$line = $new_mac_addr . " " . $new_ip_addr . "\n";
124
				$pointeur=fopen(ETHERS_FILE,"a");
125
				$pointeur=fopen(ETHERS_FILE,"a");
125
				fwrite ($pointeur, $line);
126
				fwrite ($pointeur, $line);
126
				fclose ($pointeur);
127
				fclose ($pointeur);
-
 
128
				$pointeur=fopen(ETHERS_INFO_FILE,"a");
-
 
129
				fwrite ($pointeur, $line);
-
 
130
				fclose ($pointeur);
-
 
131
				$line = $new_mac_addr . " " . $new_ip_addr . " #" . trim($_POST['info'],"\x00..\x20") . "\n";
127
				exec ("sudo /usr/bin/systemctl reload chilli");
132
				exec ("sudo /usr/bin/systemctl reload chilli");
128
				}
133
				}
129
			}
134
			}
130
		}
135
		}
131
	break;
136
	break;
Line 134... Line 139...
134
		{
139
		{
135
		if ($value == 'on')
140
		if ($value == 'on')
136
			{
141
			{
137
			$ether_file=ETHERS_FILE;
142
			$ether_file=ETHERS_FILE;
138
			exec("/bin/sed -i \"/^$key/d\" $ether_file"); 
143
			exec("/bin/sed -i \"/^$key/d\" $ether_file"); 
-
 
144
			$ether_file=ETHERS_INFO_FILE;
-
 
145
			exec("/bin/sed -i \"/^$key/d\" $ether_file"); 
139
			exec ("sudo /usr/bin/systemctl reload chilli");
146
			exec ("sudo /usr/bin/systemctl reload chilli");
140
			}
147
			}
141
		}
148
		}
142
	break;
149
	break;
143
case 'new_host' :
150
case 'new_host' :