diff options
Diffstat (limited to 'Zotlabs/Update')
-rw-r--r-- | Zotlabs/Update/_1260.php | 58 | ||||
-rw-r--r-- | Zotlabs/Update/_1261.php | 58 | ||||
-rw-r--r-- | Zotlabs/Update/_1262.php | 30 | ||||
-rw-r--r-- | Zotlabs/Update/_1263.php | 26 |
4 files changed, 172 insertions, 0 deletions
diff --git a/Zotlabs/Update/_1260.php b/Zotlabs/Update/_1260.php new file mode 100644 index 000000000..7f91418f6 --- /dev/null +++ b/Zotlabs/Update/_1260.php @@ -0,0 +1,58 @@ +<?php +namespace Zotlabs\Update; + +class _1260 { + public function run() { + + $has_sodium = function_exists('sodium_crypto_sign_keypair'); + $has_bcmath = function_exists('bcadd'); + $has_gmp = function_exists('gmp_add'); + + if (!$has_sodium) { + return UPDATE_FAILED; + } + + if (!($has_gmp || $has_bcmath)) { + return UPDATE_FAILED; + } + + dbq("START TRANSACTION"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = dbq("ALTER TABLE channel ADD channel_epubkey text NOT NULL DEFAULT ''"); + $r2 = dbq("ALTER TABLE channel ADD channel_eprvkey text NOT NULL DEFAULT ''"); + } + else { + $r1 = dbq("ALTER TABLE channel ADD channel_epubkey text NOT NULL"); + $r2 = dbq("ALTER TABLE channel ADD channel_eprvkey text NOT NULL"); + } + + $channels = dbq("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) { + dbq("COMMIT"); + return UPDATE_SUCCESS; + } + + dbq("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/Zotlabs/Update/_1261.php b/Zotlabs/Update/_1261.php new file mode 100644 index 000000000..43fd0b098 --- /dev/null +++ b/Zotlabs/Update/_1261.php @@ -0,0 +1,58 @@ +<?php +namespace Zotlabs\Update; + +use Zotlabs\Lib\Multibase; + +class _1261 { + public function run() { + + $has_sodium = function_exists('sodium_crypto_sign_keypair'); + $has_bcmath = function_exists('bcadd'); + $has_gmp = function_exists('gmp_add'); + + if (!$has_sodium) { + return UPDATE_FAILED; + } + + if (!($has_gmp || $has_bcmath)) { + return UPDATE_FAILED; + } + + dbq("START TRANSACTION"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = dbq("ALTER TABLE xchan ADD xchan_epubkey text NOT NULL DEFAULT ''"); + $r2 = dbq("ALTER TABLE xchan ADD xchan_updated timestamp NOT NULL DEFAULT '0001-01-01 00:00:00'"); + } + else { + $r1 = dbq("ALTER TABLE xchan ADD xchan_epubkey text NOT NULL"); + $r2 = dbq("ALTER TABLE xchan ADD xchan_updated datetime NOT NULL DEFAULT '0001-01-01 00:00:00'"); + } + + $channels = dbq("select * from channel where true"); + if ($channels) { + foreach ($channels as $channel) { + $epubkey = (new Multibase())->publicKey($channel['channel_epubkey']); + q("update xchan set xchan_epubkey = '%s' where xchan_url = '%s'", + dbesc($epubkey), + dbesc(channel_url($channel)) + ); + } + } + + if ($r1 && $r2) { + dbq("COMMIT"); + return UPDATE_SUCCESS; + } + + dbq("ROLLBACK"); + return UPDATE_FAILED; + + } + + public function verify() { + $columns = db_columns('xchan'); + return in_array('xchan_epubkey', $columns) && in_array('xchan_updated', $columns); + } +} + diff --git a/Zotlabs/Update/_1262.php b/Zotlabs/Update/_1262.php new file mode 100644 index 000000000..f457a0116 --- /dev/null +++ b/Zotlabs/Update/_1262.php @@ -0,0 +1,30 @@ +<?php + +namespace Zotlabs\Update; + +class _1262 { + + function run() { + + dbq("START TRANSACTION"); + + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r = true; + } + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = dbq("ALTER TABLE session MODIFY COLUMN sess_data MEDIUMTEXT NOT NULL"); + } + + if($r) { + dbq("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Update/_1263.php b/Zotlabs/Update/_1263.php new file mode 100644 index 000000000..bd12e7321 --- /dev/null +++ b/Zotlabs/Update/_1263.php @@ -0,0 +1,26 @@ +<?php + +namespace Zotlabs\Update; + +class _1263 { + + function run() { + + dbq("START TRANSACTION"); + + $poke = hash('whirlpool', 'Poke'); + $mood = hash('whirlpool', 'Mood'); + + $r = dbq("DELETE FROM app WHERE (app_id = '$poke' OR app_id = '$mood') AND app_system = 1"); + + if($r) { + dbq("COMMIT"); + return UPDATE_SUCCESS; + } + + dbq("ROLLBACK"); + return UPDATE_FAILED; + + } + +} |