Exemplo n.º 1
0
 /**
  * call the parent constructor and check for needed extensions
  */
 public function __construct()
 {
     CommonFunctions::checkForSVN();
     CommonFunctions::checkForExtensions();
     $this->error = Error::singleton();
     $this->_checkConfig();
 }
Exemplo n.º 2
0
 public function __construct($pluginname = "", $complete = false)
 {
     $pluginname == "" ? $this->plugin_request = false : ($this->plugin_request = true);
     $complete ? $this->complete_request = true : ($this->complete_request = false);
     $this->errors = Error::singleton();
     if (!$this->plugin_request || $this->complete_request) {
         $this->sysinfo = new sysinfo();
         if (PSI_MBINFO) {
             $this->mbinfo = new mbinfo();
         }
         if (PSI_HDDTEMP) {
             $this->hddtemp = new hddtemp();
         }
         if (PSI_UPSINFO) {
             $this->upsinfo = new upsinfo();
         }
     }
     $this->xml = simplexml_load_string("<?xml version='1.0'?>\n<phpsysinfo></phpsysinfo>");
     $generation = $this->xml->addChild('Generation');
     $generation->addAttribute('version', PSI_VERSION);
     $generation->addAttribute('timestamp', time());
     $options = $this->xml->addChild('Options');
     $options->addChild('tempFormat', tempFormat);
     $options->addChild('byteFormat', byteFormat);
     if (!$this->plugin_request || $this->complete_request) {
         $this->plugins = explode(",", PSI_PLUGINS);
         $plug = $options->addChild('Used_Plugins');
         foreach ($this->plugins as $plugin) {
             $plug->addChild('Plugin', $plugin);
         }
     } else {
         $this->plugins = array($pluginname);
     }
 }
Exemplo n.º 3
0
 public function __construct()
 {
     $this->error = Error::singleton();
     // don't set this params for local connection, it will not work
     $strHostname = '';
     $strUser = '';
     $strPassword = '';
     // initialize the wmi object
     $objLocator = new COM("WbemScripting.SWbemLocator");
     if ($strHostname == "") {
         $this->wmi = $objLocator->ConnectServer();
     } else {
         $this->wmi = $objLocator->ConnectServer($strHostname, "rootcimv2", "{$strHostname}\$strUser", $strPassword);
     }
 }
Exemplo n.º 4
0
/**
 * sets a user-defined error handler function
 *
 * @param integer $level   contains the level of the error raised, as an integer.
 * @param string  $message contains the error message, as a string.
 * @param string  $file    which contains the filename that the error was raised in, as a string.
 * @param integer $line    which contains the line number the error was raised at, as an integer.
 *
 * @return void
 */
function errorHandlerPsi($level, $message, $file, $line)
{
    $error = Error::singleton();
    $error->addPhpError("errorHandlerPsi : ", "Level : " . $level . " Message : " . $message . " File : " . $file . " Line : " . $line);
}
Exemplo n.º 5
0
 /**
  * build the global Error object
  */
 public function __construct()
 {
     $this->error = Error::singleton();
     $this->mbinfo = new MBInfo();
 }
 /**
  * reads a directory and return the name of the files and directorys in it
  *
  * @param string  $strPath     path of the directory which should be read
  * @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
  *
  * @return array content of the directory excluding . and ..
  */
 public static function gdc($strPath, $booErrorRep = true)
 {
     $arrDirectoryContent = array();
     $error = Error::singleton();
     if (is_dir($strPath)) {
         if ($handle = opendir($strPath)) {
             while (($strFile = readdir($handle)) !== false) {
                 if ($strFile != "." && $strFile != "..") {
                     $arrDirectoryContent[] = $strFile;
                 }
             }
             closedir($handle);
         } else {
             if ($booErrorRep) {
                 $error->addError('opendir(' . $strPath . ')', 'directory can not be read by phpsysinfo');
             }
         }
     } else {
         if ($booErrorRep) {
             $error->addError('is_dir(' . $strPath . ')', 'directory does not exist on your machine');
         }
     }
     return $arrDirectoryContent;
 }
Exemplo n.º 7
0
 * external is needed when running in static mode
 *
 * @var boolean
 */
