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
/***************************************************************************
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";
34 richard 32
		$radiuspwd = "gLMmnOpk";
1 root 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";
34 richard 52
		$radiuspwd = "gLMmnOpk";
1 root 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");
34 richard 101
	$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
1 root 102
	fclose ($handle);
34 richard 103
	$version_stable = dns_get_record("version.alcasar.info",DNS_TXT);
104
	$AVAILABLEDVERSION = $version_stable[0]['txt'];
105
	$version_devel = dns_get_record("devel.alcasar.info",DNS_TXT);
106
	$DEVELVERSION = $version_devel[0]['txt'];
1 root 107
	$file_bl = "/var/www/html/VERSION-BL";
108
	$handle = fopen ($file_bl, "r");
109
	$VERSIONBL = fread ($handle, filesize ($file_bl));
110
	fclose ($handle);
111
	$nbr_user = utilisateur ();
112
	$nbr_grp  = groupe ();
113
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
114
 
115
	if (InternetTest()){
116
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['internet_enable'];
117
	} else {
118
		$internet_status =  "<img src='/images/state_error.gif'>".$text['internet_disable'];
119
	}
120
 
121
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
122
		. "  <tr>\n"
123
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
34 richard 124
		. "    <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
1 root 125
		. "  </tr>\n"
126
		. "  <tr>\n"
34 richard 127
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-stable'] . "</font></td>\n"
128
		. "    <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
129
		. "  </tr>\n"
130
		. "  <tr>\n"
131
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-devel'] . "</font></td>\n"
132
		. "    <td><font size=\"-1\">" . $DEVELVERSION . "</font></td>\n"
133
		. "  </tr>\n"
134
		. "  <tr>\n"
1 root 135
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
136
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
137
		. "  </tr>\n"
138
		. "  <tr>\n"
139
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
140
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
141
		. "  </tr>\n"
142
		. "  <tr>\n"
143
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
144
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
145
		. "  </tr>\n"
146
		. "  <tr>\n"
147
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
148
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
149
		. "  </tr>\n"
150
		. "  <tr>\n"
151
		. "    <td valign=\"top\" colspan=\"2\"><font size=\"-1\"><a href=\"/certs/certificat_alcasar_ca.pem\">" . $text['ca'] . "</a></font></td>\n"
152
		. "  </tr>\n"
153
		. "</table>\n";
154
 
155
	return $_text;
156
} 
157
 
158
function wml_portail () {
159
	global $XPath;
160
	global $text;
161
 
162
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
163
		. "<p>" . $text['hostname'] . ":<br/>\n"
164
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
165
		. "<p>" . $text['ip'] . ":<br/>\n"
166
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
167
		. "<p>" . $text['kversion'] . ":<br/>\n"
168
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
169
		. "<p>" . $text['uptime'] . ":<br/>\n"
170
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
171
		. "<p>" . $text['users'] . ":<br/>"
172
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
173
		. "<p>" . $text['loadavg'] . ":<br/>"
174
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
175
		. "</card>\n";
176
 
177
	return $_text;
178
}
179
?>