Subversion Repositories ALCASAR

Rev

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

Rev 1764 Rev 1822
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
$conf_files=array(CONF_FILE,ETHERS_FILE);
9
$conf_files=array(CONF_FILE,ETHERS_FILE);
-
 
10
$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_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
$network_modification=0;
10
foreach ($conf_files as $file){
13
foreach ($conf_files as $file){
11
if (!file_exists($file)){
14
if (!file_exists($file)){
12
	exit("Requested file ".$file." isn't present");}
15
	exit("Requested file ".$file." isn't present");}
13
if (!is_readable($file)){
16
if (!is_readable($file)){
14
	exit("Can't read the file ".$file);}
17
	exit("Can't read the file ".$file);}
15
}
18
}
16
 
19
 
-
 
20
 
17
# Choice of language
21
# Choice of language
18
$Language = 'en';
22
$Language = 'en';
19
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
23
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
20
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
24
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
21
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
25
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
Line 162... Line 166...
162
	} else {
166
	} else {
163
		fclose($sock);
167
		fclose($sock);
164
		return true;
168
		return true;
165
	}
169
	}
166
}
170
}
167
 
-
 
168
/***********************************
171
/***********************************
169
*	Read ALCASAR_CONF_FILE     *
172
* 	Update ALCASAR_CONF_FILE   *
170
************************************/
173
***********************************/
-
 
174
 
-
 
175
/*******************************************
-
 
176
*	Read ALCASAR_CONF_FILE Before     *
-
 
177
********************************************/
-
 
178
$ouvre=fopen(CONF_FILE,"r");
-
 
179
if ($ouvre){
-
 
180
	while (!feof ($ouvre))
-
 
181
	{
-
 
182
		$tampon = fgets($ouvre, 4096);
-
 
183
		if (strpos($tampon,"=")!==false){
-
 
184
			$tmp = explode("=",$tampon);
-
 
185
			$conf[$tmp[0]] = $tmp[1];
-
 
186
		}
-
 
187
	}
-
 
188
	fclose($ouvre);
-
 
189
}
-
 
190
	
-
 
191
		
-
 
192
if(isset($_POST['dns1']) && preg_match($reg_ip,$_POST['dns1']))
-
 
193
{
-
 
194
	file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'],'DNS1='.$_POST['dns1']."\n",file_get_contents(CONF_FILE)));
-
 
195
	$network_modification=1;
-
 
196
}
-
 
197
if(isset($_POST['dns2']) && preg_match($reg_ip,$_POST['dns2']))
-
 
198
{
-
 
199
	file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'],'DNS2='.$_POST['dns2']."\n",file_get_contents(CONF_FILE)));
-
 
200
	$network_modification=1;
-
 
201
}
-
 
202
 
-
 
203
if(isset($_POST['ip_public']) && preg_match($reg_ip_cidr,$_POST['ip_public']))
-
 
204
{
-
 
205
	file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'],'PUBLIC_IP='.$_POST['ip_public']."\n",file_get_contents(CONF_FILE)));
-
 
206
	$network_modification=1;
-
 
207
}
-
 
208
 
-
 
209
if(isset($_POST['ip_gw']) && preg_match($reg_ip,$_POST['ip_gw']))
-
 
210
{
-
 
211
	file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'],'GW='.$_POST['ip_gw']."\n",file_get_contents(CONF_FILE)));
-
 
212
	$network_modification=1;
-
 
213
}
-
 
214
 
-
 
215
if(isset($_POST['ip_private']) && preg_match($reg_ip_cidr,$_POST['ip_private']))
-
 
216
{
-
 
217
	file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'],'PRIVATE_IP='.$_POST['ip_private']."\n",file_get_contents(CONF_FILE)));
-
 
218
	$network_modification=1;
-
 
219
}
-
 
220
if($network_modification)
-
 
221
{
-
 
222
	exec("sudo /usr/local/bin/alcasar-conf.sh -apply");
-
 
223
	
-
 
224
}
-
 
225
 
-
 
226
 
-
 
227
 
-
 
228
 
-
 
229
/*******************************************
-
 
230
*	Read ALCASAR_CONF_FILE Updated     *
-
 
231
********************************************/
171
$ouvre=fopen(CONF_FILE,"r");
232
$ouvre=fopen(CONF_FILE,"r");
172
if ($ouvre){
233
if ($ouvre){
173
	while (!feof ($ouvre))
234
	while (!feof ($ouvre))
174
	{
235
	{
175
		$tampon = fgets($ouvre, 4096);
236
		$tampon = fgets($ouvre, 4096);
Line 205... Line 266...
205
		return false;
266
		return false;
206
	}
267
	}
207
}
268
}
208
</script>
269
</script>
209
</head>
270
</head>
-
 
271
 
-
 
272
 
210
<body>
273
<body>
211
<table width="100%" border="0" cellspacing="0" cellpadding="0">
274
<table width="100%" border="0" cellspacing="0" cellpadding="0">
212
	<tr><th><?php echo $l_network_title; ?></th></tr>
275
	<tr><th><?php echo $l_network_title; ?></th></tr>
213
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
276
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
214
</table>
277
</table>
Line 223... Line 286...
223
		echo " <img src='/images/state_error.gif'>";
286
		echo " <img src='/images/state_error.gif'>";
224
		$IP_PUB = "-.-.-.-";}
287
		$IP_PUB = "-.-.-.-";}
225
	?></legend>
288
	?></legend>
226
	<table>
289
	<table>
227
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
290
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
-
 
291
		<?php
-
 
292
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
228
		<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr>
293
		echo "<tr><td>".$l_ip_dns1." <input style='width:120px' type='text' name='dns1' value=".$conf["DNS1"]."/></td></tr>";
229
		<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr>
294
		echo "<tr><td>".$l_ip_dns2." <input style='width:120px' type='text' name='dns2' value=".$conf["DNS2"]."/></td></tr>";
-
 
295
		?>
230
	</table>
296
	</table>
231
	</fieldset>
297
	</fieldset>
232
	</td><td>
298
	</td><td>
233
	<fieldset>
299
	<fieldset>
234
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
300
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
235
	<table>
301
	<table>
-
 
302
		<?php
-
 
303
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
236
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr>
304
		echo "<tr><td>".$l_ip_adr." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
237
		<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr>
305
		echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
-
 
306
		?>
238
	</table>
307
	</table>
239
	</fieldset>
308
	</fieldset>
240
	</td><td>
309
	</td><td>
241
	<fieldset>
310
	<fieldset>
242
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
311
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
243
	<table>
312
	<table>
-
 
313
	<?php
-
 
314
	echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
244
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr>
315
	echo "<tr><td>".$l_ip_adr."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
-
 
316
	?>
245
	</table>
317
	</table>
246
	</fieldset>
318
	</fieldset>
247
	</td></tr>
319
	</td></tr>
-
 
320
	<?php 
-
 
321
	echo "<td><input type='submit' value='$l_apply' disabled></td>"; 	
-
 
322
	echo "</form>";
-
 
323
	?>
248
</table>
324
</table>
-
 
325
 
249
<table width="100%" border="0" cellspacing="0" cellpadding="0">
326
<table width="100%" border="0" cellspacing="0" cellpadding="0">
250
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
327
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
251
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
328
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
252
</table>
329
</table>
253
<table width="100%" border=1 cellspacing=0 cellpadding=0>
330
<table width="100%" border=1 cellspacing=0 cellpadding=0>