]> git.mxchange.org Git - friendica.git/commitdiff
auto-update - create 's' keys for all users that don't have 'em
authorMike Macgirvin <mike@macgirvin.com>
Tue, 12 Oct 2010 08:14:50 +0000 (01:14 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Tue, 12 Oct 2010 08:14:50 +0000 (01:14 -0700)
boot.php
update.php

index 3f2a2551b800b57262e8fd87a84b4d9039c9523a..4deafe317c279c1a4a514e4d19ee34d2cc742b2e 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
 
 set_time_limit(0);
 
-define ( 'BUILD_ID' , 1006 );
+define ( 'BUILD_ID' , 1007 );
 
 define ( 'EOL', "<br />\r\n");
 define ( 'ATOM_TIME',  'Y-m-d\TH:i:s\Z' );
@@ -236,7 +236,6 @@ function check_config(&$a) {
                $stored = intval($build);
                $current = intval(BUILD_ID);
                if(($stored < $current) && file_exists('update.php')) {
-
                        // We're reporting a different version than what is currently installed.
                        // Run any existing update scripts to bring the database up to current.
 
index 80ec50bd272e06c272740c33070b6bab51172167..2ce83d5ce277751d70e1c57c4eab357d65c83e4f 100644 (file)
@@ -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'])
+                       );
+               }
+       }
+}