define('PSI_INTERNAL_XML', false);
if (version_compare("5.2", PHP_VERSION, ">")) {
    die("PHP 5.2 or greater is required!!!");
}
if (!extension_loaded("pcre")) {
    die("phpSysInfo requires the pcre extension to php in order to work properly.");
}
require_once APP_ROOT . '/includes/autoloader.inc.php';
// Load configuration and perform system check
try {
    require_once APP_ROOT . '/read_config.php';
} catch (Exception $e) {
}
require_once APP_ROOT . '/systemcheck.php';
if (Error::singleton()->errorsExist()) {
    $tpl = new Template("/views/errors.html");
    $tpl->set('errors', Error::singleton()->getErrors());
    echo $tpl->fetch();
    exit(-1);
}
$tpl = new Template("/views/index.html");
$tpl->set('plugins', CommonFunctions::getPlugins());
require_once '../includes/config.php';
include '../templates/' . $CONF['template'] . '/header.php';
echo $tpl->fetch();
set_page_title('Teknik Server Stats');
include '../templates/' . $CONF['template'] . '/footer.php';
Exemplo n.º 8
0
 /**
  * doing some initial tasks
  * - generate the xml structure with the right header elements
  * - get the error object for error output
  * - get a instance of the sysinfo object
  *
  * @param boolean $complete   generate xml with all plugins or not
  * @param string  $pluginname name of the plugin
  *
  * @return void
  */
 public function __construct($complete = false, $pluginname = "")
 {
     $this->_errors = Error::singleton();
     if ($pluginname == "") {
         $this->_plugin_request = false;
         $this->_plugin = '';
     } else {
         $this->_plugin_request = true;
         $this->_plugin = $pluginname;
     }
     if ($complete) {
         $this->_complete_request = true;
     } else {
         $this->_complete_request = false;
     }
     $os = PSI_OS;
     $this->_sysinfo = new $os();
     $this->_plugins = CommonFunctions::getPlugins();
     $this->_xmlbody();
 }
Exemplo n.º 9
0
 /**
  * build the global Error object
  */
 public function __construct()
 {
     $this->error = Error::singleton();
     $this->sys = new System();
 }
