mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
fix: better fix for encryption issue
This commit is contained in:
parent
ca28f037f7
commit
8969eb4071
1 changed files with 8 additions and 12 deletions
|
@ -126,17 +126,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
$paste_password = password_hash($paste_password, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
// If it's a new paste or the existing paste is encrypted, encrypt the paste
|
||||
// This is to prevent legacy pastes from getting weird
|
||||
if ($editing && !$paste->encrypt) {
|
||||
$paste_content = $_POST['paste_data'];
|
||||
} else {
|
||||
$paste_content = openssl_encrypt(
|
||||
$_POST['paste_data'],
|
||||
PP_ENCRYPTION_ALGO,
|
||||
PP_ENCRYPTION_KEY
|
||||
);
|
||||
}
|
||||
$paste_content = openssl_encrypt(
|
||||
$_POST['paste_data'],
|
||||
PP_ENCRYPTION_ALGO,
|
||||
PP_ENCRYPTION_KEY
|
||||
);
|
||||
|
||||
// Set expiry time
|
||||
$expires = calculatePasteExpiry($p_expiry);
|
||||
|
@ -145,6 +139,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
if ($editing) {
|
||||
$paste = Paste::find($_POST['paste_id']);
|
||||
if (can('edit', $paste)) {
|
||||
$paste_content = $paste->encrypt ? $paste_content : $_POST['paste_data'];
|
||||
$paste->update([
|
||||
'title' => $paste_title,
|
||||
'content' => $paste_content,
|
||||
|
@ -153,7 +148,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
'expiry' => $expires,
|
||||
'password' => $paste_password,
|
||||
'updated_at' => date_create(),
|
||||
'ip' => $ip
|
||||
'ip' => $ip,
|
||||
'encrypt' => true
|
||||
]);
|
||||
|
||||
$paste->replaceTags($tags);
|
||||
|
|
Loading…
Add table
Reference in a new issue