Subversion Repositories ALCASAR

Rev

Rev 65 | 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/                                    *
59 richard 5
 *   Copyright (C) 2010 by 3abtux & Rexy for ALCASAR                       *                                                *
1 root 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
 
59 richard 26
function request ($texte) {
1 root 27
		$strResult = 0;
28
		// Déclaration des paramètres de connexion
29
		$host = "localhost";
30
		$DB_USER = "radius";
31
		$DB_RADIUS = "radius";
110 richard 32
		$radiuspwd = "W7AH5bp8";
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
110 richard 37
		if ($texte == 'user') {$query = "SELECT UserName FROM userinfo";}
59 richard 38
		else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
1 root 39
		$result = mysql_query($query);
40
		// Recuperation des resultats
41
		$strResult = mysql_num_rows($result);
42
		// Deconnexion de la base de donnees
43
		 mysql_close();
44
		return $strResult;
45
  }
46
function xml_portail () {
47
	global $sysinfo;
48
 
49
	$_text = "  <Portail>\n"
110 richard 50
//		. "    <Utilisateur>" . htmlspecialchars( request('user'), ENT_QUOTES ) . "</Utilisateur>\n"
51
		. "    <Utilisateur>" . "</Utilisateur>\n"
52
		. "    <Groupe>" . "</Groupe>\n";
53
//		. "    <Groupe>" . htmlspecialchars( trim( request('group') ), ENT_QUOTES ) . "</Groupe>\n";
1 root 54
	$_text .= "  </Portail>\n";
55
 
56
	return $_text;
57
} 
58
// Fonction de test de connectivité internet
59
function internetTest(){
60
	$host = "www.google.fr";
61
	$port = "80";
62
	//var $num;	//non utilisé
63
	//var $error;	//non utilisé
64
 
65
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
66
		return false;
67
	} else {
68
		fclose($sock);
69
		return true;
70
	}
71
}
59 richard 72
// Fonction de test du filtrage
73
function filtrageTest($file, $search_regex){
74
	$pointeur = fopen($file,"r");
75
	$result = false;
76
	if ($pointeur)
77
		{
78
		while (!feof($pointeur))
79
			{
80
				$ligne = fgets($pointeur);
81
				if (preg_match($search_regex, $ligne, $r))
82
				{
83
				$result = true;
84
				break;
85
				}
86
			}
87
		}
88
	fclose($pointeur);
89
	return $result;
90
}
1 root 91
// html_portail()
92
function html_portail () {
93
	global $webpath;
94
	global $XPath;
95
	global $text;
96
 
97
	$file_version = "/var/www/html/VERSION";
98
	$handle = fopen ($file_version, "r");
34 richard 99
	$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
1 root 100
	fclose ($handle);
101
	$file_bl = "/var/www/html/VERSION-BL";
102
	$handle = fopen ($file_bl, "r");
103
	$VERSIONBL = fread ($handle, filesize ($file_bl));
104
	fclose ($handle);
59 richard 105
	$nbr_user = request ('user');
106
	$nbr_grp  = request ('group');
1 root 107
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
59 richard 108
	if (filtrageTest("/usr/local/bin/alcasar-iptables.sh", "/^FILTERING=\"yes\"/")){
109
		$network_filter_status = $text['enable'];}
110
	else {	$network_filter_status = $text['disable'];}
111
	if (filtrageTest("/etc/dansguardian/dansguardian.conf","/^reportinglevel = 3/")){
112
		$web_filter_status = $text['enable'];}
113
	else {	$web_filter_status = $text['disable'];}
114
	if (InternetTest()){
115
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['enable'];
65 richard 116
		$version = dns_get_record("version.alcasar.info",DNS_TXT);
117
		$AVAILABLEDVERSION = $version[0]['txt'];
1 root 118
	} else {
59 richard 119
		$internet_status =  "<img src='/images/state_error.gif'>".$text['disable'];
120
		$AVAILABLEDVERSION = "-";
1 root 121
	}
122
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
123
		. "  <tr>\n"
124
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
34 richard 125
		. "    <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
1 root 126
		. "  </tr>\n"
127
		. "  <tr>\n"
59 richard 128
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
65 richard 129
		. "    <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
34 richard 130
		. "  </tr>\n"
131
		. "  <tr>\n"
1 root 132
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
133
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
134
		. "  </tr>\n"
135
		. "  <tr>\n"
136
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
137
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
138
		. "  </tr>\n"
139
		. "  <tr>\n"
140
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
141
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
142
		. "  </tr>\n"
143
		. "  <tr>\n"
59 richard 144
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['filter'] . "</font></td>\n"
145
		. "    <td><font size=\"-1\">web : " . $web_filter_status . ", " . $text['network'] . " : " . $network_filter_status . "</font></td>\n"
146
		. "  </tr>\n"
147
		. "  <tr>\n"
1 root 148
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
149
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
150
		. "  </tr>\n"
151
		. "</table>\n";
152
	return $_text;
153
} 
154
 
155
function wml_portail () {
156
	global $XPath;
157
	global $text;
158
 
159
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
160
		. "<p>" . $text['hostname'] . ":<br/>\n"
161
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
162
		. "<p>" . $text['ip'] . ":<br/>\n"
163
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
164
		. "<p>" . $text['kversion'] . ":<br/>\n"
165
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
166
		. "<p>" . $text['uptime'] . ":<br/>\n"
167
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
168
		. "<p>" . $text['users'] . ":<br/>"
169
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
170
		. "<p>" . $text['loadavg'] . ":<br/>"
171
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
172
		. "</card>\n";
173
 
174
	return $_text;
175
}
176
?>