Exemplo n.º 10
0
}
// also require 'com_dotnet' on Windows systems
if (PHP_OS == 'WINNT') {
    $required_extensions[] = 'com_dotnet';
}
$loaded_extensions = get_loaded_extensions();
foreach ($required_extensions as $ext) {
    if (!in_array($ext, $loaded_extensions)) {
        Error::singleton()->adderror("warn", "phpsysinfo requires extension '" . $ext . "' to be loaded");
    }
}
// safe mode check
$safe_mode = @ini_get("safe_mode") ? true : false;
if ($safe_mode) {
    Error::singleton()->adderror("warn", "phpsysinfo requires to set off 'safe_mode' in 'php.ini'");
}
// include path check
$include_path = @ini_get("include_path");
if ($include_path && $include_path != "") {
    $include_path = preg_replace("/(:)|(;)/", "\n", $include_path);
    if (preg_match("/^\\.\$/m", $include_path)) {
        $include_path = ".";
    }
}
if ($include_path != ".") {
    Error::singleton()->adderror("warn", "phpsysinfo requires '.' inside the 'include_path' in php.ini");
}
// popen mode check
if (defined("PSI_MODE_POPEN") && psi_mode_popen === true) {
    Error::singleton()->adderror("warn", "installed version of php does not support proc_open() function, popen() is used");
}
Exemplo n.º 11
0
session_start();
$username = $_SESSION['loggedin_username'];
$password = $_SESSION['loggedin_password'];
$isloggedin = $_SESSION['isloggedin'];
if (!$isloggedin or $password == "") {
    header("Location: ..");
    exit;
    // this is only exit to redirect to loginform, when not logged in.
}
if (PHP_VERSION < 5.2) {
    die("PHP 5.2 or greater is required!!!");
}
define('APP_ROOT', dirname(__FILE__));
require_once './includes/common_functions.php';
checkForExtensions();
$error = Error::singleton();
if (!is_readable('/etc/phpsysinfo/config.php')) {
    $error->addError('file_exists(/etc/phpsysinfo/config.php)', '/etc/phpsysinfo/config.php does not exist or is not readable by the webserver in the phpsysinfo directory.');
} else {
    require_once '/etc/phpsysinfo/config.php';
    // get the config file
}
if ($error->ErrorsExist()) {
    echo $error->ErrorsAsHTML();
    exit;
}
//redirection part
include './includes/redir.php';
//checking config.php setting for template, if not supportet set phpsysinfo.css as default
$template = template;
if (!file_exists('templates/' . $template)) {
Exemplo n.º 12
0
    private function GetGeneralInformations() {

        $results = array();

        // Distribution
        if(CommonFunctions::rfts('/proc/version', $distribData)) {
            $results['Distribution'] = trim($distribData);
        }

        // Ip de la machine
        if(CommonFunctions::executeProgram("ifconfig", $this->config->ifnetwork.' | grep inet | cut -d":" -f2 | cut -d" " -f1', $buffer)) {
            $results['IPMachine'] = $buffer;
        }

        // Marque
        if(CommonFunctions::executeProgram("hwinfo", '--bios | grep -m1 ^\ \ \ \ Manufacturer: | cut -f2 -d\"', $buffer)) {
            $results['Marque'] = $buffer;
        }
        else {
            $results['Marque'] = '<![CDATA['.Error::singleton()->errorsAsXML().']]>';
        }

        // Model
        if(CommonFunctions::executeProgram("hwinfo", "--bios | grep -m1 ^\ \ \ \ Product: | cut -f2 -d\\\"", $buffer)) {
            $results['Model'] = $buffer;
        }

        $results['Prod'] = trim($this->config->isProductionServer);
        $results['AnnuThere'] = 0;

        // Genre
        if(CommonFunctions::executeProgram("dpkg", "-l | grep lcs-web", $buffer)) {
            if(strlen($buffer) > 0) {
                $this->genre = 'LCS';
            }
            else {
                if(CommonFunctions::executeProgram("dpkg", "-l | grep se3", $buffer)) {
                    if(strlen($buffer) > 0) {
                        $this->genre = 'SE3';
                    }
                    else {
                        $this->genre = 'UNKNOW';
                    }

                }
            }
        }


        $results['Genre'] = $this->genre;

        //Kernel
        $results['Kernel'] = $this->kernel();

        // UpTime
        $results['Uptime'] = $this->uptime();

        return '<GeneralInformations>
'.CommonFunctions::ArrayToXML($results).'
</GeneralInformations>';
    }
 /**
  * function for getting a list of values in the specified context
  * optionally filter this list, based on the list from third parameter
  *
  * @param $wmi holds the COM object that we pull the WMI data from
  * @param string $strClass name of the class where the values are stored
  * @param array  $strValue filter out only needed values, if not set all values of the class are returned
  *
  * @return array content of the class stored in an array
  */
 public static function getWMI($wmi, $strClass, $strValue = array())
 {
     $arrData = array();
     if ($wmi) {
         $value = "";
         try {
             $objWEBM = $wmi->Get($strClass);
             $arrProp = $objWEBM->Properties_;
             $arrWEBMCol = $objWEBM->Instances_();
             foreach ($arrWEBMCol as $objItem) {
                 if (is_array($arrProp)) {
                     reset($arrProp);
                 }
                 $arrInstance = array();
                 foreach ($arrProp as $propItem) {
                     $value = $objItem->{$propItem->Name};
                     //instead exploitable eval("\$value = \$objItem->".$propItem->Name.";");
                     if (empty($strValue)) {
                         if (is_string($value)) {
                             $arrInstance[$propItem->Name] = trim($value);
                         } else {
                             $arrInstance[$propItem->Name] = $value;
                         }
                     } else {
                         if (in_array($propItem->Name, $strValue)) {
                             if (is_string($value)) {
                                 $arrInstance[$propItem->Name] = trim($value);
                             } else {
                                 $arrInstance[$propItem->Name] = $value;
                             }
                         }
                     }
                 }
                 $arrData[] = $arrInstance;
             }
         } catch (Exception $e) {
             if (PSI_DEBUG) {
                 $error = Error::singleton();
                 $error->addError($e->getCode(), $e->getMessage());
             }
         }
     }
     return $arrData;
 }
Exemplo n.º 14
0
<?php

if (!defined('PSI_CONFIG_FILE')) {
    /**
     * phpSysInfo version
     */
    define('PSI_VERSION', '4.0-wip');
    /**
     * phpSysInfo configuration
     */
    define('PSI_CONFIG_FILE', APP_ROOT . '/phpsysinfo.ini');
    define('ARRAY_EXP', '/^return array \\([^;]*\\);$/');
    //array expression search
    if (!is_readable(PSI_CONFIG_FILE) || !($config = @parse_ini_file(PSI_CONFIG_FILE, true))) {
        Error::singleton()->addError('warn', "Configuration file '" . PSI_CONFIG_FILE . "' not readable");
        throw new Exception('init: config file not readable');
    } else {
        foreach ($config as $name => $group) {
            if (strtoupper($name) == "MAIN") {
                $name_prefix = 'PSI_';
            } else {
                $name_prefix = 'PSI_PLUGIN_' . strtoupper($name) . '_';
            }
            foreach ($group as $param => $value) {
                if ($value === "" || $value === "0") {
                    define($name_prefix . strtoupper($param), false);
                } elseif ($value === "1") {
                    define($name_prefix . strtoupper($param), true);
                } else {
                    if (strstr($value, ',')) {
                        define($name_prefix . strtoupper($param), 'return ' . var_export(preg_split('/\\s*,\\s*/', $value, -1, PREG_SPLIT_NO_EMPTY), 1) . ';');