Subversion Repositories ALCASAR

Rev

Rev 1805 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1805 Rev 2006
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: portail.php 1805 2016-03-10 11:53:23Z clement.siccardi $
22
// $Id: portail.php 2006 2016-07-22 13:07:10Z raphael.pion $
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 = "J7YI65SW";
32
		$radiuspwd = "J7YI65SW";
33
		// Connexion au serveur
33
		// Connexion au serveur
34
		$mysqli = new mysqli($host, $DB_USER, $radiuspwd, $DB_RADIUS);
34
		$mysqli = new mysqli($host, $DB_USER, $radiuspwd, $DB_RADIUS);
35
		if ($texte == 'user') {$query = "SELECT UserName FROM userinfo";}
35
		if ($texte == 'user') {$query = "SELECT UserName FROM userinfo";}
36
		else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
36
		else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
37
		$result = $mysqli->query($query);
37
		$result = $mysqli->query($query);
38
		// Recuperation des resultats
38
		// Recuperation des resultats
39
		$strResult = $result->num_rows;
39
		$strResult = $result->num_rows;
40
		// Deconnexion de la base de donnees
40
		// Deconnexion de la base de donnees
41
		$mysqli->close();
41
		$mysqli->close();
42
		return $strResult;
42
		return $strResult;
43
 }
43
 }
44
 
44
 
45
function xml_portail () {
45
function xml_portail () {
46
	global $sysinfo;
46
	global $sysinfo;
47
 
47
 
48
	$_text = "  <Portail>\n"
48
	$_text = "  <Portail>\n"
49
//		. "    <Utilisateur>" . htmlspecialchars( request('user'), ENT_QUOTES ) . "</Utilisateur>\n"
49
//		. "    <Utilisateur>" . htmlspecialchars( request('user'), ENT_QUOTES ) . "</Utilisateur>\n"
50
		. "    <Utilisateur>" . "</Utilisateur>\n"
50
		. "    <Utilisateur>" . "</Utilisateur>\n"
51
		. "    <Groupe>" . "</Groupe>\n";
51
		. "    <Groupe>" . "</Groupe>\n";
52
//		. "    <Groupe>" . htmlspecialchars( trim( request('group') ), ENT_QUOTES ) . "</Groupe>\n";
52
//		. "    <Groupe>" . htmlspecialchars( trim( request('group') ), ENT_QUOTES ) . "</Groupe>\n";
53
	$_text .= "  </Portail>\n";
53
	$_text .= "  </Portail>\n";
54
 
54
 
55
	return $_text;
55
	return $_text;
56
}
56
}
57
// Fonction de test de connectivité internet
57
// Fonction de test de connectivité internet
58
function internetTest($INSTALLEDVERSION){
58
function internetTest($INSTALLEDVERSION){
59
        $host = "www.google.com";  # Google Test
59
        $host = "www.google.com";  # Google Test
60
        $host2 = "svn.alcasar.net";
60
        $host2 = "svn.alcasar.net";
61
        $port = "80";
61
        $port = "80";
62
        //var $num;     //non utilisé
62
        //var $num;     //non utilisé
63
        //var $error;   //non utilisé
63
        //var $error;   //non utilisé
64
	$sock = fsockopen($host, $port, $num, $error, 2);
64
	$sock = fsockopen($host, $port, $num, $error, 2);
65
	if (!$sock){
65
	if (!$sock){
66
		return false; # Internet access is down
66
		return false; # Internet access is down
67
		}
67
		}
68
	else 	{
68
	else 	{
69
		fclose($sock);
69
		fclose($sock);
70
		$sock = fsockopen($host2, $port, $num, $error, 2);
70
		$sock = fsockopen($host2, $port, $num, $error, 2);
71
		if ($sock){
71
		if ($sock){
72
                	fputs($sock,"GET http://$host2/images/M_images/weblink-$INSTALLEDVERSION.png HTTP/1.0\n\n");
72
                	fputs($sock,"GET http://$host2/images/M_images/weblink-$INSTALLEDVERSION.png HTTP/1.0\n\n");
73
			fclose($sock); }
73
			fclose($sock); }
74
		return true;
74
		return true;
75
		}
75
		}
76
}
76
}
77
// Fonction de test du filtrage
77
// Fonction de test du filtrage
78
function filtrageTest($file, $search_regex){
78
function filtrageTest($file, $search_regex){
79
	$pointeur = fopen($file,"r");
79
	$pointeur = fopen($file,"r");
80
	$result = false;
80
	$result = false;
81
	if ($pointeur)
81
	if ($pointeur)
82
		{
82
		{
83
		while (!feof($pointeur))
83
		while (!feof($pointeur))
84
			{
84
			{
85
				$ligne = fgets($pointeur);
85
				$ligne = fgets($pointeur);
86
				if (preg_match($search_regex, $ligne, $r))
86
				if (preg_match($search_regex, $ligne, $r))
87
				{
87
				{
88
				$result = true;
88
				$result = true;
89
				break;
89
				break;
90
				}
90
				}
91
			}
91
			}
92
		}
92
		}
93
	fclose($pointeur);
93
	fclose($pointeur);
94
	return $result;
94
	return $result;
95
}
95
}
96
// html_portail()
96
// html_portail()
97
function html_portail () {
97
function html_portail () {
98
	global $webpath;
98
	global $webpath;
99
	global $XPath;
99
	global $XPath;
100
	global $text;
100
	global $text;
101
	exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
101
	exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
102
	$file_version = "/var/www/html/VERSION";
102
	$file_version = "/var/www/html/VERSION";
103
	$handle = fopen ($file_version, "r");
103
	$handle = fopen ($file_version, "r");
104
	$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
104
	$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
105
	fclose ($handle);
105
	fclose ($handle);
106
	$VERSIONBL = date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));
