]> git.mxchange.org Git - friendica.git/commitdiff
basic diaspora discovery
authorFriendika <info@friendika.com>
Tue, 19 Jul 2011 01:13:46 +0000 (18:13 -0700)
committerFriendika <info@friendika.com>
Tue, 19 Jul 2011 01:13:46 +0000 (18:13 -0700)
boot.php
database.sql
mod/register.php
mod/xrd.php
update.php
view/xrd_diaspora.tpl [new file with mode: 0644]
view/xrd_person.tpl

index 0bf92c99e17ad077c872c622c3ef82cb82345f83..abb043036bc7e53f1f3a0b33bf5012dac90a3b9d 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
 
 define ( 'FRIENDIKA_VERSION',      '2.2.1045' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1075      );
+define ( 'DB_UPDATE_VERSION',      1076      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -2957,3 +2957,15 @@ function return_bytes ($size_str) {
     }
 }}
 
+function generate_guid() {
+       $found = true;
+       do {
+               $guid = substr(random_string(),0,16);
+               $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
+                       dbesc($guid)
+               );
+               if(! count($x))
+                       $found = false;
+       } while ($found == true );
+       return $guid;
+}
\ No newline at end of file
index 8ea3e42de71e83308c6c8f9fa131ccdbc962d8cf..50697845a33a7f5c6fcdb14f021832c56445a5fa 100644 (file)
@@ -379,6 +379,7 @@ CREATE TABLE IF NOT EXISTS `session` (
 
 CREATE TABLE IF NOT EXISTS `user` (
   `uid` int(11) NOT NULL AUTO_INCREMENT,
+  `guid` char(16) NOT NULL,
   `username` char(255) NOT NULL,
   `password` char(255) NOT NULL,
   `nickname` char(255) NOT NULL,
index 549d07a91896b58a6c3185885327124a5f9aa986..94eac7a14e885099a8a51bd2bba8971fb98bedb5 100644 (file)
@@ -198,9 +198,10 @@ function register_post(&$a) {
        $spkey = openssl_pkey_get_details($sres);
        $spubkey = $spkey["key"];
 
-       $r = q("INSERT INTO `user` ( `username`, `password`, `email`, `openid`, `nickname`,
+       $r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`,
                `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked` )
-               VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
+               VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
+               dbesc(generate_guid()),
                dbesc($username),
                dbesc($new_password_encoded),
                dbesc($email),
index de0c20ea5d39c5b7ef2b2f12a387429f1fe26d1b..accc2f68ef1f0388f8a9b193aa180dafccc3f311 100644 (file)
@@ -27,6 +27,20 @@ function xrd_content(&$a) {
        header('Access-Control-Allow-Origin: *');
        header("Content-type: text/xml");
 
+       $dspr_enabled = get_config('system','diaspora_enabled');
+
+       if($dspr_enabled) {
+               $tpl = file_get_contents('view/xrd_diaspora.tpl');
+               $dspr = replace_macros($tpl,array(
+                       '$baseurl' => $a->get_baseurl(),
+                       '$dspr_guid' => $r[0]['guid'],
+                       '$dspr_key' => base64_encode($r[0]['pubkey'])
+               ));
+       }
+       else
+               $dspr = '';
+
+
        $tpl = file_get_contents('view/xrd_person.tpl');
 
        $o = replace_macros($tpl, array(
@@ -34,6 +48,7 @@ function xrd_content(&$a) {
                '$profile_url' => $a->get_baseurl() . '/profile/'       . $r[0]['nickname'],
                '$atom'        => $a->get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
                '$photo'       => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
+               '$dspr'        => $dspr,
                '$salmon'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'],
                '$salmen'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
                '$modexp'      => 'data:application/magic-public-key,'  . $salmon_key
index f2cd5573f50ae3f5d647092537638cece127d4a9..9c55f15cf554f4acfc66bca388b59e2ff30e59ba 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1075 );
+define( 'UPDATE_VERSION' , 1076 );
 
 /**
  *
@@ -601,3 +601,26 @@ function update_1074() {
        }
        q("ALTER TABLE `profile` DROP `hidewall`");
 }
+
+function update_1075() {
+       q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
+       $r = q("SELECT `uid` FROM `user` WHERE 1");
+       if(count($r)) {
+               foreach($r as $rr) {
+                       $found = true;
+                       do {
+                               $guid = substr(random_string(),0,16);
+                               $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
+                                       dbesc($guid)
+                               );
+                               if(! count($x))
+                                       $found = false;
+                       } while ($found == true );
+
+                       q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d LIMIT 1",
+                               dbesc($guid),
+                               intval($rr['uid'])
+                       );
+               }
+       }
+}
\ No newline at end of file
diff --git a/view/xrd_diaspora.tpl b/view/xrd_diaspora.tpl
new file mode 100644 (file)
index 0000000..25cda53
--- /dev/null
@@ -0,0 +1,3 @@
+       <Link rel="http://joindiaspora.com/seed_location" type="text/html" href="$baseurl/" />
+       <Link rel="http://joindiaspora.com/guid" type="text/html" href="$dspr_guid" />
+       <Link rel="diaspora-public-key" type="RSA" href="$dspr_key" />
index b99f7c1fce1afe430b1b1f26a52218762b985cb9..0dabaa5a31b0bddbf88efa78fcf53767d613d2e8 100644 (file)
@@ -19,6 +19,7 @@
     <Link rel="http://webfinger.net/rel/avatar"
           type="image/jpeg"
           href="$photo" />
+       $dspr
     <Link rel="salmon" 
           href="$salmon" />
     <Link rel="http://salmon-protocol.org/ns/salmon-replies"