Compare commits
9 Commits
cd1261418a
...
1c74b82f6e
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c74b82f6e | |||
| df131d2fb5 | |||
| 4d10b191c7 | |||
| 071113592b | |||
| b5283110d2 | |||
| 3914190175 | |||
| 0022e0d7c2 | |||
| 0f8b0154f8 | |||
| e3e3b45c65 |
15
checkloc.php
15
checkloc.php
@@ -1,5 +1,13 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
require_once 'db.inc.php';
|
||||
if (isset($_SESSION['glink']) && !empty($_SESSION['glink'])) {
|
||||
session_unset();
|
||||
session_destroy();
|
||||
} else {
|
||||
http_response_code(403);
|
||||
die('Forbidden.');
|
||||
}
|
||||
// FUNCTION TO CALCULATE HAVERSINE DISTANCE GIVEN COORDINATES OF
|
||||
// TWO POINTS, AND RADIUS (IN KM)
|
||||
function haversine_distance($lat1, $long1, $lat2, $long2, $radius) {
|
||||
@@ -36,9 +44,8 @@
|
||||
$user_long = $user_long * (M_PI / 180);
|
||||
$glink = $_GET["glink"];
|
||||
|
||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
||||
$keyspace = 'glink';
|
||||
$session = $cluster->connect($keyspace);
|
||||
$session = init_cass_db();
|
||||
|
||||
$statement = $session->prepare('SELECT latitude,longitude,radius,url FROM data WHERE shortlink=? ALLOW FILTERING;');
|
||||
$result = $session->execute($statement,array('arguments' => array($glink)));
|
||||
|
||||
|
||||
9
db.inc.php
Normal file
9
db.inc.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
function init_cass_db() {
|
||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
||||
$keyspace = 'glink';
|
||||
$session = $cluster->connect($keyspace);
|
||||
|
||||
return $session;
|
||||
}
|
||||
?>
|
||||
BIN
fonts/ArchivoBlack-Regular.ttf
Normal file
BIN
fonts/ArchivoBlack-Regular.ttf
Normal file
Binary file not shown.
68
index.html
68
index.html
@@ -1,46 +1,66 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>GLink</title>
|
||||
<link rel="stylesheet" href="index.css">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="output.css">
|
||||
</head>
|
||||
<body>
|
||||
<body class="bg-gray-50">
|
||||
<h1 class="ml-4 text-5xl font-narrow">Link Shortener</h1>
|
||||
<p class="ml-4 font-fingerpaint">Hello There!</p>
|
||||
<div id="root">
|
||||
<h1>Link Shortener</h1>
|
||||
<form id="form" method="GET" action="result.php" onsubmit="return validate()">
|
||||
|
||||
<!-- <form id="form"> -->
|
||||
<label for="url">URL:</label><span class="mandatory">*</span>
|
||||
<input type="text" name="url" id="URL" value="https://example.com" required><br><br>
|
||||
<div class="flex flex-wrap">
|
||||
<label for="URL" class="text-2xl ml-4 font-rubik self-center">URL</label>
|
||||
<span class="mandatory font-rubik self-center text-2xl">*</span>
|
||||
<span class="font-rubik self-center m-1 text-2xl">:</span>
|
||||
<div class="p-0.5 m-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:caret-gray-600 focus-within:p-[3.2px]">
|
||||
<input type="text" name="url" id="URL" placeholder="https://example.com" required class="p-2 w-full rounded-lg focus:outline-none text-center text-lg text-black font-bold">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label for="labels">GLink:</label><span class="mandatory">*</span>
|
||||
<label for="GLink" id="labels" class="glink">glink.zip/</label><input type="text" name="glink" id="GLink" class="glink" value="exampleWebsite">
|
||||
<div class="flex flex-wrap">
|
||||
<label for="labels" class="text-2xl ml-4 font-rubik self-center">GLink</label>
|
||||
<span class="mandatory font-rubik text-2xl self-center">*</span>
|
||||
<span class="font-rubik self-center m-1 text-2xl">:</span>
|
||||
<label for="GLink" id="labels" class=" ml-2 glink text-center text-xl self-center">glink.zip/</label>
|
||||
<div class="p-0.5 ml-2 mr-4 my-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:caret-gray-600 focus-within:p-[3.2px]">
|
||||
<input type="text" name="glink" id="GLink" class="glink p-2 w-full rounded-lg focus:outline-none text-center text-lg text-black font-bold" placeholder="exampleWebsite">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span role="alert" id="error" aria-hidden="true">Invalid URL</span>
|
||||
<label for="restricted" class="ml-4 self-center text-2xl font-rubik lg:invisible">Geo-restricted? : </label><input type="checkbox" name="restricted" id="restricted" class="ml-2 mr-4 my-4 text-center font-rubik ease-soft rounded-1.4 w-6 h-6 cursor-pointer checked:accent-blue-700 shadow-lg shadow-black/50 peer"><span id="loadingText" class="font-rubik self-center text-center text-xl" style="position: relative; left: 20px;"></span>
|
||||
|
||||
<br><br>
|
||||
<label for="restricted">Geo-restricted?: </label> <input type="checkbox" name="restricted" id="restricted"> <span id="loadingText" style="position: relative; left: 20px;"></span>
|
||||
<br><br>
|
||||
<label for="radius" hidden="hidden" id="radius_label">Radius: </label> <span id="mandatory-radius" class="mandatory" hidden="hidden">*</span>
|
||||
<select name="radius" id="radius" hidden="hidden">
|
||||
<option value="" selected disabled hidden>Select a radius</option>
|
||||
<span class="flex flex-wrap invisible peer-checked:visible" id="js-enabled">
|
||||
<label for="radiusSelect" id="radius_label" class="ml-4 font-rubik text-2xl self-center">Radius</label><span id="mandatory-radius" class="mandatory font-rubik text-2xl self-center">*</span><span class="font-rubik self-center m-1 text-2xl">:</span>
|
||||
<div class="p-0.5 ml-2 mr-4 my-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:p-[3.2px]">
|
||||
<select name="radius" id="radius" class="cursor-pointer text-lg p-2 w-full rounded-lg focus:outline-none invalid:text-gray-400 font-bold">
|
||||
<option value="" selected disabled hidden>Choose a radius for your geo link</option>
|
||||
<option value="5">5 mi</option>
|
||||
<option value="10">10 mi</option>
|
||||
<option value="15">15 mi</option>
|
||||
<option value="20">20 mi</option>
|
||||
</select>
|
||||
<br><br>
|
||||
<input type="submit" id="button" value="Zip It!">
|
||||
|
||||
|
||||
</div>
|
||||
</span>
|
||||
<noscript>
|
||||
<style>
|
||||
#js-enabled {display: none;}
|
||||
</style>
|
||||
</noscript>
|
||||
<span role="alert" class="m-4 font-rubik" id="error" aria-hidden="true">Invalid entry</span>
|
||||
<input type="submit" id="button" value="Zip It!" class="brightness-125 ml-4 font-rubik bg-gradient-to-r from-cyan-500 to-blue-500 shadow-lg shadow-black/50 transition hover:-translate-y-1 hover:scale-105 duration-600 ease-in-out rounded-full cursor-pointer">
|
||||
<input type="hidden" name="latitude" id="latitude">
|
||||
<input type="hidden" name="longitude" id="longitude">
|
||||
|
||||
</form>
|
||||
<hr>
|
||||
<div>
|
||||
<img src="cat.gif">
|
||||
</div>
|
||||
<script src="index.js"></script>
|
||||
<img src="./cat.gif">
|
||||
<p id="footer" class="object-none object-bottom">Insert Footer Here</p>
|
||||
<script src="./index.js"></script>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
59
login.html
Normal file
59
login.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="h-full bg-white">
|
||||
<head>
|
||||
<link rel="stylesheet" href="output.css">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body class="h-full">
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900">Log in to your account</h2>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="#" method="POST">
|
||||
<div>
|
||||
<label for="email" class="block text-sm font-medium leading-6 text-gray-900">Email address</label>
|
||||
<div class="mt-2">
|
||||
<input id="email" name="email" type="email" autocomplete="email" required class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
|
||||
<div id="email-error" class="hidden mt-2 text-red-800 text-xs">
|
||||
invalid Email
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="password" class="block text-sm font-medium leading-6 text-gray-900">Password</label>
|
||||
<div class="text-sm">
|
||||
<a href="#" class="font-semibold text-indigo-600 hover:text-indigo-500">Forgot password?</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" required class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
|
||||
</div>
|
||||
<p id="letter" class="hidden text-red-800 text-xs">
|
||||
A <b>lowercase</b> letter
|
||||
</p>
|
||||
<p id="capital" class="hidden text-red-800 text-xs">
|
||||
A <b>capital (uppercase)</b> letter
|
||||
</p>
|
||||
<p id="number" class="hidden text-red-800 text-xs">
|
||||
A <b>number</b>
|
||||
</p>
|
||||
<p id="symbol" class="hidden text-red-800 text-xs">
|
||||
A <b>symbol</b>
|
||||
</p>
|
||||
<p id="length" class="hidden text-red-800 text-xs">
|
||||
Minimum <b>10 characters</b>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Sign in</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
142
login.js
Normal file
142
login.js
Normal file
@@ -0,0 +1,142 @@
|
||||
let email = document.getElementById("email");
|
||||
let password = document.getElementById("password");
|
||||
let pswd_visible = document.getElementById("pswd-visible");
|
||||
let pswd_invisible = document.getElementById("pswd-invisible");
|
||||
let check_pswd_visible = document.getElementById("check-pswd-visible");
|
||||
let check_pswd_invisible = document.getElementById("check-pswd-invisible");
|
||||
let check_password = document.getElementById("check-password");
|
||||
pswd_visible.addEventListener('click', () => {
|
||||
pswd_visible.classList.add("hidden");
|
||||
pswd_invisible.classList.remove("hidden");
|
||||
password.type = "password";
|
||||
});
|
||||
pswd_invisible.addEventListener('click', () => {
|
||||
pswd_invisible.classList.add("hidden");
|
||||
pswd_visible.classList.remove("hidden");
|
||||
password.type = "text";
|
||||
});
|
||||
check_pswd_visible.addEventListener('click', () => {
|
||||
check_pswd_visible.classList.add("hidden");
|
||||
check_pswd_invisible.classList.remove("hidden");
|
||||
check_password.type = "password";
|
||||
});
|
||||
check_pswd_invisible.addEventListener('click', () => {
|
||||
check_pswd_invisible.classList.add("hidden");
|
||||
check_pswd_visible.classList.remove("hidden");
|
||||
check_password.type = "text";
|
||||
});
|
||||
let emailRX = new RegExp("^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z]+)+$");
|
||||
let domainError = document.getElementById("domain");
|
||||
let domainRX = new RegExp("^[a-zA-Z0-9!@#$%^&*]*$");
|
||||
let emailError = document.getElementById("email-error");
|
||||
let capsRX = new RegExp(".*[A-Z]+");
|
||||
let capsError = document.getElementById("capital");
|
||||
let lowRX = new RegExp(".*[a-z]+");
|
||||
let lowError = document.getElementById("letter");
|
||||
let numRX = new RegExp(".*[0-9]+");
|
||||
let numError = document.getElementById("number");
|
||||
let symbolRX = new RegExp(".*[!@#$%^&*]+");
|
||||
let symbolError = document.getElementById("symbol");
|
||||
let MIN_LENGTH = 10;
|
||||
let lenError = document.getElementById("length");
|
||||
let check_password_error = document.getElementById("check-password-error");
|
||||
|
||||
|
||||
email.addEventListener('keyup', function(event) {
|
||||
if (emailRX.test(email.value)) {
|
||||
console.log("email valid");
|
||||
email.classList.add("ring-green-400");
|
||||
email.classList.add("focus:ring-green-400");
|
||||
email.classList.remove("ring-red-400");
|
||||
email.classList.remove("focus:ring-red-400");
|
||||
emailError.classList.add("hidden");
|
||||
emailError.classList.remove("block");
|
||||
return true;
|
||||
} else {
|
||||
console.log("email invalid");
|
||||
email.classList.add("ring-red-400");
|
||||
email.classList.add("focus:ring-red-400");
|
||||
email.classList.remove("ring-green-400");
|
||||
email.classList.remove("focus:ring-green-400");
|
||||
emailError.classList.remove("hidden");
|
||||
emailError.classList.add("block");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
password.addEventListener('keyup', () => {
|
||||
let pswd = password.value;
|
||||
if (!capsRX.test(pswd)) {
|
||||
capsError.classList.remove("hidden");
|
||||
capsError.classList.add("block");
|
||||
} else {
|
||||
capsError.classList.add("hidden");
|
||||
capsError.classList.remove("block");
|
||||
}
|
||||
if (!lowRX.test(pswd)) {
|
||||
lowError.classList.remove("hidden");
|
||||
lowError.classList.add("block");
|
||||
} else {
|
||||
lowError.classList.add("hidden");
|
||||
lowError.classList.remove("block");
|
||||
}
|
||||
if (!numRX.test(pswd)) {
|
||||
numError.classList.remove("hidden");
|
||||
numError.classList.add("block");
|
||||
} else {
|
||||
numError.classList.add("hidden");
|
||||
numError.classList.remove("block");
|
||||
}
|
||||
if (!symbolRX.test(pswd)) {
|
||||
symbolError.classList.remove("hidden");
|
||||
symbolError.classList.add("block");
|
||||
} else {
|
||||
symbolError.classList.add("hidden");
|
||||
symbolError.classList.remove("block");
|
||||
}
|
||||
if (!domainRX.test(pswd)) {
|
||||
domainError.classList.remove("hidden");
|
||||
domainError.classList.add("block");
|
||||
} else {
|
||||
domainError.classList.add("hidden");
|
||||
domainError.classList.remove("block");
|
||||
}
|
||||
if (pswd.length < MIN_LENGTH) {
|
||||
lenError.classList.remove("hidden");
|
||||
lenError.classList.add("block");
|
||||
} else {
|
||||
lenError.classList.add("hidden");
|
||||
lenError.classList.remove("block");
|
||||
}
|
||||
if (capsError.classList.contains("block") || lowError.classList.contains("block") || numError.classList.contains("block") || symbolError.classList.contains("block") || lenError.classList.contains("block")) {
|
||||
password.classList.remove("ring-green-400");
|
||||
password.classList.remove("focus:ring-green-400");
|
||||
password.classList.add("ring-red-400");
|
||||
password.classList.add("focus:ring-red-400");
|
||||
} else {
|
||||
password.classList.add("ring-green-400");
|
||||
password.classList.add("focus:ring-green-400");
|
||||
password.classList.remove("ring-red-400");
|
||||
password.classList.remove("focus:ring-red-400");
|
||||
}
|
||||
});
|
||||
check_password.addEventListener("keyup", () => {
|
||||
let check = check_password.value;
|
||||
if (check !== password.value) {
|
||||
check_password_error.classList.remove("hidden");
|
||||
check_password_error.classList.add("block");
|
||||
} else {
|
||||
check_password_error.classList.add("hidden");
|
||||
check_password_error.classList.remove("block")
|
||||
}
|
||||
if (check_password_error.classList.contains("block")) {
|
||||
check_password.classList.remove("ring-green-400");
|
||||
check_password.classList.remove("focus:ring-green-400");
|
||||
check_password.classList.add("ring-red-400");
|
||||
check_password.classList.add("focus:ring-red-400");
|
||||
} else {
|
||||
check_password.classList.add("ring-green-400");
|
||||
check_password.classList.add("focus:ring-green-400");
|
||||
check_password.classList.remove("ring-red-400");
|
||||
check_password.classList.remove("focus:ring-red-400");
|
||||
}
|
||||
});
|
||||
27
login.php
Normal file
27
login.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$email = $_GET['email'];
|
||||
$password = $_GET['password'];
|
||||
|
||||
$session = init_cass_db();
|
||||
|
||||
$statement = $session->prepare('SELECT password FROM users WHERE email=? ALLOW FILTERING;');
|
||||
|
||||
$result = $session->execute($statement,array('arguments' => array($email)));
|
||||
|
||||
if ($result->count() <= 0) {
|
||||
echo('Invalid email address or password.');
|
||||
exit();
|
||||
} else {
|
||||
$hash = $row[0]['password'];
|
||||
|
||||
if (password_verify($password,$hash) != true) {
|
||||
echo('Invalid email address or password.');
|
||||
exit();
|
||||
} else {
|
||||
session_start();
|
||||
$_SESSION['user'] = $email;
|
||||
echo('Logged in successfully. You are ' . $_SESSION['user']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
1672
output.css
Normal file
1672
output.css
Normal file
File diff suppressed because it is too large
Load Diff
10
redirect.php
10
redirect.php
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
require_once 'db.inc.php';
|
||||
ini_set("session.cookie_secure",1);
|
||||
session_start();
|
||||
use Cassandra;
|
||||
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
@@ -7,13 +10,11 @@
|
||||
$matches_uri = preg_match('/^[a-zA-Z]+$/',$uri);
|
||||
|
||||
if (($matches_uri == 0) || ($matches_uri == false)) {
|
||||
header("Location: http://glink.zip/");
|
||||
header("Location: https://glink.zip/");
|
||||
exit;
|
||||
} else {
|
||||
|
||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
||||
$keyspace = 'glink';
|
||||
$session = $cluster->connect($keyspace);
|
||||
$session = init_cass_db();
|
||||
|
||||
$statement = $session->prepare('SELECT url,is_geo FROM data WHERE shortlink=? ALLOW FILTERING;');
|
||||
$result = $session->execute($statement,array('arguments' => array($uri)));
|
||||
@@ -29,6 +30,7 @@
|
||||
exit;
|
||||
} else {
|
||||
if ($row['is_geo'] == true) {
|
||||
$_SESSION['glink'] = $uri;
|
||||
header("Location: https://glink.zip/reqloc.html?glink=" . $uri);
|
||||
exit;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once 'db.inc.php';
|
||||
|
||||
function gen_base62_rand_shortlink($len) {
|
||||
$rand_bytes = random_bytes(intval(($len * 2) / 3));
|
||||
@@ -29,9 +30,7 @@ function gen_rand_shortlink($len) {
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$cluster = Cassandra::cluster()->withPersistentSessions(true)->build();
|
||||
$keyspace = 'glink';
|
||||
$session = $cluster->connect($keyspace);
|
||||
$session = init_cass_db();
|
||||
|
||||
$url = $_GET["url"];
|
||||
|
||||
|
||||
108
signup.html
Normal file
108
signup.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="h-full bg-white">
|
||||
<head>
|
||||
<link rel="stylesheet" href="output.css">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body class="h-full">
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900">Sign up for an account</h2>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="signup.php" method="GET">
|
||||
<div>
|
||||
<label for="email" class="block text-sm font-medium leading-6 text-gray-900">Email address</label>
|
||||
<div class="mt-2">
|
||||
<input id="email" name="email" type="email" autocomplete="email" required class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
|
||||
<div id="email-error" class="hidden mt-2 text-red-800 text-xs">
|
||||
invalid Email
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="password" class="block text-sm font-medium leading-6 text-gray-900">Password</label>
|
||||
</div>
|
||||
<div class="mt-2 relative block">
|
||||
<input id="password" name="password" type="password" autocomplete="off" required class="block w-11/12 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
|
||||
|
||||
<span id="pswd-invisible" class="absolute inset-y-0 right-0 flex items-center px-1 rounded-r-md">
|
||||
<svg class="w-6 h-6 m-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" color="black"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z">
|
||||
</path>
|
||||
</svg>
|
||||
</span>
|
||||
<span id="pswd-visible" class="absolute inset-y-0 right-0 flex items-center px-1 hidden">
|
||||
<svg class="w-6 h-6 m-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21">
|
||||
</path>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<p id="domain" class="hidden text-red-800 text-xs">
|
||||
<b>Invalid characters entered</b>
|
||||
</p>
|
||||
<p id="letter" class="hidden text-red-800 text-xs">
|
||||
A <b>lowercase</b> letter
|
||||
</p>
|
||||
<p id="capital" class="hidden text-red-800 text-xs">
|
||||
A <b>capital (uppercase)</b> letter
|
||||
</p>
|
||||
<p id="number" class="hidden text-red-800 text-xs">
|
||||
A <b>number</b>
|
||||
</p>
|
||||
<p id="symbol" class="hidden text-red-800 text-xs">
|
||||
A <b>symbol</b>
|
||||
</p>
|
||||
<p id="length" class="hidden text-red-800 text-xs">
|
||||
Minimum <b>10 characters</b>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="check-password" class="block text-sm font-medium leading-6 text-gray-900">Retype Password</label>
|
||||
</div>
|
||||
<div class="mt-2 relative block">
|
||||
<input id="check-password" name="check-password" type="password" autocomplete="off" required class="block w-11/12 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
|
||||
|
||||
<span id="check-pswd-invisible" class="absolute inset-y-0 right-0 flex items-center px-1 rounded-r-md">
|
||||
<svg class="w-6 h-6 m-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" color="black"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z">
|
||||
</path>
|
||||
</svg>
|
||||
</span>
|
||||
<span id="check-pswd-visible" class="absolute inset-y-0 right-0 flex items-center px-1 hidden">
|
||||
<svg class="w-6 h-6 m-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21">
|
||||
</path>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<p id="check-password-error" class="hidden text-red-800 text x-s">
|
||||
Passwords <b>do not</b> match
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Sign up</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
27
signup.php
Normal file
27
signup.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once 'db.inc.php';
|
||||
|
||||
$email = $_GET['email'];
|
||||
$username = $_GET['username'];
|
||||
$password = $_GET['password'];
|
||||
$id = rand(0,99999999);
|
||||
|
||||
$hash = password_hash($password,PASSWORD_BCRYPT);
|
||||
|
||||
$session = init_cass_db();
|
||||
|
||||
$statement = $session->prepare('SELECT id FROM users WHERE email=? OR username=? ALLOW FILTERING;');
|
||||
$result = $session->execute($statement, array('arguments' => array($email,$username)));
|
||||
|
||||
if ($result->count() != 0) {
|
||||
echo('The username or email address already exists. Please try another username/email address.');
|
||||
exit();
|
||||
}
|
||||
|
||||
$statement = $session->prepare('INSERT INTO users (id,email_addr,username,password_hash) VALUES (?,?,?,?);');
|
||||
$result = $session->execute($statement, array('arguments' => array($id,$email,$username,$hash)));
|
||||
|
||||
echo('Registration successful.');
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user