From 472e170f408e3d8d1db2eb066d445153aad55d73 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 29 Jan 2021 03:26:28 +0200 Subject: register and login looks ok --- README | 6 +++++ css/style.css | 1 + index.html | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 64 ---------------------------------------------------- js/arrows.js | 2 +- js/validate_hero.js | 25 ++++++++++++++++----- login.html | 55 +++++++++++++++++++++++++++++++++++++++++++++ php/database.php | 25 +++++++++++---------- php/login.php | 25 +++++++++++++++++++++ php/register.php | 27 ++++++++++++++++++++++ register.php | 27 ---------------------- 11 files changed, 213 insertions(+), 109 deletions(-) create mode 100644 README create mode 100644 index.html delete mode 100644 index.php create mode 100644 login.html create mode 100644 php/login.php create mode 100644 php/register.php delete mode 100644 register.php diff --git a/README b/README new file mode 100644 index 0000000..e9f371a --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +FILEUP + + + +for this to work you need to have mysql. Create a database and a user for this service then +modify php/configure.php as needed. Create tables described in sql/fileshare.sql diff --git a/css/style.css b/css/style.css index 76eb6e8..31778c4 100644 --- a/css/style.css +++ b/css/style.css @@ -161,6 +161,7 @@ input[type=submit] { box-shadow: 0 0.2rem 0.6rem #eee; background: #231179; color: white; + outline: none; } input:focus, diff --git a/index.html b/index.html new file mode 100644 index 0000000..6a2018b --- /dev/null +++ b/index.html @@ -0,0 +1,65 @@ + + + + + shady file upload + + + + +
+
+ + +
+
+
+ +
+ +
+

file upload service

+

that just about works

+

most of the time

+
+
+ +
+
+

Get started

+
+

Username

+ + + +

Email address

+ + + +

Password

+ + + +

Repeat Password

+ + + +

Don't have an account? Log in +

+
+
+ + +
+
+ + +
+ + + + + + diff --git a/index.php b/index.php deleted file mode 100644 index 38eb660..0000000 --- a/index.php +++ /dev/null @@ -1,64 +0,0 @@ - - - - - shady file upload - - - - -
-
- - -
-
-
- -
- -
-

file upload service

-

that just about works

-

most of the time

-
-
- -
-
-

Get started

-
-

Username

- - - -

Email address

- - - -

Password

- - -

Repeat Password

- - - -

Already have an account? Sign in -

-
-
- - -
-
- - -
- - - - - - diff --git a/js/arrows.js b/js/arrows.js index ec7352c..10ad416 100644 --- a/js/arrows.js +++ b/js/arrows.js @@ -20,7 +20,7 @@ function make_arrow() { setTimeout(make_arrow, delay); setTimeout(() => { svg.remove(); - arrows.remove(ob); + arrows.shift(); }, lifetime); } diff --git a/js/validate_hero.js b/js/validate_hero.js index 118abbf..6d29a53 100644 --- a/js/validate_hero.js +++ b/js/validate_hero.js @@ -8,6 +8,20 @@ function clear_hero_errors() errors[i].hidden = true; } } +function validate_hero_login_form() +{ + var username=document.forms["hero_form"]["username"].value; + var flag=true; + clear_hero_errors(); + + if(username.length==0) + { + document.getElementById("username-length-error").hidden=false; + flag=false; + } + document.activeElement.blur(); + return flag; +} function validate_hero_form() { var username=document.forms["hero_form"]["username"].value; @@ -28,16 +42,17 @@ function validate_hero_form() document.getElementById("email-error").hidden=false; flag=false; } - if(password !== password2) + if(password.length==0) { - document.getElementById("password-error").hidden=false; + document.getElementById("password-length-error").hidden=false; flag=false; } - - if(flag) + if(password !== password2) { - document.getElementById("success").hidden=false; + document.getElementById("password-match-error").hidden=false; + flag=false; } + document.activeElement.blur(); return flag; } diff --git a/login.html b/login.html new file mode 100644 index 0000000..525358f --- /dev/null +++ b/login.html @@ -0,0 +1,55 @@ + + + + + shady file upload + + + + +
+
+ + +
+
+
+ +
+ +
+

file upload service

+

that just about works

+

most of the time

+
+
+ +
+
+

Login

+
+

Username

+ + +

Password

+ + +

Already have an account? Sign up +

+
+
+ + +
+
+ + +
+ + + + + + diff --git a/php/database.php b/php/database.php index 934aafa..ef2b825 100644 --- a/php/database.php +++ b/php/database.php @@ -26,7 +26,7 @@ require_once "misc.php"; } } - /*returns false if this isn't a user, otherwise returns the userid*/ + /*returns false if this isn't a user, otherwise returns the user*/ function get_user(string $user) { $ret=new User; @@ -53,24 +53,25 @@ require_once "misc.php"; function authenticate(string $user, string $password) { $ret=new User; - global $password_hash_algo; - - - $hashed_pass=password_hash($password,$password_hash_algo); - $prep=$this->pdo->prepare("select user_id,username,email from users where username=:username and password=:password"); + $prep=$this->pdo->prepare("select user_id,username,email,password from users where username=:username"); $prep->bindParam(':username',$user); - $prep->bindParam(':password',$hashed_pass); - $prep->execute(); $hold=$prep->fetch(PDO::FETCH_ASSOC); + if($hold) { - $ret->user_id=hold["user_id"]; - $ret->username=hold["username"]; - $ret->email_address["email"]; - return $ret; + if(password_verify($password,$hold["password"])) + { + $ret->user_id=$hold["user_id"]; + $ret->username=$hold["username"]; + $ret->email_address=$hold["email"]; + return $ret; + }else + { + return false; + } }else { return false; diff --git a/php/login.php b/php/login.php new file mode 100644 index 0000000..e6d44dc --- /dev/null +++ b/php/login.php @@ -0,0 +1,25 @@ +authenticate($username,$password); +if(!$user) +{ + die("Password or username is incorrect"); +} + +echo "Username: {$user->username}\n"; +echo "Email: {$user->email_address}"; + + +?> diff --git a/php/register.php b/php/register.php new file mode 100644 index 0000000..b6b164c --- /dev/null +++ b/php/register.php @@ -0,0 +1,27 @@ +register_user($username,$password,$email)) +{ + echo "registered"; +}else +{ + echo "didn't register"; +} + +?> diff --git a/register.php b/register.php deleted file mode 100644 index 0c00ad4..0000000 --- a/register.php +++ /dev/null @@ -1,27 +0,0 @@ -register_user($username,$password,$email)) -{ - echo "registered"; -}else -{ - echo "didn't register"; -} - -?> -- cgit v1.2.3