Subversion Repositories ALCASAR

Rev

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

Rev 859 Rev 861
Line 1... Line 1...
1
<?php
1
<?php
2
/* written by steweb57 & Rexy */
2
/* written by steweb57 & Rexy */
3
 
3
 
4
/***************************************
4
/********************
5
* CONSTANTES AVEC CHEMINS DES FICHIERS *
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
 
-
 
11
/********************
-
 
12
* TEST DES FICHIERS *
-
 
13
*********************/
-
 
14
//Test de présence et des droits en lecture des fichiers de configuration.
-
 
15
if (!file_exists(ALCASAR_CHILLI)){
10
$conf_files=array(ALCASAR_CHILLI,CONF_FILE,ETHERS_FILE);
16
	exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
-
 
17
}
-
 
18
if (!is_readable(ALCASAR_CHILLI)){
11
foreach ($conf_files as $file){
19
	exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_CHILLI);
-
 
20
}
-
 
21
if (!file_exists(CONF_FILE)){
12
if (!file_exists($file)){
22
	exit("Fichier de configuration ".CONF_FILE." non présent");
13
	exit("Requested file ".$file." isn't present");}
23
}
-
 
24
if (!is_readable(CONF_FILE)){
14
if (!is_readable($file)){
25
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
-
 
26
}
-
 
27
if (!file_exists(ETHERS_FILE)){
-
 
28
	exit("Fichier de configuration ".ETHERS_FILE." non présent");
-
 
29
}
-
 
30
if (!is_readable(ETHERS_FILE)){
15
	exit("Can't read the file ".$file);}
31
	exit("Vous n'avez pas les droits de lecture sur le fichier ".ETHERS_FILE);
-
 
32
}
16
}
33
 
17
 
34
# Choice of language
18
# Choice of language
35
$Language = 'en';
19
$Language = 'en';
36
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
20
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
Line 45... Line 29...
45
	$l_ip_mask		= "Masque";
29
	$l_ip_mask		= "Masque";
46
	$l_ip_router		= "Passerelle";
30
	$l_ip_router		= "Passerelle";
47
	$l_ip_public		= "Adresse IP publique";
31
	$l_ip_public		= "Adresse IP publique";
48
	$l_ip_dns1		= "DNS1";
32
	$l_ip_dns1		= "DNS1";
49
	$l_ip_dns2		= "DNS2";
33
	$l_ip_dns2		= "DNS2";
50
	$l_dhcp_title		= "Serveur DHCP";
34
	$l_dhcp_title		= "Service DHCP";
51
	$l_dhcp_on		= "Le service DHCP est actuellement activé";
35
	$l_DHCP_full		= "DHCP complet";
-
 
36
	$l_DHCP_half		= "Demi DHCP ";
-
 
37
	$l_DHCP_off		= "Sans DHCP";
52
	$l_dhcp_off		= "Le service DHCP est actuellement arrêté";
38
	$l_DHCP_full_explain	= "DHCP complet";
53
	$l_switch_on		= "Démarrer le service DHCP";
39
	$l_DHCP_half_explain	= "Demi DHCP ";
54
	$l_switch_off		= "Arrêter le service DHCP";
40
	$l_DHCP_off_explain	= "Sans DHCP";
55
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
41
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
56
	$l_mac_address		= "Adresse MAC";
42
	$l_mac_address		= "Adresse MAC";
57
	$l_ip_address		= "Adresse IP";
43
	$l_ip_address		= "Adresse IP";
58
	$l_mac_del		= "Supprimer de la liste";
44
	$l_mac_del		= "Supprimer de la liste";
59
	$l_add_to_list		= "Ajouter";
45
	$l_add_to_list		= "Ajouter";
60
	$l_submit		= "Appliquer";
46
	$l_apply		= "Appliquer les changements";
61
 
47
 
