From 4a6523cd2da9ccc5a2b4a334e7a33a84f97f1e5b Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sat, 24 Jun 2017 13:42:16 -0400 Subject: Add creds.php file, attempt to connect to database --- .htaccess | 3 ++ index.php | 2 + private/controller/Controller.php | 2 + private/model/Connection.php | 23 ++++++++- private/model/creds.php | 103 ++++++++++++++++++++++++++++++++++++++ private/view/Result.php | 4 +- 6 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 .htaccess create mode 100644 private/model/creds.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..611f7cc --- /dev/null +++ b/.htaccess @@ -0,0 +1,3 @@ +RewriteEngine On +RewriteRule ^/api/ index.php +RedirectMatch 403 ^/private/.*$ diff --git a/index.php b/index.php index 425f8e9..03bce1b 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,7 @@ getHost() . + (($cred->getPort() !== '') ? ";port=" . $cred->getPort() : '') . + ";dbname=" . $cred->getDBName(), + $cred->getLogin(), + $cred->getPassword() + ); + // we destroy $cred as quickly as possible + $cred = null; + } catch (PDOException as $e) { + // we destroy $cred as quickly as possible + $cred = null; + die(json_encode(array("Result-Type" => "Error", "Content" => array($e)))); + } } } diff --git a/private/model/creds.php b/private/model/creds.php new file mode 100644 index 0000000..8ec06ad --- /dev/null +++ b/private/model/creds.php @@ -0,0 +1,103 @@ + "", "Content" => array())); -- cgit