Subversion Repositories ALCASAR

Rev

Details | 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 2611 2018-08-22 16:33:08Z tom.houdayer $
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";
2182 tom.houday 32
		$radiuspwd = "";
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
2385 tom.houday 58
function internetTest() {
59
	$host  = 'www.google.com';
60
	$host2 = 'www.alcasar.net';
61
	$port = 80;
62
 
2611 tom.houday 63
	$sock = @fsockopen($host, $port, $errno, $errstr, 2);
64
	if ($sock) {
65
		fclose($sock);
66
		return true;
2385 tom.houday 67
	}
68
 
2611 tom.houday 69
	$sock = @fsockopen($host2, $port, $errno, $errstr, 2);
70
	if ($sock) {
71
		fclose($sock);
72
		return true;
2385 tom.houday 73
	}
74
 
2611 tom.houday 75
	return false;
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;
2182 tom.houday 101
 
102
	// Read CONF_FILE
103
	define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
104
	$file_conf = fopen(CONF_FILE, 'r');
105
	if (!$file_conf) {
106
		exit('Error opening the file '.CONF_FILE);
107
	}
108
	while (!feof($file_conf)) {
2450 tom.houday 109
		$buffer = fgets($file_conf, 4096);
110
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
111
			$tmp = explode('=', $buffer, 2);
112
			$conf[trim($tmp[0])] = trim($tmp[1]);
2182 tom.houday 113
		}
114
	}
115
	fclose($file_conf);
116
 
2171 tom.houday 117
	// Get current version
2182 tom.houday 118
	$INSTALLEDVERSION = $conf['VERSION'];
2521 armand.ito 119
	$VERSIONBL = date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));
325 richard 120
	$nbr_user = request ('user');
121
	$nbr_grp  = request ('group');
122
	$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
2385 tom.houday 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'];
830 richard 125
		$version = dns_get_record("version.alcasar.net",DNS_TXT);
325 richard 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['bl-version'] . "</font></td>\n"
154
		. "    <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
155
		. "  </tr>\n"
156
		. "</table>\n";
157
	return $_text;
1805 clement.si 158
}
325 richard 159
 
160
function wml_portail () {
161
	global $XPath;
162
	global $text;
1805 clement.si 163
 
325 richard 164
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
165
		. "<p>" . $text['hostname'] . ":<br/>\n"
166
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
167
		. "<p>" . $text['ip'] . ":<br/>\n"
168
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
169
		. "<p>" . $text['kversion'] . ":<br/>\n"
170
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
171
		. "<p>" . $text['uptime'] . ":<br/>\n"
172
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
173
		. "<p>" . $text['users'] . ":<br/>"
174
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
175
		. "<p>" . $text['loadavg'] . ":<br/>"
176
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
177
		. "</card>\n";
1805 clement.si 178
 
325 richard 179
	return $_text;
180
}
181
?>