mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 05:15:16 +00:00
php warnings in lib/apps, expand use of get_actor_hublocs()
This commit is contained in:
parent
3d7c376422
commit
1322b7660c
4 changed files with 33 additions and 39 deletions
|
@ -4151,8 +4151,6 @@ class Activity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (trim($options_arr[0])) {
|
||||
case 'activitypub':
|
||||
$hublocs = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_hash = '%s' $sql_options ",
|
||||
|
|
|
@ -571,6 +571,13 @@ class Apps {
|
|||
if ($mode === 'install') {
|
||||
$papp['embed'] = true;
|
||||
}
|
||||
|
||||
$featured = $pinned = false;
|
||||
if (isset($papp['categories'])) {
|
||||
$featured = ((strpos($papp['categories'],'nav_featured_app') !== false) ? true : false);
|
||||
$pinned = ((strpos($papp['categories'],'nav_pinned_app') !== false) ? true : false);
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('app.tpl'), [
|
||||
'$app' => $papp,
|
||||
'$icon' => $icon,
|
||||
|
@ -585,8 +592,8 @@ class Apps {
|
|||
'$deleted' => ((isset($papp['deleted'])) ? intval($papp['deleted']) : false),
|
||||
'$feature' => (((isset($papp['embed']) && $papp['embed']) || $mode === 'edit') ? false : true),
|
||||
'$pin' => (((isset($papp['embed']) && $papp['embed']) || $mode === 'edit') ? false : true),
|
||||
'$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true),
|
||||
'$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true),
|
||||
'$featured' => $featured,
|
||||
'$pinned' => $pinned,
|
||||
'$navapps' => (($mode === 'nav') ? true : false),
|
||||
'$order' => (($mode === 'nav-order' || $mode === 'nav-order-pinned') ? true : false),
|
||||
'$mode' => $mode,
|
||||
|
|
|
@ -14,6 +14,7 @@ use Sabre\DAV as SDAV;
|
|||
use Zotlabs\Storage;
|
||||
use Zotlabs\Lib\Libprofile;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
|
||||
require_once('include/attach.php');
|
||||
require_once('include/auth.php');
|
||||
|
@ -28,13 +29,13 @@ class Dav extends Controller {
|
|||
*/
|
||||
function init() {
|
||||
|
||||
foreach([ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $head) {
|
||||
foreach ([ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $head) {
|
||||
|
||||
/* Basic authentication */
|
||||
|
||||
if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,5) === 'Basic') {
|
||||
if (array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,5) === 'Basic') {
|
||||
$userpass = @base64_decode(substr(trim($_SERVER[$head]),6)) ;
|
||||
if(strlen($userpass)) {
|
||||
if (strlen($userpass)) {
|
||||
list($name, $password) = explode(':', $userpass);
|
||||
$_SERVER['PHP_AUTH_USER'] = $name;
|
||||
$_SERVER['PHP_AUTH_PW'] = $password;
|
||||
|
@ -44,42 +45,43 @@ class Dav extends Controller {
|
|||
|
||||
/* Signature authentication */
|
||||
|
||||
if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') {
|
||||
if($head !== 'HTTP_AUTHORIZATION') {
|
||||
if (array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') {
|
||||
if ($head !== 'HTTP_AUTHORIZATION') {
|
||||
$_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head];
|
||||
continue;
|
||||
}
|
||||
|
||||
$sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
|
||||
if($sigblock) {
|
||||
$sigblock = HTTPSig::parse_sigheader($_SERVER[$head]);
|
||||
if ($sigblock) {
|
||||
$keyId = str_replace('acct:','',$sigblock['keyId']);
|
||||
if($keyId) {
|
||||
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
|
||||
if ($keyId) {
|
||||
$r = q("select * from hubloc where ( hubloc_addr = '%s' OR hubloc_id_url = '%s' OR hubloc_hash = '%s') limit 1",
|
||||
dbesc($keyId)
|
||||
);
|
||||
if($r) {
|
||||
if ($r) {
|
||||
$c = channelx_by_hash($r[0]['hubloc_hash']);
|
||||
if($c) {
|
||||
if ($c) {
|
||||
$a = q("select * from account where account_id = %d limit 1",
|
||||
intval($c['channel_account_id'])
|
||||
);
|
||||
if($a) {
|
||||
if ($a) {
|
||||
$record = [ 'channel' => $c, 'account' => $a[0] ];
|
||||
$channel_login = $c['channel_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(! $record)
|
||||
if (! $record) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($record) {
|
||||
$verified = \Zotlabs\Web\HTTPSig::verify('',$record['channel']['channel_pubkey']);
|
||||
if(! ($verified && $verified['header_signed'] && $verified['header_valid'])) {
|
||||
if ($record) {
|
||||
$verified = HTTPSig::verify('',$record['channel']['channel_pubkey']);
|
||||
if (! ($verified && $verified['header_signed'] && $verified['header_valid'])) {
|
||||
$record = null;
|
||||
}
|
||||
if($record['account']) {
|
||||
if ($record['account']) {
|
||||
authenticate_success($record['account']);
|
||||
if($channel_login) {
|
||||
if ($channel_login) {
|
||||
change_channel($channel_login);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,10 +117,7 @@ class Inbox extends Controller {
|
|||
// if the sender has the ability to send messages over zot/nomad, ignore messages sent via activitypub
|
||||
// as observer aware features and client side markup will be unavailable
|
||||
|
||||
$test = q("select * from hubloc where hubloc_hash = '%s' or hubloc_id_url = '%s'",
|
||||
dbesc($hsig['portable_id']),
|
||||
dbesc($hsig['portable_id'])
|
||||
);
|
||||
$test = get_actor_hublocs($hsig['portable_id'],'all,not_deleted');
|
||||
if ($test) {
|
||||
foreach ($test as $t) {
|
||||
if ($t['hubloc_network'] === 'zot6') {
|
||||
|
@ -131,11 +128,8 @@ class Inbox extends Controller {
|
|||
|
||||
// fetch the portable_id for the actor, which may or may not be the sender
|
||||
|
||||
$v = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' or hubloc_hash = '%s'",
|
||||
dbesc($AS->actor['id']),
|
||||
dbesc($AS->actor['id'])
|
||||
);
|
||||
|
||||
$v = get_actor_hublocs($AS->actor['id'],'activitypub,not_deleted');
|
||||
|
||||
if ($v && $v[0]['hubloc_hash'] !== $hsig['portable_id']) {
|
||||
// The sender is not actually the activity actor, so verify the LD signature.
|
||||
// litepub activities (with no LD signature) will always have a matching actor and sender
|
||||
|
@ -267,10 +261,6 @@ class Inbox extends Controller {
|
|||
|
||||
|
||||
foreach ($channels as $channel) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (! PConfig::Get($channel['channel_id'],'system','activitypub',Config::Get('system','activitypub',ACTIVITYPUB_ENABLED))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -320,10 +310,7 @@ class Inbox extends Controller {
|
|||
switch ($AS->type) {
|
||||
case 'Update':
|
||||
if (is_array($AS->obj) && array_key_exists('type',$AS->obj) && ActivityStreams::is_an_actor($AS->obj['type'])) {
|
||||
// pretend this is an old cache entry to force an update of all the actor details
|
||||
$AS->obj['cached'] = true;
|
||||
$AS->obj['updated'] = datetime_convert('UTC','UTC','1980-01-01', ATOM_TIME);
|
||||
Activity::actor_store($AS->obj['id'],$AS->obj);
|
||||
Activity::actor_store($AS->obj['id'],$AS->obj, true /* force cache refresh */);
|
||||
break;
|
||||
}
|
||||
case 'Accept':
|
||||
|
|
Loading…
Reference in a new issue