private final function __construct() { try { $a = Application::getAppInfo(); self::$connection = new PDO("mysql:host=" . $a->GetDBHost() . ";dbname=" . $a->GetDBName(), $a->GetDBUser(), $a->GetDBPass()); } catch (PDOException $e) { throw new Exception("Impossible to establish connection to DB"); } }
<?php session_start(); include_once dirname(__FILE__) . "/classes/User.php"; include_once dirname(__FILE__) . "/classes/Application.php"; include_once dirname(__FILE__) . "/functions/functions.php"; if (!isset($_SESSION['USERNAME'])) { redirect("login.php", 301); } else { //TODO control of session duration try { $user = new User($_SESSION['USERNAME']); $app = Application::getAppInfo(); $fs = $app->GetFS(); if (count($fs) <= 0) { throw new Exception("You have to configure widget in config file"); } $output = shell_exec("df"); $o = explode("\n", $output); $used = 0; $avail = 0; $data = NULL; foreach ($o as $line) { $l = preg_replace("/ +/", " ", $line); $e = explode(" ", $l); if (isset($e[5])) { if (isset($fs[$e[5]])) { $data[] = array($fs[$e[5]], $e[2], $e[3]); } } }