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 2385 2017-08-22 16:36:16Z tom.houdayer $
|
22 |
// $Id: portail.php 2450 2017-12-05 21:53:42Z tom.houdayer $
|
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 = "";
|
32 |
$radiuspwd = "";
|
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() {
|
58 |
function internetTest() {
|
59 |
$host = 'www.google.com';
|
59 |
$host = 'www.google.com';
|
60 |
$host2 = 'www.alcasar.net';
|
60 |
$host2 = 'www.alcasar.net';
|
61 |
$port = 80;
|
61 |
$port = 80;
|
62 |
|
62 |
|
63 |
$sock = fsockopen($host, $port, $errno, $errstr, 2);
|
63 |
$sock = fsockopen($host, $port, $errno, $errstr, 2);
|
64 |
if (!$sock) {
|
64 |
if (!$sock) {
|
65 |
return false;
|
65 |
return false;
|
66 |
}
|
66 |
}
|
67 |
fclose($sock);
|
67 |
fclose($sock);
|
68 |
|
68 |
|
69 |
$sock = fsockopen($host2, $port, $errno, $errstr, 2);
|
69 |
$sock = fsockopen($host2, $port, $errno, $errstr, 2);
|
70 |
if (!$sock) {
|
70 |
if (!$sock) {
|
71 |
return false;
|
71 |
return false;
|
72 |
}
|
72 |
}
|
73 |
fclose($sock);
|
73 |
fclose($sock);
|
74 |
|
74 |
|
75 |
return true;
|
75 |
return true;
|
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 |
|
101 |
|
102 |
// Read CONF_FILE
|
102 |
// Read CONF_FILE
|
103 |
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
|
103 |
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
|
104 |
$file_conf = fopen(CONF_FILE, 'r');
|
104 |
$file_conf = fopen(CONF_FILE, 'r');
|
105 |
if (!$file_conf) {
|
105 |
if (!$file_conf) {
|
106 |
exit('Error opening the file '.CONF_FILE);
|
106 |
exit('Error opening the file '.CONF_FILE);
|
107 |
}
|
107 |
}
|
108 |
while (!feof($file_conf)) {
|
108 |
while (!feof($file_conf)) {
|
109 |
$tampon = fgets($file_conf, 4096);
|
109 |
$buffer = fgets($file_conf, 4096);
|
110 |
if ((strpos($tampon, '=') !== false) && (substr($tampon, 0, 1) !== '#')) {
|
110 |
if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
|
111 |
$tmp = explode('=', $tampon);
|
111 |
$tmp = explode('=', $buffer, 2);
|
112 |
$conf[$tmp[0]] = trim($tmp[1]);
|
112 |
$conf[trim($tmp[0])] = trim($tmp[1]);
|
113 |
}
|
113 |
}
|
114 |
}
|
114 |
}
|
115 |
fclose($file_conf);
|
115 |
fclose($file_conf);
|
116 |
|
116 |
|
117 |
exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
|
117 |
exec ("sudo /usr/local/bin/alcasar-watchdog.sh -lt");
|
118 |
// Get current version
|
118 |
// Get current version
|
119 |
$INSTALLEDVERSION = $conf['VERSION'];
|
119 |
$INSTALLEDVERSION = $conf['VERSION'];
|
120 |
$VERSIONBL = date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));
|
120 |
$VERSIONBL = date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));
|
121 |
$nbr_user = request ('user');
|
121 |
$nbr_user = request ('user');
|
122 |
$nbr_grp = request ('group');
|
122 |
$nbr_grp = request ('group');
|
123 |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
|
123 |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
|
124 |
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
|
124 |
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
|
125 |
$internet_status = "<img src='/images/state_ok.gif'>".$text['enable'];
|
125 |
$internet_status = "<img src='/images/state_ok.gif'>".$text['enable'];
|
126 |
$version = dns_get_record("version.alcasar.net",DNS_TXT);
|
126 |
$version = dns_get_record("version.alcasar.net",DNS_TXT);
|
127 |
$AVAILABLEDVERSION = $version[0]['txt'];
|
127 |
$AVAILABLEDVERSION = $version[0]['txt'];
|
128 |
} else {
|
128 |
} else {
|
129 |
$internet_status = "<img src='/images/state_error.gif'>".$text['disable'];
|
129 |
$internet_status = "<img src='/images/state_error.gif'>".$text['disable'];
|
130 |
$AVAILABLEDVERSION = "-";
|
130 |
$AVAILABLEDVERSION = "-";
|
131 |
}
|
131 |
}
|
132 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
132 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
133 |
. " <tr>\n"
|
133 |
. " <tr>\n"
|
134 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
|
134 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
|
135 |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
|
135 |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
|
136 |
. " </tr>\n"
|
136 |
. " </tr>\n"
|
137 |
. " <tr>\n"
|
137 |
. " <tr>\n"
|
138 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
|
138 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
|
139 |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
|
139 |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
|
140 |
. " </tr>\n"
|
140 |
. " </tr>\n"
|
141 |
. " <tr>\n"
|
141 |
. " <tr>\n"
|
142 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
|
142 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
|
143 |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
|
143 |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
|
144 |
. " </tr>\n"
|
144 |
. " </tr>\n"
|
145 |
. " <tr>\n"
|
145 |
. " <tr>\n"
|
146 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\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"
|
147 |
. " <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
|
148 |
. " </tr>\n"
|
148 |
. " </tr>\n"
|
149 |
. " <tr>\n"
|
149 |
. " <tr>\n"
|
150 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
|
150 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n"
|
151 |
. " <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
|
151 |
. " <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n"
|
152 |
. " </tr>\n"
|
152 |
. " </tr>\n"
|
153 |
. " <tr>\n"
|
153 |
. " <tr>\n"
|
154 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
|
154 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
|
155 |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
|
155 |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
|
156 |
. " </tr>\n"
|
156 |
. " </tr>\n"
|
157 |
. "</table>\n";
|
157 |
. "</table>\n";
|
158 |
return $_text;
|
158 |
return $_text;
|
159 |
}
|
159 |
}
|
160 |
|
160 |
|
161 |
function wml_portail () {
|
161 |
function wml_portail () {
|
162 |
global $XPath;
|
162 |
global $XPath;
|
163 |
global $text;
|
163 |
global $text;
|
164 |
|
164 |
|
165 |
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n"
|
165 |
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n"
|
166 |
. "<p>" . $text['hostname'] . ":<br/>\n"
|
166 |
. "<p>" . $text['hostname'] . ":<br/>\n"
|
167 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
|
167 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
|
168 |
. "<p>" . $text['ip'] . ":<br/>\n"
|
168 |
. "<p>" . $text['ip'] . ":<br/>\n"
|
169 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
|
169 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
|
170 |
. "<p>" . $text['kversion'] . ":<br/>\n"
|
170 |
. "<p>" . $text['kversion'] . ":<br/>\n"
|
171 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
|
171 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
|
172 |
. "<p>" . $text['uptime'] . ":<br/>\n"
|
172 |
. "<p>" . $text['uptime'] . ":<br/>\n"
|
173 |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
|
173 |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
|
174 |
. "<p>" . $text['users'] . ":<br/>"
|
174 |
. "<p>" . $text['users'] . ":<br/>"
|
175 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
|
175 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
|
176 |
. "<p>" . $text['loadavg'] . ":<br/>"
|
176 |
. "<p>" . $text['loadavg'] . ":<br/>"
|
177 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
|
177 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
|
178 |
. "</card>\n";
|
178 |
. "</card>\n";
|
179 |
|
179 |
|
180 |
return $_text;
|
180 |
return $_text;
|
181 |
}
|
181 |
}
|
182 |
?>
|
182 |
?>
|
183 |
|
183 |
|