From ebaa2a084ad407848aba06611fb11dcf1fcdfbdb Mon Sep 17 00:00:00 2001 From: o-psi Date: Mon, 18 Dec 2023 17:34:59 +0000 Subject: [PATCH] add readable password generation --- client_contacts.php | 27 +++++- client_logins.php | 209 +++++++++++++++++++++++++------------------- 2 files changed, 143 insertions(+), 93 deletions(-) diff --git a/client_contacts.php b/client_contacts.php index 2b060187..084835e6 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -241,12 +241,36 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); +?> diff --git a/client_logins.php b/client_logins.php index dc1ddf21..a7030acc 100644 --- a/client_logins.php +++ b/client_logins.php @@ -50,7 +50,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- +
@@ -67,107 +69,110 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- "> - - - - - - - - - + "> + + + + + + + + + - "; - } - $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username'])); - if (empty($login_username)) { - $login_username_display = "-"; - } else { - $login_username_display = "$login_username"; - } - $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password'])); - $login_otp_secret = nullable_htmlentities($row['login_otp_secret']); - $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"'; - if (empty($login_otp_secret)) { - $otp_display = "-"; - } else { - $otp_display = " Hover.."; - } - $login_note = nullable_htmlentities($row['login_note']); - $login_important = intval($row['login_important']); - $login_contact_id = intval($row['login_contact_id']); - $login_vendor_id = intval($row['login_vendor_id']); - $login_asset_id = intval($row['login_asset_id']); - $login_software_id = intval($row['login_software_id']); + while ($row = mysqli_fetch_array($sql)) { + $login_id = intval($row['login_id']); + $login_name = nullable_htmlentities($row['login_name']); + $login_description = nullable_htmlentities($row['login_description']); + if (empty($login_description)) { + $login_description_display = "-"; + } else { + $login_description_display = $login_description; + } + $login_uri = nullable_htmlentities($row['login_uri']); + if (empty($login_uri)) { + $login_uri_display = "-"; + } else { + $login_uri_display = "$login_uri"; + } + $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username'])); + if (empty($login_username)) { + $login_username_display = "-"; + } else { + $login_username_display = "$login_username"; + } + $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password'])); + $login_otp_secret = nullable_htmlentities($row['login_otp_secret']); + $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"'; + if (empty($login_otp_secret)) { + $otp_display = "-"; + } else { + $otp_display = " Hover.."; + } + $login_note = nullable_htmlentities($row['login_note']); + $login_important = intval($row['login_important']); + $login_contact_id = intval($row['login_contact_id']); + $login_vendor_id = intval($row['login_vendor_id']); + $login_asset_id = intval($row['login_asset_id']); + $login_software_id = intval($row['login_software_id']); ?> - "> - - - - - - - "> + + + + + + + - + + + ?>
NameDescriptionUsernamePasswordOTPURIAction
NameDescriptionUsernamePasswordOTPURIAction
- - - - - - - -
+ + + + + + + + - -
+ ?>
@@ -176,8 +181,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); function showOTP(id, secret) { //Send a GET request to ajax.php as ajax.php?get_totp_token=true&totp_secret=SECRET jQuery.get( - "ajax.php", - {get_totp_token: 'true', totp_secret: secret}, + "ajax.php", { + get_totp_token: 'true', + totp_secret: secret + }, function(data) { //If we get a response from post.php, parse it as JSON const token = JSON.parse(data); @@ -191,8 +198,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); function showOTPViaLoginID(login_id) { // Send a GET request to ajax.php as ajax.php?get_totp_token_via_id=true&login_id=ID jQuery.get( - "ajax.php", - {get_totp_token_via_id: 'true', login_id: login_id}, + "ajax.php", { + get_totp_token_via_id: 'true', + login_id: login_id + }, function(data) { //If we get a response from post.php, parse it as JSON const token = JSON.parse(data); @@ -204,7 +213,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); } function generatePassword() { - document.getElementById("password").value = "" + document.getElementById("password").value = "" + } + + function generatePassword() { + var url = '/ajax.php?get_readable_pass=true'; + + // Make an AJAX request to the server + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var password = xhr.responseText; + + document.getElementById("password").value = password; + } + }; + xhr.send(); } @@ -219,4 +245,3 @@ require_once "client_login_import_modal.php"; require_once "client_login_export_modal.php"; require_once "footer.php"; -