provide a broken feed for services which require a broken feed
This commit is contained in:
parent
195eb71200
commit
b88be137ca
@ -1,40 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zotlabs\Module;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
|
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
|
||||||
|
|
||||||
class Feed extends \Zotlabs\Web\Controller {
|
class Feed extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
$params = array();
|
$params = [];
|
||||||
|
|
||||||
|
$params['begin'] = ((x($_REQUEST,'date_begin')) ? $_REQUEST['date_begin'] : NULL_DATE);
|
||||||
|
$params['end'] = ((x($_REQUEST,'date_end')) ? $_REQUEST['date_end'] : '');
|
||||||
|
$params['type'] = ((stristr(argv(0),'json')) ? 'json' : 'xml');
|
||||||
|
$params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0);
|
||||||
|
$params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0);
|
||||||
|
$params['start'] = ((x($params,'start')) ? intval($params['start']) : 0);
|
||||||
|
$params['records'] = ((x($params,'records')) ? intval($params['records']) : 40);
|
||||||
|
$params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc');
|
||||||
|
$params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : '');
|
||||||
|
$params['compat'] = ((x($_REQUEST,'compat')) ? intval($_REQUEST['compat']) : 0);
|
||||||
|
|
||||||
$params['begin'] = ((x($_REQUEST,'date_begin')) ? $_REQUEST['date_begin'] : NULL_DATE);
|
|
||||||
$params['end'] = ((x($_REQUEST,'date_end')) ? $_REQUEST['date_end'] : '');
|
|
||||||
$params['type'] = ((stristr(argv(0),'json')) ? 'json' : 'xml');
|
|
||||||
$params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0);
|
|
||||||
$params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0);
|
|
||||||
$params['start'] = ((x($params,'start')) ? intval($params['start']) : 0);
|
|
||||||
$params['records'] = ((x($params,'records')) ? intval($params['records']) : 40);
|
|
||||||
$params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc');
|
|
||||||
$params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : '');
|
|
||||||
|
|
||||||
$channel = '';
|
|
||||||
if(argc() > 1) {
|
if(argc() > 1) {
|
||||||
$r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1",
|
|
||||||
dbesc(argv(1))
|
if(observer_prohibited(true)) {
|
||||||
);
|
|
||||||
if(!($r && count($r)))
|
|
||||||
killme();
|
killme();
|
||||||
|
}
|
||||||
|
|
||||||
$channel = $r[0];
|
$channel = channelx_by_nick(argv(1));
|
||||||
|
if(! $channel) {
|
||||||
if(observer_prohibited(true))
|
|
||||||
killme();
|
killme();
|
||||||
|
}
|
||||||
|
|
||||||
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
|
|
||||||
|
logger('public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
|
||||||
|
|
||||||
echo get_public_feed($channel,$params);
|
echo get_public_feed($channel,$params);
|
||||||
|
|
||||||
@ -43,6 +44,4 @@ class Feed extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,33 +94,39 @@ class Wfinger extends \Zotlabs\Web\Controller {
|
|||||||
$result['links'] = [
|
$result['links'] = [
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://webfinger.net/rel/avatar',
|
'rel' => 'http://webfinger.net/rel/avatar',
|
||||||
'type' => $r[0]['xchan_photo_mimetype'],
|
'type' => $r[0]['xchan_photo_mimetype'],
|
||||||
'href' => $r[0]['xchan_photo_l']
|
'href' => $r[0]['xchan_photo_l']
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://webfinger.net/rel/profile-page',
|
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||||
'href' => z_root() . '/profile/' . $r[0]['channel_address'],
|
'href' => z_root() . '/profile/' . $r[0]['channel_address'],
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://webfinger.net/rel/blog',
|
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
||||||
|
'type' => 'application/atom+xml',
|
||||||
|
'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1'
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
'rel' => 'http://webfinger.net/rel/blog',
|
||||||
'href' => z_root() . '/channel/' . $r[0]['channel_address'],
|
'href' => z_root() . '/channel/' . $r[0]['channel_address'],
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
'template' => z_root() . '/follow/url={uri}',
|
'template' => z_root() . '/follow/url={uri}',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'http://purl.org/zot/protocol',
|
'rel' => 'http://purl.org/zot/protocol',
|
||||||
'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'],
|
'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'],
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'rel' => 'magic-public-key',
|
'rel' => 'magic-public-key',
|
||||||
'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
|
'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller {
|
|||||||
'$aliases' => $aliases,
|
'$aliases' => $aliases,
|
||||||
'$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'],
|
'$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'],
|
||||||
'$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'],
|
'$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'],
|
||||||
'$atom' => z_root() . '/feed/' . $r[0]['channel_address'],
|
'$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1',
|
||||||
'$zot_post' => z_root() . '/post/' . $r[0]['channel_address'],
|
'$zot_post' => z_root() . '/post/' . $r[0]['channel_address'],
|
||||||
'$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'],
|
'$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'],
|
||||||
'$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'],
|
'$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'],
|
||||||
|
@ -22,24 +22,20 @@ function get_public_feed($channel, $params) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if(! $params)
|
if(! $params)
|
||||||
$params = array();
|
$params = [];
|
||||||
|
|
||||||
$params['type'] = ((x($params,'type')) ? $params['type'] : 'xml');
|
$params['type'] = ((x($params,'type')) ? $params['type'] : 'xml');
|
||||||
$params['begin'] = ((x($params,'begin')) ? $params['begin'] : NULL_DATE);
|
$params['begin'] = ((x($params,'begin')) ? $params['begin'] : NULL_DATE);
|
||||||
$params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now'));
|
$params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now'));
|
||||||
$params['start'] = ((x($params,'start')) ? $params['start'] : 0);
|
$params['start'] = ((x($params,'start')) ? $params['start'] : 0);
|
||||||
$params['records'] = ((x($params,'records')) ? $params['records'] : 40);
|
$params['records'] = ((x($params,'records')) ? $params['records'] : 40);
|
||||||
$params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc');
|
$params['direction'] = ((x($params,'direction'))? $params['direction'] : 'desc');
|
||||||
$params['pages'] = ((x($params,'pages')) ? intval($params['pages']) : 0);
|
$params['pages'] = ((x($params,'pages')) ? intval($params['pages']) : 0);
|
||||||
$params['top'] = ((x($params,'top')) ? intval($params['top']) : 0);
|
$params['top'] = ((x($params,'top')) ? intval($params['top']) : 0);
|
||||||
$params['cat'] = ((x($params,'cat')) ? $params['cat'] : '');
|
$params['cat'] = ((x($params,'cat')) ? $params['cat'] : '');
|
||||||
|
$params['compat'] = ((x($params,'compat')) ? intval($params['compat']) : 0);
|
||||||
|
|
||||||
|
|
||||||
// put a sane lower limit on feed requests if not specified
|
|
||||||
|
|
||||||
// if($params['begin'] <= NULL_DATE)
|
|
||||||
// $params['begin'] = datetime_convert('UTC','UTC','now - 1 month');
|
|
||||||
|
|
||||||
switch($params['type']) {
|
switch($params['type']) {
|
||||||
case 'json':
|
case 'json':
|
||||||
header("Content-type: application/atom+json");
|
header("Content-type: application/atom+json");
|
||||||
@ -61,6 +57,7 @@ function get_public_feed($channel, $params) {
|
|||||||
* @param array $params
|
* @param array $params
|
||||||
* @return string with an atom feed
|
* @return string with an atom feed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function get_feed_for($channel, $observer_hash, $params) {
|
function get_feed_for($channel, $observer_hash, $params) {
|
||||||
|
|
||||||
if(! $channel)
|
if(! $channel)
|
||||||
@ -74,18 +71,24 @@ function get_feed_for($channel, $observer_hash, $params) {
|
|||||||
http_status_exit(403);
|
http_status_exit(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logger('params: ' . print_r($params,true));
|
||||||
|
|
||||||
$feed_template = get_markup_template('atom_feed.tpl');
|
$feed_template = get_markup_template('atom_feed.tpl');
|
||||||
|
|
||||||
$atom = '';
|
$atom = '';
|
||||||
|
|
||||||
|
$feed_author = '';
|
||||||
|
if(intval($params['compat']) === 1) {
|
||||||
|
$feed_author = atom_author('author',$channel['channel_address'],$channel['xchan_url'],300,300,$channel['xchan_photo_mimetype'],$channel['xchan_photo_l']);
|
||||||
|
}
|
||||||
|
|
||||||
$atom .= replace_macros($feed_template, array(
|
$atom .= replace_macros($feed_template, array(
|
||||||
'$version' => xmlify(Zotlabs\Lib\System::get_project_version()),
|
'$version' => xmlify(Zotlabs\Lib\System::get_project_version()),
|
||||||
'$red' => xmlify(Zotlabs\Lib\System::get_platform_name()),
|
'$red' => xmlify(Zotlabs\Lib\System::get_platform_name()),
|
||||||
'$feed_id' => xmlify($channel['xchan_url']),
|
'$feed_id' => xmlify($channel['xchan_url']),
|
||||||
'$feed_title' => xmlify($channel['channel_name']),
|
'$feed_title' => xmlify($channel['channel_name']),
|
||||||
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)),
|
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)),
|
||||||
'$hub' => '', // feed_hublinks(),
|
'$author' => $feed_author,
|
||||||
'$salmon' => '', // feed_salmonlinks($channel['channel_address']),
|
|
||||||
'$name' => xmlify($channel['channel_name']),
|
'$name' => xmlify($channel['channel_name']),
|
||||||
'$profile_page' => xmlify($channel['xchan_url']),
|
'$profile_page' => xmlify($channel['xchan_url']),
|
||||||
'$mimephoto' => xmlify($channel['xchan_photo_mimetype']),
|
'$mimephoto' => xmlify($channel['xchan_photo_mimetype']),
|
||||||
@ -107,18 +110,21 @@ function get_feed_for($channel, $observer_hash, $params) {
|
|||||||
// a much simpler interface
|
// a much simpler interface
|
||||||
call_hooks('atom_feed', $atom);
|
call_hooks('atom_feed', $atom);
|
||||||
|
|
||||||
$items = items_fetch(array(
|
$items = items_fetch(
|
||||||
'wall' => '1',
|
[
|
||||||
'datequery' => $params['end'],
|
'wall' => '1',
|
||||||
'datequery2' => $params['begin'],
|
'datequery' => $params['end'],
|
||||||
'start' => $params['start'], // FIXME
|
'datequery2' => $params['begin'],
|
||||||
'records' => $params['records'], // FIXME
|
'start' => intval($params['start']),
|
||||||
'direction' => $params['direction'], // FIXME
|
'records' => intval($params['records']),
|
||||||
'pages' => $params['pages'],
|
'direction' => dbesc($params['direction']),
|
||||||
'order' => 'post',
|
'pages' => $params['pages'],
|
||||||
'top' => $params['top'],
|
'order' => dbesc('post'),
|
||||||
'cat' => $params['cat']
|
'top' => $params['top'],
|
||||||
), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module);
|
'cat' => $params['cat'],
|
||||||
|
'compat' => $params['compat']
|
||||||
|
], $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module
|
||||||
|
);
|
||||||
|
|
||||||
if($items) {
|
if($items) {
|
||||||
$type = 'html';
|
$type = 'html';
|
||||||
@ -1247,10 +1253,11 @@ function atom_author($tag, $name, $uri, $h, $w, $type, $photo) {
|
|||||||
$photo = xmlify($photo);
|
$photo = xmlify($photo);
|
||||||
|
|
||||||
$o .= "<$tag>\r\n";
|
$o .= "<$tag>\r\n";
|
||||||
$o .= "<name>$name</name>\r\n";
|
$o .= " <id>$uri</id>\r\n";
|
||||||
$o .= "<uri>$uri</uri>\r\n";
|
$o .= " <name>$name</name>\r\n";
|
||||||
$o .= '<link rel="photo" type="' . $type . '" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
|
$o .= " <uri>$uri</uri>\r\n";
|
||||||
$o .= '<link rel="avatar" type="' . $type . '" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
|
$o .= ' <link rel="photo" type="' . $type . '" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
|
||||||
|
$o .= ' <link rel="avatar" type="' . $type . '" media:width="' . $w . '" media:height="' . $h . '" href="' . $photo . '" />' . "\r\n";
|
||||||
|
|
||||||
call_hooks('atom_author', $o);
|
call_hooks('atom_author', $o);
|
||||||
|
|
||||||
|
@ -3885,6 +3885,10 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(intval($arr['compat']) === 1) {
|
||||||
|
$sql_extra = " AND author_xchan = owner_xchan and item_wall = 1 and item_private = 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
if ($arr['datequery']) {
|
if ($arr['datequery']) {
|
||||||
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('UTC','UTC',$arr['datequery']))));
|
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('UTC','UTC',$arr['datequery']))));
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,8 @@
|
|||||||
<generator uri="http://hubzilla.org" version="{{$version}}">{{$red}}</generator>
|
<generator uri="http://hubzilla.org" version="{{$version}}">{{$red}}</generator>
|
||||||
<link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
|
<link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
|
||||||
<link rel="alternate" type="text/html" href="{{$profile_page}}" />
|
<link rel="alternate" type="text/html" href="{{$profile_page}}" />
|
||||||
{{if $hub}}
|
{{if $author}}
|
||||||
{{$hub}}
|
{{$author}}
|
||||||
{{/if}}
|
|
||||||
{{if $salmon}}
|
|
||||||
{{$salmon}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<updated>{{$feed_updated}}</updated>
|
<updated>{{$feed_updated}}</updated>
|
||||||
|
Reference in New Issue
Block a user