Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
1 root 1
<?php
2
/* written by steweb57 */
3
 
4
# Choice of language
5
$Language = 'en';
6
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
7
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
8
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
9
if($Language == 'fr'){
10
	$l_network_title	= "Configuration réseau";
11
	$l_network_title1	= "Gestion de la configuration réseau";
12
	$l_eth0_legend		= "Eth0 (Interface connectée à Internet)";
13
	$l_eth1_legend		= "Eth1 (Réseau de consultation)";
14
	$l_internet_legend	= "INTERNET";
15
	$l_ip_adr			= "Adresse IP";
16
	$l_ip_mask			= "Masque";
17
	$l_ip_router		= "Passerelle";
18
	$l_ip_public		= "Adresse IP public :";
19
	$l_ip_dns1			= "DNS1";
20
} else {
21
	$l_network_title	= "Network configuration";
22
	$l_eth0_legend		= "Eth0 (Internet connected interface)";
23
	$l_eth1_legend		= "Eth1 (Private network)";
24
	$l_internet_legend	= "INTERNET";
25
	$l_ip_adr			= "IP Address";
26
	$l_ip_mask			= "Mask";
27
	$l_ip_router		= "Router";
28
	$l_ip_public		= "Public IP address:";
29
	$l_ip_dns1			= "DNS1 :";
30
}
31
 
32
/********************************************************************
33
*	CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION			*
34
*********************************************************************/
35
 
36
define ("ALCASAR_CHILLI", "/etc/chilli/config");
37
define ("ALCASAR_ETH0", "/etc/sysconfig/network-scripts/ifcfg-eth0");
38
define ("ALCASAR_ETH1", "/etc/sysconfig/network-scripts/ifcfg-eth1");
39
 
40
/********************************************************************
41
*				TEST DES FICHIERS DE CONFIGURATION					*
42
*********************************************************************/
43
 
44
//Test de présence et des droits en lecture des fichiers de configuration.
45
if (!file_exists(ALCASAR_CHILLI)){
46
	exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
47
}
48
if (!file_exists(ALCASAR_ETH0)){
49
	exit("Fichier de configuration ".ALCASAR_ETH0." non présent");
50
}
51
if (!file_exists(ALCASAR_ETH0)){
52
	exit("Fichier de configuration ".ALCASAR_ETH1." non présent");
53
}
54
if (!is_readable(ALCASAR_ETH0)){
55
	exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH0);
56
}
57
if (!is_readable(ALCASAR_ETH0)){
58
	exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_ETH1);
59
}
60
 
61
/********************************************************************
62
*			Lecture du fichier ALCASAR_CHILLI						*
63
*********************************************************************/
64
//Lecture du fichier ALCASAR_ETH0
65
$ouvre=fopen(ALCASAR_CHILLI,"r");
66
if ($ouvre){
67
	while (!feof ($ouvre))
68
	{
69
		$tampon = fgets($ouvre, 4096);
70
		if (strpos($tampon,"=")!==false){
71
			$tmp = explode("=",$tampon);
72
			$chilli[$tmp[0]] = $tmp[1];
73
		}
74
	}
75
}else{
76
	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
77
}
78
fclose($ouvre);
79
 
80
/********************************************************************
81
*			Lecture du fichier ALCASAR_ETH0							*
82
*********************************************************************/
83
 
84
//Lecture du fichier ALCASAR_ETH0
85
$ouvre=fopen(ALCASAR_ETH0,"r");
86
if ($ouvre){
87
	while (!feof ($ouvre))
88
	{
89
		$tampon = fgets($ouvre, 4096);
90
		if (strpos($tampon,"=")!==false){
91
			$tmp = explode("=",$tampon);
92
			$eth0[$tmp[0]] = $tmp[1];
93
		}
94
	}
95
}else{
96
	exit("Erreur d'ouverture du fichier ".ALCASAR_ETH0);
97
}
98
fclose($ouvre);
99
 
100
/********************************************************************
101
*			Lecture du fichier ALCASAR_ETH1							*
102
*********************************************************************/
103
 
104
//Lecture du fichier ALCASAR_ETH1
105
$ouvre=fopen(ALCASAR_ETH1,"r");
106
if ($ouvre){
107
	while (!feof ($ouvre))
108
	{
109
		$tampon = fgets($ouvre, 4096);
110
		if (strpos($tampon,"=")!==false){
111
			$tmp = explode("=",$tampon);
112
			$eth1[$tmp[0]] = $tmp[1];
113
		}
114
	}
115
}else{
116
	exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
117
}
118
fclose($ouvre);
119
 
120
 
121
/********************************************************************
122
*			Recherche IP public										*
123
*********************************************************************/
124
$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");
125
 
126
 
127
 
128
/************************
129
*		TO DO			*
130
*************************/
131
//modification de la conf réseau, cmd : ifconfig eth0 .....
132
//synhro de la modification réseau dans les différentes couches d'alcasar
133
//gestion du dhcp (affichage,modification, ajout @static)
134
 
135
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
136
<html><!-- written by steweb57 -->
137
<head>
138
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
139
<title><?php echo $l_network_title; ?></title>
140
<link rel="stylesheet" href="../css/style.css" type="text/css">
141
</head>
142
<body>
143
<table width="100%" border="0" cellspacing="0" cellpadding="0">
144
	<tr><th><?php echo $l_network_title1; ?></th></tr>
145
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
146
</table>
147
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
148
	<tr><td valign="middle" align="left">
149
	<fieldset>
150
	<legend><?php echo $l_eth0_legend; ?></legend>
151
	<table>
152
		<tr><td><?php echo $l_ip_adr; ?></td><td><?php echo $eth0["IPADDR"]; ?></td></tr>
153
		<tr><td><?php echo $l_ip_mask; ?></td><td><?php echo $eth0["NETMASK"]; ?></td></tr>
154
		<tr><td><?php echo $l_ip_router; ?></td><td><?php echo $eth0["GATEWAY"]; ?></td></tr>
155
	</table>
156
	</fieldset>
157
	<br />
158
	<fieldset>
159
	<legend><?php echo $l_eth1_legend; ?></legend>
160
	<table>
161
		<tr><td><?php echo $l_ip_adr; ?></td><td><?php echo $eth1["IPADDR"]; ?></td></tr>
162
		<tr><td><?php echo $l_ip_mask; ?></td><td><?php echo $eth1["NETMASK"]; ?></td></tr>
163
	</table>
164
	</fieldset>
165
	<br />
166
	<fieldset>
167
	<legend><?php echo $l_internet_legend; ?></legend>
168
	<table>
169
		<tr><td> <?php echo $l_ip_public." ".$IP_PUB;?></td></tr>
170
		<tr><td><?php echo $l_ip_dns1." ".$eth0["DNS1"]; ?></td></tr>
171
	</table>
172
	</fieldset>
173
	<br />
174
	</td></tr>
175
</table>
176
</body>
177
</html>