made encryption work again.

I did something.
This commit is contained in:
aftercase 2021-08-19 19:44:03 +01:00
parent f5e5e54be6
commit 3ae82cf630
2 changed files with 11 additions and 13 deletions

View file

@ -132,6 +132,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$p_code = trim(htmlspecialchars($_POST['format']));
$p_expiry = trim(htmlspecialchars($_POST['paste_expire_date']));
$p_password = $_POST['pass'];
$tag_input = $_POST['tag_input'];
if (empty($p_password)) {
$p_password = null;
@ -139,11 +140,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$p_password = password_hash($p_password, PASSWORD_DEFAULT);
}
$p_encrypt = $_POST['encrypted'] === '1';
$tag_input = $_POST['tag_input'];
if ($p_encrypt) {
$p_encrypt = $_POST['encrypted'];
if ($p_encrypt == "" || $p_encrypt == null) {
$p_encrypt = "0";
} else {
// Encrypt option
$p_encrypt = "1";
$p_content = openssl_encrypt($p_content, PP_ENCRYPTION_ALGO, PP_ENCRYPTION_KEY);
}

View file

@ -57,13 +57,9 @@ $row = $conn->querySelectOne(
// This is used in the theme files.
$totalpastes = getSiteTotalPastes($conn);
$notfound = null;
$is_private = false;
if ($row === null) {
if (!$row) {
header('HTTP/1.1 404 Not Found');
$notfound = $lang['notfound']; // "Not found";
goto Not_Valid_Paste;
} else {
$paste_title = $row['title'];
$paste_code = $row['code'];
@ -105,7 +101,7 @@ if ($row === null) {
}
}
if ($p_encrypt) {
if ($p_encrypt == 1) {
$p_content = openssl_decrypt($p_content, PP_ENCRYPTION_ALGO, PP_ENCRYPTION_KEY);
}
@ -260,7 +256,7 @@ if ($p_password == "NONE" || $p_password === null) {
Not_Valid_Paste:
// Private paste not valid
if ($is_private || $notfound) {
if ($is_private == '1') {
// Display errors
require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/errors.php');