Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti 2018-12-10 10:38:06 +01:00
commit 15a689c6f5
5 changed files with 53 additions and 3 deletions

View File

@ -145,7 +145,7 @@ class New_channel extends \Zotlabs\Web\Controller {
$canadd = true;
if($r && ($limit !== false)) {
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
if ($r[0]['total'] >= $limit) {
if ($r[0]['total'] > $limit) {
$canadd = false;
}
}

View File

@ -347,6 +347,10 @@ class Ping extends \Zotlabs\Web\Controller {
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
$result = array();
if(argv(1) === 'home') {
$sql_extra .= ' and item_wall = 1 ';
}
$r = q("SELECT * FROM item
WHERE uid = %d
AND item_unseen = 1
@ -362,8 +366,6 @@ class Ping extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
foreach($r as $item) {
if((argv(1) === 'home') && (! intval($item['item_wall'])))
continue;
$result[] = \Zotlabs\Lib\Enotify::format($item);
}
}

View File

@ -14,6 +14,15 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($me)
);
if(! $r) {
$w = discover_by_webbie($me);
if($w) {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($me)
);
}
}
if($r) {
if($r[0]['hubloc_url'] === z_root())
goaway(z_root() . '/login');
@ -49,7 +58,16 @@ class Rmagic extends \Zotlabs\Web\Controller {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($address)
);
if(! $r) {
$w = discover_by_webbie($address);
if($w) {
$r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1",
dbesc($address)
);
}
}
}
if($r) {
$url = $r[0]['hubloc_url'];
}

View File

@ -439,6 +439,7 @@ define ( 'TERM_OBJ_APP', 7 );
* various namespaces we may need to parse
*/
define ( 'PROTOCOL_ZOT', 'http://purl.org/zot/protocol' );
define ( 'PROTOCOL_ZOT6', 'http://purl.org/zot/protocol/6.0' );
define ( 'NAMESPACE_ZOT', 'http://purl.org/zot' );
define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' );

View File

@ -1,4 +1,8 @@
<?php
use Zotlabs\Lib\Zotfinger;
use Zotlabs\Lib\Libzot;
/**
* @file include/network.php
* @brief Network related functions.
@ -1196,6 +1200,31 @@ function discover_by_webbie($webbie, $protocol = '') {
}
}
}
foreach($x['links'] as $link) {
if(array_key_exists('rel',$link)) {
if($link['rel'] === PROTOCOL_ZOT6 && ((! $protocol) || (strtolower($protocol) === 'zot6'))) {
logger('zot6 found for ' . $webbie, LOGGER_DEBUG);
$record = Zotfinger::exec($link['href']);
// Check the HTTP signature
$hsig = $record['signature'];
if($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $link['href']) && $hsig['header_valid'] === true && $hsig['content_valid'] === true)
$hsig_valid = true;
if(! $hsig_valid) {
logger('http signature not valid: ' . print_r($hsig,true));
continue;
}
$x = Libzot::import_xchan($record['data']);
if($x['success']) {
return $x['hash'];
}
}
}
}
}
logger('webfinger: ' . print_r($x,true), LOGGER_DATA, LOG_INFO);