From 4d0b828879f05ce3e07f7ca947a0f15ccb33b693 Mon Sep 17 00:00:00 2001
From: larry_the_cow <larry@gentoo.org>
Date: Sun, 3 Feb 2019 15:45:18 +0000
Subject: [PATCH] Restore encrypted notes

send_backup() decrypts the notes if MSGENCRYPTED is enabled.
So, re-encrypt the notes on restore.
---
 chat.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/chat.php b/chat.php
index 6c77b80..054c761 100644
--- a/chat.php
+++ b/chat.php
@@ -767,6 +767,9 @@ function restore_backup($C){
 			}elseif($note['type']==='staff'){
 				$note['type']=1;
 			}
+			if(MSGENCRYPTED){
+				$note['text']=openssl_encrypt($note['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
+			}
 			$stmt->execute([$note['type'], $note['lastedited'], $note['editedby'], $note['text']]);
 		}
 	}