Last active
December 5, 2020 14:55
-
-
Save Shefali199/5c8a0ec59ee8b088c451c24d8d7e25ff to your computer and use it in GitHub Desktop.
Password Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (!isset($_SESSION['user_id'])) | |
die("Not logged in."); | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
if (isset($_POST['adde'])) { | |
$title = htmlspecialchars($_POST['title']); | |
$url = htmlspecialchars($_POST['url']); | |
$time = shell_exec("powershell get-date -format \"{dd-MMM-yyyy HH:mm:ss}\""); | |
$user_id = $_SESSION['user_id']; | |
if (isset($_SESSION['encvala'])) { | |
try { | |
$sql = 'INSERT INTO tpu_details(title, pw, url, time, user_id) VALUES (:t, :pw, :u, :time, :ui)'; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([':t' => $title, ':pw' => htmlspecialchars($_SESSION['encvala']), ':u' => $url, ':time' => $time, ':ui' => $user_id]); | |
$_SESSION['success'] = "Entry added"; | |
header("Location: View.php"); | |
return; | |
} catch (PDOException $e) { | |
throw $e; | |
} | |
} | |
} | |
?> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script> | |
<script> | |
function encrypt() { | |
var p1 = document.getElementById("pw").value; | |
var ev = CryptoJS.AES.encrypt(p1, sessionStorage.getItem("key")).toString(); | |
var params = "envala=" + ev; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'Ajax.php', true); | |
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhr.send(params); | |
} | |
</script> | |
<script> | |
</script> | |
<script> | |
var pass = ""; | |
function generate_pw() { | |
pass = ""; | |
var len = document.getElementById('len').value; | |
if (len <= 0 || isNaN(len)) | |
alert("Please give a valid length"); | |
if (len > 1000) | |
alert("Length too large! Maximum permissible length is 1000."); | |
var charset = ""; | |
if (document.getElementById("number").checked == true) | |
charset += "0123456789"; | |
if (document.getElementById("lc").checked == true) | |
charset += "abcdefghijklmnopqrstuvwxyz"; | |
if (document.getElementById("uc").checked == true) | |
charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
if (document.getElementById("as").checked == true) | |
charset += "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"; | |
if (document.getElementById("sp").checked == true) | |
charset += " "; | |
if (charset == "") | |
alert("Character set is empty"); | |
if (charset != "") { | |
for (var i = 0; i < len; i++) { | |
var char = Math.floor(Math.random() * (charset.length)); | |
pass += charset.charAt(char); | |
} | |
console.log(pass); | |
document.getElementById('showp').innerHTML = "<p>" + pass + "</p>"; | |
sessionStorage.setItem("randomp", pass); | |
} | |
} | |
function showpw() { | |
var x = document.getElementById("pw"); | |
if (x.type === "password") { | |
x.type = "text"; | |
} else { | |
x.type = "password"; | |
} | |
} | |
</script> | |
<script> | |
function select_pw() { | |
document.getElementById('pw').value = sessionStorage.getItem("randomp", pass); | |
sessionStorage.setItem("randomp", ""); | |
} | |
</script> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
</style> | |
</head> | |
<body> | |
<div id="1"> | |
<h1>Add new entry</h1> | |
<p> | |
<form method="POST" onclick="encrypt()" action="Add.php"> | |
<label for="nam">Title<font color="red">*</font></label><br /> | |
<input type="text" name="title" id="nam" required><br /><br /> | |
<label for="pw">Password<font color="red">*</font></label><br /> | |
<input type="password" name="pass" id="pw" required><br /> | |
<input type="checkbox" onclick="showpw()">Show Password<br><br> | |
<label for="url">URL:</label><br /> | |
<input type="text" name="url" id="url"><br /> | |
<p> | |
<font color="red">*</font> Required information | |
</p> | |
<input type="submit" value="Add entry" name="adde"> | |
<a href="view.php">Cancel</a> | |
</form> | |
</p> | |
</div> | |
<div id="2"> | |
<h1>Generate a strong password here!!</h1> | |
<h3>Character set:</h3> | |
<input type='checkbox' id='number' name='no.' value='numbers'> | |
<label for='number'>Numbers (0123456789)</label><br> | |
<input type='checkbox' id="lc" name="lc" value="lowercase"> | |
<label for="lc">Lowercase (abcdefghijklmnopqrstuvwxyz)</label><br> | |
<input type="checkbox" id="uc" name="uc" value="uppercase"> | |
<label for="uc">Uppercase (ABCDEFGHIJKLMNOPQRSTUVWXYZ)</label><br> | |
<input type="checkbox" id="as" name="as" value="ascii_sym"> | |
<label for="as">ASCII Symbols (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)</label><br> | |
<input type="checkbox" id="sp" name="sp" value="space"> | |
<label for="sp">Space ( )</label><br> | |
<label for="len">Length: </label><input type="text" id="len" name="length"><br><br> | |
<button onclick="generate_pw()">Generate</button> | |
<button onclick="select_pw()">Select</button><br> | |
<p>Password: <p id="showp"></p> | |
</p> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if(isset($_POST['hashs'])) | |
$_SESSION['phashs'] = $_POST['hashs']; | |
if(isset($_POST['hashl'])) | |
$_SESSION['phashl'] = $_POST['hashl']; | |
if(isset($_POST['envala'])) | |
$_SESSION['encvala'] = $_POST['envala']; | |
if(isset($_POST['hashcp'])) | |
$_SESSION['hashcp'] = $_POST['hashcp']; | |
if(isset($_POST['newobject'])) | |
$_SESSION['user_details'] = $_POST['newobject']; | |
if(isset($_POST['envalu'])) | |
$_SESSION['encvalu'] = $_POST['envalu']; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (!isset($_SESSION['user_id'])) | |
die("Not logged in."); | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$search = $_GET['det_id']; | |
$sql = "SELECT * FROM tpu_details where det_id LIKE ?"; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([$search]); | |
$row = $stmt->fetch(); | |
if ($row === false) { | |
$_SESSION['error'] = 'Bad value for det_id'; | |
header('Location: view.php'); | |
return; | |
} | |
$title = $row['title']; | |
$time = $row['time']; | |
$user_id = $row['user_id']; | |
if ($user_id !== $_SESSION['user_id']) { | |
$_SESSION['error'] = 'Bad value for det_id'; | |
header('Location: view.php'); | |
return; | |
} else { | |
if (isset($_POST['del']) && isset($_GET['det_id'])) { | |
$sql = "DELETE FROM tpu_details WHERE det_id = :zip"; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([':zip' => $search]); | |
$_SESSION['success'] = 'Record deleted'; | |
header('Location: view.php'); | |
return; | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h2>Are you sure that you want to delete this entry?</h2> | |
<form method="POST" action="Delete.php?det_id=<?php echo $search ?>"> | |
<p>Title: <?php echo $title; ?></p> | |
<p>Time added / last updated: <?php echo $time; ?> (IST)</p> | |
<button name="del">Delete</button> | |
<a href="View.php">Cancel</a> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if(!isset($_SESSION['user_id'])) | |
die("Not logged in."); | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$search = $_SESSION['user_id']; | |
$sql = "SELECT * FROM tpu_details WHERE user_id LIKE ?"; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([$search]); | |
$data = $stmt->fetchAll(); | |
echo json_encode($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Welcome to Shefali Sharma's Password Manager</h1> | |
<p>Remember 1 password for many passwords</p> | |
<p><a href="login.php">Log in</a></p> | |
<p>New user? <a href="Signin.php">Sign up here</a></p> | |
<p>Key features:</p> | |
<ul>All the sensitive information is encrypted and decrypted on the client side</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (isset($_POST['cancel'])) { | |
// Redirect the browser to index.php | |
session_start(); | |
session_destroy(); | |
header("Location: index.php"); | |
return; | |
} | |
$failure; | |
//Establishing connection with the database server | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
if (isset($_POST['login'])) { | |
if (isset($_SESSION['phashl'])) { | |
$search = $_POST['email']; | |
$sql = 'SELECT * FROM users WHERE email LIKE ?'; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([$search]); | |
$user = $stmt->fetch(); | |
if ($user === false) { | |
$_SESSION['error'] = "User with this email has not registered"; | |
header("Location: login.php"); | |
return; | |
} else { | |
$_SESSION['user_id'] = $user['user_id']; | |
if ($user['password'] === $_SESSION['phashl']) { | |
$_SESSION['pw'] = $user['password']; | |
$_SESSION['success'] = "Successfully logged in"; | |
header("Location: view.php"); | |
} else { | |
$_SESSION['error'] = "Wrong email-password combination"; | |
header("Location: login.php"); | |
return; | |
} | |
} | |
} | |
} | |
?> | |
<script> | |
function make_key() { //Function that creates a key for the user | |
var pw = document.getElementById("pw").value; | |
var phash = 0; | |
for (var i = 0; i < pw.length; i++) { | |
var charCode = pw.charCodeAt(i); | |
phash = ((phash << 7) - phash) + charCode; | |
phash = phash & phash; | |
} | |
var pshash = phash.toString(); | |
var params = "hashl=" + pshash; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'Ajax.php', true); | |
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhr.send(params); | |
sessionStorage.setItem("key", pshash); | |
} | |
</script> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<?php if (isset($_SESSION['error'])) { | |
echo ('<p style="color: red;">' . $_SESSION['error'] . "</p>\n"); | |
unset($_SESSION['error']); | |
} ?> | |
<h1>Log in</h1> | |
<p>Please fill this form to Log in</p> | |
<form method="POST" onsubmit="make_key()" action="login.php"> | |
<label for="nam">Email<font color="red">*</font></label><br /> | |
<input type="text" name="email" id="nam" required><br /><br /> | |
<label for="id_1723">Password<font color="red">*</font></label><br /> | |
<input type="password" name="pass" id="pw" required><br /> | |
<p> | |
<font color="red">*</font> Required information | |
</p> | |
<input type="submit" value="Log In" name="login"> | |
<a href="index.php">Cancel</a> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (isset($_POST['cancel'])) { | |
// Redirect the browser to index.php | |
session_start(); | |
session_destroy(); | |
header("Location: index.php"); | |
return; | |
} | |
//Establishing connection with the database server | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$failure; | |
if (isset($_POST['signin'])) { | |
$_SESSION['username'] = htmlspecialchars($_POST['name']); | |
$_SESSION['email'] = htmlspecialchars($_POST['email']); | |
if (isset($_SESSION['phashs'])) { | |
$stmt = $pdo->prepare("SELECT * FROM users"); | |
try { | |
$pw = htmlspecialchars($_SESSION['phashs']); | |
$sql = 'INSERT INTO users(name, email, password) VALUES(:nam, :em, :pw)'; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([':nam' => $_SESSION['username'], ':em' => $_SESSION['email'], ':pw' => $pw]); | |
$search = $_POST['email']; | |
$sql = 'SELECT * FROM users WHERE email LIKE ?'; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([$search]); | |
$user = $stmt->fetch(); | |
$_SESSION['user_id'] = $user['user_id']; | |
$_SESSION['pw'] = $_SESSION['phashs']; | |
} catch (PDOException $e) { | |
if ($e->errorInfo[0] == '23000' && $e->errorInfo[1] == '1062') { | |
$failure = "User with this email has already registered"; | |
$_SESSION['error'] = $failure; | |
header("Location: signin.php"); | |
return; | |
} else { | |
throw $e; | |
header("Location: signin.php"); | |
return; | |
} | |
} | |
if ($failure !== true) { | |
$_SESSION['success'] = "Successfully signed in"; | |
header("Location: view.php"); | |
} | |
} | |
} | |
?> | |
<script> | |
function generate_hash() { | |
var p1 = document.getElementById("pw1").value; | |
var p2 = document.getElementById("pw2").value; | |
var phash = 0; | |
var isemailvalid = 0; | |
if (p1 == p2) { | |
for (var i = 0; i < p1.length; i++) { | |
var charCode = p1.charCodeAt(i); | |
phash = ((phash << 7) - phash) + charCode; | |
phash = phash & phash; | |
} | |
var pshash = phash.toString(); | |
var params = "hashs=" + pshash; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'Ajax.php', true); | |
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhr.send(params); | |
} else | |
alert("The entered passwords are not same"); | |
} | |
</script> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<?php if (isset($_SESSION['error'])) { | |
echo ('<p style="color: red;">' . $_SESSION['error'] . "</p>\n"); | |
unset($_SESSION['error']); | |
} ?> | |
<h1>Sign in</h1> | |
<p>Please fill this form to create an account</p> | |
<form method="POST" onsubmit="generate_hash()" action="signin.php"> | |
<label for="nam">Name<font color="red">*</font></label><br /> | |
<input type="text" name="name" id="nam" required><br /><br /> | |
<label for="email">Email<font color="red">*</font></label><br /> | |
<input type="text" name="email" id="email" required><br /><br /> | |
<label for="pw1">New password<font color="red">*</font></label><br /> | |
<input type="password" name="pass" id="pw1" required><br /><br /> | |
<label for="pw2">Confirm password<font color="red">*</font></label><br /> | |
<input type="password" name="cpass" id="pw2" required><br /> | |
<p> | |
<font color="red">*</font> Required information | |
</p> | |
<input type="submit" value="Sign In" name="signin"> | |
<a href="index.php">Cancel</a> | |
</form> | |
<p>Already have an account? <a href="login.php">Login here</a></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (!isset($_SESSION['user_id'])) | |
die("Not logged in."); | |
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=pwgm', 'fred', 'zap'); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$search = $_GET['det_id']; | |
$stmt = $pdo->prepare("SELECT * FROM tpu_details WHERE det_id = :xyz"); | |
$stmt->execute(array(":xyz" => $_GET['det_id'])); | |
$row = $stmt->fetch(); | |
if (gettype($row) === "bool") { | |
$_SESSION['error'] = 'Bad value for det_id dne'; | |
header('Location: view.php'); | |
return; | |
} | |
$title = $row['title']; | |
$pw = $row['pw']; | |
$url = $row['url']; | |
$det_id = $row['det_id']; | |
$user_id = $row['user_id']; | |
if ($user_id !== $_SESSION['user_id']) { | |
$_SESSION['error'] = 'Bad value for det_id oui'; | |
header('Location: view.php'); | |
return; | |
} else { | |
if (isset($_POST['upe']) && isset($_GET['det_id'])) { | |
$time = shell_exec("powershell get-date -format \"{dd-MMM-yyyy HH:mm:ss}\""); | |
$sql = "UPDATE tpu_details SET title = :t, pw = :pw, url = :u, time = :tm WHERE det_id = '$search'"; | |
$stmt = $pdo->prepare($sql); | |
$stmt->execute([ | |
':t' => htmlspecialchars($_POST['title']), | |
':pw' => htmlspecialchars($_SESSION['encvalu']), | |
':u' => htmlspecialchars($_POST['url']), | |
':tm' => $time | |
]); | |
$_SESSION['success'] = 'Entry updated'; | |
header('Location: view.php'); | |
return; | |
} | |
} | |
?> | |
<!--<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>--> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script> | |
<script> | |
//var CryptoJS = require("crypto-js"); | |
function encrypt() { | |
var p1 = document.getElementById("pw").value; | |
var ev = CryptoJS.AES.encrypt(p1, sessionStorage.getItem("key")).toString(); | |
var params = "envalu=" + ev; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'Ajax.php', true); | |
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xhr.send(params); | |
} | |
</script> | |
<script> | |
var pass = ""; | |
function generate_pw() { | |
pass = ""; | |
var len = document.getElementById('len').value; | |
if (len <= 0 || isNaN(len)) | |
alert("Please give a valid length"); | |
if (len > 1000) | |
alert("Length too large! Maximum permissible length is 1000."); | |
var charset = ""; | |
if (document.getElementById("number").checked == true) | |
charset += "0123456789"; | |
if (document.getElementById("lc").checked == true) | |
charset += "abcdefghijklmnopqrstuvwxyz"; | |
if (document.getElementById("uc").checked == true) | |
charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
if (document.getElementById("as").checked == true) | |
charset += "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"; | |
if (document.getElementById("sp").checked == true) | |
charset += " "; | |
if (charset == "") | |
alert("Character set is empty"); | |
if (charset != "") { | |
for (var i = 0; i < len; i++) { | |
var char = Math.floor(Math.random() * (charset.length)); | |
pass += charset.charAt(char); | |
} | |
console.log(pass); | |
document.getElementById('showp').innerHTML = "<p>" + pass + "</p>"; | |
sessionStorage.setItem("randomp", pass); | |
} | |
} | |
function showpw() { | |
var x = document.getElementById("id_1723"); | |
if (x.type === "password") { | |
x.type = "text"; | |
} else { | |
x.type = "password"; | |
} | |
} | |
</script> | |
<script> | |
function select_pw() { | |
document.getElementById('id_1723').value = sessionStorage.getItem("randomp", pass); | |
sessionStorage.setItem("randomp", ""); | |
} | |
</script> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Update Entry</h1> | |
<form method="POST" onclick="encrypt()" action="Update.php?det_id=<?php echo $search ?>"> | |
<label for="nam">Title<font color="red">*</font></label><br /> | |
<input type="text" name="title" id="nam" value="<?= $title ?>" required><br /><br /> | |
<label for="id_1723">Password<font color="red">*</font></label><br /> | |
<input type="password" name="pass" id="id_1723" size="80" required><br /> | |
<input type="checkbox" onclick="showpw()">Show Password<br><br> | |
<label for="id_c17">URL:</label><br /> | |
<input type="text" name="url" id="id_c17" value="<?= $url ?>" size="45"><br /><br /> | |
<p> | |
<font color="red">*</font> Required information | |
</p> | |
<input type="submit" value="Update entry" name="upe"> | |
<a href="view.php">Cancel</a> | |
</form> | |
</div> | |
<div id="2"> | |
<h1>Generate a strong password here!!</h1> | |
<h3>Character set:</h3> | |
<input type='checkbox' id='number' name='no.' value='numbers'> | |
<label for='number'>Numbers (0123456789)</label><br> | |
<input type='checkbox' id="lc" name="lc" value="lowercase"> | |
<label for="lc">Lowercase (abcdefghijklmnopqrstuvwxyz)</label><br> | |
<input type="checkbox" id="uc" name="uc" value="uppercase"> | |
<label for="uc">Uppercase (ABCDEFGHIJKLMNOPQRSTUVWXYZ)</label><br> | |
<input type="checkbox" id="as" name="as" value="ascii_sym"> | |
<label for="as">ASCII Symbols (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)</label><br> | |
<input type="checkbox" id="sp" name="sp" value="space"> | |
<label for="sp">Space ( )</label><br> | |
<label for="len">Length: </label><input type="text" id="len" name="length"><br><br> | |
<button onclick="generate_pw()">Generate</button> | |
<button onclick="select_pw()">Select</button><br> | |
<p>Password: <p id="showp"></p> | |
</p> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (!isset($_SESSION['user_id'])) | |
die("Not logged in."); | |
if (isset($_POST['logout'])) { | |
// Redirect the browser to index.php | |
session_start(); | |
session_destroy(); | |
header("Location: index.php"); | |
return; | |
} | |
?> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script> | |
<script> | |
function searchTable() { | |
// Declare variables | |
var input, filter, table, tr, td, i, txtValue; | |
input = document.getElementById("sb"); | |
filter = input.value.toUpperCase(); | |
table = document.getElementById("details"); | |
tr = table.getElementsByTagName("tr"); | |
// Loop through all table rows, and hide those who don't match the search query | |
for (i = 0; i < tr.length; i++) { | |
td = tr[i].getElementsByTagName("td")[0]; | |
if (td) { | |
txtValue = td.textContent || td.innerText; | |
if (txtValue.toUpperCase().indexOf(filter) > -1) { | |
tr[i].style.display = ""; | |
} else { | |
tr[i].style.display = "none"; | |
} | |
} | |
} | |
} | |
</script> | |
<script> | |
function copy2cb(p) { | |
p.toString(); | |
var copyText = p; | |
copyText.select(); | |
document.execCommand("copy"); | |
alert("Copied the password. Don't forget to refresh your clipboard after use"); | |
} | |
</script> | |
<script> | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'get_data.php', true); | |
xhr.onload = function() { | |
if (this.status == 200) { | |
var pws = JSON.parse(this.responseText); | |
var table = "<tr><th>Title</th><th>Password</th><th>URL</th><th>Added/Last Updated (IST)</th><th>Action</th></tr>"; | |
for (var i in pws) { | |
var bytes = CryptoJS.AES.decrypt((pws[i].pw).toString(), sessionStorage.getItem("key").toString()); | |
pws[i].pw = bytes.toString(CryptoJS.enc.Utf8); | |
//pws[i].pw = bytes; | |
if (i % 2 == 0) { | |
table += '<tr><td id=\"bl\">' + pws[i].title + "</td><td id=\"bl\" id=\"" + i + "\">" + pws[i].pw + "</td><td id=\"bl\">" + "<a href=" + pws[i].url + " target=\"_blank\">" + pws[i].url + "</a>" + "</td><td id=\"bl\">" + pws[i].time + "</td><td id=\"bl\">" + "<button onclick=\"copy2cb(" + pws[i].pw + ")\">Copy to clipboard</button> <a href=\"Update.php?det_id=" + pws[i].det_id + "\">Update</a> <a href=\"Delete.php?det_id=" + pws[i].det_id + "\">Delete</a></td></tr>"; | |
} | |
if (i % 2 == 1) { | |
table += '<tr><td id=\"gr\">' + pws[i].title + "</td><td id=\"gr\" id=\"hide\">" + pws[i].pw + "</td><td id=\"gr\">" + "<a href=" + pws[i].url + " target=\"_blank\">" + pws[i].url + "</a>" + "</td><td id=\"gr\">" + pws[i].time + "</td><td id=\"gr\">" + "<button onclick=\"copy2cb(" + pws[i].pw + ")\">Copy to clipboard</button> <a href=\"Update.php?det_id=" + pws[i].det_id + "\">Update</a> <a href=\"Delete.php?det_id=" + pws[i].det_id + "\">Delete</a></td></tr>"; | |
} | |
} | |
if (table == "<tr><th>Title</th><th>Password</th><th>URL</th><th>Added/Last Updated</th><th>Action</th></tr>") | |
document.getElementById('details').innerHTML = "<p>No entries found</p>"; | |
else | |
document.getElementById('details').innerHTML = table; | |
} | |
} | |
xhr.send(); | |
</script> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
table { | |
border: 2px solid black; | |
position: center; | |
background: black; | |
} | |
td, | |
th { | |
border: 2px solid black; | |
text-align: center; | |
font-weight: bold; | |
} | |
td { | |
background: white; | |
} | |
th { | |
background: black; | |
color: white; | |
} | |
h2 { | |
text-align: center; | |
} | |
a { | |
color: black; | |
text-decoration: none; | |
} | |
tr, | |
#bl { | |
background: #5f90d4; | |
} | |
tr, | |
#gr { | |
background: #c3cddb; | |
} | |
</style> | |
</head> | |
<body bgcolor=#01114a> | |
<a id="hr" href="Add.php"> | |
<font color=white><b>Add new password</b></font> | |
</a> | |
<form method="POST" action="view.php"> | |
<button name="logout">Logout</button> | |
</form> | |
<h2> | |
<font color="white">Details</font> | |
</h2> | |
<?php if (isset($_SESSION['success'])) { | |
echo ('<p style="color: green;"><b>' . $_SESSION['success'] . "</b></p>\n"); | |
unset($_SESSION['success']); | |
} | |
if (isset($_SESSION['error'])) { | |
echo ('<p style="color: red;"><b>' . $_SESSION['error'] . "</b></p>\n"); | |
unset($_SESSION['error']); | |
} | |
?> | |
<label for="sb"> | |
<font color="white"><b>Search:</b></font> | |
</label><input type="text" name="search_bar" id="sb" onkeyup="searchTable()"> | |
<table id="details" width="100%"> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment