Subversion Repositories ALCASAR

Rev

Rev 736 | Rev 841 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 richard 1
<?php
838 richard 2
/* written by steweb57 & Rexy */
318 richard 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_eth0_legend		= "Eth0 (Interface connectée à Internet)";
12
	$l_eth1_legend		= "Eth1 (Réseau de consultation)";
13
	$l_internet_legend	= "INTERNET";
14
	$l_ip_adr		= "Adresse IP";
15
	$l_ip_mask		= "Masque";
16
	$l_ip_router		= "Passerelle";
736 franck 17
	$l_ip_public		= "Adresse IP publique";
318 richard 18
	$l_ip_dns1		= "DNS1";
19
	$l_ip_dns2		= "DNS2";
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
	$l_ip_dns2		= "DNS2";
31
}
32
 
33
/********************************************************************
34
*	CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION			*
35
*********************************************************************/
355 richard 36
define ("ALCASAR_CHILLI", "/etc/chilli.conf");
612 richard 37
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
838 richard 38
 
318 richard 39
/********************************************************************
40
*				TEST DES FICHIERS DE CONFIGURATION					*
41
*********************************************************************/
42
//Test de présence et des droits en lecture des fichiers de configuration.
43
if (!file_exists(ALCASAR_CHILLI)){
44
	exit("Fichier de configuration ".ALCASAR_CHILLI." non présent");
45
}
654 richard 46
if (!file_exists(CONF_FILE)){
47
	exit("Fichier de configuration ".CONF_FILE." non présent");
318 richard 48
}
654 richard 49
if (!is_readable(ALCASAR_CHILLI)){
50
	exit("Vous n'avez pas les droits de lecture sur le fichier ".ALCASAR_CHILLI);
318 richard 51
}
654 richard 52
if (!is_readable(CONF_FILE)){
53
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
318 richard 54
}
55
 
56
// Fonction de test de connectivité internet
57
function internetTest(){
696 franck 58
	$host = "www.google.fr"; # Google Test
318 richard 59
	$port = "80";
60
	//var $num;	//non utilisé
61
	//var $error;	//non utilisé
62
 
63
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
64
		return false;
65
	} else {
66
		fclose($sock);
67
		return true;
68
	}
69
}
838 richard 70
/********************************************************
71
*		Lecture du fichier ALCASAR_CHILLI	*
72
*********************************************************/
318 richard 73
$ouvre=fopen(ALCASAR_CHILLI,"r");
74
if ($ouvre){
75
	while (!feof ($ouvre))
76
	{
77
		$tampon = fgets($ouvre, 4096);
78
		if (strpos($tampon,"=")!==false){
79
			$tmp = explode("=",$tampon);
80
			$chilli[$tmp[0]] = $tmp[1];
81
		}
82
	}
83
}else{
84
	exit("Erreur d'ouverture du fichier ".ALCASAR_CHILLI);
85
}
86
fclose($ouvre);
87
 
838 richard 88
/****************************************************************
89
*		Lecture du fichier CONF_FILE			*
90
*****************************************************************/
654 richard 91
$ouvre=fopen(CONF_FILE,"r");
318 richard 92
if ($ouvre){
93
	while (!feof ($ouvre))
94
	{
95
		$tampon = fgets($ouvre, 4096);
96
		if (strpos($tampon,"=")!==false){
97
			$tmp = explode("=",$tampon);
654 richard 98
			$conf[$tmp[0]] = $tmp[1];
318 richard 99
		}
100
	}
101
}else{
102
	exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
103
}
104
fclose($ouvre);
105
 
106
/************************
107
*	TO DO		*
108
*************************/
838 richard 109
//modification de la conf réseau  --> V3.0
318 richard 110
//gestion du dhcp (affichage,modification, ajout @static)
111
 
112
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
113
<html><!-- written by steweb57 / rexy -->
114
<head>
115
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
116
<title><?php echo $l_network_title; ?></title>
335 richard 117
<link rel="stylesheet" href="/css/style.css" type="text/css">
318 richard 118
</head>
119
<body>
120
<table width="100%" border="0" cellspacing="0" cellpadding="0">
353 richard 121
	<tr><th><?php echo $l_network_title; ?></th></tr>
318 richard 122
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
123
</table>
124
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
125
	<tr><td valign="middle" align="left">
126
	<fieldset>
127
	<legend><?php echo $l_internet_legend;
128
 	if (InternetTest()){
129
		echo " <img src='/images/state_ok.gif'> $l_enable";
130
		$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
131
	else 	{
132
		echo " <img src='/images/state_error.gif'> $l_disable";
133
		$IP_PUB = "-.-.-.-";}
134
	?></legend>
135
	<table>
136
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
654 richard 137
		<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr>
138
		<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr>
318 richard 139
	</table>
140
	</fieldset>
141
	</td><td>
142
	<fieldset>
143
	<legend><?php echo $l_eth0_legend; ?></legend>
144
	<table>
654 richard 145
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr>
146
		<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr>
318 richard 147
	</table>
148
	</fieldset>
149
	</td><td>
150
	<fieldset>
151
	<legend><?php echo $l_eth1_legend; ?></legend>
152
	<table>
654 richard 153
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr>
318 richard 154
	</table>
155
	</fieldset>
156
	</td></tr>
157
</table>
353 richard 158
<table width="100%" border="0" cellspacing="0" cellpadding="0">
356 richard 159
	<tr><th><?php echo $l_main_services; ?></th></tr>
353 richard 160
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
318 richard 161
</table>
162
</body>
163
</html>