Revert changes

This commit is contained in:
Miguel Nogueira 2018-06-08 17:58:18 +00:00
parent 50f811e5ec
commit d30748f47a
2 changed files with 1420 additions and 36 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,4 @@
<?php
use \ParagonIE\EasyDB\Exception;
class Application
{
private $database = [];
@ -20,44 +17,39 @@ class Application
$this->database['hostname'] = $cConfigArray['core']['database']['hostname'];
$this->database['dbname'] = $cConfigArray['core']['database']['dbname'];
$this->db = $this->instDB();
$this->instDB();
}
private function isHostAlive($domain)
{
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1; // Site is down
else
{
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
protected function instDB()
{// ConstructorFailed
{
$dsn = "mysql:host=" . $this->database['hostname'] . "dbname=" . $this->database['dbname'];
$username = $this->database['username'];
$password = $this->database['password'];
try
{
// FIXME: Find hidden bug ($Conn is null)
$Conn = \ParagonIE\EasyDB\Factory::create(
'mysql:host=' . $this->database['hostname'] . ';dbname=' . $this->database['dbname'],
$this->database['username'],
$this->database['password']
);
if (is_null($Conn))
{
throw new Exception("ERROR! There is no usable connection object.");
}
}
catch (ConstructorFailed $Ex)
{
Analog::log("ALARM! Database connection failed! Message from Wrapper: " . $Ex->getMessage(), Analog::ALERT);
}
catch (Exception $ConEx)
{
Analog::log("ALERT! Unstable DB connection", Analog::ALERT);
}
finally
{
Analog::log("Returning DB connection\n" . var_dump($Conn), Analog::DEBUG);
return $Conn;
}
echo $this->database['hostname'];
$Conn = \ParagonIE\EasyDB\Factory::create($dsn, $username, $password);
$this->db = $Conn;
}
public function Exists($Table, $IDRowColumnName, $SearchValue)