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 2521 2018-04-02 19:46:16Z armand.ito $
|
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 |
|
|
|
63 |
$sock = fsockopen($host, $port, $errno, $errstr, 2);
|
|
|
64 |
if (!$sock) {
|
|
|
65 |
return false;
|
|
|
66 |
}
|
|
|
67 |
fclose($sock);
|
|
|
68 |
|
|
|
69 |
$sock = fsockopen($host2, $port, $errno, $errstr, 2);
|
|
|
70 |
if (!$sock) {
|
|
|
71 |
return false;
|
|
|
72 |
}
|
|
|
73 |
fclose($sock);
|
|
|
74 |
|
|
|
75 |
return true;
|
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 |
|
783 |
richard |
117 |
exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
|
2171 |
tom.houday |
118 |
// Get current version
|
2182 |
tom.houday |
119 |
$INSTALLEDVERSION = $conf['VERSION'];
|
2521 |
armand.ito |
120 |
$VERSIONBL = date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));
|
325 |
richard |
121 |
$nbr_user = request ('user');
|
|
|
122 |
$nbr_grp = request ('group');
|
|
|
123 |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
|
2385 |
tom.houday |
124 |
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
|
325 |
richard |
125 |
$internet_status = "<img src='/images/state_ok.gif'>".$text['enable'];
|
830 |
richard |
126 |
$version = dns_get_record("version.alcasar.net",DNS_TXT);
|
325 |
richard |
127 |
$AVAILABLEDVERSION = $version[0]['txt'];
|
|
|
128 |
} else {
|
|
|
129 |
$internet_status = "<img src='/images/state_error.gif'>".$text['disable'];
|
|
|
130 |
$AVAILABLEDVERSION = "-";
|
|
|
131 |
}
|
|
|
132 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
|
|
133 |
. " <tr>\n"
|
648 |
richard |
134 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
|
|
|
135 |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
|
|
|
136 |
. " </tr>\n"
|
|
|
137 |
. " <tr>\n"
|
325 |
richard |
138 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
|
|
|
139 |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
|
|
|
140 |
. " </tr>\n"
|
|
|
141 |
. " <tr>\n"
|
|
|
142 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
|
|
|
143 |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
|
|
|
144 |
. " </tr>\n"
|
|
|
145 |
. " <tr>\n"
|
|
|
146 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n"
|
|
|
147 |
. " <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
|
|
|
148 |
. " </tr>\n"
|
|
|
149 |
. " <tr>\n"
|
|
|
150 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
|
|
|
151 |
. " <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
|
|
|
152 |
. " </tr>\n"
|
|
|
153 |
. " <tr>\n"
|
|
|
154 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
|
|
|
155 |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
|
|
|
156 |
. " </tr>\n"
|
|
|
157 |
. "</table>\n";
|
|
|
158 |
return $_text;
|
1805 |
clement.si |
159 |
}
|
325 |
richard |
160 |
|
|
|
161 |
function wml_portail () {
|
|
|
162 |
global $XPath;
|
|
|
163 |
global $text;
|
1805 |
clement.si |
164 |
|
325 |
richard |
165 |
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n"
|
|
|
166 |
. "<p>" . $text['hostname'] . ":<br/>\n"
|
|
|
167 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
|
|
|
168 |
. "<p>" . $text['ip'] . ":<br/>\n"
|
|
|
169 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
|
|
|
170 |
. "<p>" . $text['kversion'] . ":<br/>\n"
|
|
|
171 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
|
|
|
172 |
. "<p>" . $text['uptime'] . ":<br/>\n"
|
|
|
173 |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
|
|
|
174 |
. "<p>" . $text['users'] . ":<br/>"
|
|
|
175 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
|
|
|
176 |
. "<p>" . $text['loadavg'] . ":<br/>"
|
|
|
177 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
|
|
|
178 |
. "</card>\n";
|
1805 |
clement.si |
179 |
|
325 |
richard |
180 |
return $_text;
|
|
|
181 |
}
|
|
|
182 |
?>
|