Subversion Repositories ALCASAR

Rev

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

Rev 2976 Rev 3031
Line 18... Line 18...
18
		$strResult = $result->num_rows;
18
		$strResult = $result->num_rows;
19
		// Deconnexion de la base de donnees
19
		// Deconnexion de la base de donnees
20
		$mysqli->close();
20
		$mysqli->close();
21
		return $strResult;
21
		return $strResult;
22
 }
22
 }
-
 
23
// router test
-
 
24
function routerTest($host) {
-
 
25
	$port = 80;
-
 
26
 
-
 
27
	$test = exec("ping -c 3 $host", $out, $res);
-
 
28
 
-
 
29
	return ($res == 0) ? true : false;
-
 
30
}
23
 
31
 
24
// Internet test
32
// Internet test
25
function internetTest() {
33
function internetTest() {
26
	$host  = 'www.google.com';
34
	$host  = 'www.google.com';
27
	$host2 = 'www.alcasar.net';
35
	$host2 = 'www.alcasar.net';
Line 68... Line 76...
68
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
76
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
69
	}
77
	}
70
if ($Language === 'fr') {
78
if ($Language === 'fr') {
71
	$locale_time = "fr_FR";
79
	$locale_time = "fr_FR";
72
	$l_title = "Bienvenue dans l'ACC (ALCASAR Control Center)";
80
	$l_title = "Bienvenue dans l'ACC (ALCASAR Control Center)";
73
	$l_internet_link = "Connexion Internet";
81
	$l_internet_link = "Accès";
-
 
82
	$l_lan = "LAN";
-
 
83
	$l_router = "Routeur";
-
 
84
	$l_DNS = "DNS";
74
	$l_enable = "Active";
85
	$l_enable = "Activé";
75
	$l_disable = "Désactivée";
86
	$l_disable = "Désactivé";
76
	$l_version = "Version instalée";
87
	$l_version = "Version instalée";
77
	$l_available = "Version disponible";
88
	$l_available = "Version disponible";
78
	$l_users = "Nombre d'utilisateurs / connectés";
89
	$l_users = "Nombre d'utilisateurs / connectés";
79
	$l_groups = "Nombre de groupes";
90
	$l_groups = "Nombre de groupes";
80
	$l_system_date = "Date du système";
91
	$l_system_date = "Date du système";
81
}
92
}
82
else if ($Language === 'es') {
93
else if ($Language === 'es') {
83
	$locale_time = "es_ES";
94
	$locale_time = "es_ES";
84
	$l_title = "Bienvenido al ACC (Centro de Control de ALCASAR)";
95
	$l_title = "Bienvenido al ACC (Centro de Control de ALCASAR)";
85
	$l_internet_link = "Conexión a Internet";
96
	$l_internet_link = "Acceso";
86
	$l_enable = "Activo";
97
	$l_enable = "Activo";
-
 
98
	$l_lan = "LAN";
-
 
99
	$l_router = "Rúter";
-
 
100
	$l_DNS = "DNS";
87
	$l_disable = "Desactivado";
101
	$l_disable = "Desactivado";
88
	$l_version = "Versión instalada";
102
	$l_version = "Versión instalada";
89
	$l_available = "Versión disponible";
103
	$l_available = "Versión disponible";
90
	$l_users = "Número de usuarios / conectados";
104
	$l_users = "Número de usuarios / conectados";
91
	$l_groups = "Número de grupos";
105
	$l_groups = "Número de grupos";
92
	$l_system_date = "Fecha del sistema";
106
	$l_system_date = "Fecha del sistema";
93
}
107
}
94
else {
108
else {
95
	$locale_time = "en_EN";
109
	$locale_time = "en_EN";
96
	$l_title = "Welcome in ACC (ALCASAR Control Center)";
110
	$l_title = "Welcome in ACC (ALCASAR Control Center)";
97
	$l_internet_link = "Internet connection";
111
	$l_internet_link = "Access";
-
 
112
	$l_lan = "LAN";
-
 
113
	$l_router = "Router";
-
 
114
	$l_DNS = "DNS";
98
	$l_enable = "Enabled";
115
	$l_enable = "Enabled";
99
	$l_disable = "Disabled";
116
	$l_disable = "Disabled";
100
	$l_version = "Installed version";
117
	$l_version = "Installed version";
101
	$l_available = "Available version";
118
	$l_available = "Available version";
102
	$l_users = "Number of users / connected";
119
	$l_users = "Number of users / connected";
Line 115... Line 132...
115
		<div class ="panel-row">
132
		<div class ="panel-row">
116
			<div class="panel-cell">
133
			<div class="panel-cell">
117
<?
134
<?
118
// Read CONF_FILE
135
// Read CONF_FILE
119
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
136
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
120
$file_conf = fopen(CONF_FILE, 'r');
137
	$file_conf = fopen(CONF_FILE, 'r');
121
if (!$file_conf) {
138
	if (!$file_conf) {
122
	exit('Error opening the file '.CONF_FILE);}
139
		exit('Error opening the file '.CONF_FILE);}
123
while (!feof($file_conf)) {
140
	while (!feof($file_conf)) {
124
	$buffer = fgets($file_conf, 4096);
141
		$buffer = fgets($file_conf, 4096);
125
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
142
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
126
		$tmp = explode('=', $buffer, 2);
143
			$tmp = explode('=', $buffer, 2);
127
		$conf[trim($tmp[0])] = trim($tmp[1]);
144
			$conf[trim($tmp[0])] = trim($tmp[1]);
-
 
145
		}
128
	}
146
	}
129
}
-
 