106
	$VERSIONBL = date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));
107
	$nbr_user = request ('user');
107
	$nbr_user = request ('user');
108
	$nbr_grp  = request ('group');
108
	$nbr_grp  = request ('group');
109
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
109
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
110
	if (filtrageTest("/usr/local/etc/alcasar.conf", "/^PROTOCOLS_FILTERING=on/")){
-
 
111
		$network_filter_status = $text['enable'];}
-
 
112
	else {	$network_filter_status = $text['disable'];}
-
 
113
	if ((filtrageTest("/var/www/html/index.php","/network_pb = False/")) && (internetTest($INSTALLEDVERSION))){
110
	if ((filtrageTest("/var/www/html/index.php","/network_pb = False/")) && (internetTest($INSTALLEDVERSION))){
114
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['enable'];
111
		$internet_status =  "<img src='/images/state_ok.gif'>".$text['enable'];
115
		$version = dns_get_record("version.alcasar.net",DNS_TXT);
112
		$version = dns_get_record("version.alcasar.net",DNS_TXT);
116
		$AVAILABLEDVERSION = $version[0]['txt'];
113
		$AVAILABLEDVERSION = $version[0]['txt'];
117
	} else {
114
	} else {
118
		$internet_status =  "<img src='/images/state_error.gif'>".$text['disable'];
115
		$internet_status =  "<img src='/images/state_error.gif'>".$text['disable'];
119
		$AVAILABLEDVERSION = "-";
116
		$AVAILABLEDVERSION = "-";
120
	}
117
	}
121
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
118
	$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
122
		. "  <tr>\n"
119
		. "  <tr>\n"
123
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
120
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
124
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
121
		. "    <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
125
		. "  </tr>\n"
122
		. "  </tr>\n"
126
		. "  <tr>\n"
123
		. "  <tr>\n"
127
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
124
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
128
		. "    <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
125
		. "    <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
129
		. "  </tr>\n"
126
		. "  </tr>\n"
130
		. "  <tr>\n"
127
		. "  <tr>\n"
131
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
128
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
132
		. "    <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
129
		. "    <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
133
		. "  </tr>\n"
130
		. "  </tr>\n"
134
		. "  <tr>\n"
131
		. "  <tr>\n"
135
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
132
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
136
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
133
		. "    <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
137
		. "  </tr>\n"
134
		. "  </tr>\n"
138
		. "  <tr>\n"
135
		. "  <tr>\n"
139
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
136
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
140
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
137
		. "    <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
141
		. "  </tr>\n"
138
		. "  </tr>\n"
142
		. "  <tr>\n"
-
 
143
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['net_filter'] . "</font></td>\n"
-
 
144
		. "    <td><font size=\"-1\">" . $network_filter_status . "</font></td>\n"
-
 
145
		. "  </tr>\n"
-
 
146
		. "  <tr>\n"
139
		. "  <tr>\n"
147
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
140
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
148
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
141
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
149
		. "  </tr>\n"
142
		. "  </tr>\n"
150
		. "</table>\n";
143
		. "</table>\n";
151
	return $_text;
144
	return $_text;
152
}
145
}
153
 
146
 
154
function wml_portail () {
147
function wml_portail () {
155
	global $XPath;
148
	global $XPath;
156
	global $text;
149
	global $text;
157
 
150
 
158
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
151
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
159
		. "<p>" . $text['hostname'] . ":<br/>\n"
152
		. "<p>" . $text['hostname'] . ":<br/>\n"
160
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
153
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
161
		. "<p>" . $text['ip'] . ":<br/>\n"
154
		. "<p>" . $text['ip'] . ":<br/>\n"
162
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
155
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
163
		. "<p>" . $text['kversion'] . ":<br/>\n"
156
		. "<p>" . $text['kversion'] . ":<br/>\n"
164
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
157
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
165
		. "<p>" . $text['uptime'] . ":<br/>\n"
158
		. "<p>" . $text['uptime'] . ":<br/>\n"
166
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
159
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
167
		. "<p>" . $text['users'] . ":<br/>"
160
		. "<p>" . $text['users'] . ":<br/>"
168
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
161
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
169
		. "<p>" . $text['loadavg'] . ":<br/>"
162
		. "<p>" . $text['loadavg'] . ":<br/>"
170
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
163
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
171
		. "</card>\n";
164
		. "</card>\n";
172
 
165
 
173
	return $_text;
166
	return $_text;
174
}
167
}
175
?>
168
?>
176
 
169