Subversion Repositories ALCASAR

Rev

Rev 719 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
325 richard 1
<?php 
2
/***************************************************************************
3
 *   Copyright (C) 2006 by phpSysInfo - A PHP System Information Script    *
4
 *   http://phpsysinfo.sourceforge.net/                                    *
5
 *   addons by 3abtux & Rexy for ALCASAR                                   *
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
 
426 franck 22
// $Id: portail.php 783 2011-12-17 14:24:08Z richard $
325 richard 23
 
24
// xml_utilisateur()
25
 
26
function request ($texte) {
27
		$strResult = 0;
28
		// Déclaration des paramètres de connexion
29
		$host = "localhost";
30
		$DB_USER = "radius";
31
		$DB_RADIUS = "radius";
783 richard 32
		$radiuspwd = "";
325 richard 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
		if ($texte == 'user') {$query = "SELECT UserName FROM userinfo";}
38
		else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
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"
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";
54
	$_text .= "  </Portail>\n";
55
 
56
	return $_text;
57
} 
58
// Fonction de test de connectivité internet
59
function internetTest(){
783 richard 60
        $host = "www.google.com";  # Google Test
679 richard 61
        $host2 = "www.alcasar.info";
421 franck 62
        $port = "80";
63
        //var $num;     //non utilisé
64
        //var $error;   //non utilisé
783 richard 65
	$sock = fsockopen($host, $port, $num, $error, 2);
66
	if (!$sock){
67
		return false; # Internet access is down
68
		}
679 richard 69
	else 	{   
70
		fclose($sock);
783 richard 71
		$sock = fsockopen($host2, $port, $num, $error, 2);
72
		if ($sock){
719 franck 73
                	fputs($sock,"GET http://$host2/images/M_images/weblink24.png HTTP/1.0\n\n");
783 richard 74
			fclose($sock); }
679 richard 75
		return true;
76
		}
719 franck 77
}
325 richard 78
// Fonction de test du filtrage
79
function filtrageTest($file, $search_regex){
80
	$pointeur = fopen($file,"r");
81
	$result = false;
82
	if ($pointeur)
83
		{
84
		while (!feof($pointeur))
85
			{
86
				$ligne = fgets($pointeur);
87
				if (preg_match($search_regex, $ligne, $r))
88
				{
89
				$result = true;
90
				break;
91
				}
92
			}
93
		}
94
	fclose($pointeur);
95
	return $result;
96
}
97
// html_portail()
98
function html_portail () {
99
	global $webpath;
100
	global $XPath;
101
	global $text;
783 richard 102
	exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
325 richard 103
	$file_version = "/var/www/html/VERSION";
104
	$handle = fopen ($file_version, "r");
105
	$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
106
	fclose ($handle);
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 = request ('user');
112
	$nbr_grp  = request ('group');
113
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
697 franck 114
	if (filtrageTest("/usr/local/etc/alcasar.conf", "/^PROTOCOLS_FILTERING=on/")){
325 richard 115
		$network_filter_status = $text['enable'];}
116
	else {	$network_filter_status = $text['disable'];}
117
	if (filtrageTest("/etc/dansguardian/dansguardian.conf","/^reportinglevel = 3/")){
118
		$web_filter_status = $text['enable'];}
119
	else {	$web_filter_status = $text['disable'];}
120
	if (filtrageTest("/etc/dansguardian/dansguardian.conf","/^proxyport = 8090/")){
121
		$web_antivir_status = $text['enable'];}
122
	else {	$web_antivir_status = $text['disable'];}
783 richard 123
	if ((filtrageTest("/var/www/html/index.php","/network_pb = False/")) && (internetTest())){
325 richard 124
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['enable'];
125
		$version = dns_get_record("version.alcasar.info",DNS_TXT);
126
		$AVAILABLEDVERSION = $version[0]['txt'];
127
	} else {
128
		$internet_status =  "<img src='/images/state_error.gif'>".$text['disable'];
129
		$AVAILABLEDVERSION = "-";
130
	}
131
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
132
		. "  <tr>\n"
648 richard 133
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
134
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
135
		. "  </tr>\n"
136
		. "  <tr>\n"
325 richard 137
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
138
		. "    <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
139
		. "  </tr>\n"
140
		. "  <tr>\n"
141
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
142
		. "    <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
143
		. "  </tr>\n"
144
		. "  <tr>\n"
145
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
146
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
147
		. "  </tr>\n"
148
		. "  <tr>\n"
149
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
150
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
151
		. "  </tr>\n"
152
		. "  <tr>\n"
153
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['net_filter'] . "</font></td>\n"
154
		. "    <td><font size=\"-1\">" . $network_filter_status . "</font></td>\n"
155
		. "  </tr>\n"
156
		. "  <tr>\n"
157
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['web_filter'] . "</font></td>\n"
158
		. "    <td><font size=\"-1\">antivirus : " . $web_antivir_status . ", domain/url : " . $web_filter_status . "</font></td>\n"
159
		. "  </tr>\n"
160
		. "  <tr>\n"
161
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
162
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
163
		. "  </tr>\n"
164
		. "</table>\n";
165
	return $_text;
166
} 
167
 
168
function wml_portail () {
169
	global $XPath;
170
	global $text;
171
 
172
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
173
		. "<p>" . $text['hostname'] . ":<br/>\n"
174
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
175
		. "<p>" . $text['ip'] . ":<br/>\n"
176
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
177
		. "<p>" . $text['kversion'] . ":<br/>\n"
178
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
179
		. "<p>" . $text['uptime'] . ":<br/>\n"
180
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
181
		. "<p>" . $text['users'] . ":<br/>"
182
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
183
		. "<p>" . $text['loadavg'] . ":<br/>"
184
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
185
		. "</card>\n";
186
 
187
	return $_text;
188
}
189
?>