From ab17bd016fa42c9745b2ddd67e1199dbc50c9425 Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 04:01:10 -1100 Subject: [PATCH 1/9] Updated readme --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index ac94635..3041a25 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # Simple_PHP_Auth A Personal PHP Auth which you might find useful. Created for a Faster deployment of your Authentication Web App. +I Basically use it for simple login/Register and stuffs like that. + +# How to Use + +You can take hold of this lib by. +1. Starting up your terminal and punching +$ git clone https://github.com/Kofacts/Simple_PHP_Auth.git +2. Having done that, the package would be installed in a folder named "Simple_PHP_Auth" +3. Create a New instance of the login class which takes two params. Connection name and DB Name with table users_details. + $login = new login($connect,"user_details"); +4. Having done that, You can verify a user by calling. +$login->verifyLogin($_POST['username'],$_POST['password'],$callback_url,$error_message); +5. To register, you can use +$login->register($username,$password,$email,$telephone,$address); in this order + +Actually more features are still been added. + +# I Saw a Bug.. +Wheew. That's Awesome, Do send me a mail obodugorapheal[at]gmail.com + +# Contribute? +DO Send me a pull request. + +# How to Thank Me? +Just Star. Actually... Em, that's just it. + + + From 39793ff97d83ffb95eb989932338083f23e1db68 Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 04:53:32 -1100 Subject: [PATCH 2/9] Added the Some other classes --- src/login.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/login.php b/src/login.php index e291e40..2457912 100644 --- a/src/login.php +++ b/src/login.php @@ -28,7 +28,7 @@ public function __construct($connect,$tablename) $this->tablename=$tablename; } - public function verifyLogin($username,$password,$callback,$errormessage1,$errormessage2) + public function verifyLogin($username,$password,$errormessage1,$errormessage2) { //Verify the user. @@ -50,7 +50,7 @@ public function verifyLogin($username,$password,$callback,$errormessage1,$errorm session_start(); $_SESSION['username']=$this->username; $_SESSION['password']=$this->password; - header("Location: $callback"); + //Stores just the session. ob_flush(); } elseif(!$search11->num_rows>0) @@ -73,6 +73,25 @@ public function verifyLogin($username,$password,$callback,$errormessage1,$errorm } } + public function redirect($url) + { + header("Location: $url"); + } + + public function isLoggedin() + { + //Once the user is logged in. + + if($_SESSION['username']==$this->username && $_SESSION['password']==$this->password) + { + return $this; + } + else{ + $this->redirect("http://www.facebooks.com"); + } + } + + public function logout() { From c6f520d71fd56db2ab87b2ca8d0808ee2c48367a Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 05:01:53 -1100 Subject: [PATCH 3/9] Updated ReadMe.md --- README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3041a25..10a168d 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,34 @@ I Basically use it for simple login/Register and stuffs like that. You can take hold of this lib by. 1. Starting up your terminal and punching + $ git clone https://github.com/Kofacts/Simple_PHP_Auth.git + + 2. Having done that, the package would be installed in a folder named "Simple_PHP_Auth" + + 3. Create a New instance of the login class which takes two params. Connection name and DB Name with table users_details. + $login = new login($connect,"user_details"); -4. Having done that, You can verify a user by calling. + +4. Having done that, You can verify a user by calling. + $login->verifyLogin($_POST['username'],$_POST['password'],$callback_url,$error_message); -5. To register, you can use + +5. You can also Check if the user is loggedin via: + +$login->isLoggedin(); + + +6. To register, you can use + $login->register($username,$password,$email,$telephone,$address); in this order +7. Once the user is loggedin, you can redirect the user using the "redirect() method"; + +$login->redirect(); + Actually more features are still been added. # I Saw a Bug.. From 999a6d2dc7babc5e6eeddd289bcfc9ee85fcc28a Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 05:21:48 -1100 Subject: [PATCH 4/9] Implementing namespacing --- src/login.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/login.php b/src/login.php index 2457912..6e47b46 100644 --- a/src/login.php +++ b/src/login.php @@ -1,4 +1,6 @@ username=$username; $this->password=$password; - $this->callback-$callback; + //$this->callback=$callback; $username1=$this->username; $password1=$this->password; $search1="SELECT * FROM $this->tablename WHERE username='$username1' AND password='$password1'"; @@ -84,10 +86,10 @@ public function isLoggedin() if($_SESSION['username']==$this->username && $_SESSION['password']==$this->password) { - return $this; + return true; } else{ - $this->redirect("http://www.facebooks.com"); + return false; } } From d7f69a8ccbd0ee766320f534dabb02ee5373454a Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 05:35:09 -1100 Subject: [PATCH 5/9] Updated Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 10a168d..4d89e83 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ I Basically use it for simple login/Register and stuffs like that. # How to Use You can take hold of this lib by. + 1. Starting up your terminal and punching $ git clone https://github.com/Kofacts/Simple_PHP_Auth.git From 3a9d8d28431972cf64c09dff6a3e8adff899e4ce Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 05:48:08 -1100 Subject: [PATCH 6/9] Updated Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d89e83..27be159 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ You can take hold of this lib by. $login->register($username,$password,$email,$telephone,$address); in this order -7. Once the user is loggedin, you can redirect the user using the "redirect() method"; +7. Once the user is loggedin, you can redirect the user using the "redirect($url) method"; -$login->redirect(); +$login->redirect($url); Actually more features are still been added. From 67bbbec77f1b8a6c2928ce0a3b2b5c98d8342fb0 Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 06:20:01 -1100 Subject: [PATCH 7/9] Added some updated to the README.md file --- README.md | 2 +- src/Auth.php | 8 ++++++++ test/index.php | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 27be159..fea22b4 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ You can take hold of this lib by. 7. Once the user is loggedin, you can redirect the user using the "redirect($url) method"; -$login->redirect($url); +$login->redirect($url); Actually more features are still been added. diff --git a/src/Auth.php b/src/Auth.php index aa8639d..862e42a 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -1,12 +1,15 @@ verifyLogin($_POST['username'],$_POST['password'],"http://facebook.com","Failed Login","Error"); + $login= new l\login($connect,"user_details"); + //Logs the user in first. + $login->verifyLogin($_POST['username'],$_POST['password'],"Failed Login","Error"); + + if($login->isLoggedin()==TRUE) + { + //Checks when the user is loggedin in.. + var_dump("hello"); + } + else{ + $login->redirect("http://scholarsjoint.com"); + } //$login::guest(); } } From c39b60a1a1559b19215f1691a3043ca4f67fe68c Mon Sep 17 00:00:00 2001 From: Kofacts Date: Tue, 20 Dec 2016 06:28:30 -1100 Subject: [PATCH 8/9] Added Parameter fields and related changes --- src/login.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/login.php b/src/login.php index 6e47b46..494ddad 100644 --- a/src/login.php +++ b/src/login.php @@ -23,6 +23,10 @@ class login{ protected $errormessage1; protected $errormessage2; + /** + * @param requires the connect and table Name. + * + **/ public function __construct($connect,$tablename) { //Empty Shit. @@ -30,6 +34,11 @@ public function __construct($connect,$tablename) $this->tablename=$tablename; } + /** + * @param needs the username, password, error message to display + * Error message can be encapsulated into HTML codes. + **/ + public function verifyLogin($username,$password,$errormessage1,$errormessage2) { //Verify the user. From 81ec40d624b6e8b361fe154fd800e3a7aad9eba2 Mon Sep 17 00:00:00 2001 From: Kofacts Date: Wed, 21 Dec 2016 07:58:11 -1100 Subject: [PATCH 9/9] Implemented Namespacing and some other stuffs --- src/Auth.php | 40 +++++++++++++++++++++++++++++++++------- src/login.php | 2 +- test/index.php | 7 +++++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 862e42a..94dc49e 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -1,25 +1,51 @@ isAlwaysLoggedin(); + + } - public static void user() + static function username() { - + //Use this method to echo the name of the guest. + echo $username; + } - static function guest() + static function email() { + echo $email; + } + static function addr() + { + echo $address; + } + + public function isAlwaysLoggedin() + { + //Check if the user is logged in else redirect. + if($this->isLoggedin()==TRUE) + { + return true; + } + else{ + die("You Need to log in"); + } } } \ No newline at end of file diff --git a/src/login.php b/src/login.php index 494ddad..c27b0aa 100644 --- a/src/login.php +++ b/src/login.php @@ -36,7 +36,7 @@ public function __construct($connect,$tablename) /** * @param needs the username, password, error message to display - * Error message can be encapsulated into HTML codes. + * Error message can be encapsulated into HTML codes. **/ public function verifyLogin($username,$password,$errormessage1,$errormessage2) diff --git a/test/index.php b/test/index.php index 9cfb797..029981c 100644 --- a/test/index.php +++ b/test/index.php @@ -1,6 +1,8 @@ isLoggedin()==TRUE) { //Checks when the user is loggedin in.. - var_dump("hello"); + $auth= new details\Auth(); + $auth::guest(); } else{ $login->redirect("http://scholarsjoint.com");