From ca784b878869279c95deaaadb754f17646e172dc Mon Sep 17 00:00:00 2001 From: Neku Date: Sun, 15 Dec 2013 10:17:54 +0100 Subject: some changes --- moe/api.php | 28 -------- moe/core.php | 71 ------------------- moe/css/style.css | 179 ++++++++++++++++++++++++++++++++++++++++++++++++ moe/includes/api.php | 23 +++++++ moe/includes/core.php | 36 ++++++++++ moe/login/index.html | 48 +++++++++++++ moe/register/index.html | 45 ++++++++++++ moe/settings.php | 22 ------ 8 files changed, 331 insertions(+), 121 deletions(-) delete mode 100644 moe/api.php delete mode 100644 moe/core.php create mode 100644 moe/css/style.css create mode 100644 moe/includes/api.php create mode 100644 moe/includes/core.php create mode 100644 moe/login/index.html create mode 100644 moe/register/index.html delete mode 100644 moe/settings.php diff --git a/moe/api.php b/moe/api.php deleted file mode 100644 index f9313f5..0000000 --- a/moe/api.php +++ /dev/null @@ -1,28 +0,0 @@ - 'closedreg'); - json_encode($return); - } - -}elseif ($in['action']['0']=='login') { - login($in['info']['0'], $in['info']['1']); -} -?> \ No newline at end of file diff --git a/moe/core.php b/moe/core.php deleted file mode 100644 index c2a5c67..0000000 --- a/moe/core.php +++ /dev/null @@ -1,71 +0,0 @@ -prepare("SELECT password FROM users WHERE username = (:user)"); - $do->bindParam(':user', $username); - $do->execute(); - $pass = $do->fetch(); - - // Check if hash is the same as the one in DB - if($pass['0']===$password){ - // Return good result - $return = array('action' => 'cp', 'info' => 'Logged in.'); - }else{ - // Return bad result - $return = array('info' => 'Wrong username or password, try again.'); - } - // Return result with JSON - json_encode($return); -) - -// Registration function -function register ($username, $password, $email) { - global $db; - - // Check if username, email, etc exists - $do = $db->prepare("SELECT user,email FROM users WHERE username = (:user) OR email = (:email)"); - $do->bindParam(':user', $username); - $do->bindParam(':email', $email); - $do->exeute(); - $count = $do->rowCount(); - - // If already exists display mess, otherwise continue - if(!$count==='0'){ - // Return result - $return = array('info' => 'User already exists.'); - }else{ - // Generate password hash - $hash = password_hash($password, PASSWORD_BCRYPT, bsettings)."\n"; - // Register new user - $do = $db->prepare("INSERT INTO users (username, password, email, date) VALUES (:user, :pass, :email, :date)"); - $do->bindParam(':user', $username); - $do->bindParam(':pass', $hash); - $do->bindParam(':email', $email); - $do->bindValue(':date', date('Y-m-d')); - $do->exeute(); - // Return that user has been made and goto login - $return = array('action' => 'login', 'info' => 'User has been made, login.'); - } - // Return JSON - json_encode($return); -} - -function delete ($id, $delid) { - global $db; - -} -?> \ No newline at end of file diff --git a/moe/css/style.css b/moe/css/style.css new file mode 100644 index 0000000..2ee2921 --- /dev/null +++ b/moe/css/style.css @@ -0,0 +1,179 @@ +@charset "utf-8"; +/* CSS Document */ + +/* ---------- GENERAL ---------- */ + +body { + background: #eaeaea; + color: #999; + font: 100%/1.5em sans-serif; + margin: 0; +} + +h3 { margin: 0; } + +a { + color: #999; + text-decoration: none; +} + +a:hover { color: #1dabb8; } + +fieldset { + border: none; + margin: 0; +} + +input { + border: none; + font-family: inherit; + font-size: inherit; + margin: 0; + -webkit-appearance: none; +} + +input:focus { + outline: none; +} + +input[type="submit"] { cursor: pointer; } + +.clearfix { *zoom: 1; } +.clearfix:before, .clearfix:after { + content: ""; + display: table; +} +.clearfix:after { clear: both; } + +/* ---------- LOGIN-FORM ---------- */ + +#login-form { + margin: 50px auto; + width: 300px; +} + +#login-form h3 { + background-color: #282830; + border-radius: 5px 5px 0 0; + color: #fff; + font-size: 14px; + padding: 20px; + text-align: center; + text-transform: uppercase; +} + +#login-form fieldset { + background: #fff; + border-radius: 0 0 5px 5px; + padding: 20px; + position: relative; +} + +#login-form fieldset:before { + background-color: #fff; + content: ""; + height: 8px; + left: 50%; + margin: -4px 0 0 -4px; + position: absolute; + top: 0; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + width: 8px; +} + +#login-form input { + font-size: 14px; +} + +#login-form input[type="email"], +#login-form input[type="password"] { + border: 1px solid #dcdcdc; + padding: 12px 10px; + width: 238px; +} + +#login-form input[type="email"] { + border-radius: 3px 3px 0 0; +} + +#login-form input[type="password"] { + border-top: none; + border-radius: 0px 0px 3px 3px; +} + +#login-form input[type="submit"] { + background: #1dabb8; + border-radius: 3px; + color: #fff; + float: right; + font-weight: bold; + margin-top: 20px; + padding: 12px 20px; +} + +#login-form input[type="submit"]:hover { background: #198d98; } + +#login-form footer { + font-size: 12px; + margin-top: 16px; +} + +.info { + background: #e5e5e5; + border-radius: 50%; + display: inline-block; + height: 20px; + line-height: 20px; + margin: 0 10px 0 0; + text-align: center; + width: 20px; +} + +#fail { +display: none; +} +#fail:target { +display: block; +} + +#fail:target { + margin: 50px auto; + width: 300px; +} + +#fail:target h3 { + background-color: #282830; + border-radius: 5px 5px 0 0; + color: #fff; + font-size: 14px; + padding: 20px; + text-align: center; + text-transform: uppercase; +} + +#fail:target fieldset { + background: #fff; + border-radius: 0 0 5px 5px; + padding: 20px; + position: relative; +} + +#fail:target fieldset:before { + background-color: #fff; + content: ""; + height: 8px; + left: 50%; + margin: -4px 0 0 -4px; + position: absolute; + top: 0; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + width: 8px; +} \ No newline at end of file diff --git a/moe/includes/api.php b/moe/includes/api.php new file mode 100644 index 0000000..da0d652 --- /dev/null +++ b/moe/includes/api.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/moe/includes/core.php b/moe/includes/core.php new file mode 100644 index 0000000..59d6d4e --- /dev/null +++ b/moe/includes/core.php @@ -0,0 +1,36 @@ + "SET NAMES 'UTF8'")); + +function register ($email, $pass) { + global $db; + $do = $db->prepare("SELECT email FROM accounts WHERE email = (:email)"); + $do->bindParam(':email', $email); + $do->execute(); + $result = $do->fetch(); + if($result['email'] === $email){ + header('Location: ../register/index.html#fail'); + }else{ + $do = $db->prepare("INSERT INTO accounts (email, pass) VALUES (:email, :pass)"); + $do->bindParam(':email', $email); + $hash = password_hash($pass, PASSWORD_DEFAULT); + $do->bindParam(':pass', $hash); + $do->execute(); + header('Location: api.php?do=cp'); + } +} + +function login ($email, $pass) { + global $db; + $do = $db->prepare("SELECT pass FROM accounts WHERE email = (:email)"); + $do->bindParam(':email', $email); + $do->execute(); + $result = $do->fetch(PDO::FETCH_ASSOC); + + if (password_verify($pass, $result['pass'])) { + header('Location: api.php?do=cp'); + }else{ + header('Location: ../login/index.html#fail'); + } +} +?> \ No newline at end of file diff --git a/moe/login/index.html b/moe/login/index.html new file mode 100644 index 0000000..fc3f767 --- /dev/null +++ b/moe/login/index.html @@ -0,0 +1,48 @@ + + + + + + Moe Login + + + + + + + +
+ +

Login

+ +
+ +
+ + + + + + + + +
+ +
+ +
+
+

Wrong email or password

+
+

You have entered the wrong email or password, or something else went wrong.

+
+
+ + \ No newline at end of file diff --git a/moe/register/index.html b/moe/register/index.html new file mode 100644 index 0000000..6396878 --- /dev/null +++ b/moe/register/index.html @@ -0,0 +1,45 @@ + + + + + + Moe Register + + + + + + + +
+ +

Register

+ +
+ +
+ + + + + + + + +
+ +
+ +
+
+

Email in use

+
+

This email is already in use, choose another one or login to your existing account.

+
+
+ + \ No newline at end of file diff --git a/moe/settings.php b/moe/settings.php deleted file mode 100644 index 4c4277f..0000000 --- a/moe/settings.php +++ /dev/null @@ -1,22 +0,0 @@ - 11)); -?> \ No newline at end of file -- cgit v1.2.3