130
fclose($file_conf);
147
	fclose($file_conf);
131
// Get current version
148
// Get current version
132
$INSTALLEDVERSION = $conf['VERSION'];
149
$INSTALLEDVERSION = $conf['VERSION'];
133
setlocale (LC_TIME, $locale_time);
150
setlocale (LC_TIME, $locale_time);
134
$SYSTEM_DATE = strftime('%A, %e %B %Y, %T %Z');
151
$SYSTEM_DATE = strftime('%A, %e %B %Y, %T %Z');
135
$nb_users = request ('user');
152
$nb_users = request ('user');
136
$nb_groups  = request ('group');
153
$nb_groups  = request ('group');
137
$nb_online_users = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
154
$nb_online_users = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
-
 
155
 
-
 
156
// LAN Status (Is connected and has IP)
-
 
157
$tmp = file_get_contents("/sys/class/net/".$conf['EXTIF']."/operstate");
-
 
158
if(strcmp($tmp,"up")==1){
-
 
159
	$lan_status =  $l_lan." : ".$l_enable." <img src='/images/state_ok.gif'> ";	
-
 
160
} else{
-
 
161
	$lan_status =  $l_lan." : ".$l_disable." <img src='/images/state_error.gif'> ";
-
 
162
}
-
 
163
 
-
 
164
// Router status
-
 
165
$mask = strrchr($conf['PUBLIC_IP'],"/");
-
 
166
if(routerTest($conf['GW']) && ($conf['GW'].$mask != $conf['PUBLIC_IP'])){
-
 
167
	$router_status =  $l_router." : ".$l_enable." <img src='/images/state_ok.gif'> ";	
-
 
168
} else{
-
 
169
	$router_status =  $l_router." : ".$l_disable." <img src='/images/state_error.gif'> ";
-
 
170
}
-
 
171
 
-
 
172
// Internet status
138
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
173
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
139
	$internet_status =  "<img src='/images/state_ok.gif'>".$l_enable;
174
	$internet_status =  $l_DNS." : ".$l_enable." <img src='/images/state_ok.gif'> ";
140
	$version = dns_get_record("version.alcasar.net",DNS_TXT);
175
	$version = dns_get_record("version.alcasar.net",DNS_TXT);
141
	if (!empty($version)) {
176
	if (!empty($version)) {
142
		$AVAILABLEDVERSION = $version[0]['txt'];
177
		$AVAILABLEDVERSION = $version[0]['txt'];
143
	} else {
178
	} else {
144
		$AVAILABLEDVERSION = "-";
179
		$AVAILABLEDVERSION = "-";
145
	}
180
	}
146
} else {
181
} else {
147
	$internet_status =  "<img src='/images/state_error.gif'>".$l_disable;
182
	$internet_status =  $l_DNS." : ".$l_disable." <img src='/images/state_error.gif'> ";
148
	$AVAILABLEDVERSION = "-";
183
	$AVAILABLEDVERSION = "-";
149
}
184
}
-
 
185
 
150
echo $l_internet_link."	: ".$internet_status."<br>\n";
186
echo $l_internet_link."\t".$lan_status.$router_status.$internet_status."<br>\n";
151
echo $l_version."	: ".$INSTALLEDVERSION."<br>\n";
187
echo $l_version."	: ".$INSTALLEDVERSION."<br>\n";
152
echo $l_available."	: ".$AVAILABLEDVERSION."<br>\n";
188
echo $l_available."	: ".$AVAILABLEDVERSION."<br>\n";
153
echo "</div><div class=\"panel-cell\">";
189
echo "</div><div class=\"panel-cell\">";
154
echo $l_users."		: ".$nb_users." / ".$nb_online_users."<br>\n";
190
echo $l_users."		: ".$nb_users." / ".$nb_online_users."<br>\n";
155
echo $l_groups."	: ".$nb_groups."<br>\n";
191
echo $l_groups."	: ".$nb_groups."<br>\n";