Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
1 root 1
<?php 
2
/***************************************************************************
3
 *   Copyright (C) 2006 by phpSysInfo - A PHP System Information Script    *
4
 *   http://phpsysinfo.sourceforge.net/                                    *
5
 *                                                                         *
6
 *   This program is free software; you can redistribute it and/or modify  *
7
 *   it under the terms of the GNU General Public License as published by  *
8
 *   the Free Software Foundation; either version 2 of the License, or     *
9
 *   (at your option) any later version.                                   *
10
 *                                                                         *
11
 *   This program is distributed in the hope that it will be useful,       *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU General Public License for more details.                          *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU General Public License     *
17
 *   along with this program; if not, write to the                         *
18
 *   Free Software Foundation, Inc.,                                       *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20
 ***************************************************************************/
21
 
22
// $Id: vitals.php,v 1.32 2007/02/18 18:59:54 bigmichi1 Exp $
23
 
24
// xml_utilisateur()
25
 
26
function utilisateur () {
27
		$strResult = 0;
28
		// Déclaration des paramètres de connexion
29
		$host = "localhost";
30
		$DB_USER = "radius";
31
		$DB_RADIUS = "radius";
32
		$radiuspwd = "radius";
33
		// Connexion au serveur
34
		mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur");
35
		mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees");
36
		// Creation et envoi de la requete
37
		$query = "SELECT UserName FROM userinfo";
38
		$result = mysql_query($query);
39
		// Recuperation des resultats
40
		$strResult = mysql_num_rows($result);
41
		// Deconnexion de la base de donnees
42
		 mysql_close();
43
		return $strResult;
44
  }
45
 
46
function groupe () {
47
		$strResult = 0;
48
		// Déclaration des paramètres de connexion
49
		$host = "localhost";
50
		$DB_USER = "radius";
51
		$DB_RADIUS = "radius";
52
		$radiuspwd = "radius";
53
		// Connexion au serveur
54
		mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur");
55
		mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees");
56
		// Creation et envoi de la requete
57
		$query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";
58
		$result = mysql_query($query);
59
		// Recuperation des resultats
60
		$strResult = mysql_num_rows($result);
61
		// Deconnexion de la base de donnees
62
		 mysql_close();
63
		return $strResult;
64
  }
65
 
66
function xml_portail () {
67
	global $sysinfo;
68
 
69
	$_text = "  <Portail>\n"
70
//		. "    <Utilisateur>" . htmlspecialchars( $sysinfo->utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n"
71
		. "    <Utilisateur>" . htmlspecialchars( utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n"
72
		. "    <Groupe>" . htmlspecialchars( trim( groupe() ), ENT_QUOTES ) . "</Groupe>\n";
73
	$_text .= "  </Portail>\n";
74
 
75
	return $_text;
76
} 
77
 
78
// Fonction de test de connectivité internet
79
function internetTest(){
80
	$host = "www.google.fr";
81
	$port = "80";
82
	//var $num;	//non utilisé
83
	//var $error;	//non utilisé
84
 
85
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
86
		return false;
87
	} else {
88
		fclose($sock);
89
		return true;
90
	}
91
}
92
 
93
// html_portail()
94
function html_portail () {
95
	global $webpath;
96
	global $XPath;
97
	global $text;
98
 
99
	$file_version = "/var/www/html/VERSION";
100
	$handle = fopen ($file_version, "r");
101
	$VERSIONPORTAIL = fread ($handle, filesize ($file_version));
102
	fclose ($handle);
103
 
104
	$file_bl = "/var/www/html/VERSION-BL";
105
	$handle = fopen ($file_bl, "r");
106
	$VERSIONBL = fread ($handle, filesize ($file_bl));
107
	fclose ($handle);
108
	$nbr_user = utilisateur ();
109
	$nbr_grp  = groupe ();
110
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
111
	//$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");	
112
 
113
	if (InternetTest()){
114
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['internet_enable'];
115
	} else {
116
		$internet_status =  "<img src='/images/state_error.gif'>".$text['internet_disable'];
117
	}
118
 
119
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
120
		. "  <tr>\n"
121
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
122
		. "    <td><font size=\"-1\">" . $VERSIONPORTAIL . "</font></td>\n"
123
		. "  </tr>\n"
124
		. "  <tr>\n"
125
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
126
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
127
		. "  </tr>\n"
128
		. "  <tr>\n"
129
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
130
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
131
		. "  </tr>\n"
132
		. "  <tr>\n"
133
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
134
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
135
		. "  </tr>\n"
136
		/*. "  <tr>\n"
137
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['public-ip'] . "</font></td>\n"
138
		. "    <td><font size=\"-1\">" . $IP_PUB . "</font></td>\n"
139
		. "  </tr>\n"*/
140
		. "  <tr>\n"
141
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
142
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
143
		. "  </tr>\n"
144
		. "  <tr>\n"
145
		. "    <td valign=\"top\" colspan=\"2\"><font size=\"-1\"><a href=\"/certs/certificat_alcasar_ca.pem\">" . $text['ca'] . "</a></font></td>\n"
146
		. "  </tr>\n"
147
		. "</table>\n";
148
 
149
	return $_text;
150
} 
151
 
152
function wml_portail () {
153
	global $XPath;
154
	global $text;
155
 
156
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
157
		. "<p>" . $text['hostname'] . ":<br/>\n"
158
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
159
		. "<p>" . $text['ip'] . ":<br/>\n"
160
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
161
		. "<p>" . $text['kversion'] . ":<br/>\n"
162
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
163
		. "<p>" . $text['uptime'] . ":<br/>\n"
164
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
165
		. "<p>" . $text['users'] . ":<br/>"
166
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
167
		. "<p>" . $text['loadavg'] . ":<br/>"
168
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
169
		. "</card>\n";
170
 
171
	return $_text;
172
}
173
?>