aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-01-07 15:34:25 +0000
committerMario <mario@mariovavti.com>2024-01-07 15:34:25 +0000
commit5ee4f37b8d2bfaee253e0e65acb74a414c602a33 (patch)
tree5b19ca33d305f099f9dfd6ed3ff403d5e01f9bc3
parent3dc122db8402a17cc2ffe015552d116d66243f1b (diff)
downloadvolse-hubzilla-5ee4f37b8d2bfaee253e0e65acb74a414c602a33.tar.gz
volse-hubzilla-5ee4f37b8d2bfaee253e0e65acb74a414c602a33.tar.bz2
volse-hubzilla-5ee4f37b8d2bfaee253e0e65acb74a414c602a33.zip
DB update 1260 - REQUIRES SODIUM PHP EXTENSION!!!
-rw-r--r--Zotlabs/Update/_1260.php46
-rw-r--r--boot.php2
2 files changed, 47 insertions, 1 deletions
diff --git a/Zotlabs/Update/_1260.php b/Zotlabs/Update/_1260.php
new file mode 100644
index 000000000..1e1f1ebf0
--- /dev/null
+++ b/Zotlabs/Update/_1260.php
@@ -0,0 +1,46 @@
+<?php
+namespace Zotlabs\Update;
+
+class _1260 {
+ public function run() {
+
+ $has_sodium = function_exists('sodium_crypto_sign_keypair');
+
+ if (!$has_sodium) {
+ return UPDATE_FAILED;
+ }
+
+ q("START TRANSACTION");
+
+ $r1 = q("ALTER TABLE channel ADD channel_epubkey text NOT NULL");
+ $r2 = q("ALTER TABLE channel ADD channel_eprvkey text NOT NULL");
+
+ $channels = q("select channel_id from channel where true");
+ if ($channels) {
+ foreach ($channels as $channel) {
+ $keys = sodium_crypto_sign_keypair();
+ $pubkey = sodium_bin2base64(sodium_crypto_sign_publickey($keys), SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING);
+ $prvkey = sodium_bin2base64(sodium_crypto_sign_secretkey($keys), SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING);
+ q("update channel set channel_epubkey = '%s', channel_eprvkey = '%s' where channel_id = %d",
+ dbesc($pubkey),
+ dbesc($prvkey),
+ intval($channel['channel_id'])
+ );
+ }
+ }
+
+ if ($r1 && $r2) {
+ q("COMMIT");
+ return UPDATE_SUCCESS;
+ }
+
+ q("ROLLBACK");
+ return UPDATE_FAILED;
+ }
+
+ public function verify() {
+ $columns = db_columns('channel');
+ return in_array('channel_epubkey', $columns) && in_array('channel_eprvkey', $columns);
+ }
+}
+
diff --git a/boot.php b/boot.php
index a1528e58d..6c1c43704 100644
--- a/boot.php
+++ b/boot.php
@@ -65,7 +65,7 @@ define('PLATFORM_NAME', 'hubzilla');
define('STD_VERSION', '8.9.1');
define('ZOT_REVISION', '6.0');
-define('DB_UPDATE_VERSION', 1259);
+define('DB_UPDATE_VERSION', 1260);
define('PROJECT_BASE', __DIR__);