starting on pinging the basic elements of federation and communication
This commit is contained in:
parent
fb173900a1
commit
62a8298b54
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
functino vcard_from_xchan($xchan) {
|
||||
function vcard_from_xchan($xchan) {
|
||||
return replace_macros(get_markup_template('xchan_vcard.tpl'),array(
|
||||
$name => $abook['xchan_name'],
|
||||
$photo => $abook['xchan_photo_l']
|
||||
|
@ -3,8 +3,8 @@
|
||||
function follow_widget() {
|
||||
|
||||
return replace_macros(get_markup_template('follow.tpl'),array(
|
||||
'$connect' => t('Add New Contact'),
|
||||
'$desc' => t('Enter address or web location'),
|
||||
'$connect' => t('Add New Channel'),
|
||||
'$desc' => t('Enter webbie (channel location)'),
|
||||
'$hint' => t('Example: bob@example.com, http://example.com/barbara'),
|
||||
'$follow' => t('Connect')
|
||||
));
|
||||
|
@ -2,13 +2,11 @@
|
||||
|
||||
|
||||
//
|
||||
// Takes a $uid and a url/handle and adds a new contact
|
||||
// Currently if the contact is DFRN, interactive needs to be true, to redirect to the
|
||||
// dfrn_request page.
|
||||
// Takes a $uid and a url/handle and adds a new channel
|
||||
|
||||
// Otherwise this can be used to bulk add statusnet contacts, twitter contacts, etc.
|
||||
// Returns an array
|
||||
// $return['success'] boolean true if successful
|
||||
// $return['abook_id'] Address book ID if successful
|
||||
// $return['message'] error text if success is false.
|
||||
|
||||
|
||||
@ -19,10 +17,6 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
// remove ajax junk, e.g. Twitter
|
||||
|
||||
$url = str_replace('/#!/','/',$url);
|
||||
|
||||
if(! allowed_url($url)) {
|
||||
$result['message'] = t('Disallowed profile URL.');
|
||||
return $result;
|
||||
@ -33,14 +27,17 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$arr = array('url' => $url, 'contact' => array());
|
||||
$arr = array('url' => $url, 'channel' => array());
|
||||
|
||||
call_hooks('follow', $arr);
|
||||
|
||||
if(x($arr['contact'],'name'))
|
||||
$ret = $arr['contact'];
|
||||
else
|
||||
$ret = probe_url($url);
|
||||
$ret = zot_probe_url($url);
|
||||
|
||||
|
||||
|
||||
|
||||
if($ret['network'] === NETWORK_DFRN) {
|
||||
if($interactive) {
|
||||
|
@ -89,18 +89,27 @@ function create_identity($arr) {
|
||||
|
||||
set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false);
|
||||
|
||||
// Ensure that there is a host keypair.
|
||||
|
||||
if((! get_config('system','pubkey')) && (! get_config('system','prvkey'))) {
|
||||
$hostkey = new_keypair(4096);
|
||||
set_config('system','pubkey',$hostkey['pubkey']);
|
||||
set_config('system','prvkey',$hostkey['prvkey']);
|
||||
}
|
||||
|
||||
|
||||
// Create a verified hub location pointing to this site.
|
||||
|
||||
$r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_flags,
|
||||
hubloc_url, hubloc_url_sig, hubloc_callback, hubloc_sitekey )
|
||||
values ( '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
|
||||
hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey )
|
||||
values ( '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
|
||||
dbesc($guid),
|
||||
dbesc($sig),
|
||||
dbesc($hash),
|
||||
intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0),
|
||||
dbesc(z_root()),
|
||||
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
|
||||
dbesc(get_app()->get_hostname()),
|
||||
dbesc(z_root() . '/post'),
|
||||
dbesc(get_config('system','pubkey'))
|
||||
);
|
||||
@ -118,7 +127,7 @@ function create_identity($arr) {
|
||||
dbesc($a->get_baseurl() . "/photo/profile/l/{$newuid}"),
|
||||
dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}"),
|
||||
dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"),
|
||||
dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()),
|
||||
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
|
||||
dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']),
|
||||
dbesc($ret['channel']['channel_name']),
|
||||
dbesc('zot'),
|
||||
|
@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `abook` (
|
||||
KEY `abook_connnected` (`abook_connnected`),
|
||||
KEY `abook_flags` (`abook_flags`),
|
||||
KEY `abook_profile` (`abook_profile`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `account` (
|
||||
`account_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
@ -472,6 +472,7 @@ CREATE TABLE IF NOT EXISTS `hubloc` (
|
||||
`hubloc_flags` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`hubloc_url` char(255) NOT NULL DEFAULT '',
|
||||
`hubloc_url_sig` char(255) NOT NULL,
|
||||
`hubloc_host` char(255) NOT NULL DEFAULT '',
|
||||
`hubloc_callback` char(255) NOT NULL DEFAULT '',
|
||||
`hubloc_connect` char(255) NOT NULL DEFAULT '',
|
||||
`hubloc_sitekey` text NOT NULL,
|
||||
@ -481,7 +482,8 @@ CREATE TABLE IF NOT EXISTS `hubloc` (
|
||||
KEY `hubloc_flags` (`hubloc_flags`),
|
||||
KEY `hubloc_guid_sig` (`hubloc_guid_sig`),
|
||||
KEY `hubloc_url_sig` (`hubloc_url_sig`),
|
||||
KEY `hubloc_connect` (`hubloc_connect`)
|
||||
KEY `hubloc_connect` (`hubloc_connect`),
|
||||
KEY `hubloc_host` (`hubloc_host`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `intro` (
|
||||
|
@ -24,6 +24,7 @@ function abook_init(&$a) {
|
||||
}
|
||||
else {
|
||||
$abook_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if($abook_id) {
|
||||
@ -426,8 +427,7 @@ EOT;
|
||||
|
||||
$search = ((x($_REQUEST,'search')) ? notags(trim($_REQUEST['search'])) : '');
|
||||
|
||||
|
||||
// $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
|
||||
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
|
||||
|
||||
$tabs = array(
|
||||
array(
|
||||
@ -498,17 +498,21 @@ EOT;
|
||||
// $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
|
||||
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
|
||||
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
|
||||
intval($_SESSION['uid']));
|
||||
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
|
||||
where abook_channel = %d and not (abook_flags & %d) $sql_extra $sql_extra2 ",
|
||||
intval(local_user()),
|
||||
intval(ABOOK_FLAG_SELF)
|
||||
);
|
||||
if(count($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
$total = $r[0]['total'];
|
||||
}
|
||||
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ",
|
||||
intval($_SESSION['uid']),
|
||||
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_chan = xchan.xchan_hash
|
||||
WHERE abook_channel = %d and not (abook_flags & %d) $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d , %d ",
|
||||
intval(local_user()),
|
||||
intval(ABOOK_FLAG_SELF),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
);
|
||||
|
@ -24,10 +24,10 @@ function follow_init(&$a) {
|
||||
goaway($return_url);
|
||||
}
|
||||
|
||||
info( t('Contact added') . EOL);
|
||||
info( t('Channel added') . EOL);
|
||||
|
||||
if(strstr($return_url,'contacts'))
|
||||
goaway($a->get_baseurl() . '/contacts/' . $contact_id);
|
||||
if(strstr($return_url,'channel'))
|
||||
goaway($a->get_baseurl() . '/channel/' . $result['channel_id']);
|
||||
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
|
@ -67,8 +67,10 @@ function zfinger_init(&$a) {
|
||||
$ret['hubs'][] = array(
|
||||
'primary' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false),
|
||||
'url' => $hub['hubloc_url'],
|
||||
'url_sig' => $hub['hubloc_url_sig'],
|
||||
/// hmmm we probably shouldn't sign somebody else's hub. FIXME
|
||||
'url_sig' => base64url_encode(rsa_sign($hub['hubloc_url'],$e['channel_prvkey'])),
|
||||
'url_sig2' => base64url_encode(rsa_sign($hub['hubloc_url'],$e['channel_prvkey'])),
|
||||
'host' => $hub['hubloc_host'],
|
||||
'callback' => $hub['hubloc_callback'],
|
||||
'sitekey' => $hub['hubloc_sitekey']
|
||||
);
|
||||
|
@ -1 +1 @@
|
||||
2012-10-30.123
|
||||
2012-10-31.124
|
||||
|
Reference in New Issue
Block a user