Subversion Repositories ALCASAR

Rev

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