Subversion Repositories ALCASAR

Rev

Rev 360 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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