Database crentials were incorrect.
Also wrapped database logic inside the correct try catch block to prevent further mishaps and information leakages. Fixes #6.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \ParagonIE\EasyDB\Exception;
|
||||
|
||||
class Application
|
||||
{
|
||||
private $database = [];
|
||||
@@ -11,6 +13,8 @@ class Application
|
||||
$config = new Config();
|
||||
$cConfigArray = $config->getConfig();
|
||||
|
||||
|
||||
|
||||
$this->database['username'] = $cConfigArray['core']['database']['username'];
|
||||
$this->database['password'] = $cConfigArray['core']['database']['password'];
|
||||
$this->database['hostname'] = $cConfigArray['core']['database']['hostname'];
|
||||
@@ -21,15 +25,30 @@ class Application
|
||||
}
|
||||
|
||||
protected function instDB()
|
||||
{
|
||||
{// ConstructorFailed
|
||||
|
||||
|
||||
return \ParagonIE\EasyDB\Factory::create(
|
||||
try
|
||||
{
|
||||
|
||||
$connection = \ParagonIE\EasyDB\Factory::create(
|
||||
'mysql:host=' . $this->database['hostname'] . ';dbname=' . $this->database['dbname'],
|
||||
$this->database['username'],
|
||||
$this->database['password']
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
catch (ConstructorFailed $Ex)
|
||||
{
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
exit("An error has ocurred and therefore we are unable to fulfill your request for information. Sorry.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
public function Exists($Table, $IDRowColumnName, $SearchValue)
|
||||
{
|
||||
$exists = $db->cell(
|
||||
|
Reference in New Issue
Block a user