mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +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);
|
$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(
|
$paste_content = openssl_encrypt(
|
||||||
$_POST['paste_data'],
|
$_POST['paste_data'],
|
||||||
PP_ENCRYPTION_ALGO,
|
PP_ENCRYPTION_ALGO,
|
||||||
PP_ENCRYPTION_KEY
|
PP_ENCRYPTION_KEY
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Set expiry time
|
// Set expiry time
|
||||||
$expires = calculatePasteExpiry($p_expiry);
|
$expires = calculatePasteExpiry($p_expiry);
|
||||||
|
@ -145,6 +139,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$paste = Paste::find($_POST['paste_id']);
|
$paste = Paste::find($_POST['paste_id']);
|
||||||
if (can('edit', $paste)) {
|
if (can('edit', $paste)) {
|
||||||
|
$paste_content = $paste->encrypt ? $paste_content : $_POST['paste_data'];
|
||||||
$paste->update([
|
$paste->update([
|
||||||
'title' => $paste_title,
|
'title' => $paste_title,
|
||||||
'content' => $paste_content,
|
'content' => $paste_content,
|
||||||
|
@ -153,7 +148,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
'expiry' => $expires,
|
'expiry' => $expires,
|
||||||
'password' => $paste_password,
|
'password' => $paste_password,
|
||||||
'updated_at' => date_create(),
|
'updated_at' => date_create(),
|
||||||
'ip' => $ip
|
'ip' => $ip,
|
||||||
|
'encrypt' => true
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$paste->replaceTags($tags);
|
$paste->replaceTags($tags);
|
||||||
|
|
Loading…
Add table
Reference in a new issue