Subversion Repositories ALCASAR

Rev

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