bearcaps and other stuff

This commit is contained in:
zotlabs 2019-08-15 23:53:02 -07:00
parent b9f20f4403
commit 532def0244
4 changed files with 35 additions and 4 deletions

View file

@ -54,12 +54,31 @@ class Activity {
}
else {
$m = parse_url($url);
// handle bearcaps
if ($m['scheme'] === 'bear' && $m['query']) {
$params = explode('&',$m['query']);
if ($params) {
foreach ($params as $p) {
if (substr($p,0,2) === 'u=') {
$url = substr($p,2);
}
if (substr($p,0,2) === 't=') {
$token = substr($p,2);
}
}
}
}
$headers = [
'Accept' => 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'Host' => $m['host'],
'(request-target)' => 'get ' . get_request_string($url),
'Date' => datetime_convert('UTC','UTC','now','D, d M Y H:i:s') . ' UTC'
];
if (isset($token)) {
$headers['Authorization'] = 'Bearer ' . $token;
}
$h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false);
$x = z_fetch_url($url, true, $redirects, [ 'headers' => $h ] );
}

View file

@ -61,11 +61,19 @@ class Libprofile {
if ($profile) {
$p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
dbesc($nickname),
dbesc($profile)
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
dbesc($nickname),
dbesc($profile)
);
if (! $p) {
$p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.id = %d LIMIT 1",
dbesc($nickname),
intval($profile)
);
}
}
if (! $p) {

View file

@ -22,6 +22,9 @@ require_once('vendor/autoload.php');
if (file_exists('addon/vendor/autoload.php')) {
require_once('addon/vendor/autoload.php');
}
if (file_exists('addon/version.php')) {
require_once('addon/version.php');
}
require_once('include/config.php');
require_once('include/network.php');

View file

@ -1684,6 +1684,7 @@ function get_site_info() {
'site_name' => (($site_name) ? $site_name : ''),
'version' => $version,
'version_tag' => $tag,
'addon_version' => defined('ADDON_VERSION') ? ADDON_VERSION : 'unknown',
'server_role' => System::get_server_role(),
'commit' => $commit,
'plugins' => $visible_plugins,