62
} else {
48
} else {
63
	$l_network_title	= "Network configuration";
49
	$l_network_title	= "Network configuration";
64
	$l_eth0_legend		= "Eth0 (Internet connected interface)";
50
	$l_eth0_legend		= "Eth0 (Internet connected interface)";
65
	$l_eth1_legend		= "Eth1 (Private network)";
51
	$l_eth1_legend		= "Eth1 (Private network)";
Line 68... Line 54...
68
	$l_ip_mask		= "Mask";
54
	$l_ip_mask		= "Mask";
69
	$l_ip_router		= "Gateway";
55
	$l_ip_router		= "Gateway";
70
	$l_ip_public		= "Public IP address";
56
	$l_ip_public		= "Public IP address";
71
	$l_ip_dns1		= "DNS1 :";
57
	$l_ip_dns1		= "DNS1 :";
72
	$l_ip_dns2		= "DNS2";
58
	$l_ip_dns2		= "DNS2";
73
	$l_dhcp_title		= "DHCP server";
59
	$l_dhcp_title		= "DHCP service";
-
 
60
	$l_DHCP_full		= "Full DHCP";
74
	$l_dhcp_on		= "The DHCP service is enabled";
61
	$l_DHCP_half		= "Half DHCP ";
75
	$l_dhcp_off		= "The DHCP service is disabled";
62
	$l_DHCP_off		= "No DHCP";
-
 
63
	$l_DHCP_full_explain	= "Full DHCP";
76
	$l_switch_on		= "Start the DHCP service";
64
	$l_DHCP_half_explain	= "Half DHCP ";
77
	$l_switch_off		= "Stop the DHCP service";
65
	$l_DHCP_off_explain	= "No DHCP";
78
	$l_static_dhcp_title	= "Static IP addresses reservation";
66
	$l_static_dhcp_title	= "Static IP addresses reservation";
79
	$l_mac_address		= "MAC Address";
67
	$l_mac_address		= "MAC Address";
80
	$l_ip_address		= "IP Address";
68
	$l_ip_address		= "IP Address";
81
	$l_mac_del		= "Delete from list";
69
	$l_mac_del		= "Delete from list";
82
	$l_add_to_list		= "Add";
70
	$l_add_to_list		= "Add";
83
	$l_submit		= "Apply";
71
	$l_apply		= "Apply changes";
84
}
72
}
85
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
73
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
86
switch ($choix)
74
switch ($choix)
87
{
75
{
88
case 'DHCP_On' :
76
case 'DHCP_Full' :
89
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -on");
77
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -full");
90
	break;
78
	break;
91
case 'DHCP_Off' :
79
case 'DHCP_Off' :
92
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -off");
80
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -off");
93
	break;
81
	break;
-
 
82
case 'DHCP_Half' :
-
 
83
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -half");
-
 
84
	break;
94
case 'new_mac' :
85
case 'new_mac' :
95
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
86
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
96
		{
87
		{
97
		$tab=file(ETHERS_FILE);
88
		$tab=file(ETHERS_FILE);
98
		$insert="True";
89
		$insert="True";
Line 180... Line 171...
180
}else{
171
}else{
181
	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
172
	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
182
}
173
}
183
fclose($ouvre);
174
fclose($ouvre);
184
 
175
 
185
/****************************************************************
176
/***********************************
186
*		Lecture du fichier CONF_FILE			*
177
*	Read ALCASAR_CONF_FILE     *
187
*****************************************************************/
178
************************************/
188
$ouvre=fopen(CONF_FILE,"r");
179
$ouvre=fopen(CONF_FILE,"r");
189
if ($ouvre){
180
if ($ouvre){
190
	while (!feof ($ouvre))
181
	while (!feof ($ouvre))
191
	{
182
	{
192
		$tampon = fgets($ouvre, 4096);
183
		$tampon = fgets($ouvre, 4096);
Line 256... Line 247...
256
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
247
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
257
</table>
248
</table>
258
<table width="100%" border=1 cellspacing=0 cellpadding=0>
249
<table width="100%" border=1 cellspacing=0 cellpadding=0>
259
<tr><td valign="middle" align="left">
250
<tr><td valign="middle" align="left">
260
<?
251
<?
261
if (strncmp ($conf["DHCP"],"on",2) == 0)
252
$dhcp_state=trim($conf["DHCP"]);
262
 	{
-
 
263
	echo "<CENTER><H3>$l_dhcp_on</H3></CENTER>";
253
echo "<CENTER><H3>${"l_DHCP_".$dhcp_state}</H3></CENTER>";
264
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
254
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
265
	echo "<input type=hidden name='choix' value=\"DHCP_Off\">";
255
echo "<select name='choix'>";
266
	echo "<input type=submit value=\"$l_switch_off\">";
256
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
267
	}
-
 
268
else
-
 
269
	{
-
 
270
	echo "<CENTER><H3>$l_dhcp_off</H3></CENTER>";
257
echo "<option value=\"DHCP_Half\" ";if (!strcmp($dhcp_state,"half")) echo "selected";echo ">$l_DHCP_half";
271
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
258
echo "<option value=\"DHCP_Full\" ";if (!strcmp($dhcp_state,"full")) echo "selected";echo ">$l_DHCP_full";
-
 
259
echo "</select>";
272
	echo "<input type=hidden name='choix' value=\"DHCP_On\">";
260
echo "<input type=submit value='$l_apply'>";
273
	echo "<input type=submit value=\"$l_switch_on\">";
261
echo "<td align='center'>";
-
 
262
echo "$l_DHCP_off : $l_DHCP_off_explain<br>$l_DHCP_half : $l_DHCP_half_explain<br>$l_DHCP_full : $l_DHCP_full_explain";
274
	}
263
echo "</td>";
275
echo "</FORM>";
264
echo "</FORM>";
276
echo "</td></tr>";
265
echo "</td></tr>";
277
echo "</TABLE>";
-
 
278
if (strncmp($conf["DHCP"],"on",2) == 0) require ('network2.php');
266
if (strncmp($conf["DHCP"],"full",2) == 0) { require ('network2.php');}
-
 
267
else { echo "</TABLE>"; }
279
?>
268
?>
280
</BODY>
-
 
281
</body>
269
</body>
282
</html>
270
</html>