Subversion Repositories ALCASAR

Rev

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

Rev 1493 Rev 1578
Line 2... Line 2...
2
/* written by steweb57 & Rexy */
2
/* written by steweb57 & Rexy */
3
 
3
 
4
/********************
4
/********************
5
* TEST CONF FILES   *
5
* TEST CONF FILES   *
6
*********************/
6
*********************/
7
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
7
//define ("ALCASAR_CHILLI", "/etc/chilli.conf");
8
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
8
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
9
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
9
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
10
$conf_files=array(ALCASAR_CHILLI,CONF_FILE,ETHERS_FILE);
10
$conf_files=array(CONF_FILE,ETHERS_FILE);
11
foreach ($conf_files as $file){
11
foreach ($conf_files as $file){
12
if (!file_exists($file)){
12
if (!file_exists($file)){
13
	exit("Requested file ".$file." isn't present");}
13
	exit("Requested file ".$file." isn't present");}
14
if (!is_readable($file)){
14
if (!is_readable($file)){
15
	exit("Can't read the file ".$file);}
15
	exit("Can't read the file ".$file);}
Line 102... Line 102...
102
			{
102
			{
103
			$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
103
			$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
104
			$pointeur=fopen(ETHERS_FILE,"a");
104
			$pointeur=fopen(ETHERS_FILE,"a");
105
			fwrite ($pointeur, $line);
105
			fwrite ($pointeur, $line);
106
			fclose ($pointeur);
106
			fclose ($pointeur);
107
			exec ("sudo service chilli restart");
107
			exec ("/usr/bin/systemctl reload chilli");
108
			}
108
			}
109
		}
109
		}
110
	break;
110
	break;
111
case 'del_mac' :
111
case 'del_mac' :
112
	$tab=file(ETHERS_FILE);
112
	$tab=file(ETHERS_FILE);
Line 127... Line 127...
127
					}
127
					}
128
				}
128
				}
129
			if (! $remove_line) {fwrite($pointeur,$line);}
129
			if (! $remove_line) {fwrite($pointeur,$line);}
130
			}
130
			}
131
		fclose($pointeur);
131
		fclose($pointeur);
132
		# exec ("sudo service chilli restart");
132
		exec ("sudo /usr/bin/systemctl reload chilli");
133
		}
133
		}
134
	break;
134
	break;
135
}
135
}
136
 
136
 
137
// Fonction de test de connectivité internet
137
// Fonction de test de connectivité internet
Line 148... Line 148...
148
		return true;
148
		return true;
149
	}
149
	}
150
}
150
}
151
/********************************************************
151
/********************************************************
152
*		Lecture du fichier ALCASAR_CHILLI	*
152
*		Lecture du fichier ALCASAR_CHILLI	*
-
 
153
*		     (not need any more)		*
153
*********************************************************/
154
*********************************************************/
154
$ouvre=fopen(ALCASAR_CHILLI,"r");
155
//$ouvre=fopen(ALCASAR_CHILLI,"r");
155
if ($ouvre){
156
//if ($ouvre){
156
	while (!feof ($ouvre))
157
//	while (!feof ($ouvre))
157
	{
158
//	{
158
		$tampon = fgets($ouvre, 4096);
159
//		$tampon = fgets($ouvre, 4096);
159
		if (strpos($tampon,"=")!==false){
160
//		if (strpos($tampon,"=")!==false){
160
			$tmp = explode("=",$tampon);
161
//			$tmp = explode("=",$tampon);
161
			$chilli[$tmp[0]] = $tmp[1];
162
//			$chilli[$tmp[0]] = $tmp[1];
162
		}
163
//		}
163
	}
164
//	}
164
}else{
165
//}else{
165
	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
166
//	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
166
}
167
//}
167
fclose($ouvre);
168
//fclose($ouvre);
168
 
169
 
169
/***********************************
170
/***********************************
170
*	Read ALCASAR_CONF_FILE     *
171
*	Read ALCASAR_CONF_FILE     *
171
************************************/
172
************************************/
172
$ouvre=fopen(CONF_FILE,"r");
173
$ouvre=fopen(CONF_FILE,"r");
Line 193... Line 194...
193
<html><!-- written by steweb57 & rexy -->
194
<html><!-- written by steweb57 & rexy -->
194
<head>
195
<head>
195
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
196
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
196
<title><?php echo $l_network_title; ?></title>
197
<title><?php echo $l_network_title; ?></title>
197
<link rel="stylesheet" href="/css/style.css" type="text/css">
198
<link rel="stylesheet" href="/css/style.css" type="text/css">
-
 
199
<script type="text/javascript">
-
 
200
function MAC_Control(formulaire){
-
 
201
/*MAC control (upper case and '-' separator*/
-
 
202
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
-
 
203
	if (regex1.test(document.forms[formulaire].add_mac.value)){
-
 
204
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
-
 
205
		return true;
-
 
206
	} else {
-
 
207
		alert("Invalid MAC address");//non internationnalisé
-
 
208
		return false;
-
 
209
	}
-
 
210
}
-
 
211
</script>
198
</head>
212
</head>
199
<body>
213
<body>
200
<table width="100%" border="0" cellspacing="0" cellpadding="0">
214
<table width="100%" border="0" cellspacing="0" cellpadding="0">
201
	<tr><th><?php echo $l_network_title; ?></th></tr>
215
	<tr><th><?php echo $l_network_title; ?></th></tr>
202
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
216
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>