Subversion Repositories ALCASAR

Rev

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

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