Subversion Repositories ALCASAR

Rev

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

Rev 1707 Rev 1710
Line 1... Line 1...
1
<?php
1
<?php
2
/* written by steweb57 & Rexy */
2
/* written by steweb57 & Rexy */
3
 
3
 
4
/********************
4
/********************
5
* TEST CONF FILES   *
5
* CONF FILES EXIST  *
6
*********************/
6
*********************/
7
//define ("ALCASAR_CHILLI", "/etc/chilli.conf");
-
 
8
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
7
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
9
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
8
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
10
$conf_files=array(CONF_FILE,ETHERS_FILE);
9
$conf_files=array(CONF_FILE,ETHERS_FILE);
11
foreach ($conf_files as $file){
10
foreach ($conf_files as $file){
12
if (!file_exists($file)){
11
if (!file_exists($file)){
Line 78... Line 77...
78
case 'new_mac' :
77
case 'new_mac' :
79
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
78
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
80
		{
79
		{
81
		$tab=file(ETHERS_FILE);
80
		$tab=file(ETHERS_FILE);
82
		$insert="True";
81
		$insert="True";
83
		if ($tab)  # le fichier n'est pas vide
82
		if ($tab)  # the file isn't empty
84
			{
83
			{
85
			foreach ($tab as $line)  # verify that MAC or IP addresses doesn't exist
84
			foreach ($tab as $line)  # verify that MAC or IP addresses doesn't exist
86
				{
85
				{
87
				$field=explode(" ", $line);
86
				$field=explode(" ", $line);
88
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
87
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
Line 136... Line 135...
136
 
135
 
137
// Fonction de test de connectivité internet
136
// Fonction de test de connectivité internet
138
function internetTest(){
137
function internetTest(){
139
	$host = "www.google.fr"; # Google Test
138
	$host = "www.google.fr"; # Google Test
140
	$port = "80";
139
	$port = "80";
141
	//var $num;	//non utilisé
140
	//var $num;	//not used
142
	//var $error;	//non utilisé
141
	//var $error;	//not used
143
	
142
	
144
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
143
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
145
		return false;
144
		return false;
146
	} else {
145
	} else {
147
		fclose($sock);
146
		fclose($sock);
148
		return true;
147
		return true;
149
	}
148
	}
150
}
149
}
151
/********************************************************
-
 
152
*		Lecture du fichier ALCASAR_CHILLI	*
-
 
153
*		     (not need any more)		*
-
 
154
*********************************************************/
-
 
155
//$ouvre=fopen(ALCASAR_CHILLI,"r");
-
 
156
//if ($ouvre){
-
 
157
//	while (!feof ($ouvre))
-
 
158
//	{
-
 
159
//		$tampon = fgets($ouvre, 4096);
-
 
160
//		if (strpos($tampon,"=")!==false){
-
 
161
//			$tmp = explode("=",$tampon);
-
 
162
//			$chilli[$tmp[0]] = $tmp[1];
-
 
163
//		}
-
 
164
//	}
-
 
165
//}else{
-
 
166
//	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
-
 
167
//}
-
 
168
//fclose($ouvre);
-
 
169
 
150
 
170
/***********************************
151
/***********************************
171
*	Read ALCASAR_CONF_FILE     *
152
*	Read ALCASAR_CONF_FILE     *
172
************************************/
153
************************************/
173
$ouvre=fopen(CONF_FILE,"r");
154
$ouvre=fopen(CONF_FILE,"r");
Line 267... Line 248...
267
echo "<br>$l_DHCP_off_explain";
248
echo "<br>$l_DHCP_off_explain";
268
echo "</FORM>";
249
echo "</FORM>";
269
echo "</td></tr>";
250
echo "</td></tr>";
270
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
251
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
271
else { echo "</TABLE>"; }
252
else { echo "</TABLE>"; }
-
 
253
$maxsize=100000;
272
?>
254
?>
-
 
255
 
-
 
256
<table width="100%" border="0" cellspacing="0" cellpadding="0">
-
 
257
	<tr><th>Import de certificat</th></tr>
-
 
258
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
-
 
259
</table>
-
 
260
<table width="100%" border="1" cellspacing="0" cellpadding="0">
-
 
261
	<tr><td>
-
 
262
	<form method="post" action="network.php" enctype="multipart/form-data">
-
 
263
	Clé privée (.key): <input type="file" name="key"/><br/>
-
 
264
	Certificat (.crt):<input type="file" name="crt"/><br/>
-
 
265
	Server-chain (Recommandé : .crt):<input type="file" name="sc"/>
-
 
266
	<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $maxsize ?>" /><br/>
-
 
267
	<input type="submit" value="Valider"/>
-
 
268
	</form>
-
 
269
	</td><td>
-
 
270
	<form method="post" action="network.php">
-
 
271
	<input type="hidden" name="default"/>
-
 
272
	<input type="submit" value="Retourner aux certificats par défaut"/>
-
 
273
	</form>
-
 
274
	</td>
-
 
275
	</tr>
-
 
276
</table>
-
 
277
 
273
</body>
278
</body>
274
</html>
279
</html>
-
 
280
 
-
 
281
<?php
-
 
282
if(isset($_POST['default'])){
-
 
283
	echo "Retour au certificats par défaut";
-
 
284
	exec("sudo alcasar-defaultcert.sh");
-
 
285
}
-
 
286
if(isset($_POST['MAX_FILE_SIZE'])){
-
 
287
	echo "changement";
-
 
288
	$maxsize = 100000;
-
 
289
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
-
 
290
		$dest = "/tmp/";
-
 
291
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
-
 
292
		{
-
 
293
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
-
 
294
			{
-
 
295
				$scpath = "";
-
 
296
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
-
 
297
				{
-
 
298
					$scpath = $dest."server-chain.crt";
-
 
299
					move_uploaded_file($_FILES['key']['tmp_name'], $scpath);
-
 
300
				}
-
 
301
				$keypath = $dest."alcasar.key";
-
 
302
				$crtpath = $dest."alcasar.crt";
-
 
303
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
-
 
304
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
-
 
305
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
-
 
306
			}
-
 
307
		}
-
 
308
	}
-
 
309
}
-
 
310
?>
-
 
311