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:
Miguel Nogueira
2018-06-08 15:38:27 +00:00
parent 65a3c7bf1b
commit c9d71b422a
3 changed files with 62 additions and 9 deletions

View File

@@ -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(