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 <?php
use \ParagonIE\EasyDB\Exception;
class Application class Application
{ {
private $database = []; private $database = [];
@ -20,44 +17,39 @@ class Application
$this->database['hostname'] = $cConfigArray['core']['database']['hostname']; $this->database['hostname'] = $cConfigArray['core']['database']['hostname'];
$this->database['dbname'] = $cConfigArray['core']['database']['dbname']; $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() protected function instDB()
{// ConstructorFailed
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); $dsn = "mysql:host=" . $this->database['hostname'] . "dbname=" . $this->database['dbname'];
return $Conn; $username = $this->database['username'];
} $password = $this->database['password'];
echo $this->database['hostname'];
$Conn = \ParagonIE\EasyDB\Factory::create($dsn, $username, $password);
$this->db = $Conn;
} }
public function Exists($Table, $IDRowColumnName, $SearchValue) public function Exists($Table, $IDRowColumnName, $SearchValue)