0,0 → 1,179 |
<?php |
/*************************************************************************** |
* Copyright (C) 2006 by phpSysInfo - A PHP System Information Script * |
* http://phpsysinfo.sourceforge.net/ * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License, or * |
* (at your option) any later version. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
|
// $Id: vitals.php,v 1.32 2007/02/18 18:59:54 bigmichi1 Exp $ |
|
// xml_utilisateur() |
|
function utilisateur () { |
$strResult = 0; |
// Déclaration des paramètres de connexion |
$host = "localhost"; |
$DB_USER = "radius"; |
$DB_RADIUS = "radius"; |
$radiuspwd = "gLMmnOpk"; |
// Connexion au serveur |
mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur"); |
mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees"); |
// Creation et envoi de la requete |
$query = "SELECT UserName FROM userinfo"; |
$result = mysql_query($query); |
// Recuperation des resultats |
$strResult = mysql_num_rows($result); |
// Deconnexion de la base de donnees |
mysql_close(); |
return $strResult; |
} |
|
function groupe () { |
$strResult = 0; |
// Déclaration des paramètres de connexion |
$host = "localhost"; |
$DB_USER = "radius"; |
$DB_RADIUS = "radius"; |
$radiuspwd = "gLMmnOpk"; |
// Connexion au serveur |
mysql_connect($host, $DB_USER,$radiuspwd) or die("erreur de connexion au serveur"); |
mysql_select_db($DB_RADIUS) or die("erreur de connexion a la base de donnees"); |
// Creation et envoi de la requete |
$query = "SELECT GroupName FROM radusergroup GROUP BY GroupName"; |
$result = mysql_query($query); |
// Recuperation des resultats |
$strResult = mysql_num_rows($result); |
// Deconnexion de la base de donnees |
mysql_close(); |
return $strResult; |
} |
|
function xml_portail () { |
global $sysinfo; |
|
$_text = " <Portail>\n" |
// . " <Utilisateur>" . htmlspecialchars( $sysinfo->utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n" |
. " <Utilisateur>" . htmlspecialchars( utilisateur(), ENT_QUOTES ) . "</Utilisateur>\n" |
. " <Groupe>" . htmlspecialchars( trim( groupe() ), ENT_QUOTES ) . "</Groupe>\n"; |
$_text .= " </Portail>\n"; |
|
return $_text; |
} |
|
// Fonction de test de connectivité internet |
function internetTest(){ |
$host = "www.google.fr"; |
$port = "80"; |
//var $num; //non utilisé |
//var $error; //non utilisé |
|
if (! $sock = @fsockopen($host, $port, $num, $error, 5)) { |
return false; |
} else { |
fclose($sock); |
return true; |
} |
} |
|
// html_portail() |
function html_portail () { |
global $webpath; |
global $XPath; |
global $text; |
|
$file_version = "/var/www/html/VERSION"; |
$handle = fopen ($file_version, "r"); |
$INSTALLEDVERSION = fread ($handle, filesize ($file_version)); |
fclose ($handle); |
$version_stable = dns_get_record("version.alcasar.info",DNS_TXT); |
$AVAILABLEDVERSION = $version_stable[0]['txt']; |
$version_devel = dns_get_record("devel.alcasar.info",DNS_TXT); |
$DEVELVERSION = $version_devel[0]['txt']; |
$file_bl = "/var/www/html/VERSION-BL"; |
$handle = fopen ($file_bl, "r"); |
$VERSIONBL = fread ($handle, filesize ($file_bl)); |
fclose ($handle); |
$nbr_user = utilisateur (); |
$nbr_grp = groupe (); |
$nbr_user_online = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l"); |
|
if (InternetTest()){ |
$internet_status = "<img src='/images/state_ok.gif'>".$text['internet_enable']; |
} else { |
$internet_status = "<img src='/images/state_error.gif'>".$text['internet_disable']; |
} |
|
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-version'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $INSTALLEDVERSION . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-stable'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $AVAILABLEDVERSION . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['portail-devel'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $DEVELVERSION . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['utilisateur'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $nbr_user_online . " / " . $nbr_user . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['groupe'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $nbr_grp . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['bl-version'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $VERSIONBL . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\"><font size=\"-1\">" . $text['internet_link'] . "</font></td>\n" |
. " <td><font size=\"-1\">" . $internet_status . "</font></td>\n" |
. " </tr>\n" |
. " <tr>\n" |
. " <td valign=\"top\" colspan=\"2\"><font size=\"-1\"><a href=\"/certs/certificat_alcasar_ca.pem\">" . $text['ca'] . "</a></font></td>\n" |
. " </tr>\n" |
. "</table>\n"; |
|
return $_text; |
} |
|
function wml_portail () { |
global $XPath; |
global $text; |
|
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n" |
. "<p>" . $text['hostname'] . ":<br/>\n" |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n" |
. "<p>" . $text['ip'] . ":<br/>\n" |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n" |
. "<p>" . $text['kversion'] . ":<br/>\n" |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n" |
. "<p>" . $text['uptime'] . ":<br/>\n" |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n" |
. "<p>" . $text['users'] . ":<br/>" |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n" |
. "<p>" . $text['loadavg'] . ":<br/>" |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n" |
. "</card>\n"; |
|
return $_text; |
} |
?> |