From a7de7ed80a9db5ecb74e0f4a3836032d9561ee8f Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Fri, 15 Dec 2017 19:44:52 +0100 Subject: [PATCH] Login --- application/config/autoload.php | 4 ++-- application/config/database.php | 8 ++++---- application/core/MY_Controller.php | 6 ++---- application/models/beheer/User.php | 26 ++++++++++++++++++++++++++ public/index.php | 3 ++- 5 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 application/models/beheer/User.php diff --git a/application/config/autoload.php b/application/config/autoload.php index d20f488..34afbb7 100755 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -1,5 +1,5 @@ 'first'); */ -$autoload['model'] = array(); +$autoload['model'] = ['beheer/User']; diff --git a/application/config/database.php b/application/config/database.php index bf9857f..1b40188 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -75,10 +75,10 @@ $query_builder = TRUE; $db['default'] = array( 'dsn' => '', - 'hostname' => 'localhost', - 'username' => '', - 'password' => '', - 'database' => '', + 'hostname' => getenv('DB_HOST'), + 'username' => getenv('DB_USER'), + 'password' => getenv('DB_PASS'), + 'database' => getenv('DB_NAME'), 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 2016b03..ee5427f 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -19,14 +19,12 @@ class MY_Controller extends CI_Controller { private function handle() { - $this->environment(); + } function clean_input( $post ) { - $value = $this->input->post( $post ); - -// $escapedValue = $this->db->escape_string( $value, TRUE ); + $value = $this->input->input_stream( $post, TRUE ); $denulledValue = str_replace( 'null', '', $value); diff --git a/application/models/beheer/User.php b/application/models/beheer/User.php new file mode 100644 index 0000000..bf38e31 --- /dev/null +++ b/application/models/beheer/User.php @@ -0,0 +1,26 @@ +get( [ + 'UCASE(username)' => strtoupper( $username )], FALSE, TRUE); + + return $user; + } + +} \ No newline at end of file diff --git a/public/index.php b/public/index.php index dcb94ad..6c67e0f 100755 --- a/public/index.php +++ b/public/index.php @@ -11,6 +11,7 @@ include_once('../vendor/autoload.php'); $dotenv = new Dotenv\Dotenv('../'); $dotenv->load(); +$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'ENVIRONMENT']); /** @@ -67,7 +68,7 @@ $dotenv->load(); * * NOTE: If you change these, also change the error_reporting() code below */ - define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); + define('ENVIRONMENT', getenv('ENVIRONMENT')); /* *---------------------------------------------------------------