basic diaspora discovery

This commit is contained in:
Friendika 2011-07-18 18:13:46 -07:00
parent 25b4aacf3b
commit c0b8e63a3f
7 changed files with 60 additions and 4 deletions

View File

@ -2,7 +2,7 @@
define ( 'FRIENDIKA_VERSION', '2.2.1045' ); define ( 'FRIENDIKA_VERSION', '2.2.1045' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1075 ); define ( 'DB_UPDATE_VERSION', 1076 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); 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;
}

View File

@ -379,6 +379,7 @@ CREATE TABLE IF NOT EXISTS `session` (
CREATE TABLE IF NOT EXISTS `user` ( CREATE TABLE IF NOT EXISTS `user` (
`uid` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL AUTO_INCREMENT,
`guid` char(16) NOT NULL,
`username` char(255) NOT NULL, `username` char(255) NOT NULL,
`password` char(255) NOT NULL, `password` char(255) NOT NULL,
`nickname` char(255) NOT NULL, `nickname` char(255) NOT NULL,

View File

@ -198,9 +198,10 @@ function register_post(&$a) {
$spkey = openssl_pkey_get_details($sres); $spkey = openssl_pkey_get_details($sres);
$spubkey = $spkey["key"]; $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` ) `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($username),
dbesc($new_password_encoded), dbesc($new_password_encoded),
dbesc($email), dbesc($email),

View File

@ -27,6 +27,20 @@ function xrd_content(&$a) {
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
header("Content-type: text/xml"); 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'); $tpl = file_get_contents('view/xrd_person.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
@ -34,6 +48,7 @@ function xrd_content(&$a) {
'$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'], '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
'$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'], '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
'$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg', '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
'$dspr' => $dspr,
'$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'], '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'],
'$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key '$modexp' => 'data:application/magic-public-key,' . $salmon_key

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1075 ); define( 'UPDATE_VERSION' , 1076 );
/** /**
* *
@ -601,3 +601,26 @@ function update_1074() {
} }
q("ALTER TABLE `profile` DROP `hidewall`"); 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'])
);
}
}
}

3
view/xrd_diaspora.tpl Normal file
View File

@ -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" />

View File

@ -19,6 +19,7 @@
<Link rel="http://webfinger.net/rel/avatar" <Link rel="http://webfinger.net/rel/avatar"
type="image/jpeg" type="image/jpeg"
href="$photo" /> href="$photo" />
$dspr
<Link rel="salmon" <Link rel="salmon"
href="$salmon" /> href="$salmon" />
<Link rel="http://salmon-protocol.org/ns/salmon-replies" <Link rel="http://salmon-protocol.org/ns/salmon-replies"