diff --git a/.htaccess b/.htaccess index 3e4fb32..5d64a02 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,6 @@ RewriteEngine On +RewriteRule ^home/([a-z0-9]+)/([a-z0-9]+) validate.php?data=$1&&data2=$2 RewriteRule ^home/([a-z0-9]+) validate.php?data=$1 RewriteRule ^home validate.php?data=home RewriteRule ^logout logout.php diff --git a/controller/AuthController.php b/controller/AuthController.php index c2fa320..2c438f4 100644 --- a/controller/AuthController.php +++ b/controller/AuthController.php @@ -24,7 +24,7 @@ function fn_Login($conn, $username, $password) return "success"; } else{ - return "Failed to login " .$count; + return "Failed to login "; } } catch (Exception $e) @@ -32,4 +32,44 @@ function fn_Login($conn, $username, $password) return "Failed to login " .$e->getMessage(); } } + + function insert_2authfactorlogs($conn,$username, $hash) + { + try + { + $now = new DateTime(); + $dt = $now->format('Y-m-d H:i:s'); + $dt1 = $now->format('m-Y-d H:i:s'); + $dt2 = $now->format('d-m-Y H:i:s'); + $dttime = $now->format('Y-m-d H:i:s'); + $id = round($dt).round($dt1).round($dt2).round(microtime(true)); + + $sql = "INSERT INTO 2authfactorlogs (2authID, username, status, dt, hash) + VALUES ('$id', '$username', 'active', '$dttime', $hash)"; + $conn->exec($sql); + return "success"; + } + catch (Exception $e) + { + return "Failed to login " .$e->getMessage(); + } + } + + function insert_2authfactor_func($conn,$username, $code) + { + try + { + $now = new DateTime(); + $dttime = $now->format('Y-m-d H:i:s'); + $sql = "INSERT INTO 2authfactor (userid, status, code, dt) + VALUES ('$username', 'active', '$code', '$dttime')"; + $conn->exec($sql); + return "success"; + } + catch (Exception $e) + { + return "Failed to login " .$e->getMessage(); + } + } + } \ No newline at end of file diff --git a/validate.php b/validate.php index f6e0046..b162888 100644 --- a/validate.php +++ b/validate.php @@ -36,7 +36,8 @@ if (strtoupper($data) == "LOGIN" || strtoupper($data) == "REGISTER" || strtoupper($data) == "FORGOTPASS" || - strtoupper($data) == "LOGOUT") + strtoupper($data) == "LOGOUT" || + strtoupper($data) == "TWOAUTHFACTOR") { echo ' '; @@ -61,6 +62,10 @@ else if(strtoupper($data) == "FORGOTPASS") { include "view/auth/forgotpassword.php"; + } + else if(strtoupper($data) == "TWOAUTHFACTOR") + { + include "view/auth/2authfactor.front.php"; } else if(strtoupper($data) == "LOGOUT") { diff --git a/view/auth/2authfactor.front.php b/view/auth/2authfactor.front.php new file mode 100644 index 0000000..2c70014 --- /dev/null +++ b/view/auth/2authfactor.front.php @@ -0,0 +1,35 @@ +