Line 1... |
Line 1... |
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 |
* *
|
5 |
* Copyright (C) 2010 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 |
* *
|
Line 21... |
Line 21... |
21 |
|
21 |
|
22 |
// $Id: vitals.php,v 1.32 2007/02/18 18:59:54 bigmichi1 Exp $
|
22 |
// $Id: vitals.php,v 1.32 2007/02/18 18:59:54 bigmichi1 Exp $
|
23 |
|
23 |
|
24 |
// xml_utilisateur()
|
24 |
// xml_utilisateur()
|
25 |
|
25 |
|
26 |
function utilisateur () {
|
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";
|
- |
|
32 |
$radiuspwd = "gLMmnOpk";
|
- |
|
33 |
// Connexion au serveur
|
- |
|
34 |
mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur");
|
- |
|
35 |
mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees");
|
- |
|
36 |
// Creation et envoi de la requete
|
- |
|
37 |
$query = "SELECT UserName FROM userinfo";
|
- |
|
38 |
$result = mysql_query($query);
|
- |
|
39 |
// Recuperation des resultats
|
- |
|
40 |
$strResult = mysql_num_rows($result);
|
- |
|
41 |
// Deconnexion de la base de donnees
|
- |
|
42 |
mysql_close();
|
- |
|
43 |
return $strResult;
|
- |
|
44 |
}
|
- |
|
45 |
|
- |
|
46 |
function groupe () {
|
- |
|
47 |
$strResult = 0;
|
27 |
$strResult = 0;
|
48 |
// Déclaration des paramètres de connexion
|
28 |
// Déclaration des paramètres de connexion
|
49 |
$host = "localhost";
|
29 |
$host = "localhost";
|
50 |
$DB_USER = "radius";
|
30 |
$DB_USER = "radius";
|
51 |
$DB_RADIUS = "radius";
|
31 |
$DB_RADIUS = "radius";
|
52 |
$radiuspwd = "gLMmnOpk";
|
32 |
$radiuspwd = "xKosCPLa";
|
53 |
// Connexion au serveur
|
33 |
// Connexion au serveur
|
54 |
mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur");
|
34 |
mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur");
|
55 |
mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees");
|
35 |
mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees");
|
56 |
// Creation et envoi de la requete
|
36 |
// Creation et envoi de la requete
|
- |
|
37 |
if ($texte = 'user') {$query = "SELECT UserName FROM userinfo";}
|
57 |
$query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";
|
38 |
else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
|
58 |
$result = mysql_query($query);
|
39 |
$result = mysql_query($query);
|
59 |
// Recuperation des resultats
|
40 |
// Recuperation des resultats
|
60 |
$strResult = mysql_num_rows($result);
|
41 |
$strResult = mysql_num_rows($result);
|
61 |
// Deconnexion de la base de donnees
|
42 |
// Deconnexion de la base de donnees
|
62 |
mysql_close();
|
43 |
mysql_close();
|
63 |
return $strResult;
|
44 |
return $strResult;
|
64 |
}
|
45 |
}
|
65 |
|
- |
|
66 |
function xml_portail () {
|
46 |
function xml_portail () {
|
67 |
global $sysinfo;
|
47 |
global $sysinfo;
|
68 |
|
48 |
|
69 |
$_text = " <Portail>\n"
|
49 |
$_text = " <Portail>\n"
|
70 |
// . " <Utilisateur>" . htmlspecialchars( $sysinfo->utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n"
|
50 |
// . " <Utilisateur>" . htmlspecialchars( $sysinfo->utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n"
|
71 |
. " <Utilisateur>" . htmlspecialchars( utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n"
|
51 |
. " <Utilisateur>" . htmlspecialchars( request('user'), ENT_QUOTES ) . "</Utilisateur>\n"
|
72 |
. " <Groupe>" . htmlspecialchars( trim( groupe() ), ENT_QUOTES ) . "</Groupe>\n";
|
52 |
. " <Groupe>" . htmlspecialchars( trim( request('group') ), ENT_QUOTES ) . "</Groupe>\n";
|
73 |
$_text .= " </Portail>\n";
|
53 |
$_text .= " </Portail>\n";
|
74 |
|
54 |
|
75 |
return $_text;
|
55 |
return $_text;
|
76 |
}
|
56 |
}
|
77 |
|
- |
|
78 |
// Fonction de test de connectivité internet
|
57 |
// Fonction de test de connectivité internet
|
79 |
function internetTest(){
|
58 |
function internetTest(){
|
80 |
$host = "www.google.fr";
|
59 |
$host = "www.google.fr";
|
81 |
$port = "80";
|
60 |
$port = "80";
|
82 |
//var $num; //non utilisé
|
61 |
//var $num; //non utilisé
|
Line 87... |
Line 66... |
87 |
} else {
|
66 |
} else {
|
88 |
fclose($sock);
|
67 |
fclose($sock);
|
89 |
return true;
|
68 |
return true;
|
90 |
}
|
69 |
}
|
91 |
}
|
70 |
}
|
- |
|
71 |
// Fonction de test du filtrage
|
- |
|
72 |
function filtrageTest($file, $search_regex){
|
- |
|
73 |
$pointeur = fopen($file,"r");
|
- |
|
74 |
$result = false;
|
- |
|
75 |
if ($pointeur)
|
- |
|
76 |
{
|
- |
|
77 |
while (!feof($pointeur))
|
- |
|
78 |
{
|
- |
|
79 |
$ligne = fgets($pointeur);
|
- |
|
80 |
if (preg_match($search_regex, $ligne, $r))
|
- |
|
81 |
{
|
- |
|
82 |
$result = true;
|
- |
|
83 |
break;
|
- |
|
84 |
}
|
- |
|
85 |
}
|
- |
|
86 |
}
|
- |
|
87 |
fclose($pointeur);
|
- |
|
88 |
return $result;
|
92 |
|
89 |
}
|
93 |
// html_portail()
|
90 |
// html_portail()
|
94 |
function html_portail () {
|
91 |
function html_portail () {
|
95 |
global $webpath;
|
92 |
global $webpath;
|
96 |
global $XPath;
|
93 |
global $XPath;
|
97 |
global $text;
|
94 |
global $text;
|
98 |
|
95 |
|
99 |
$file_version = "/var/www/html/VERSION";
|
96 |
$file_version = "/var/www/html/VERSION";
|
100 |
$handle = fopen ($file_version, "r");
|
97 |
$handle = fopen ($file_version, "r");
|
101 |
$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
|
98 |
$INSTALLEDVERSION = fread ($handle, filesize ($file_version));
|
102 |
fclose ($handle);
|
99 |
fclose ($handle);
|
103 |
$version_stable = dns_get_record("version.alcasar.info",DNS_TXT);
|
- |
|
104 |
$AVAILABLEDVERSION = $version_stable[0]['txt'];
|
- |
|
105 |
$version_devel = dns_get_record("devel.alcasar.info",DNS_TXT);
|
- |
|
106 |
$DEVELVERSION = $version_devel[0]['txt'];
|
- |
|
107 |
$file_bl = "/var/www/html/VERSION-BL";
|
100 |
$file_bl = "/var/www/html/VERSION-BL";
|
108 |
$handle = fopen ($file_bl, "r");
|
101 |
$handle = fopen ($file_bl, "r");
|
109 |
$VERSIONBL = fread ($handle, filesize ($file_bl));
|
102 |
$VERSIONBL = fread ($handle, filesize ($file_bl));
|
110 |
fclose ($handle);
|
103 |
fclose ($handle);
|
111 |
$nbr_user = utilisateur ();
|
104 |
$nbr_user = request ('user');
|
112 |
$nbr_grp = groupe ();
|
105 |
$nbr_grp = request ('group');
|
113 |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
|
106 |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
|
- |
|
107 |
if (filtrageTest("/usr/local/bin/alcasar-iptables.sh", "/^FILTERING=\"yes\"/")){
|
- |
|
108 |
$network_filter_status = $text['enable'];}
|
- |
|
109 |
else { $network_filter_status = $text['disable'];}
|
- |
|
110 |
if (filtrageTest("/etc/dansguardian/dansguardian.conf","/^reportinglevel = 3/")){
|
- |
|
111 |
$web_filter_status = $text['enable'];}
|
- |
|
112 |
else { $web_filter_status = $text['disable'];}
|
114 |
|
- |
|
115 |
if (InternetTest()){
|
113 |
if (InternetTest()){
|
116 |
$internet_status = "<img src='/images/state_ok.gif'>".$text['internet_enable'];
|
114 |
$internet_status = "<img src='/images/state_ok.gif'>".$text['enable'];
|
- |
|
115 |
$version_stable = dns_get_record("version.alcasar.info",DNS_TXT);
|
- |
|
116 |
$AVAILABLEDVERSION = $version_stable[0]['txt'];
|
- |
|
117 |
$version_devel = dns_get_record("devel.alcasar.info",DNS_TXT);
|
- |
|
118 |
$DEVELVERSION = $version_devel[0]['txt'];
|
- |
|
119 |
|
117 |
} else {
|
120 |
} else {
|
118 |
$internet_status = "<img src='/images/state_error.gif'>".$text['internet_disable'];
|
121 |
$internet_status = "<img src='/images/state_error.gif'>".$text['disable'];
|
- |
|
122 |
$AVAILABLEDVERSION = "-";
|
- |
|
123 |
$DEVELVERSION = "-";
|
119 |
}
|
124 |
}
|
120 |
|
- |
|
121 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
125 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
122 |
. " <tr>\n"
|
126 |
. " <tr>\n"
|
123 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
|
127 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n"
|
124 |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
|
128 |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n"
|
125 |
. " </tr>\n"
|
129 |
. " </tr>\n"
|
126 |
. " <tr>\n"
|
130 |
. " <tr>\n"
|
127 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-stable'] . "</font></td>\n"
|
131 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-disp'] . "</font></td>\n"
|
128 |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n"
|
132 |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . " (stable), " . $DEVELVERSION . " (devel)</font></td>\n"
|
129 |
. " </tr>\n"
|
- |
|
130 |
. " <tr>\n"
|
- |
|
131 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-devel'] . "</font></td>\n"
|
- |
|
132 |
. " <td><font size=\"-1\">" . $DEVELVERSION . "</font></td>\n"
|
- |
|
133 |
. " </tr>\n"
|
133 |
. " </tr>\n"
|
134 |
. " <tr>\n"
|
134 |
. " <tr>\n"
|
135 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\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"
|
136 |
. " <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n"
|
137 |
. " </tr>\n"
|
137 |
. " </tr>\n"
|
Line 142... |
Line 142... |
142 |
. " <tr>\n"
|
142 |
. " <tr>\n"
|
143 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
|
143 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n"
|
144 |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
|
144 |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n"
|
145 |
. " </tr>\n"
|
145 |
. " </tr>\n"
|
146 |
. " <tr>\n"
|
146 |
. " <tr>\n"
|
147 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
|
147 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['filter'] . "</font></td>\n"
|
148 |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
|
148 |
. " <td><font size=\"-1\">web : " . $web_filter_status . ", " . $text['network'] . " : " . $network_filter_status . "</font></td>\n"
|
149 |
. " </tr>\n"
|
149 |
. " </tr>\n"
|
150 |
. " <tr>\n"
|
150 |
. " <tr>\n"
|
151 |
. " <td valign=\"top\" colspan=\"2\"><font size=\"-1\"><a href=\"/certs/certificat_alcasar_ca.pem\">" . $text['ca'] . "</a></font></td>\n"
|
151 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n"
|
- |
|
152 |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n"
|
152 |
. " </tr>\n"
|
153 |
. " </tr>\n"
|
153 |
. "</table>\n";
|
154 |
. "</table>\n";
|
154 |
|
- |
|
155 |
return $_text;
|
155 |
return $_text;
|
156 |
}
|
156 |
}
|
157 |
|
157 |
|
158 |
function wml_portail () {
|
158 |
function wml_portail () {
|
159 |
global $XPath;
|
159 |
global $XPath;
|