aboutsummaryrefslogtreecommitdiffstats
path: root/update.php
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-10-12 01:14:50 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-10-12 01:14:50 -0700
commitcc64742e2340038f4f14d1cdef492250b54c0a38 (patch)
treef348309f3a638d095522b95699c9b349b6935f43 /update.php
parentb9d768972e94dfa5e1511779726091214dece5cf (diff)
downloadvolse-hubzilla-cc64742e2340038f4f14d1cdef492250b54c0a38.tar.gz
volse-hubzilla-cc64742e2340038f4f14d1cdef492250b54c0a38.tar.bz2
volse-hubzilla-cc64742e2340038f4f14d1cdef492250b54c0a38.zip
auto-update - create 's' keys for all users that don't have 'em
Diffstat (limited to 'update.php')
-rw-r--r--update.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/update.php b/update.php
index 80ec50bd2..2ce83d5ce 100644
--- a/update.php
+++ b/update.php
@@ -40,4 +40,26 @@ function update_1005() {
q("ALTER TABLE `user` ADD `spubkey` TEXT NOT NULL AFTER `prvkey` ,
ADD `sprvkey` TEXT NOT NULL AFTER `spubkey`");
-} \ No newline at end of file
+}
+
+function update_1006() {
+
+ // create 's' keys for everybody that does not have one
+
+ $r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $sres=openssl_pkey_new(array('encrypt_key' => false ));
+ $sprvkey = '';
+ openssl_pkey_export($sres, $sprvkey);
+ $spkey = openssl_pkey_get_details($sres);
+ $spubkey = $spkey["key"];
+ $r = q("UPDATE `user` SET `spubkey` = '%s', `sprvkey` = '%s'
+ WHERE `uid` = %d LIMIT 1",
+ dbesc($spubkey),
+ dbesc($sprvkey),
+ intval($rr['uid'])
+ );
+ }
+ }
+}