Merge branch '2019.06-rc'
# Conflicts: # CHANGELOG # VERSION # boot.php
This commit is contained in:
commit
c1f99c70b1
594 changed files with 94180 additions and 68341 deletions
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
|
||||
require_once 'mod/hostxrd.php';
|
||||
require_once 'mod/nodeinfo.php';
|
||||
require_once 'mod/xrd.php';
|
||||
|
||||
function _well_known_init(App $a)
|
||||
{
|
||||
if ($a->argc > 1) {
|
||||
switch ($a->argv[1]) {
|
||||
case "host-meta":
|
||||
hostxrd_init($a);
|
||||
break;
|
||||
case "x-social-relay":
|
||||
wk_social_relay();
|
||||
break;
|
||||
case "nodeinfo":
|
||||
nodeinfo_wellknown($a);
|
||||
break;
|
||||
case "webfinger":
|
||||
xrd_init($a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
function wk_social_relay()
|
||||
{
|
||||
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
||||
|
||||
if ($subscribe) {
|
||||
$scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL);
|
||||
} else {
|
||||
$scope = SR_SCOPE_NONE;
|
||||
}
|
||||
|
||||
$tags = [];
|
||||
|
||||
if ($scope == SR_SCOPE_TAGS) {
|
||||
$server_tags = Config::get('system', 'relay_server_tags');
|
||||
$tagitems = explode(",", $server_tags);
|
||||
|
||||
/// @todo Check if it was better to use "strtolower" on the tags
|
||||
foreach ($tagitems AS $tag) {
|
||||
$tag = trim($tag, "# ");
|
||||
$tags[$tag] = $tag;
|
||||
}
|
||||
|
||||
if (Config::get('system', 'relay_user_tags')) {
|
||||
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
|
||||
|
||||
foreach ($terms AS $term) {
|
||||
$tag = trim($term["term"], "#");
|
||||
$tags[$tag] = $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$taglist = [];
|
||||
foreach ($tags AS $tag) {
|
||||
if (!empty($tag)) {
|
||||
$taglist[] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
$relay = [
|
||||
'subscribe' => $subscribe,
|
||||
'scope' => $scope,
|
||||
'tags' => $taglist,
|
||||
'protocols' => ['diaspora' => ['receive' => System::baseUrl() . '/receive/public'],
|
||||
'dfrn' => ['receive' => System::baseUrl() . '/dfrn_notify']]
|
||||
];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
2720
mod/admin.php
2720
mod/admin.php
File diff suppressed because it is too large
Load diff
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/allfriends.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
||||
|
||||
function allfriends_content(App $a)
|
||||
{
|
||||
$o = '';
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = 0;
|
||||
if ($a->argc > 1) {
|
||||
$cid = intval($a->argv[1]);
|
||||
}
|
||||
|
||||
if (!$cid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = $a->user['uid'];
|
||||
|
||||
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['id' => $cid, 'uid' => local_user()]);
|
||||
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->page['aside'] = "";
|
||||
Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
|
||||
|
||||
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$r = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
if (!DBA::isResult($r)) {
|
||||
$o .= L10n::t('No friends to display.');
|
||||
return $o;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
|
||||
$entries = [];
|
||||
foreach ($r as $rr) {
|
||||
//get further details of the contact
|
||||
$contact_details = Model\Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
||||
|
||||
$connlnk = '';
|
||||
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
|
||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
||||
if ($rr['cid']) {
|
||||
$rr['id'] = $rr['cid'];
|
||||
$photo_menu = Model\Contact::photoMenu($rr);
|
||||
} else {
|
||||
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
||||
$photo_menu = [
|
||||
'profile' => [L10n::t("View Profile"), Model\Contact::magicLink($rr['url'])],
|
||||
'follow' => [L10n::t("Connect/Follow"), $connlnk]
|
||||
];
|
||||
}
|
||||
|
||||
$entry = [
|
||||
'url' => Model\Contact::magicLink($rr['url']),
|
||||
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||
'name' => $contact_details['name'],
|
||||
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||
'img_hover' => $contact_details['name'],
|
||||
'details' => $contact_details['location'],
|
||||
'tags' => $contact_details['keywords'],
|
||||
'about' => $contact_details['about'],
|
||||
'account_type' => Model\Contact::getAccountType($contact_details),
|
||||
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
||||
'photo_menu' => $photo_menu,
|
||||
'conntxt' => L10n::t('Connect'),
|
||||
'connlnk' => $connlnk,
|
||||
'id' => ++$id,
|
||||
];
|
||||
$entries[] = $entry;
|
||||
}
|
||||
|
||||
$tab_str = Module\Contact::getTabsHTML($a, $contact, 4);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
49
mod/amcd.php
49
mod/amcd.php
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
function amcd_content()
|
||||
{
|
||||
echo <<< JSON
|
||||
{
|
||||
"version":1,
|
||||
"sessionstatus":{
|
||||
"method":"GET",
|
||||
"path":"/session"
|
||||
},
|
||||
"auth-methods": {
|
||||
"username-password-form": {
|
||||
"connect": {
|
||||
"method":"POST",
|
||||
"path":"/login",
|
||||
"params": {
|
||||
"username":"login-name",
|
||||
"password":"password"
|
||||
},
|
||||
"onsuccess": { "action":"reload" }
|
||||
},
|
||||
"disconnect": {
|
||||
"method":"GET",
|
||||
"path":"\/logout"
|
||||
}
|
||||
}
|
||||
}
|
||||
"methods": {
|
||||
"username-password-form": {
|
||||
"connect": {
|
||||
"method":"POST",
|
||||
"path":"\/login",
|
||||
"params": {
|
||||
"username":"login-name",
|
||||
"password":"password"
|
||||
},
|
||||
"onsuccess": { "action":"reload" }
|
||||
},
|
||||
"disconnect": {
|
||||
"method":"GET",
|
||||
"path":"\/logout"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
exit();
|
||||
}
|
33
mod/apps.php
33
mod/apps.php
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/apps.php
|
||||
*/
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
function apps_content()
|
||||
{
|
||||
$privateaddons = Config::get('config', 'private_addons');
|
||||
if ($privateaddons === "1") {
|
||||
if (! local_user()) {
|
||||
info(L10n::t('You must be logged in to use addons. '));
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
$title = L10n::t('Applications');
|
||||
|
||||
$apps = Nav::getAppMenu();
|
||||
|
||||
if (count($apps) == 0) {
|
||||
notice(L10n::t('No installed applications.') . EOL);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('apps.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$title' => $title,
|
||||
'$apps' => $apps,
|
||||
]);
|
||||
}
|
168
mod/babel.php
168
mod/babel.php
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/babel.php
|
||||
*/
|
||||
|
||||
use Friendica\Content\Text;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
function visible_whitespace($s)
|
||||
{
|
||||
$s = str_replace(' ', ' ', $s);
|
||||
|
||||
return str_replace(["\r\n", "\n", "\r"], '<br />', $s);
|
||||
}
|
||||
|
||||
function babel_content()
|
||||
{
|
||||
$results = [];
|
||||
if (!empty($_REQUEST['text'])) {
|
||||
switch (defaults($_REQUEST, 'type', 'bbcode')) {
|
||||
case 'bbcode':
|
||||
$bbcode = trim($_REQUEST['text']);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Source input'),
|
||||
'content' => visible_whitespace($bbcode)
|
||||
];
|
||||
|
||||
$plain = Text\BBCode::toPlaintext($bbcode, false);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::toPlaintext'),
|
||||
'content' => visible_whitespace($plain)
|
||||
];
|
||||
|
||||
$html = Text\BBCode::convert($bbcode);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::convert (raw HTML)'),
|
||||
'content' => visible_whitespace(htmlspecialchars($html))
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::convert'),
|
||||
'content' => $html
|
||||
];
|
||||
|
||||
$bbcode2 = Text\HTML::toBBCode($html);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::convert => HTML::toBBCode'),
|
||||
'content' => visible_whitespace($bbcode2)
|
||||
];
|
||||
|
||||
$markdown = Text\BBCode::toMarkdown($bbcode);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::toMarkdown'),
|
||||
'content' => visible_whitespace($markdown)
|
||||
];
|
||||
|
||||
$html2 = Text\Markdown::convert($markdown);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert'),
|
||||
'content' => $html2
|
||||
];
|
||||
|
||||
$bbcode3 = Text\Markdown::toBBCode($markdown);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
|
||||
'content' => visible_whitespace($bbcode3)
|
||||
];
|
||||
|
||||
$bbcode4 = Text\HTML::toBBCode($html2);
|
||||
$results[] = [
|
||||
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
|
||||
'content' => visible_whitespace($bbcode4)
|
||||
];
|
||||
|
||||
$item = [
|
||||
'body' => $bbcode,
|
||||
'tag' => '',
|
||||
];
|
||||
|
||||
\Friendica\Model\Item::setHashtags($item);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Item Body'),
|
||||
'content' => visible_whitespace($item['body'])
|
||||
];
|
||||
$results[] = [
|
||||
'title' => L10n::t('Item Tags'),
|
||||
'content' => $item['tag']
|
||||
];
|
||||
break;
|
||||
case 'markdown':
|
||||
$markdown = trim($_REQUEST['text']);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Source input (Diaspora format)'),
|
||||
'content' => '<pre>' . $markdown . '</pre>'
|
||||
];
|
||||
|
||||
$html = Text\Markdown::convert($markdown);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Markdown::convert (raw HTML)'),
|
||||
'content' => visible_whitespace(htmlspecialchars($html))
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => L10n::t('Markdown::convert'),
|
||||
'content' => $html
|
||||
];
|
||||
|
||||
$bbcode = Text\Markdown::toBBCode($markdown);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Markdown::toBBCode'),
|
||||
'content' => '<pre>' . $bbcode . '</pre>'
|
||||
];
|
||||
break;
|
||||
case 'html' :
|
||||
$html = trim($_REQUEST['text']);
|
||||
$results[] = [
|
||||
'title' => L10n::t('Raw HTML input'),
|
||||
'content' => htmlspecialchars($html)
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML Input'),
|
||||
'content' => $html
|
||||
];
|
||||
|
||||
$bbcode = Text\HTML::toBBCode($html);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toBBCode'),
|
||||
'content' => visible_whitespace($bbcode)
|
||||
];
|
||||
|
||||
$html2 = Text\BBCode::convert($bbcode);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toBBCode => BBCode::convert'),
|
||||
'content' => $html2
|
||||
];
|
||||
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'),
|
||||
'content' => htmlspecialchars($html2)
|
||||
];
|
||||
|
||||
$markdown = Text\HTML::toMarkdown($html);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toMarkdown'),
|
||||
'content' => visible_whitespace($markdown)
|
||||
];
|
||||
|
||||
$text = Text\HTML::toPlaintext($html);
|
||||
$results[] = [
|
||||
'title' => L10n::t('HTML::toPlaintext'),
|
||||
'content' => '<pre>' . $text . '</pre>'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('babel.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$text' => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
|
||||
'$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
|
||||
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
|
||||
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
|
||||
'$results' => $results
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/bookmarklet.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Login;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function bookmarklet_init()
|
||||
{
|
||||
$_GET["mode"] = "minimal";
|
||||
}
|
||||
|
||||
function bookmarklet_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
$o = '<h2>' . L10n::t('Login') . '</h2>';
|
||||
$o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? false : true);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', ''));
|
||||
$page = Strings::normaliseLink(System::baseUrl() . "/bookmarklet");
|
||||
|
||||
if (!strstr($referer, $page)) {
|
||||
if (empty($_REQUEST["url"])) {
|
||||
System::httpExit(400, ["title" => L10n::t('Bad Request')]);
|
||||
}
|
||||
|
||||
$content = add_page_info($_REQUEST["url"]);
|
||||
|
||||
$x = [
|
||||
'is_owner' => true,
|
||||
'allow_location' => $a->user['allow_location'],
|
||||
'default_location' => $a->user['default-location'],
|
||||
'nickname' => $a->user['nickname'],
|
||||
'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
|
||||
'default_perms' => ACL::getDefaultUserPermissions($a->user),
|
||||
'acl' => ACL::getFullSelectorHTML($a->user, true),
|
||||
'bang' => '',
|
||||
'visitor' => 'block',
|
||||
'profile_uid' => local_user(),
|
||||
'title' => trim(defaults($_REQUEST, 'title', ''), "*"),
|
||||
'content' => $content
|
||||
];
|
||||
$o = status_editor($a, $x, 0, false);
|
||||
$o .= "<script>window.resizeTo(800,550);</script>";
|
||||
} else {
|
||||
$o = '<h2>' . L10n::t('The post was created') . '</h2>';
|
||||
$o .= "<script>window.close()</script>";
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
12
mod/cal.php
12
mod/cal.php
|
@ -31,11 +31,11 @@ function cal_init(App $a)
|
|||
}
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
System::httpExit(403, ['title' => L10n::t('Access denied.')]);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
||||
}
|
||||
|
||||
if ($a->argc < 2) {
|
||||
System::httpExit(403, ['title' => L10n::t('Access denied.')]);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
||||
}
|
||||
|
||||
Nav::setSelected('events');
|
||||
|
@ -43,7 +43,7 @@ function cal_init(App $a)
|
|||
$nick = $a->argv[1];
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
|
||||
if (!DBA::isResult($user)) {
|
||||
System::httpExit(404, ['title' => L10n::t('Page not found.')]);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$a->data['user'] = $user;
|
||||
|
@ -59,7 +59,7 @@ function cal_init(App $a)
|
|||
|
||||
$account_type = Contact::getAccountType($profile);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("vcard-widget.tpl");
|
||||
$tpl = Renderer::getMarkupTemplate("widget/vcard.tpl");
|
||||
|
||||
$vcard_widget = Renderer::replaceMacros($tpl, [
|
||||
'$name' => $profile['name'],
|
||||
|
@ -90,7 +90,6 @@ function cal_content(App $a)
|
|||
|
||||
$htpl = Renderer::getMarkupTemplate('event_head.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$module_url' => '/cal/' . $a->data['user']['nickname'],
|
||||
'$modparams' => 2,
|
||||
'$i18n' => $i18n,
|
||||
|
@ -148,7 +147,7 @@ function cal_content(App $a)
|
|||
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
|
||||
|
||||
// get the tab navigation bar
|
||||
$tabs = Profile::getTabs($a, false, $a->data['user']['nickname']);
|
||||
$tabs = Profile::getTabs($a, 'cal', false, $a->data['user']['nickname']);
|
||||
|
||||
// The view mode part is similiar to /mod/events.php
|
||||
if ($mode == 'view') {
|
||||
|
@ -268,7 +267,6 @@ function cal_content(App $a)
|
|||
}
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$tabs' => $tabs,
|
||||
'$title' => L10n::t('Events'),
|
||||
'$view' => L10n::t('View'),
|
||||
|
|
|
@ -47,7 +47,7 @@ function common_content(App $a)
|
|||
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['self' => true, 'uid' => $uid]);
|
||||
|
||||
if (DBA::isResult($contact)) {
|
||||
$vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate("vcard-widget.tpl"), [
|
||||
$vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate("widget/vcard.tpl"), [
|
||||
'$name' => $contact['name'],
|
||||
'$photo' => $contact['photo'],
|
||||
'url' => 'contact/' . $cid
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/credits.php
|
||||
* Show a credits page for all the developers who helped with the project
|
||||
* (only contributors to the git repositories for friendica core and the
|
||||
* addons repository will be listed though ATM)
|
||||
*/
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
function credits_content()
|
||||
{
|
||||
/* fill the page with credits */
|
||||
$credits_string = file_get_contents('CREDITS.txt');
|
||||
$names = explode("\n", $credits_string);
|
||||
$tpl = Renderer::getMarkupTemplate('credits.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$title' => L10n::t('Credits'),
|
||||
'$thanks' => L10n::t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'),
|
||||
'$names' => $names,
|
||||
]);
|
||||
}
|
|
@ -28,8 +28,6 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\Group;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -136,163 +134,153 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
$site_pubkey = $contact['site-pubkey'];
|
||||
$dfrn_confirm = $contact['confirm'];
|
||||
$aes_allow = $contact['aes_allow'];
|
||||
$protocol = $contact['network'];
|
||||
|
||||
$network = ((strlen($contact['issued-id'])) ? Protocol::DFRN : Protocol::OSTATUS);
|
||||
/*
|
||||
* Generate a key pair for all further communications with this person.
|
||||
* We have a keypair for every contact, and a site key for unknown people.
|
||||
* This provides a means to carry on relationships with other people if
|
||||
* any single key is compromised. It is a robust key. We're much more
|
||||
* worried about key leakage than anybody cracking it.
|
||||
*/
|
||||
$res = Crypto::newKeypair(4096);
|
||||
|
||||
if ($contact['network']) {
|
||||
$network = $contact['network'];
|
||||
$private_key = $res['prvkey'];
|
||||
$public_key = $res['pubkey'];
|
||||
|
||||
// Save the private key. Send them the public key.
|
||||
$fields = ['prvkey' => $private_key, 'protocol' => Protocol::DFRN];
|
||||
DBA::update('contact', $fields, ['id' => $contact_id]);
|
||||
|
||||
$params = [];
|
||||
|
||||
/*
|
||||
* Per the DFRN protocol, we will verify both ends by encrypting the dfrn_id with our
|
||||
* site private key (person on the other end can decrypt it with our site public key).
|
||||
* Then encrypt our profile URL with the other person's site public key. They can decrypt
|
||||
* it with their site private key. If the decryption on the other end fails for either
|
||||
* item, it indicates tampering or key failure on at least one site and we will not be
|
||||
* able to provide a secure communication pathway.
|
||||
*
|
||||
* If other site is willing to accept full encryption, (aes_allow is 1 AND we have php5.3
|
||||
* or later) then we encrypt the personal public key we send them using AES-256-CBC and a
|
||||
* random key which is encrypted with their site public key.
|
||||
*/
|
||||
|
||||
$src_aes_key = openssl_random_pseudo_bytes(64);
|
||||
|
||||
$result = '';
|
||||
openssl_private_encrypt($dfrn_id, $result, $user['prvkey']);
|
||||
|
||||
$params['dfrn_id'] = bin2hex($result);
|
||||
$params['public_key'] = $public_key;
|
||||
|
||||
$my_url = System::baseUrl() . '/profile/' . $user['nickname'];
|
||||
|
||||
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
|
||||
$params['source_url'] = bin2hex($params['source_url']);
|
||||
|
||||
if ($aes_allow && function_exists('openssl_encrypt')) {
|
||||
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
|
||||
$params['aes_key'] = bin2hex($params['aes_key']);
|
||||
$params['public_key'] = bin2hex(openssl_encrypt($public_key, 'AES-256-CBC', $src_aes_key));
|
||||
}
|
||||
|
||||
if ($network === Protocol::DFRN) {
|
||||
/*
|
||||
* Generate a key pair for all further communications with this person.
|
||||
* We have a keypair for every contact, and a site key for unknown people.
|
||||
* This provides a means to carry on relationships with other people if
|
||||
* any single key is compromised. It is a robust key. We're much more
|
||||
* worried about key leakage than anybody cracking it.
|
||||
*/
|
||||
$res = Crypto::newKeypair(4096);
|
||||
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION;
|
||||
if ($duplex == 1) {
|
||||
$params['duplex'] = 1;
|
||||
}
|
||||
|
||||
$private_key = $res['prvkey'];
|
||||
$public_key = $res['pubkey'];
|
||||
if ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
$params['page'] = 1;
|
||||
}
|
||||
|
||||
// Save the private key. Send them the public key.
|
||||
q("UPDATE `contact` SET `prvkey` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
DBA::escape($private_key),
|
||||
intval($contact_id),
|
||||
intval($uid)
|
||||
);
|
||||
if ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
|
||||
$params['page'] = 2;
|
||||
}
|
||||
|
||||
$params = [];
|
||||
Logger::log('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), Logger::DATA);
|
||||
|
||||
/*
|
||||
* Per the DFRN protocol, we will verify both ends by encrypting the dfrn_id with our
|
||||
* site private key (person on the other end can decrypt it with our site public key).
|
||||
* Then encrypt our profile URL with the other person's site public key. They can decrypt
|
||||
* it with their site private key. If the decryption on the other end fails for either
|
||||
* item, it indicates tampering or key failure on at least one site and we will not be
|
||||
* able to provide a secure communication pathway.
|
||||
*
|
||||
* If other site is willing to accept full encryption, (aes_allow is 1 AND we have php5.3
|
||||
* or later) then we encrypt the personal public key we send them using AES-256-CBC and a
|
||||
* random key which is encrypted with their site public key.
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* POST all this stuff to the other site.
|
||||
* Temporarily raise the network timeout to 120 seconds because the default 60
|
||||
* doesn't always give the other side quite enough time to decrypt everything.
|
||||
*
|
||||
*/
|
||||
|
||||
$src_aes_key = openssl_random_pseudo_bytes(64);
|
||||
$res = Network::post($dfrn_confirm, $params, [], 120)->getBody();
|
||||
|
||||
$result = '';
|
||||
openssl_private_encrypt($dfrn_id, $result, $user['prvkey']);
|
||||
Logger::log(' Confirm: received data: ' . $res, Logger::DATA);
|
||||
|
||||
$params['dfrn_id'] = bin2hex($result);
|
||||
$params['public_key'] = $public_key;
|
||||
// Now figure out what they responded. Try to be robust if the remote site is
|
||||
// having difficulty and throwing up errors of some kind.
|
||||
|
||||
$my_url = System::baseUrl() . '/profile/' . $user['nickname'];
|
||||
$leading_junk = substr($res, 0, strpos($res, '<?xml'));
|
||||
|
||||
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
|
||||
$params['source_url'] = bin2hex($params['source_url']);
|
||||
$res = substr($res, strpos($res, '<?xml'));
|
||||
if (!strlen($res)) {
|
||||
// No XML at all, this exchange is messed up really bad.
|
||||
// We shouldn't proceed, because the xml parser might choke,
|
||||
// and $status is going to be zero, which indicates success.
|
||||
// We can hardly call this a success.
|
||||
notice(L10n::t('Response from remote site was not understood.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($aes_allow && function_exists('openssl_encrypt')) {
|
||||
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
|
||||
$params['aes_key'] = bin2hex($params['aes_key']);
|
||||
$params['public_key'] = bin2hex(openssl_encrypt($public_key, 'AES-256-CBC', $src_aes_key));
|
||||
if (strlen($leading_junk) && Config::get('system', 'debugging')) {
|
||||
// This might be more common. Mixed error text and some XML.
|
||||
// If we're configured for debugging, show the text. Proceed in either case.
|
||||
notice(L10n::t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL);
|
||||
}
|
||||
|
||||
if (stristr($res, "<status") === false) {
|
||||
// wrong xml! stop here!
|
||||
Logger::log('Unexpected response posting to ' . $dfrn_confirm);
|
||||
notice(L10n::t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$xml = XML::parseString($res);
|
||||
$status = (int) $xml->status;
|
||||
$message = XML::unescape($xml->message); // human readable text of what may have gone wrong.
|
||||
switch ($status) {
|
||||
case 0:
|
||||
info(L10n::t("Confirmation completed successfully.") . EOL);
|
||||
break;
|
||||
case 1:
|
||||
// birthday paradox - generate new dfrn-id and fall through.
|
||||
$new_dfrn_id = Strings::getRandomHex();
|
||||
q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
DBA::escape($new_dfrn_id),
|
||||
intval($contact_id),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
case 2:
|
||||
notice(L10n::t("Temporary failure. Please wait and try again.") . EOL);
|
||||
break;
|
||||
case 3:
|
||||
notice(L10n::t("Introduction failed or was revoked.") . EOL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($message)) {
|
||||
notice(L10n::t('Remote site reported: ') . $message . EOL);
|
||||
}
|
||||
|
||||
if (($status == 0) && $intro_id) {
|
||||
$intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
|
||||
if (DBA::isResult($intro)) {
|
||||
DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
|
||||
}
|
||||
|
||||
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION;
|
||||
if ($duplex == 1) {
|
||||
$params['duplex'] = 1;
|
||||
}
|
||||
// Success. Delete the notification.
|
||||
DBA::delete('intro', ['id' => $intro_id]);
|
||||
}
|
||||
|
||||
if ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
$params['page'] = 1;
|
||||
}
|
||||
|
||||
if ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
|
||||
$params['page'] = 2;
|
||||
}
|
||||
|
||||
Logger::log('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), Logger::DATA);
|
||||
|
||||
/*
|
||||
*
|
||||
* POST all this stuff to the other site.
|
||||
* Temporarily raise the network timeout to 120 seconds because the default 60
|
||||
* doesn't always give the other side quite enough time to decrypt everything.
|
||||
*
|
||||
*/
|
||||
|
||||
$res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody();
|
||||
|
||||
Logger::log(' Confirm: received data: ' . $res, Logger::DATA);
|
||||
|
||||
// Now figure out what they responded. Try to be robust if the remote site is
|
||||
// having difficulty and throwing up errors of some kind.
|
||||
|
||||
$leading_junk = substr($res, 0, strpos($res, '<?xml'));
|
||||
|
||||
$res = substr($res, strpos($res, '<?xml'));
|
||||
if (!strlen($res)) {
|
||||
// No XML at all, this exchange is messed up really bad.
|
||||
// We shouldn't proceed, because the xml parser might choke,
|
||||
// and $status is going to be zero, which indicates success.
|
||||
// We can hardly call this a success.
|
||||
notice(L10n::t('Response from remote site was not understood.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($leading_junk) && Config::get('system', 'debugging')) {
|
||||
// This might be more common. Mixed error text and some XML.
|
||||
// If we're configured for debugging, show the text. Proceed in either case.
|
||||
notice(L10n::t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL);
|
||||
}
|
||||
|
||||
if (stristr($res, "<status") === false) {
|
||||
// wrong xml! stop here!
|
||||
Logger::log('Unexpected response posting to ' . $dfrn_confirm);
|
||||
notice(L10n::t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$xml = XML::parseString($res);
|
||||
$status = (int) $xml->status;
|
||||
$message = XML::unescape($xml->message); // human readable text of what may have gone wrong.
|
||||
switch ($status) {
|
||||
case 0:
|
||||
info(L10n::t("Confirmation completed successfully.") . EOL);
|
||||
break;
|
||||
case 1:
|
||||
// birthday paradox - generate new dfrn-id and fall through.
|
||||
$new_dfrn_id = Strings::getRandomHex();
|
||||
q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
DBA::escape($new_dfrn_id),
|
||||
intval($contact_id),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
case 2:
|
||||
notice(L10n::t("Temporary failure. Please wait and try again.") . EOL);
|
||||
break;
|
||||
case 3:
|
||||
notice(L10n::t("Introduction failed or was revoked.") . EOL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($message)) {
|
||||
notice(L10n::t('Remote site reported: ') . $message . EOL);
|
||||
}
|
||||
|
||||
if (($status == 0) && $intro_id) {
|
||||
$intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
|
||||
if (DBA::isResult($intro)) {
|
||||
DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
|
||||
}
|
||||
|
||||
// Success. Delete the notification.
|
||||
DBA::delete('intro', ['id' => $intro_id]);
|
||||
}
|
||||
|
||||
if ($status != 0) {
|
||||
return;
|
||||
}
|
||||
if ($status != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -306,101 +294,39 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
|
||||
Logger::log('dfrn_confirm: confirm - imported photos');
|
||||
|
||||
if ($network === Protocol::DFRN) {
|
||||
$new_relation = Contact::FOLLOWER;
|
||||
$new_relation = Contact::FOLLOWER;
|
||||
|
||||
if (($relation == Contact::SHARING) || ($duplex)) {
|
||||
$new_relation = Contact::FRIEND;
|
||||
}
|
||||
|
||||
if (($relation == Contact::SHARING) && ($duplex)) {
|
||||
$duplex = 0;
|
||||
}
|
||||
|
||||
$r = q("UPDATE `contact` SET `rel` = %d,
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`blocked` = 0,
|
||||
`pending` = 0,
|
||||
`duplex` = %d,
|
||||
`hidden` = %d,
|
||||
`network` = '%s' WHERE `id` = %d
|
||||
",
|
||||
intval($new_relation),
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
intval($duplex),
|
||||
intval($hidden),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
intval($contact_id)
|
||||
);
|
||||
} else {
|
||||
if ($network == Protocol::ACTIVITYPUB) {
|
||||
ActivityPub\Transmitter::sendContactAccept($contact['url'], $contact['hub-verify'], $uid);
|
||||
// Setting "pending" to true on a bidirectional contact request could create a problem when it isn't accepted on the other side
|
||||
// Then we have got a situation where - although one direction is accepted - the contact still appears as pending.
|
||||
// Possibly we need two different "pending" fields, one for incoming, one for outgoing?
|
||||
// This has to be thought over, but for now this here is a better solution.
|
||||
// $pending = $duplex;
|
||||
$pending = false;
|
||||
} else {
|
||||
$pending = false;
|
||||
}
|
||||
|
||||
// $network !== Protocol::DFRN
|
||||
$network = defaults($contact, 'network', Protocol::OSTATUS);
|
||||
|
||||
$arr = Probe::uri($contact['url'], $network);
|
||||
|
||||
$notify = defaults($contact, 'notify' , $arr['notify']);
|
||||
$poll = defaults($contact, 'poll' , $arr['poll']);
|
||||
|
||||
$addr = $arr['addr'];
|
||||
|
||||
$new_relation = $contact['rel'];
|
||||
$writable = $contact['writable'];
|
||||
|
||||
if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
|
||||
if ($duplex) {
|
||||
$new_relation = Contact::FRIEND;
|
||||
} else {
|
||||
$new_relation = Contact::FOLLOWER;
|
||||
}
|
||||
|
||||
if ($new_relation != Contact::FOLLOWER) {
|
||||
$writable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
DBA::delete('intro', ['id' => $intro_id]);
|
||||
|
||||
$fields = ['name-date' => DateTimeFormat::utcNow(),
|
||||
'uri-date' => DateTimeFormat::utcNow(), 'addr' => $addr,
|
||||
'notify' => $notify, 'poll' => $poll, 'blocked' => false,
|
||||
'pending' => $pending, 'network' => $network,
|
||||
'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation];
|
||||
DBA::update('contact', $fields, ['id' => $contact_id]);
|
||||
if (($relation == Contact::SHARING) || ($duplex)) {
|
||||
$new_relation = Contact::FRIEND;
|
||||
}
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
notice(L10n::t('Unable to set contact photo.') . EOL);
|
||||
if (($relation == Contact::SHARING) && ($duplex)) {
|
||||
$duplex = 0;
|
||||
}
|
||||
|
||||
$r = q("UPDATE `contact` SET `rel` = %d,
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`blocked` = 0,
|
||||
`pending` = 0,
|
||||
`duplex` = %d,
|
||||
`hidden` = %d,
|
||||
`network` = '%s' WHERE `id` = %d
|
||||
",
|
||||
intval($new_relation),
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
DBA::escape(DateTimeFormat::utcNow()),
|
||||
intval($duplex),
|
||||
intval($hidden),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
intval($contact_id)
|
||||
);
|
||||
|
||||
// reload contact info
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
|
||||
if (DBA::isResult($contact) && ($contact['network'] === Protocol::DIASPORA)) {
|
||||
$ret = Diaspora::sendShare($user, $contact);
|
||||
Logger::log('share returns: ' . $ret);
|
||||
}
|
||||
}
|
||||
|
||||
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
|
||||
|
||||
if ($network == Protocol::ACTIVITYPUB && $duplex) {
|
||||
ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
|
||||
}
|
||||
|
||||
// Let's send our user to the contact editor in case they want to
|
||||
// do anything special with this new friend.
|
||||
if ($handsfree === null) {
|
||||
|
|
|
@ -29,7 +29,7 @@ function dfrn_notify_post(App $a) {
|
|||
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
|
||||
if (!DBA::isResult($user)) {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
dfrn_dispatch_private($user, $postdata);
|
||||
} elseif (!dfrn_dispatch_public($postdata)) {
|
||||
|
@ -190,13 +190,13 @@ function dfrn_dispatch_public($postdata)
|
|||
}
|
||||
|
||||
// Fetch the corresponding public contact
|
||||
$contact = Contact::getDetailsByAddr($msg['author'], 0);
|
||||
if (!$contact) {
|
||||
$contact_id = Contact::getIdForURL($msg['author']);
|
||||
if (empty($contact_id)) {
|
||||
Logger::log('Contact not found for address ' . $msg['author']);
|
||||
System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found');
|
||||
}
|
||||
|
||||
$importer = DFRN::getImporter($contact['id']);
|
||||
$importer = DFRN::getImporter($contact_id);
|
||||
|
||||
// This should never fail
|
||||
if (empty($importer)) {
|
||||
|
|
|
@ -50,7 +50,7 @@ function dfrn_poll_init(App $a)
|
|||
|
||||
if (($dfrn_id === '') && empty($_POST['dfrn_id'])) {
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
System::httpExit(403);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
$user = '';
|
||||
|
@ -59,7 +59,7 @@ function dfrn_poll_init(App $a)
|
|||
DBA::escape($a->argv[1])
|
||||
);
|
||||
if (!$r) {
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$hidewall = ($r[0]['hidewall'] && !local_user());
|
||||
|
@ -483,7 +483,7 @@ function dfrn_poll_content(App $a)
|
|||
// heluecht: I don't know why we don't fail immediately when the user or contact hadn't been found.
|
||||
// Since it doesn't make sense to continue from this point on, we now fail here. This should be safe.
|
||||
if (!DBA::isResult($r)) {
|
||||
System::httpExit(404, ["title" => L10n::t('Page not found.')]);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// URL reply
|
||||
|
|
|
@ -476,7 +476,7 @@ function dfrn_request_post(App $a)
|
|||
|
||||
function dfrn_request_content(App $a)
|
||||
{
|
||||
if (($a->argc != 2) || (!count($a->profile))) {
|
||||
if ($a->argc != 2 || empty($a->profile)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,230 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/directory.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function directory_init(App $a)
|
||||
{
|
||||
if (local_user()) {
|
||||
$a->page['aside'] .= Widget::findPeople();
|
||||
$a->page['aside'] .= Widget::follow();
|
||||
} else {
|
||||
unset($_SESSION['theme']);
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
}
|
||||
|
||||
function directory_post(App $a)
|
||||
{
|
||||
if (!empty($_POST['search'])) {
|
||||
$a->data['search'] = $_POST['search'];
|
||||
}
|
||||
}
|
||||
|
||||
function directory_content(App $a)
|
||||
{
|
||||
if ((Config::get('system', 'block_public') && !local_user() && !remote_user())
|
||||
|| (Config::get('system', 'block_local_dir') && !local_user() && !remote_user())
|
||||
) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$o = '';
|
||||
$entries = [];
|
||||
|
||||
Nav::setSelected('directory');
|
||||
|
||||
if (!empty($a->data['search'])) {
|
||||
$search = Strings::escapeTags(trim($a->data['search']));
|
||||
} else {
|
||||
$search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
|
||||
}
|
||||
|
||||
$gdirpath = '';
|
||||
$dirurl = Config::get('system', 'directory');
|
||||
if (strlen($dirurl)) {
|
||||
$gdirpath = Profile::zrl($dirurl, true);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$search = DBA::escape($search);
|
||||
|
||||
$sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
|
||||
(`user`.`nickname` LIKE '%$search%') OR
|
||||
(`profile`.`pdesc` LIKE '%$search%') OR
|
||||
(`profile`.`locality` LIKE '%$search%') OR
|
||||
(`profile`.`region` LIKE '%$search%') OR
|
||||
(`profile`.`country-name` LIKE '%$search%') OR
|
||||
(`profile`.`gender` LIKE '%$search%') OR
|
||||
(`profile`.`marital` LIKE '%$search%') OR
|
||||
(`profile`.`sexual` LIKE '%$search%') OR
|
||||
(`profile`.`about` LIKE '%$search%') OR
|
||||
(`profile`.`romance` LIKE '%$search%') OR
|
||||
(`profile`.`work` LIKE '%$search%') OR
|
||||
(`profile`.`education` LIKE '%$search%') OR
|
||||
(`profile`.`pub_keywords` LIKE '%$search%') OR
|
||||
(`profile`.`prv_keywords` LIKE '%$search%'))";
|
||||
} else {
|
||||
$sql_extra = '';
|
||||
}
|
||||
|
||||
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
|
||||
|
||||
|
||||
$total = 0;
|
||||
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` FROM `profile`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
|
||||
if (DBA::isResult($cnt)) {
|
||||
$total = $cnt['total'];
|
||||
}
|
||||
$pager = new Pager($a->query_string, 60);
|
||||
|
||||
$order = " ORDER BY `name` ASC ";
|
||||
|
||||
$limit = $pager->getStart()."," . $pager->getItemsPerPage();
|
||||
|
||||
$r = DBA::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
|
||||
`contact`.`addr`, `contact`.`url` AS `profile_url` FROM `profile`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
|
||||
$sql_extra $order LIMIT $limit"
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
if (in_array('small', $a->argv)) {
|
||||
$photo = 'thumb';
|
||||
} else {
|
||||
$photo = 'photo';
|
||||
}
|
||||
|
||||
while ($rr = DBA::fetch($r)) {
|
||||
$entries[] = format_directory_entry($rr, $photo);
|
||||
}
|
||||
DBA::close($r);
|
||||
} else {
|
||||
info(L10n::t("No entries \x28some entries may be hidden\x29.") . EOL);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('directory_header.tpl');
|
||||
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$search' => $search,
|
||||
'$globaldir' => L10n::t('Global Directory'),
|
||||
'$gdirpath' => $gdirpath,
|
||||
'$desc' => L10n::t('Find on this site'),
|
||||
'$contacts' => $entries,
|
||||
'$finding' => L10n::t('Results for:'),
|
||||
'$findterm' => (strlen($search) ? $search : ""),
|
||||
'$title' => L10n::t('Site Directory'),
|
||||
'$search_mod' => 'directory',
|
||||
'$submit' => L10n::t('Find'),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format contact/profile/user data from the database into an usable
|
||||
* array for displaying directory entries.
|
||||
*
|
||||
* @param array $arr The directory entry from the database.
|
||||
* @param string $photo_size Avatar size (thumb, photo or micro).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function format_directory_entry(array $arr, $photo_size = 'photo')
|
||||
{
|
||||
$itemurl = (($arr['addr'] != "") ? $arr['addr'] : $arr['profile_url']);
|
||||
|
||||
$profile_link = $arr['profile_url'];
|
||||
|
||||
$pdesc = (($arr['pdesc']) ? $arr['pdesc'] . '<br />' : '');
|
||||
|
||||
$details = '';
|
||||
if (strlen($arr['locality'])) {
|
||||
$details .= $arr['locality'];
|
||||
}
|
||||
if (strlen($arr['region'])) {
|
||||
if (strlen($arr['locality'])) {
|
||||
$details .= ', ';
|
||||
}
|
||||
$details .= $arr['region'];
|
||||
}
|
||||
if (strlen($arr['country-name'])) {
|
||||
if (strlen($details)) {
|
||||
$details .= ', ';
|
||||
}
|
||||
$details .= $arr['country-name'];
|
||||
}
|
||||
|
||||
$profile = $arr;
|
||||
|
||||
if (!empty($profile['address'])
|
||||
|| !empty($profile['locality'])
|
||||
|| !empty($profile['region'])
|
||||
|| !empty($profile['postal-code'])
|
||||
|| !empty($profile['country-name'])
|
||||
) {
|
||||
$location = L10n::t('Location:');
|
||||
} else {
|
||||
$location = '';
|
||||
}
|
||||
|
||||
$gender = (!empty($profile['gender']) ? L10n::t('Gender:') : false);
|
||||
$marital = (!empty($profile['marital']) ? L10n::t('Status:') : false);
|
||||
$homepage = (!empty($profile['homepage']) ? L10n::t('Homepage:') : false);
|
||||
$about = (!empty($profile['about']) ? L10n::t('About:') : false);
|
||||
|
||||
$location_e = $location;
|
||||
|
||||
$photo_menu = [
|
||||
'profile' => [L10n::t("View Profile"), Contact::magicLink($profile_link)]
|
||||
];
|
||||
|
||||
$entry = [
|
||||
'id' => $arr['id'],
|
||||
'url' => Contact::magicLInk($profile_link),
|
||||
'itemurl' => $itemurl,
|
||||
'thumb' => ProxyUtils::proxifyUrl($arr[$photo_size], false, ProxyUtils::SIZE_THUMB),
|
||||
'img_hover' => $arr['name'],
|
||||
'name' => $arr['name'],
|
||||
'details' => $details,
|
||||
'account_type' => Contact::getAccountType($arr),
|
||||
'profile' => $profile,
|
||||
'location' => $location_e,
|
||||
'tags' => $arr['pub_keywords'],
|
||||
'gender' => $gender,
|
||||
'pdesc' => $pdesc,
|
||||
'marital' => $marital,
|
||||
'homepage' => $homepage,
|
||||
'about' => $about,
|
||||
'photo_menu' => $photo_menu,
|
||||
|
||||
];
|
||||
|
||||
$hook = ['contact' => $arr, 'entry' => $entry];
|
||||
|
||||
Hook::callAll('directory_item', $hook);
|
||||
|
||||
unset($profile);
|
||||
unset($location);
|
||||
|
||||
return $hook['entry'];
|
||||
}
|
265
mod/dirfind.php
265
mod/dirfind.php
|
@ -1,265 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/dirfind.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
||||
function dirfind_init(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL );
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($a->page['aside'])) {
|
||||
$a->page['aside'] = '';
|
||||
}
|
||||
|
||||
$a->page['aside'] .= Widget::findPeople();
|
||||
|
||||
$a->page['aside'] .= Widget::follow();
|
||||
}
|
||||
|
||||
function dirfind_content(App $a, $prefix = "") {
|
||||
|
||||
$community = false;
|
||||
$discover_user = false;
|
||||
|
||||
$local = Config::get('system','poco_local_search');
|
||||
|
||||
$search = $prefix.Strings::escapeTags(trim(defaults($_REQUEST, 'search', '')));
|
||||
|
||||
$header = '';
|
||||
|
||||
if (strpos($search,'@') === 0) {
|
||||
$search = substr($search,1);
|
||||
$header = L10n::t('People Search - %s', $search);
|
||||
if ((filter_var($search, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($search)) ||
|
||||
(substr(Strings::normaliseLink($search), 0, 7) == "http://")) {
|
||||
$user_data = Probe::uri($search);
|
||||
$discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($search,'!') === 0) {
|
||||
$search = substr($search,1);
|
||||
$community = true;
|
||||
$header = L10n::t('Forum Search - %s', $search);
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($search) {
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
if ($discover_user) {
|
||||
$j = new stdClass();
|
||||
$j->total = 1;
|
||||
$j->items_page = 1;
|
||||
$j->page = $pager->getPage();
|
||||
|
||||
$objresult = new stdClass();
|
||||
$objresult->cid = 0;
|
||||
$objresult->name = $user_data["name"];
|
||||
$objresult->addr = $user_data["addr"];
|
||||
$objresult->url = $user_data["url"];
|
||||
$objresult->photo = $user_data["photo"];
|
||||
$objresult->tags = "";
|
||||
$objresult->network = $user_data["network"];
|
||||
|
||||
$contact = Model\Contact::getDetailsByURL($user_data["url"], local_user());
|
||||
$objresult->cid = $contact["cid"];
|
||||
$objresult->pcid = $contact["zid"];
|
||||
|
||||
$j->results[] = $objresult;
|
||||
|
||||
// Add the contact to the global contacts if it isn't already in our system
|
||||
if (($contact["cid"] == 0) && ($contact["zid"] == 0) && ($contact["gid"] == 0)) {
|
||||
Model\GContact::update($user_data);
|
||||
}
|
||||
} elseif ($local) {
|
||||
if ($community) {
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$pager->setItemsPerPage(80);
|
||||
|
||||
if (Config::get('system','diaspora_enabled')) {
|
||||
$diaspora = Protocol::DIASPORA;
|
||||
} else {
|
||||
$diaspora = Protocol::DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system','ostatus_disabled')) {
|
||||
$ostatus = Protocol::OSTATUS;
|
||||
} else {
|
||||
$ostatus = Protocol::DFRN;
|
||||
}
|
||||
|
||||
$search2 = "%".$search."%";
|
||||
|
||||
/// @TODO These 2 SELECTs are not checked on validity with DBA::isResult()
|
||||
$count = q("SELECT count(*) AS `total` FROM `gcontact`
|
||||
WHERE NOT `hide` AND `network` IN ('%s', '%s', '%s', '%s') AND
|
||||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`url` LIKE '%s' OR `name` LIKE '%s' OR `location` LIKE '%s' OR
|
||||
`addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql",
|
||||
DBA::escape(Protocol::ACTIVITYPUB), DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
|
||||
DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)),
|
||||
DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)));
|
||||
|
||||
$results = q("SELECT `nurl`
|
||||
FROM `gcontact`
|
||||
WHERE NOT `hide` AND `network` IN ('%s', '%s', '%s', '%s') AND
|
||||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`url` LIKE '%s' OR `name` LIKE '%s' OR `location` LIKE '%s' OR
|
||||
`addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql
|
||||
GROUP BY `nurl`
|
||||
ORDER BY `updated` DESC LIMIT %d, %d",
|
||||
DBA::escape(Protocol::ACTIVITYPUB), DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
|
||||
DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)),
|
||||
DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)), DBA::escape(Strings::escapeHtml($search2)),
|
||||
$pager->getStart(), $pager->getItemsPerPage());
|
||||
$j = new stdClass();
|
||||
$j->total = $count[0]["total"];
|
||||
$j->items_page = $pager->getItemsPerPage();
|
||||
$j->page = $pager->getPage();
|
||||
foreach ($results AS $result) {
|
||||
if (PortableContact::alternateOStatusUrl($result["nurl"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$urlparts = parse_url($result["nurl"]);
|
||||
|
||||
// Ignore results that look strange.
|
||||
// For historic reasons the gcontact table does contain some garbage.
|
||||
if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = Model\Contact::getDetailsByURL($result["nurl"], local_user());
|
||||
|
||||
if ($result["name"] == "") {
|
||||
$result["name"] = end(explode("/", $urlparts["path"]));
|
||||
}
|
||||
|
||||
$objresult = new stdClass();
|
||||
$objresult->cid = $result["cid"];
|
||||
$objresult->pcid = $result["zid"];
|
||||
$objresult->name = $result["name"];
|
||||
$objresult->addr = $result["addr"];
|
||||
$objresult->url = $result["url"];
|
||||
$objresult->photo = $result["photo"];
|
||||
$objresult->tags = $result["keywords"];
|
||||
$objresult->network = $result["network"];
|
||||
|
||||
$j->results[] = $objresult;
|
||||
}
|
||||
|
||||
// Add found profiles from the global directory to the local directory
|
||||
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', "dirsearch", urlencode($search));
|
||||
} elseif (strlen(Config::get('system','directory'))) {
|
||||
$p = (($pager->getPage() != 1) ? '&p=' . $pager->getPage() : '');
|
||||
|
||||
$x = Network::fetchUrl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||
|
||||
$j = json_decode($x);
|
||||
$pager->setItemsPerPage($j->items_page);
|
||||
}
|
||||
|
||||
if (!empty($j->results)) {
|
||||
$id = 0;
|
||||
|
||||
$entries = [];
|
||||
foreach ($j->results as $jj) {
|
||||
|
||||
$alt_text = "";
|
||||
|
||||
$contact_details = Model\Contact::getDetailsByURL($jj->url, local_user());
|
||||
|
||||
$itemurl = (($contact_details["addr"] != "") ? $contact_details["addr"] : $jj->url);
|
||||
|
||||
// If We already know this contact then don't show the "connect" button
|
||||
if ($jj->cid > 0) {
|
||||
$connlnk = "";
|
||||
$conntxt = "";
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]);
|
||||
if (DBA::isResult($contact)) {
|
||||
$photo_menu = Model\Contact::photoMenu($contact);
|
||||
$details = Module\Contact::getContactTemplateVars($contact);
|
||||
$alt_text = $details['alt_text'];
|
||||
} else {
|
||||
$photo_menu = [];
|
||||
}
|
||||
} else {
|
||||
$connlnk = System::baseUrl().'/follow/?url='.(!empty($jj->connect) ? $jj->connect : $jj->url);
|
||||
$conntxt = L10n::t('Connect');
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $jj->pcid]);
|
||||
if (DBA::isResult($contact)) {
|
||||
$photo_menu = Model\Contact::photoMenu($contact);
|
||||
} else {
|
||||
$photo_menu = [];
|
||||
}
|
||||
|
||||
$photo_menu['profile'] = [L10n::t("View Profile"), Model\Contact::magicLink($jj->url)];
|
||||
$photo_menu['follow'] = [L10n::t("Connect/Follow"), $connlnk];
|
||||
}
|
||||
|
||||
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
|
||||
|
||||
$entry = [
|
||||
'alt_text' => $alt_text,
|
||||
'url' => Model\Contact::magicLink($jj->url),
|
||||
'itemurl' => $itemurl,
|
||||
'name' => $jj->name,
|
||||
'thumb' => ProxyUtils::proxifyUrl($jj->photo, false, ProxyUtils::SIZE_THUMB),
|
||||
'img_hover' => $jj->tags,
|
||||
'conntxt' => $conntxt,
|
||||
'connlnk' => $connlnk,
|
||||
'photo_menu' => $photo_menu,
|
||||
'details' => $contact_details['location'],
|
||||
'tags' => $contact_details['keywords'],
|
||||
'about' => $contact_details['about'],
|
||||
'account_type' => Model\Contact::getAccountType($contact_details),
|
||||
'network' => ContactSelector::networkToName($jj->network, $jj->url),
|
||||
'id' => ++$id,
|
||||
];
|
||||
$entries[] = $entry;
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl,[
|
||||
'title' => $header,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull($j->total),
|
||||
]);
|
||||
} else {
|
||||
info(L10n::t('No matches') . EOL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -20,6 +20,7 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Module\Objects;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -76,7 +77,11 @@ function display_init(App $a)
|
|||
}
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
System::httpExit(404);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($a->argc >= 3 && $nick == 'feed-item') {
|
||||
displayShowFeed($item['id'], $a->argc > 3 && $a->argv[3] == 'conversation.atom');
|
||||
}
|
||||
|
||||
if ($a->argc >= 3 && $nick == 'feed-item') {
|
||||
|
@ -185,23 +190,13 @@ function display_fetchauthor($a, $item)
|
|||
|
||||
$profiledata["photo"] = System::removedBaseUrl($profiledata["photo"]);
|
||||
|
||||
if (local_user()) {
|
||||
if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
$profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
|
||||
}
|
||||
} elseif ($profiledata["network"] == Protocol::DFRN) {
|
||||
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
|
||||
$profiledata["remoteconnect"] = $connect;
|
||||
}
|
||||
|
||||
return($profiledata);
|
||||
return $profiledata;
|
||||
}
|
||||
|
||||
function display_content(App $a, $update = false, $update_uid = 0)
|
||||
{
|
||||
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
throw new HTTPException\ForbiddenException(L10n::t('Public access denied.'));
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
@ -254,7 +249,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
}
|
||||
|
||||
if (!$item_id) {
|
||||
System::httpExit(404);
|
||||
throw new HTTPException\NotFoundException(L10n::t('The requested item doesn\'t exist or has been deleted.'));
|
||||
}
|
||||
|
||||
// We are displaying an "alternate" link if that post was public. See issue 2864
|
||||
|
@ -303,8 +298,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$is_owner = (local_user() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? true : false);
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$is_remote_contact) {
|
||||
notice(L10n::t('Access to this profile has been restricted.') . EOL);
|
||||
return;
|
||||
throw new HTTPException\ForbiddenException(L10n::t('Access to this profile has been restricted.'));
|
||||
}
|
||||
|
||||
// We need the editor here to be able to reshare an item.
|
||||
|
@ -340,7 +334,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
System::httpExit(404);
|
||||
throw new HTTPException\NotFoundException(L10n::t('The requested item doesn\'t exist or has been deleted.'));
|
||||
}
|
||||
|
||||
$item['uri'] = $item['parent-uri'];
|
||||
|
@ -415,7 +409,7 @@ function displayShowFeed($item_id, $conversation)
|
|||
{
|
||||
$xml = DFRN::itemFeed($item_id, $conversation);
|
||||
if ($xml == '') {
|
||||
System::httpExit(500);
|
||||
throw new HTTPException\InternalServerErrorException(L10n::t('The feed for this item is unavailable.'));
|
||||
}
|
||||
header("Content-type: application/atom+xml");
|
||||
echo $xml;
|
||||
|
|
|
@ -8,7 +8,6 @@ use Friendica\Content\Feature;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -48,7 +47,6 @@ function editpost_content(App $a)
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('jot-header.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$ispublic' => ' ', // L10n::t('Visible to <strong>everybody</strong>'),
|
||||
'$geotag' => $geotag,
|
||||
'$nickname' => $a->user['nickname']
|
||||
|
@ -91,7 +89,6 @@ function editpost_content(App $a)
|
|||
'$posttype' => $item['post-type'],
|
||||
'$content' => undo_post_tagging($item['body']),
|
||||
'$post_id' => $post_id,
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$defloc' => $a->user['default-location'],
|
||||
'$visitor' => 'none',
|
||||
'$pvisit' => 'none',
|
||||
|
|
|
@ -21,6 +21,7 @@ use Friendica\Module\Login;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
function events_init(App $a)
|
||||
{
|
||||
|
@ -195,7 +196,7 @@ function events_post(App $a)
|
|||
$item_id = Event::store($datarray);
|
||||
|
||||
if (!$cid) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
|
||||
}
|
||||
|
||||
$a->internalRedirect('events');
|
||||
|
@ -237,7 +238,6 @@ function events_content(App $a)
|
|||
|
||||
$htpl = Renderer::getMarkupTemplate('event_head.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$module_url' => '/events',
|
||||
'$modparams' => 1,
|
||||
'$i18n' => $i18n,
|
||||
|
@ -247,7 +247,7 @@ function events_content(App $a)
|
|||
$tabs = '';
|
||||
// tabs
|
||||
if ($a->theme_events_in_profile) {
|
||||
$tabs = Profile::getTabs($a, true);
|
||||
$tabs = Profile::getTabs($a, 'events', true);
|
||||
}
|
||||
|
||||
$mode = 'view';
|
||||
|
@ -379,7 +379,6 @@ function events_content(App $a)
|
|||
}
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$tabs' => $tabs,
|
||||
'$title' => L10n::t('Events'),
|
||||
'$view' => L10n::t('View'),
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* @param App $a
|
||||
|
@ -27,6 +28,12 @@ function fbrowser_content(App $a)
|
|||
exit();
|
||||
}
|
||||
|
||||
// Needed to match the correct template in a module that uses a different theme than the user/site/default
|
||||
$theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null));
|
||||
if ($theme && is_file("view/theme/$theme/config.php")) {
|
||||
$a->setCurrentTheme($theme);
|
||||
}
|
||||
|
||||
$template_file = "filebrowser.tpl";
|
||||
|
||||
$o = '';
|
||||
|
@ -97,7 +104,6 @@ function fbrowser_content(App $a)
|
|||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$type' => 'image',
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$path' => $path,
|
||||
'$folders' => $albums,
|
||||
'$files' => $files,
|
||||
|
@ -127,7 +133,6 @@ function fbrowser_content(App $a)
|
|||
$tpl = Renderer::getMarkupTemplate($template_file);
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$type' => 'file',
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$path' => [ [ "", L10n::t("Files")] ],
|
||||
'$folders' => false,
|
||||
'$files' => $files,
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file_tag_list_to_file mod/feedtest.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Protocol\Feed;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
function feedtest_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
info(L10n::t('You must be logged in to use this module'));
|
||||
return;
|
||||
};
|
||||
|
||||
$result = [];
|
||||
if (!empty($_REQUEST['url'])) {
|
||||
$url = $_REQUEST['url'];
|
||||
|
||||
$importer = DBA::selectFirst('user', [], ['uid' => local_user()]);
|
||||
|
||||
$contact_id = Contact::getIdForURL($url, local_user(), true);
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
|
||||
$xml = Network::fetchUrl($contact['poll']);
|
||||
|
||||
$dummy = null;
|
||||
$import_result = Feed::import($xml, $importer, $contact, $dummy, true);
|
||||
|
||||
$result = [
|
||||
'input' => $xml,
|
||||
'output' => var_export($import_result, true),
|
||||
];
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('feedtest.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
|
||||
'$result' => $result
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
This file is part of the Diaspora protocol. It is used for fetching single public posts.
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
function fetch_init(App $a)
|
||||
{
|
||||
|
||||
if (($a->argc != 3) || (!in_array($a->argv[1], ["post", "status_message", "reshare"]))) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$guid = $a->argv[2];
|
||||
|
||||
// Fetch the item
|
||||
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network',
|
||||
'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'attach'];
|
||||
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
if (!DBA::isResult($item)) {
|
||||
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$item = Item::selectFirst(['author-link'], $condition);
|
||||
if (DBA::isResult($item)) {
|
||||
$parts = parse_url($item["author-link"]);
|
||||
$host = $parts["scheme"]."://".$parts["host"];
|
||||
|
||||
if (Strings::normaliseLink($host) != Strings::normaliseLink(System::baseUrl())) {
|
||||
$location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
|
||||
|
||||
header("HTTP/1.1 301 Moved Permanently");
|
||||
header("Location:".$location);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
// Fetch some data from the author (We could combine both queries - but I think this is more readable)
|
||||
$user = User::getOwnerDataById($item["uid"]);
|
||||
if (!$user) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$status = Diaspora::buildStatus($item, $user);
|
||||
$xml = Diaspora::buildPostXml($status["type"], $status["message"]);
|
||||
|
||||
// Send the envelope
|
||||
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
|
||||
echo Diaspora::buildMagicEnvelope($xml, $user);
|
||||
|
||||
exit();
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/filer.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function filer_content(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||
|
||||
Logger::log('filer: tag ' . $term . ' item ' . $item_id);
|
||||
|
||||
if ($item_id && strlen($term)) {
|
||||
// file item
|
||||
FileTag::saveFile(local_user(), $item_id, $term);
|
||||
} else {
|
||||
// return filer dialog
|
||||
$filetags = PConfig::get(local_user(), 'system', 'filetags');
|
||||
$filetags = FileTag::fileToList($filetags, 'file');
|
||||
$filetags = explode(",", $filetags);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
|
||||
'$submit' => L10n::t('Save'),
|
||||
]);
|
||||
|
||||
echo $o;
|
||||
}
|
||||
exit();
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function filerm_content(App $a)
|
||||
{
|
||||
if (! local_user())
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
||||
$cat = XML::unescape(trim(defaults($_GET, 'cat', '')));
|
||||
|
||||
$category = (($cat) ? true : false);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
$term = $cat;
|
||||
}
|
||||
|
||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||
|
||||
Logger::log('filerm: tag ' . $term . ' item ' . $item_id . ' category ' . ($category ? 'true' : 'false'));
|
||||
|
||||
if ($item_id && strlen($term)) {
|
||||
if (FileTag::unsaveFile(local_user(), $item_id, $term, $category)) {
|
||||
info('Item removed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
info('Item was not deleted');
|
||||
}
|
||||
|
||||
$a->internalRedirect('/network?f=&file=' . rawurlencode($term));
|
||||
exit();
|
||||
}
|
|
@ -17,7 +17,7 @@ use Friendica\Util\Strings;
|
|||
function follow_post(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
System::httpExit(403, ['title' => L10n::t('Access denied.')]);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['cancel'])) {
|
||||
|
@ -91,32 +91,34 @@ function follow_content(App $a)
|
|||
|
||||
$ret = Probe::uri($url);
|
||||
|
||||
if (($ret['network'] == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
|
||||
$protocol = Contact::getProtocol($ret['url'], $ret['network']);
|
||||
|
||||
if (($protocol == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
|
||||
notice(L10n::t("Diaspora support isn't enabled. Contact can't be added."));
|
||||
$submit = '';
|
||||
//$a->internalRedirect($_SESSION['return_path']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if (($ret['network'] == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
|
||||
if (($protocol == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
|
||||
notice(L10n::t("OStatus support is disabled. Contact can't be added."));
|
||||
$submit = '';
|
||||
//$a->internalRedirect($_SESSION['return_path']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($ret['network'] == Protocol::PHANTOM) {
|
||||
if ($protocol == Protocol::PHANTOM) {
|
||||
notice(L10n::t("The network type couldn't be detected. Contact can't be added."));
|
||||
$submit = '';
|
||||
//$a->internalRedirect($_SESSION['return_path']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($ret['network'] == Protocol::MAIL) {
|
||||
if ($protocol == Protocol::MAIL) {
|
||||
$ret['url'] = $ret['addr'];
|
||||
}
|
||||
|
||||
if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($r)) {
|
||||
if (($protocol === Protocol::DFRN) && !DBA::isResult($r)) {
|
||||
$request = $ret['request'];
|
||||
$tpl = Renderer::getMarkupTemplate('dfrn_request.tpl');
|
||||
} else {
|
||||
|
@ -147,7 +149,7 @@ function follow_content(App $a)
|
|||
$gcontact_id = $r[0]['id'];
|
||||
}
|
||||
|
||||
if ($ret['network'] === Protocol::DIASPORA) {
|
||||
if ($protocol === Protocol::DIASPORA) {
|
||||
$r[0]['location'] = '';
|
||||
$r[0]['about'] = '';
|
||||
}
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/friendica.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\Register;
|
||||
|
||||
function friendica_init(App $a)
|
||||
{
|
||||
if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
|
||||
$register_policies = [
|
||||
Register::CLOSED => 'REGISTER_CLOSED',
|
||||
Register::APPROVE => 'REGISTER_APPROVE',
|
||||
Register::OPEN => 'REGISTER_OPEN'
|
||||
];
|
||||
|
||||
$register_policy_int = intval(Config::get('config', 'register_policy'));
|
||||
if ($register_policy_int !== Register::CLOSED && Config::get('config', 'invitation_only')) {
|
||||
$register_policy = 'REGISTER_INVITATION';
|
||||
} else {
|
||||
$register_policy = $register_policies[$register_policy_int];
|
||||
}
|
||||
|
||||
$condition = [];
|
||||
$admin = false;
|
||||
if (!empty(Config::get('config', 'admin_nickname'))) {
|
||||
$condition['nickname'] = Config::get('config', 'admin_nickname');
|
||||
}
|
||||
if (!empty(Config::get('config', 'admin_email'))) {
|
||||
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
|
||||
$condition['email'] = $adminlist[0];
|
||||
$administrator = DBA::selectFirst('user', ['username', 'nickname'], $condition);
|
||||
if (DBA::isResult($administrator)) {
|
||||
$admin = [
|
||||
'name' => $administrator['username'],
|
||||
'profile'=> System::baseUrl() . '/profile/' . $administrator['nickname'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$visible_addons = Addon::getVisibleList();
|
||||
|
||||
Config::load('feature_lock');
|
||||
$locked_features = [];
|
||||
$featureLock = Config::get('config', 'feature_lock');
|
||||
if (isset($featureLock)) {
|
||||
foreach ($featureLock as $k => $v) {
|
||||
if ($k === 'config_loaded') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$locked_features[$k] = intval($v);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'version' => FRIENDICA_VERSION,
|
||||
'url' => System::baseUrl(),
|
||||
'addons' => $visible_addons,
|
||||
'locked_features' => $locked_features,
|
||||
'explicit_content' => (int)Config::get('system', 'explicit_content', false),
|
||||
'language' => Config::get('system','language'),
|
||||
'register_policy' => $register_policy,
|
||||
'admin' => $admin,
|
||||
'site_name' => Config::get('config', 'sitename'),
|
||||
'platform' => FRIENDICA_PLATFORM,
|
||||
'info' => Config::get('config', 'info'),
|
||||
'no_scrape_url' => System::baseUrl().'/noscrape'
|
||||
];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($data);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function friendica_content(App $a)
|
||||
{
|
||||
$o = '<h1>Friendica</h1>' . PHP_EOL;
|
||||
$o .= '<p>';
|
||||
$o .= L10n::t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
|
||||
'<strong>' . FRIENDICA_VERSION . '</strong>', System::baseUrl(), '<strong>' . DB_UPDATE_VERSION . '</strong>',
|
||||
'<strong>' . Config::get("system", "post_update_version") . '</strong>');
|
||||
$o .= '</p>' . PHP_EOL;
|
||||
|
||||
$o .= '<p>';
|
||||
$o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
|
||||
$o .= '</p>' . PHP_EOL;
|
||||
|
||||
$o .= '<p>';
|
||||
$o .= L10n::t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.L10n::t('the bugtracker at github').'</a>';
|
||||
$o .= '</p>' . PHP_EOL;
|
||||
$o .= '<p>';
|
||||
$o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
|
||||
$o .= '</p>' . PHP_EOL;
|
||||
|
||||
$visible_addons = Addon::getVisibleList();
|
||||
if (count($visible_addons)) {
|
||||
$o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
|
||||
$sorted = $visible_addons;
|
||||
$s = '';
|
||||
sort($sorted);
|
||||
foreach ($sorted as $p) {
|
||||
if (strlen($p)) {
|
||||
if (strlen($s)) {
|
||||
$s .= ', ';
|
||||
}
|
||||
$s .= $p;
|
||||
}
|
||||
}
|
||||
$o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
|
||||
} else {
|
||||
$o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
|
||||
}
|
||||
|
||||
if (Config::get('system', 'tosdisplay'))
|
||||
{
|
||||
$o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
|
||||
}
|
||||
|
||||
$blocklist = Config::get('system', 'blocklist', []);
|
||||
if (!empty($blocklist)) {
|
||||
$o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
|
||||
$o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
|
||||
foreach ($blocklist as $b) {
|
||||
$o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
|
||||
}
|
||||
$o .= '</tbody></table></div>' . PHP_EOL;
|
||||
}
|
||||
|
||||
Hook::callAll('about_hook', $o);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -10,10 +10,11 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
function fsuggest_post(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,53 +23,38 @@ function fsuggest_post(App $a)
|
|||
}
|
||||
|
||||
$contact_id = intval($a->argv[1]);
|
||||
if (empty($contact_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
|
||||
if (! DBA::isResult($contact)) {
|
||||
// We do query the "uid" as well to ensure that it is our contact
|
||||
if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
|
||||
notice(L10n::t('Contact not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$new_contact = intval($_POST['suggest']);
|
||||
$suggest_contact_id = intval($_POST['suggest']);
|
||||
if (empty($suggest_contact_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hash = Strings::getRandomHex();
|
||||
// We do query the "uid" as well to ensure that it is our contact
|
||||
$contact = DBA::selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
notice(L10n::t('Suggested contact not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
|
||||
|
||||
if ($new_contact) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($new_contact),
|
||||
intval(local_user())
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
|
||||
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
|
||||
intval(local_user()),
|
||||
intval($contact_id),
|
||||
DBA::escape($contact['name']),
|
||||
DBA::escape($contact['url']),
|
||||
DBA::escape($contact['request']),
|
||||
DBA::escape($contact['photo']),
|
||||
DBA::escape($hash),
|
||||
DBA::escape(DateTimeFormat::utcNow())
|
||||
);
|
||||
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
|
||||
DBA::escape($hash),
|
||||
intval(local_user())
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$fsuggest_id = $contact['id'];
|
||||
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
DBA::escape($note),
|
||||
intval($fsuggest_id),
|
||||
intval(local_user())
|
||||
);
|
||||
Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', $fsuggest_id);
|
||||
}
|
||||
$fields = ['uid' => local_user(),'cid' => $contact_id, 'name' => $contact['name'],
|
||||
'url' => $contact['url'], 'request' => $contact['request'],
|
||||
'photo' => $contact['avatar'], 'note' => $note, 'created' => DateTimeFormat::utcNow()];
|
||||
DBA::insert('fsuggest', $fields);
|
||||
|
||||
info(L10n::t('Friend suggestion sent.') . EOL);
|
||||
}
|
||||
}
|
||||
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, DBA::lastInsertId());
|
||||
|
||||
info(L10n::t('Friend suggestion sent.') . EOL);
|
||||
}
|
||||
|
||||
function fsuggest_content(App $a)
|
||||
|
|
|
@ -17,9 +17,7 @@ function hcard_init(App $a)
|
|||
if ($a->argc > 1) {
|
||||
$which = $a->argv[1];
|
||||
} else {
|
||||
notice(L10n::t('No profile') . EOL);
|
||||
$a->error = 404;
|
||||
return;
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('No profile'));
|
||||
}
|
||||
|
||||
$profile = 0;
|
||||
|
|
119
mod/help.php
119
mod/help.php
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/help.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function load_doc_file($s)
|
||||
{
|
||||
$lang = Config::get('system', 'language');
|
||||
$b = basename($s);
|
||||
$d = dirname($s);
|
||||
if (file_exists("$d/$lang/$b")) {
|
||||
return file_get_contents("$d/$lang/$b");
|
||||
}
|
||||
|
||||
if (file_exists($s)) {
|
||||
return file_get_contents($s);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function help_content(App $a)
|
||||
{
|
||||
Nav::setSelected('help');
|
||||
|
||||
$text = '';
|
||||
$filename = '';
|
||||
|
||||
if ($a->argc > 1) {
|
||||
$path = '';
|
||||
// looping through the argv keys bigger than 0 to build
|
||||
// a path relative to /help
|
||||
for ($x = 1; $x < $a->argc; $x ++) {
|
||||
if (strlen($path)) {
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
$path .= $a->getArgumentValue($x);
|
||||
}
|
||||
$title = basename($path);
|
||||
$filename = $path;
|
||||
$text = load_doc_file('doc/' . $path . '.md');
|
||||
$a->page['title'] = L10n::t('Help:') . ' ' . str_replace('-', ' ', Strings::escapeTags($title));
|
||||
}
|
||||
|
||||
$home = load_doc_file('doc/Home.md');
|
||||
if (!$text) {
|
||||
$text = $home;
|
||||
$filename = "Home";
|
||||
$a->page['title'] = L10n::t('Help');
|
||||
} else {
|
||||
$a->page['aside'] = Markdown::convert($home, false);
|
||||
}
|
||||
|
||||
if (!strlen($text)) {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . L10n::t('Not Found'));
|
||||
$tpl = Renderer::getMarkupTemplate("404.tpl");
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$message' => L10n::t('Page not found.')
|
||||
]);
|
||||
}
|
||||
|
||||
$html = Markdown::convert($text, false);
|
||||
|
||||
if ($filename !== "Home") {
|
||||
// create TOC but not for home
|
||||
$lines = explode("\n", $html);
|
||||
$toc = "<h2>TOC</h2><ul id='toc'>";
|
||||
$lastlevel = 1;
|
||||
$idnum = [0, 0, 0, 0, 0, 0, 0];
|
||||
foreach ($lines as &$line) {
|
||||
if (substr($line, 0, 2) == "<h") {
|
||||
$level = substr($line, 2, 1);
|
||||
if ($level != "r") {
|
||||
$level = intval($level);
|
||||
if ($level < $lastlevel) {
|
||||
for ($k = $level; $k < $lastlevel; $k++) {
|
||||
$toc .= "</ul></li>";
|
||||
}
|
||||
|
||||
for ($k = $level + 1; $k < count($idnum); $k++) {
|
||||
$idnum[$k] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($level > $lastlevel) {
|
||||
$toc .= "<li><ul>";
|
||||
}
|
||||
|
||||
$idnum[$level] ++;
|
||||
$id = implode("_", array_slice($idnum, 1, $level));
|
||||
$href = System::baseUrl() . "/help/{$filename}#{$id}";
|
||||
$toc .= "<li><a href='{$href}'>" . strip_tags($line) . "</a></li>";
|
||||
$line = "<a name='{$id}'></a>" . $line;
|
||||
$lastlevel = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($k = 0; $k < $lastlevel; $k++) {
|
||||
$toc .= "</ul>";
|
||||
}
|
||||
|
||||
$html = implode("\n", $lines);
|
||||
|
||||
$a->page['aside'] = '<div class="help-aside-wrapper widget"><div id="toc-wrapper">' . $toc . '</div>' . $a->page['aside'] . '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
64
mod/home.php
64
mod/home.php
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/home.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
if(! function_exists('home_init')) {
|
||||
function home_init(App $a) {
|
||||
|
||||
$ret = [];
|
||||
Hook::callAll('home_init',$ret);
|
||||
|
||||
if (local_user() && ($a->user['nickname'])) {
|
||||
$a->internalRedirect('network');
|
||||
}
|
||||
|
||||
if (strlen(Config::get('system','singleuser'))) {
|
||||
$a->internalRedirect('profile/' . Config::get('system','singleuser'));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
if(! function_exists('home_content')) {
|
||||
function home_content(App $a) {
|
||||
|
||||
if (!empty($_SESSION['theme'])) {
|
||||
unset($_SESSION['theme']);
|
||||
}
|
||||
if (!empty($_SESSION['mobile-theme'])) {
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
|
||||
$customhome = false;
|
||||
$defaultheader = '<h1>' . (Config::get('config', 'sitename') ? L10n::t('Welcome to %s', Config::get('config', 'sitename')) : '') . '</h1>';
|
||||
|
||||
$homefilepath = $a->getBasePath() . "/home.html";
|
||||
$cssfilepath = $a->getBasePath() . "/home.css";
|
||||
if (file_exists($homefilepath)) {
|
||||
$customhome = $homefilepath;
|
||||
if (file_exists($cssfilepath)) {
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.System::baseUrl().'/home.css'.'" media="all" />';
|
||||
}
|
||||
}
|
||||
|
||||
$login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
|
||||
|
||||
$content = '';
|
||||
Hook::callAll("home_content",$content);
|
||||
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('home.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$defaultheader' => $defaultheader,
|
||||
'$customhome' => $customhome,
|
||||
'$login' => $login,
|
||||
'$content' => $content
|
||||
]);
|
||||
}}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/hostxrd.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Protocol\Salmon;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
function hostxrd_init(App $a)
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: text/xml");
|
||||
$pubkey = Config::get('system', 'site_pubkey');
|
||||
|
||||
if (! $pubkey) {
|
||||
$res = Crypto::newKeypair(1024);
|
||||
|
||||
Config::set('system','site_prvkey', $res['prvkey']);
|
||||
Config::set('system','site_pubkey', $res['pubkey']);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
|
||||
echo Renderer::replaceMacros($tpl, [
|
||||
'$zhost' => $a->getHostName(),
|
||||
'$zroot' => System::baseUrl(),
|
||||
'$domain' => System::baseUrl(),
|
||||
'$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]
|
||||
);
|
||||
|
||||
exit();
|
||||
}
|
|
@ -31,7 +31,7 @@ function hovercard_content()
|
|||
|
||||
// Get out if the system doesn't have public access allowed
|
||||
if (intval(Config::get('system', 'block_public'))) {
|
||||
System::httpExit(401);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
// Return the raw content of the template. We use this to make templates usable for js functions.
|
||||
|
|
158
mod/invite.php
158
mod/invite.php
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Module: invite.php
|
||||
*
|
||||
* Send email invitations to join social network
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Protocol\Email;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function invite_post(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/', 'send_invite');
|
||||
|
||||
$max_invites = intval(Config::get('system', 'max_invites'));
|
||||
if (! $max_invites) {
|
||||
$max_invites = 50;
|
||||
}
|
||||
|
||||
$current_invites = intval(PConfig::get(local_user(), 'system', 'sent_invites'));
|
||||
if ($current_invites > $max_invites) {
|
||||
notice(L10n::t('Total invitation limit exceeded.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$recipients = !empty($_POST['recipients']) ? explode("\n", $_POST['recipients']) : [];
|
||||
$message = !empty($_POST['message']) ? Strings::escapeTags(trim($_POST['message'])) : '';
|
||||
|
||||
$total = 0;
|
||||
$invitation_only = false;
|
||||
$invites_remaining = null;
|
||||
|
||||
if (Config::get('system', 'invitation_only')) {
|
||||
$invitation_only = true;
|
||||
$invites_remaining = PConfig::get(local_user(), 'system', 'invites_remaining');
|
||||
if ((! $invites_remaining) && (! is_site_admin())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
$recipient = trim($recipient);
|
||||
|
||||
if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
|
||||
notice(L10n::t('%s : Not a valid email address.', $recipient) . EOL);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($invitation_only && ($invites_remaining || is_site_admin())) {
|
||||
$code = Friendica\Model\Register::createForInvitation();
|
||||
$nmessage = str_replace('$invite_code', $code, $message);
|
||||
|
||||
if (! is_site_admin()) {
|
||||
$invites_remaining --;
|
||||
if ($invites_remaining >= 0) {
|
||||
PConfig::set(local_user(), 'system', 'invites_remaining', $invites_remaining);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$nmessage = $message;
|
||||
}
|
||||
|
||||
$additional_headers = 'From: ' . $a->user['email'] . "\n"
|
||||
. 'Sender: ' . $a->getSenderEmailAddress() . "\n"
|
||||
. 'Content-type: text/plain; charset=UTF-8' . "\n"
|
||||
. 'Content-transfer-encoding: 8bit';
|
||||
|
||||
$res = mail(
|
||||
$recipient,
|
||||
Email::encodeHeader(L10n::t('Please join us on Friendica'), 'UTF-8'),
|
||||
$nmessage,
|
||||
$additional_headers);
|
||||
|
||||
if ($res) {
|
||||
$total ++;
|
||||
$current_invites ++;
|
||||
PConfig::set(local_user(), 'system', 'sent_invites', $current_invites);
|
||||
if ($current_invites > $max_invites) {
|
||||
notice(L10n::t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
notice(L10n::t('%s : Message delivery failed.', $recipient) . EOL);
|
||||
}
|
||||
|
||||
}
|
||||
notice(L10n::tt("%d message sent.", "%d messages sent.", $total) . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
function invite_content(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('invite.tpl');
|
||||
$invonly = false;
|
||||
|
||||
if (Config::get('system', 'invitation_only')) {
|
||||
$invonly = true;
|
||||
$x = PConfig::get(local_user(), 'system', 'invites_remaining');
|
||||
if ((! $x) && (! is_site_admin())) {
|
||||
notice(L10n::t('You have no more invitations available') . EOL);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$dirloc = Config::get('system', 'directory');
|
||||
if (strlen($dirloc)) {
|
||||
if (intval(Config::get('config', 'register_policy')) === Register::CLOSED) {
|
||||
$linktxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirloc . '/servers');
|
||||
} else {
|
||||
$linktxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', System::baseUrl())
|
||||
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirloc . '/servers');
|
||||
}
|
||||
} else { // there is no global directory URL defined
|
||||
if (intval(Config::get('config', 'register_policy')) === Register::CLOSED) {
|
||||
$o = L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
|
||||
return $o;
|
||||
} else {
|
||||
$linktxt = L10n::t('To accept this invitation, please visit and register at %s.', System::baseUrl()
|
||||
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.'));
|
||||
}
|
||||
}
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken("send_invite"),
|
||||
'$title' => L10n::t('Send invitations'),
|
||||
'$recipients' => ['recipients', L10n::t('Enter email addresses, one per line:')],
|
||||
'$message' => ['message', L10n::t('Your message:'),L10n::t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
|
||||
. $linktxt
|
||||
. "\r\n" . "\r\n" . (($invonly) ? L10n::t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .L10n::t('Once you have registered, please connect with me via my profile page at:')
|
||||
. "\r\n" . "\r\n" . System::baseUrl() . '/profile/' . $a->user['nickname']
|
||||
. "\r\n" . "\r\n" . L10n::t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n"],
|
||||
'$submit' => L10n::t('Submit')
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
17
mod/item.php
17
mod/item.php
|
@ -27,12 +27,12 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Attach;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Attach;
|
||||
use Friendica\Model\Term;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\Email;
|
||||
|
@ -40,6 +40,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
use Friendica\Util\Emailer;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
require_once 'include/items.php';
|
||||
|
||||
|
@ -327,10 +328,9 @@ function item_post(App $a) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($categories))
|
||||
{
|
||||
if (!empty($categories)) {
|
||||
// get the "fileas" tags for this post
|
||||
$filedas = FileTag::fileToList($categories, 'file');
|
||||
$filedas = FileTag::fileToArray($categories);
|
||||
}
|
||||
|
||||
// save old and new categories, so we can determine what needs to be deleted from pconfig
|
||||
|
@ -338,10 +338,9 @@ function item_post(App $a) {
|
|||
$categories = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
|
||||
$categories_new = $categories;
|
||||
|
||||
if (!empty($filedas))
|
||||
{
|
||||
if (!empty($filedas) && is_array($filedas)) {
|
||||
// append the fileas stuff to the new categories list
|
||||
$categories .= FileTag::listToFile($filedas, 'file');
|
||||
$categories .= FileTag::arrayToFile($filedas);
|
||||
}
|
||||
|
||||
// get contact info for poster
|
||||
|
@ -605,8 +604,6 @@ function item_post(App $a) {
|
|||
$origin = $_REQUEST['origin'];
|
||||
}
|
||||
|
||||
$notify_type = ($toplevel_item_id ? 'comment-new' : 'wall-new');
|
||||
|
||||
$uri = ($message_id ? $message_id : Item::newURI($api_source ? $profile_uid : $uid, $guid));
|
||||
|
||||
// Fallback so that we alway have a parent uri
|
||||
|
@ -871,7 +868,7 @@ function item_post(App $a) {
|
|||
// When we are doing some forum posting via ! we have to start the notifier manually.
|
||||
// These kind of posts don't initiate the notifier call in the item class.
|
||||
if ($only_to_forum) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post_id);
|
||||
}
|
||||
|
||||
Logger::log('post_complete');
|
||||
|
|
48
mod/like.php
48
mod/like.php
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function like_content(App $a) {
|
||||
if (!local_user() && !remote_user()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$verb = Strings::escapeTags(trim($_GET['verb']));
|
||||
|
||||
if (!$verb) {
|
||||
$verb = 'like';
|
||||
}
|
||||
|
||||
$item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
|
||||
|
||||
$r = Item::performLike($item_id, $verb);
|
||||
if (!$r) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = defaults($_REQUEST, 'return', '');
|
||||
|
||||
like_content_return($a, $return_path);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Decide how to return. If we were called with a 'return' argument,
|
||||
// then redirect back to the calling page. If not, just quietly end
|
||||
|
||||
function like_content_return(App $a, $return_path) {
|
||||
if ($return_path) {
|
||||
$rand = '_=' . time();
|
||||
if (strpos($return_path, '?')) {
|
||||
$rand = "&$rand";
|
||||
} else {
|
||||
$rand = "?$rand";
|
||||
}
|
||||
|
||||
$a->internalRedirect($return_path . $rand);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/localtime.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
function localtime_post(App $a)
|
||||
{
|
||||
$t = $_REQUEST['time'];
|
||||
if (! $t) {
|
||||
$t = 'now';
|
||||
}
|
||||
|
||||
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
|
||||
|
||||
if ($_POST['timezone']) {
|
||||
$a->data['mod-localtime'] = DateTimeFormat::convert($t, $_POST['timezone'], 'UTC', $bd_format);
|
||||
}
|
||||
}
|
||||
|
||||
function localtime_content(App $a)
|
||||
{
|
||||
$t = $_REQUEST['time'];
|
||||
if (! $t) {
|
||||
$t = 'now';
|
||||
}
|
||||
|
||||
$o = '<h3>' . L10n::t('Time Conversion') . '</h3>';
|
||||
|
||||
$o .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
|
||||
|
||||
|
||||
|
||||
$o .= '<p>' . L10n::t('UTC time: %s', $t) . '</p>';
|
||||
|
||||
if ($_REQUEST['timezone']) {
|
||||
$o .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
|
||||
}
|
||||
|
||||
if (!empty($a->data['mod-localtime'])) {
|
||||
$o .= '<p>' . L10n::t('Converted localtime: %s', $a->data['mod-localtime']) . '</p>';
|
||||
}
|
||||
|
||||
|
||||
$o .= '<form action ="' . System::baseUrl() . '/localtime?f=&time=' . $t . '" method="post" >';
|
||||
|
||||
$o .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
|
||||
|
||||
$o .= Temporal::getTimezoneSelect(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles');
|
||||
|
||||
$o .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -139,7 +139,6 @@ function lostpass_generate_password($user)
|
|||
'$lbl5' => '<a href="' . System::baseUrl() . '">' . L10n::t('click here to login') . '</a>.',
|
||||
'$lbl6' => L10n::t('Your password may be changed from the <em>Settings</em> page after successful login.'),
|
||||
'$newpass' => $new_password,
|
||||
'$baseurl' => System::baseUrl()
|
||||
]);
|
||||
|
||||
info("Your password has been reset." . EOL);
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/maintenance.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function maintenance_content(App $a)
|
||||
{
|
||||
$reason = Config::get('system', 'maintenance_reason');
|
||||
|
||||
if (substr(Strings::normaliseLink($reason), 0, 7) == 'http://') {
|
||||
header("HTTP/1.1 307 Temporary Redirect");
|
||||
header("Location:".$reason);
|
||||
return;
|
||||
}
|
||||
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
header('Status: 503 Service Temporarily Unavailable');
|
||||
header('Retry-After: 600');
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('maintenance.tpl'), [
|
||||
'$sysdown' => L10n::t('System down for maintenance'),
|
||||
'$reason' => $reason
|
||||
]);
|
||||
}
|
|
@ -2,11 +2,12 @@
|
|||
/**
|
||||
* @file mod/manage.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Authentication;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
function manage_post(App $a) {
|
||||
|
@ -108,7 +109,7 @@ function manage_post(App $a) {
|
|||
unset($_SESSION['sysmsg_info']);
|
||||
}
|
||||
|
||||
Authentication::setAuthenticatedSessionForUser($r[0], true, true);
|
||||
Session::setAuthenticatedForUser($a, $r[0], true, true);
|
||||
|
||||
if ($limited_id) {
|
||||
$_SESSION['submanage'] = $original_id;
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
function manifest_content(App $a) {
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('manifest.tpl');
|
||||
|
||||
header('Content-type: application/manifest+json');
|
||||
|
||||
$touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
|
||||
if ($touch_icon == '') {
|
||||
$touch_icon = 'images/friendica-128.png';
|
||||
}
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$touch_icon' => $touch_icon,
|
||||
'$title' => Config::get('config', 'sitename', 'Friendica'),
|
||||
]);
|
||||
|
||||
echo $o;
|
||||
|
||||
exit();
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
function modexp_init(App $a) {
|
||||
|
||||
if($a->argc != 2)
|
||||
exit();
|
||||
|
||||
$nick = $a->argv[1];
|
||||
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
||||
DBA::escape($nick)
|
||||
);
|
||||
|
||||
if (! DBA::isResult($r)) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$lines = explode("\n",$r[0]['spubkey']);
|
||||
unset($lines[0]);
|
||||
unset($lines[count($lines)]);
|
||||
$x = base64_decode(implode('',$lines));
|
||||
|
||||
$r = ASN_BASE::parseASNString($x);
|
||||
|
||||
$m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
|
||||
$e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
|
||||
|
||||
header("Content-type: application/magic-public-key");
|
||||
echo 'RSA' . '.' . $m . '.' . $e;
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
|
|
@ -77,9 +77,7 @@ function network_init(App $a)
|
|||
|
||||
// convert query string to array. remove friendica args
|
||||
$query_array = [];
|
||||
$query_string = str_replace($a->cmd . '?', '', $a->query_string);
|
||||
parse_str($query_string, $query_array);
|
||||
array_shift($query_array);
|
||||
parse_str(parse_url($a->query_string, PHP_URL_QUERY), $query_array);
|
||||
|
||||
// fetch last used network view and redirect if needed
|
||||
if (!$is_a_date_query) {
|
||||
|
@ -99,7 +97,7 @@ function network_init(App $a)
|
|||
|
||||
if ($remember_tab) {
|
||||
// redirect if current selected tab is '/network' and
|
||||
// last selected tab is _not_ '/network?f=&order=comment'.
|
||||
// last selected tab is _not_ '/network?order=comment'.
|
||||
// and this isn't a date query
|
||||
|
||||
$tab_baseurls = [
|
||||
|
@ -111,12 +109,12 @@ function network_init(App $a)
|
|||
'', //bookmarked
|
||||
];
|
||||
$tab_args = [
|
||||
'f=&order=comment', //all
|
||||
'f=&order=post', //postord
|
||||
'f=&conv=1', //conv
|
||||
'order=comment', //all
|
||||
'order=post', //postord
|
||||
'conv=1', //conv
|
||||
'', //new
|
||||
'f=&star=1', //starred
|
||||
'f=&bmark=1', //bookmarked
|
||||
'star=1', //starred
|
||||
'bmark=1', //bookmarked
|
||||
];
|
||||
|
||||
$k = array_search('active', $last_sel_tabs);
|
||||
|
@ -140,7 +138,7 @@ function network_init(App $a)
|
|||
|
||||
if ($remember_tab) {
|
||||
$net_args = array_merge($query_array, $net_args);
|
||||
$net_queries = build_querystring($net_args);
|
||||
$net_queries = http_build_query($net_args);
|
||||
|
||||
$redir_url = ($net_queries ? $net_baseurl . '?' . $net_queries : $net_baseurl);
|
||||
|
||||
|
@ -154,7 +152,7 @@ function network_init(App $a)
|
|||
|
||||
$a->page['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
|
||||
$a->page['aside'] .= ForumManager::widget(local_user(), $cid);
|
||||
$a->page['aside'] .= posted_date_widget('network', local_user(), false);
|
||||
$a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
|
||||
$a->page['aside'] .= Widget::networks('network', defaults($_GET, 'nets', '') );
|
||||
$a->page['aside'] .= saved_searches($search);
|
||||
$a->page['aside'] .= Widget::fileAs('network', defaults($_GET, 'file', '') );
|
||||
|
@ -202,12 +200,12 @@ function saved_searches($search)
|
|||
*
|
||||
* urls -> returns
|
||||
* '/network' => $no_active = 'active'
|
||||
* '/network?f=&order=comment' => $comment_active = 'active'
|
||||
* '/network?f=&order=post' => $postord_active = 'active'
|
||||
* '/network?f=&conv=1', => $conv_active = 'active'
|
||||
* '/network?order=comment' => $comment_active = 'active'
|
||||
* '/network?order=post' => $postord_active = 'active'
|
||||
* '/network?conv=1', => $conv_active = 'active'
|
||||
* '/network/new', => $new_active = 'active'
|
||||
* '/network?f=&star=1', => $starred_active = 'active'
|
||||
* '/network?f=&bmark=1', => $bookmarked_active = 'active'
|
||||
* '/network?star=1', => $starred_active = 'active'
|
||||
* '/network?bmark=1', => $bookmarked_active = 'active'
|
||||
*
|
||||
* @param App $a
|
||||
* @return array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active);
|
||||
|
@ -973,7 +971,7 @@ function network_tabs(App $a)
|
|||
$tabs = [
|
||||
[
|
||||
'label' => L10n::t('Commented Order'),
|
||||
'url' => str_replace('/new', '', $cmd) . '?f=&order=comment' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
|
||||
'url' => str_replace('/new', '', $cmd) . '?order=comment' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
|
||||
'sel' => $all_active,
|
||||
'title' => L10n::t('Sort by Comment Date'),
|
||||
'id' => 'commented-order-tab',
|
||||
|
@ -981,7 +979,7 @@ function network_tabs(App $a)
|
|||
],
|
||||
[
|
||||
'label' => L10n::t('Posted Order'),
|
||||
'url' => str_replace('/new', '', $cmd) . '?f=&order=post' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
|
||||
'url' => str_replace('/new', '', $cmd) . '?order=post' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
|
||||
'sel' => $postord_active,
|
||||
'title' => L10n::t('Sort by Post Date'),
|
||||
'id' => 'posted-order-tab',
|
||||
|
@ -991,7 +989,7 @@ function network_tabs(App $a)
|
|||
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Personal'),
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
|
||||
'sel' => $conv_active,
|
||||
'title' => L10n::t('Posts that mention or involve you'),
|
||||
'id' => 'personal-tab',
|
||||
|
@ -1001,7 +999,7 @@ function network_tabs(App $a)
|
|||
if (Feature::isEnabled(local_user(), 'new_tab')) {
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('New'),
|
||||
'url' => 'network/new' . (!empty($_GET['cid']) ? '/?f=&cid=' . $_GET['cid'] : ''),
|
||||
'url' => 'network/new' . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : ''),
|
||||
'sel' => $new_active,
|
||||
'title' => L10n::t('Activity Stream - by date'),
|
||||
'id' => 'activitiy-by-date-tab',
|
||||
|
@ -1012,7 +1010,7 @@ function network_tabs(App $a)
|
|||
if (Feature::isEnabled(local_user(), 'link_tab')) {
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Shared Links'),
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
|
||||
'sel' => $bookmarked_active,
|
||||
'title' => L10n::t('Interesting Links'),
|
||||
'id' => 'shared-links-tab',
|
||||
|
@ -1022,7 +1020,7 @@ function network_tabs(App $a)
|
|||
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Starred'),
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
|
||||
'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&star=1',
|
||||
'sel' => $starred_active,
|
||||
'title' => L10n::t('Favourite Posts'),
|
||||
'id' => 'starred-posts-tab',
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/newmember.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
|
||||
function newmember_content(App $a)
|
||||
{
|
||||
$o = '<div class="generic-page-wrapper">';
|
||||
$o .= '<h1>' . L10n::t('Welcome to Friendica') . '</h1>';
|
||||
$o .= '<h3>' . L10n::t('New Member Checklist') . '</h3>';
|
||||
$o .= '<div style="font-size: 120%;">';
|
||||
$o .= L10n::t('We would like to offer some tips and links to help make your experience enjoyable. Click any item to visit the relevant page. A link to this page will be visible from your home page for two weeks after your initial registration and then will quietly disappear.');
|
||||
$o .= '<h4>' . L10n::t('Getting Started') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
$o .= '<li> ' . '<a target="newmember" href="help/Quick-Start-guide">' . L10n::t('Friendica Walk-Through') . '</a><br />' . L10n::t('On your <em>Quick Start</em> page - find a brief introduction to your profile and network tabs, make some new connections, and find some groups to join.') . '</li>' . EOL;
|
||||
$o .= '</ul>';
|
||||
$o .= '<h4>' . L10n::t('Settings') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
$o .= '<li>' . '<a target="newmember" href="settings">' . L10n::t('Go to Your Settings') . '</a><br />' . L10n::t('On your <em>Settings</em> page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '</li>' . EOL;
|
||||
$o .= '<li>' . L10n::t('Review the other settings, particularly the privacy settings. An unpublished directory listing is like having an unlisted phone number. In general, you should probably publish your listing - unless all of your friends and potential friends know exactly how to find you.') . '</li>' . EOL;
|
||||
$o .= '</ul>';
|
||||
$o .= '<h4>' . L10n::t('Profile') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
$o .= '<li>' . '<a target="newmember" href="profile_photo">' . L10n::t('Upload Profile Photo') . '</a><br />' . L10n::t('Upload a profile photo if you have not done so already. Studies have shown that people with real photos of themselves are ten times more likely to make friends than people who do not.') . '</li>' . EOL;
|
||||
$o .= '<li>' . '<a target="newmember" href="profiles">' . L10n::t('Edit Your Profile') . '</a><br />' . L10n::t('Edit your <strong>default</strong> profile to your liking. Review the settings for hiding your list of friends and hiding the profile from unknown visitors.') . '</li>' . EOL;
|
||||
$o .= '<li>' . '<a target="newmember" href="profiles">' . L10n::t('Profile Keywords') . '</a><br />' . L10n::t('Set some public keywords for your default profile which describe your interests. We may be able to find other people with similar interests and suggest friendships.') . '</li>' . EOL;
|
||||
$o .= '</ul>';
|
||||
$o .= '<h4>' . L10n::t('Connecting') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
|
||||
$mail_disabled = ((function_exists('imap_open') && (!Config::get('system', 'imap_disabled'))) ? 0 : 1);
|
||||
|
||||
if (!$mail_disabled) {
|
||||
$o .= '<li>' . '<a target="newmember" href="settings/connectors">' . L10n::t('Importing Emails') . '</a><br />' . L10n::t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL;
|
||||
}
|
||||
|
||||
$o .= '<li>' . '<a target="newmember" href="contact">' . L10n::t('Go to Your Contacts Page') . '</a><br />' . L10n::t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL;
|
||||
$o .= '<li>' . '<a target="newmember" href="directory">' . L10n::t("Go to Your Site's Directory") . '</a><br />' . L10n::t('The Directory page lets you find other people in this network or other federated sites. Look for a <em>Connect</em> or <em>Follow</em> link on their profile page. Provide your own Identity Address if requested.') . '</li>' . EOL;
|
||||
$o .= '<li>' . '<a target="newmember" href="contact">' . L10n::t('Finding New People') . '</a><br />' . L10n::t("On the side panel of the Contacts page are several tools to find new friends. We can match people by interest, look up people by name or interest, and provide suggestions based on network relationships. On a brand new site, friend suggestions will usually begin to be populated within 24 hours.") . '</li>' . EOL;
|
||||
$o .= '</ul>';
|
||||
$o .= '<h4>' . L10n::t('Groups') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
$o .= '<li>' . '<a target="newmember" href="contact">' . L10n::t('Group Your Contacts') . '</a><br />' . L10n::t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.') . '</li>' . EOL;
|
||||
|
||||
if (Config::get('system', 'newuser_private')) {
|
||||
$o .= '<li>' . '<a target="newmember" href="help/Groups-and-Privacy">' . L10n::t("Why Aren't My Posts Public?") . '</a><br />' . L10n::t("Friendica respects your privacy. By default, your posts will only show up to people you've added as friends. For more information, see the help section from the link above.") . '</li>' . EOL;
|
||||
}
|
||||
|
||||
$o .= '</ul>';
|
||||
$o .= '<h4>' . L10n::t('Getting Help') . '</h4>';
|
||||
$o .= '<ul>';
|
||||
$o .= '<li>' . '<a target="newmember" href="help">' . L10n::t('Go to the Help Section') . '</a><br />' . L10n::t('Our <strong>help</strong> pages may be consulted for detail on other program features and resources.') . '</li>' . EOL;
|
||||
$o .= '</ul>';
|
||||
$o .= '</div>';
|
||||
$o .= '</div>';
|
||||
|
||||
return $o;
|
||||
}
|
221
mod/nodeinfo.php
221
mod/nodeinfo.php
|
@ -1,221 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/nodeinfo.php
|
||||
*
|
||||
* Documentation: http://nodeinfo.diaspora.software/schema.html
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
function nodeinfo_wellknown(App $a) {
|
||||
if (!Config::get('system', 'nodeinfo')) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
|
||||
'href' => System::baseUrl().'/nodeinfo/1.0']]];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
function nodeinfo_init(App $a) {
|
||||
if (!Config::get('system', 'nodeinfo')) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
if (($a->argc != 2) || ($a->argv[1] != '1.0')) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$smtp = (function_exists('imap_open') && !Config::get('system', 'imap_disabled') && !Config::get('system', 'dfrn_only'));
|
||||
|
||||
$nodeinfo = [];
|
||||
$nodeinfo['version'] = '1.0';
|
||||
$nodeinfo['software'] = ['name' => 'friendica', 'version' => FRIENDICA_VERSION.'-'.DB_UPDATE_VERSION];
|
||||
|
||||
$nodeinfo['protocols'] = [];
|
||||
$nodeinfo['protocols']['inbound'] = [];
|
||||
$nodeinfo['protocols']['outbound'] = [];
|
||||
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$nodeinfo['protocols']['inbound'][] = 'diaspora';
|
||||
$nodeinfo['protocols']['outbound'][] = 'diaspora';
|
||||
}
|
||||
|
||||
$nodeinfo['protocols']['inbound'][] = 'friendica';
|
||||
$nodeinfo['protocols']['outbound'][] = 'friendica';
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$nodeinfo['protocols']['inbound'][] = 'gnusocial';
|
||||
$nodeinfo['protocols']['outbound'][] = 'gnusocial';
|
||||
}
|
||||
|
||||
$nodeinfo['services'] = [];
|
||||
$nodeinfo['services']['inbound'] = [];
|
||||
$nodeinfo['services']['outbound'] = [];
|
||||
|
||||
$nodeinfo['usage'] = [];
|
||||
|
||||
$nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED;
|
||||
|
||||
$nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')];
|
||||
|
||||
if (Config::get('system', 'nodeinfo')) {
|
||||
|
||||
$nodeinfo['usage']['users'] = ['total' => (int)Config::get('nodeinfo', 'total_users'),
|
||||
'activeHalfyear' => (int)Config::get('nodeinfo', 'active_users_halfyear'),
|
||||
'activeMonth' => (int)Config::get('nodeinfo', 'active_users_monthly')];
|
||||
$nodeinfo['usage']['localPosts'] = (int)Config::get('nodeinfo', 'local_posts');
|
||||
$nodeinfo['usage']['localComments'] = (int)Config::get('nodeinfo', 'local_comments');
|
||||
|
||||
if (Addon::isEnabled('blogger')) {
|
||||
$nodeinfo['services']['outbound'][] = 'blogger';
|
||||
}
|
||||
if (Addon::isEnabled('dwpost')) {
|
||||
$nodeinfo['services']['outbound'][] = 'dreamwidth';
|
||||
}
|
||||
if (Addon::isEnabled('statusnet')) {
|
||||
$nodeinfo['services']['inbound'][] = 'gnusocial';
|
||||
$nodeinfo['services']['outbound'][] = 'gnusocial';
|
||||
}
|
||||
if (Addon::isEnabled('ijpost')) {
|
||||
$nodeinfo['services']['outbound'][] = 'insanejournal';
|
||||
}
|
||||
if (Addon::isEnabled('libertree')) {
|
||||
$nodeinfo['services']['outbound'][] = 'libertree';
|
||||
}
|
||||
if (Addon::isEnabled('buffer')) {
|
||||
$nodeinfo['services']['outbound'][] = 'linkedin';
|
||||
}
|
||||
if (Addon::isEnabled('ljpost')) {
|
||||
$nodeinfo['services']['outbound'][] = 'livejournal';
|
||||
}
|
||||
if (Addon::isEnabled('buffer')) {
|
||||
$nodeinfo['services']['outbound'][] = 'pinterest';
|
||||
}
|
||||
if (Addon::isEnabled('posterous')) {
|
||||
$nodeinfo['services']['outbound'][] = 'posterous';
|
||||
}
|
||||
if (Addon::isEnabled('pumpio')) {
|
||||
$nodeinfo['services']['inbound'][] = 'pumpio';
|
||||
$nodeinfo['services']['outbound'][] = 'pumpio';
|
||||
}
|
||||
|
||||
if ($smtp) {
|
||||
$nodeinfo['services']['outbound'][] = 'smtp';
|
||||
}
|
||||
if (Addon::isEnabled('tumblr')) {
|
||||
$nodeinfo['services']['outbound'][] = 'tumblr';
|
||||
}
|
||||
if (Addon::isEnabled('twitter') || Addon::isEnabled('buffer')) {
|
||||
$nodeinfo['services']['outbound'][] = 'twitter';
|
||||
}
|
||||
if (Addon::isEnabled('wppost')) {
|
||||
$nodeinfo['services']['outbound'][] = 'wordpress';
|
||||
}
|
||||
$nodeinfo['metadata']['protocols'] = $nodeinfo['protocols'];
|
||||
$nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0';
|
||||
$nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0';
|
||||
$nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0';
|
||||
|
||||
$nodeinfo['metadata']['services'] = $nodeinfo['services'];
|
||||
|
||||
if (Addon::isEnabled('twitter')) {
|
||||
$nodeinfo['metadata']['services']['inbound'][] = 'twitter';
|
||||
}
|
||||
|
||||
$nodeinfo['metadata']['explicitContent'] = Config::get('system', 'explicit_content', false) == true;
|
||||
}
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function nodeinfo_cron() {
|
||||
|
||||
$a = \get_app();
|
||||
|
||||
// If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.
|
||||
if (Addon::isEnabled('statistics_json')) {
|
||||
Config::set('system', 'nodeinfo', true);
|
||||
|
||||
$addon = 'statistics_json';
|
||||
$addons = Config::get('system', 'addon');
|
||||
|
||||
if ($addons) {
|
||||
$addons_arr = explode(',',str_replace(' ', '',$addons));
|
||||
|
||||
$idx = array_search($addon, $addons_arr);
|
||||
if ($idx !== false) {
|
||||
unset($addons_arr[$idx]);
|
||||
Addon::uninstall($addon);
|
||||
Config::set('system', 'addon', implode(', ',$addons_arr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'nodeinfo')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::log('cron_start');
|
||||
|
||||
$users = q("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
|
||||
FROM `user`
|
||||
INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`
|
||||
AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
|
||||
AND NOT `user`.`account_expired`");
|
||||
if (is_array($users)) {
|
||||
$total_users = count($users);
|
||||
$active_users_halfyear = 0;
|
||||
$active_users_monthly = 0;
|
||||
|
||||
$halfyear = time() - (180 * 24 * 60 * 60);
|
||||
$month = time() - (30 * 24 * 60 * 60);
|
||||
|
||||
foreach ($users AS $user) {
|
||||
if ((strtotime($user['login_date']) > $halfyear) ||
|
||||
(strtotime($user['last-item']) > $halfyear)) {
|
||||
++$active_users_halfyear;
|
||||
}
|
||||
if ((strtotime($user['login_date']) > $month) ||
|
||||
(strtotime($user['last-item']) > $month)) {
|
||||
++$active_users_monthly;
|
||||
}
|
||||
}
|
||||
Config::set('nodeinfo', 'total_users', $total_users);
|
||||
Config::set('nodeinfo', 'active_users_halfyear', $active_users_halfyear);
|
||||
Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly);
|
||||
|
||||
Logger::log('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, Logger::DEBUG);
|
||||
}
|
||||
|
||||
$local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
|
||||
Config::set('nodeinfo', 'local_posts', $local_posts);
|
||||
Logger::log('local_posts: ' . $local_posts, Logger::DEBUG);
|
||||
|
||||
$local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
|
||||
Config::set('nodeinfo', 'local_comments', $local_comments);
|
||||
Logger::log('local_comments: ' . $local_comments, Logger::DEBUG);
|
||||
|
||||
// Now trying to register
|
||||
$url = 'http://the-federation.info/register/'.$a->getHostName();
|
||||
Logger::log('registering url: '.$url, Logger::DEBUG);
|
||||
$ret = Network::fetchUrl($url);
|
||||
Logger::log('registering answer: '.$ret, Logger::DEBUG);
|
||||
|
||||
Logger::log('cron_end');
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/nogroup.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
|
||||
function nogroup_init(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function nogroup_content(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
||||
$a->internalRedirect('group/none');
|
||||
}
|
|
@ -28,7 +28,7 @@ function notes_content(App $a, $update = false)
|
|||
return;
|
||||
}
|
||||
|
||||
$o = Profile::getTabs($a, true);
|
||||
$o = Profile::getTabs($a, 'notes', true);
|
||||
|
||||
if (!$update) {
|
||||
$o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/notice.php
|
||||
* GNU Social -> friendica items permanent-url compatibility
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
function notice_init(App $a)
|
||||
{
|
||||
$id = $a->argv[1];
|
||||
$r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id));
|
||||
if (DBA::isResult($r)) {
|
||||
$nick = $r[0]['nickname'];
|
||||
$a->internalRedirect('display/' . $nick . '/' . $id);
|
||||
} else {
|
||||
$a->error = 404;
|
||||
notice(L10n::t('Item not found.') . EOL);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
|
@ -121,6 +121,9 @@ function notifications_content(App $a)
|
|||
} elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
|
||||
$notif_header = L10n::t('Home Notifications');
|
||||
$notifs = $nm->homeNotifs($show, $startrec, $perpage);
|
||||
// fallback - redirect to main page
|
||||
} else {
|
||||
$a->internalRedirect('notifications');
|
||||
}
|
||||
|
||||
// Set the pager
|
||||
|
@ -223,6 +226,14 @@ function notifications_content(App $a)
|
|||
'$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
|
||||
]);
|
||||
|
||||
$contact = DBA::selectFirst('contact', ['network', 'protocol'], ['id' => $notif['contact_id']]);
|
||||
|
||||
if (($contact['network'] != Protocol::DFRN) || ($contact['protocol'] == Protocol::ACTIVITYPUB)) {
|
||||
$action = 'follow_confirm';
|
||||
} else {
|
||||
$action = 'dfrn_confirm';
|
||||
}
|
||||
|
||||
$header = $notif['name'];
|
||||
|
||||
if ($notif['addr'] != '') {
|
||||
|
@ -270,6 +281,7 @@ function notifications_content(App $a)
|
|||
'$note' => $notif['note'],
|
||||
'$ignore' => L10n::t('Ignore'),
|
||||
'$discard' => $discard,
|
||||
'$action' => $action,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/notify.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\NotificationsManager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Module\Login;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
function notify_init(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nm = new NotificationsManager();
|
||||
|
||||
if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
|
||||
$note = $nm->getByID($a->argv[2]);
|
||||
if ($note) {
|
||||
$nm->setSeen($note);
|
||||
|
||||
// The friendica client has problems with the GUID. this is some workaround
|
||||
if ($a->isFriendicaApp()) {
|
||||
require_once("include/items.php");
|
||||
$urldata = parse_url($note['link']);
|
||||
$guid = basename($urldata["path"]);
|
||||
$itemdata = Item::getIdAndNickByGuid($guid, local_user());
|
||||
if ($itemdata["id"] != 0) {
|
||||
$note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
|
||||
}
|
||||
}
|
||||
|
||||
System::externalRedirect($note['link']);
|
||||
}
|
||||
|
||||
$a->internalRedirect();
|
||||
}
|
||||
|
||||
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
|
||||
$r = $nm->setAllSeen();
|
||||
$j = json_encode(['result' => ($r) ? 'success' : 'fail']);
|
||||
echo $j;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function notify_content(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$notif_content = '';
|
||||
|
||||
$nm = new NotificationsManager();
|
||||
|
||||
$notif_tpl = Renderer::getMarkupTemplate('notifications.tpl');
|
||||
|
||||
$not_tpl = Renderer::getMarkupTemplate('notify.tpl');
|
||||
|
||||
$r = $nm->getAll(['seen'=>0]);
|
||||
if (DBA::isResult($r) > 0) {
|
||||
foreach ($r as $it) {
|
||||
$notif_content .= Renderer::replaceMacros($not_tpl, [
|
||||
'$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
|
||||
'$item_image' => $it['photo'],
|
||||
'$item_text' => strip_tags(BBCode::convert($it['msg'])),
|
||||
'$item_when' => Temporal::getRelativeDate($it['date'])
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$notif_content .= L10n::t('No more system notifications.');
|
||||
}
|
||||
|
||||
$o = Renderer::replaceMacros($notif_tpl, [
|
||||
'$notif_header' => L10n::t('System Notifications'),
|
||||
'$tabs' => false, // $tabs,
|
||||
'$notif_content' => $notif_content,
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -4,10 +4,10 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Authentication;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
|
@ -52,7 +52,7 @@ function openid_content(App $a) {
|
|||
|
||||
unset($_SESSION['openid']);
|
||||
|
||||
Authentication::setAuthenticatedSessionForUser($r[0],true,true);
|
||||
Session::setAuthenticatedForUser($a, $r[0],true,true);
|
||||
|
||||
// just in case there was no return url set
|
||||
// and we fell through
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
|
||||
function opensearch_content(App $a) {
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('opensearch.tpl');
|
||||
|
||||
header("Content-type: application/opensearchdescription+xml");
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$nodename' => $a->getHostName(),
|
||||
]);
|
||||
|
||||
echo $o;
|
||||
|
||||
exit();
|
||||
}
|
|
@ -9,12 +9,14 @@
|
|||
*
|
||||
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\ParseUrl;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function parse_url_content(App $a)
|
||||
{
|
||||
|
@ -25,10 +27,14 @@ function parse_url_content(App $a)
|
|||
|
||||
$br = "\n";
|
||||
|
||||
if (!empty($_GET['binurl'])) {
|
||||
if (!empty($_GET['binurl']) && Strings::isHex($_GET['binurl'])) {
|
||||
$url = trim(hex2bin($_GET['binurl']));
|
||||
} else {
|
||||
} elseif (!empty($_GET['url'])) {
|
||||
$url = trim($_GET['url']);
|
||||
// fallback in case no url is valid
|
||||
} else {
|
||||
Logger::info('No url given');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!empty($_GET['title'])) {
|
||||
|
@ -64,9 +70,8 @@ function parse_url_content(App $a)
|
|||
|
||||
// Check if the URL is an image, video or audio file. If so format
|
||||
// the URL with the corresponding BBCode media tag
|
||||
$redirects = 0;
|
||||
// Fetch the header of the URL
|
||||
$curlResponse = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
|
||||
$curlResponse = Network::curl($url, false, ['novalidate' => true, 'nobody' => true]);
|
||||
|
||||
if ($curlResponse->isSuccess()) {
|
||||
// Convert the header fields into an array
|
||||
|
|
365
mod/photos.php
365
mod/photos.php
|
@ -29,8 +29,8 @@ use Friendica\Util\Crypto;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function photos_init(App $a) {
|
||||
|
@ -47,23 +47,21 @@ function photos_init(App $a) {
|
|||
|
||||
if ($a->argc > 1) {
|
||||
$nick = $a->argv[1];
|
||||
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||
DBA::escape($nick)
|
||||
);
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
|
||||
|
||||
if (!DBA::isResult($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->data['user'] = $user[0];
|
||||
$a->profile_uid = $user[0]['uid'];
|
||||
$a->data['user'] = $user;
|
||||
$a->profile_uid = $user['uid'];
|
||||
$is_owner = (local_user() && (local_user() == $a->profile_uid));
|
||||
|
||||
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
||||
|
||||
$account_type = Contact::getAccountType($profile);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("vcard-widget.tpl");
|
||||
$tpl = Renderer::getMarkupTemplate("widget/vcard.tpl");
|
||||
|
||||
$vcard_widget = Renderer::replaceMacros($tpl, [
|
||||
'$name' => $profile['name'],
|
||||
|
@ -115,7 +113,6 @@ function photos_init(App $a) {
|
|||
'$title' => L10n::t('Photo Albums'),
|
||||
'$recent' => L10n::t('Recent Photos'),
|
||||
'$albums' => $ret['albums'],
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'],
|
||||
'$can_post' => $can_post
|
||||
]);
|
||||
|
@ -170,12 +167,7 @@ function photos_post(App $a)
|
|||
}
|
||||
|
||||
if ($contact_id > 0) {
|
||||
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
if (DBA::exists('contact', ['id' => $contact_id, 'uid' => $page_owner_uid, 'blocked' => false, 'pending' => false])) {
|
||||
$can_post = true;
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
|
@ -196,6 +188,9 @@ function photos_post(App $a)
|
|||
}
|
||||
|
||||
if ($a->argc > 3 && $a->argv[2] === 'album') {
|
||||
if (!Strings::isHex($a->argv[3])) {
|
||||
$a->internalRedirect('photos/' . $a->data['user']['nickname'] . '/album');
|
||||
}
|
||||
$album = hex2bin($a->argv[3]);
|
||||
|
||||
if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
|
||||
|
@ -235,36 +230,12 @@ function photos_post(App $a)
|
|||
}
|
||||
|
||||
/*
|
||||
* DELETE photo album and all its photos
|
||||
* DELETE all photos filed in a given album
|
||||
*/
|
||||
|
||||
if ($_POST['dropalbum'] == L10n::t('Delete Album')) {
|
||||
// Check if we should do HTML-based delete confirmation
|
||||
if (!empty($_REQUEST['confirm'])) {
|
||||
$drop_url = $a->query_string;
|
||||
|
||||
$extra_inputs = [
|
||||
['name' => 'albumname', 'value' => $_POST['albumname']],
|
||||
];
|
||||
|
||||
$a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this photo album and all its photos?'),
|
||||
'$extra_inputs' => $extra_inputs,
|
||||
'$confirm' => L10n::t('Delete Album'),
|
||||
'$confirm_url' => $drop_url,
|
||||
'$confirm_name' => 'dropalbum', // Needed so that confirmation will bring us back into this if statement
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
|
||||
$a->error = 1; // Set $a->error so the other module functions don't execute
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($_POST['dropalbum'])) {
|
||||
$res = [];
|
||||
|
||||
// get the list of photos we are about to delete
|
||||
|
||||
if ($visitor) {
|
||||
$r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `album` = '%s'",
|
||||
intval($visitor),
|
||||
|
@ -282,77 +253,57 @@ function photos_post(App $a)
|
|||
foreach ($r as $rr) {
|
||||
$res[] = $rr['rid'];
|
||||
}
|
||||
|
||||
// remove the associated photos
|
||||
Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
|
||||
|
||||
// find and delete the corresponding item with all the comments and likes/dislikes
|
||||
Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
|
||||
|
||||
// Update the photo albums cache
|
||||
Photo::clearAlbumCache($page_owner_uid);
|
||||
notice(L10n::t('Album successfully deleted'));
|
||||
} else {
|
||||
$a->internalRedirect($_SESSION['photo_return']);
|
||||
return; // NOTREACHED
|
||||
notice(L10n::t('Album was empty.'));
|
||||
}
|
||||
}
|
||||
|
||||
$a->internalRedirect('photos/' . $a->argv[1]);
|
||||
}
|
||||
|
||||
if ($a->argc > 3 && $a->argv[2] === 'image') {
|
||||
// Check if the user has responded to a delete confirmation query for a single photo
|
||||
if (!empty($_POST['canceled'])) {
|
||||
$a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
|
||||
}
|
||||
|
||||
if (!empty($_POST['delete'])) {
|
||||
// same as above but remove single photo
|
||||
if ($visitor) {
|
||||
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => $a->argv[3]];
|
||||
|
||||
} else {
|
||||
$condition = ['uid' => local_user(), 'resource-id' => $a->argv[3]];
|
||||
}
|
||||
|
||||
// remove the associated photos
|
||||
Photo::delete(['resource-id' => $res, 'uid' => $page_owner_uid]);
|
||||
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
||||
|
||||
// find and delete the corresponding item with all the comments and likes/dislikes
|
||||
Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
|
||||
if (DBA::isResult($photo)) {
|
||||
Photo::delete(['uid' => $page_owner_uid, 'resource-id' => $photo['resource-id']]);
|
||||
|
||||
// Update the photo albums cache
|
||||
Photo::clearAlbumCache($page_owner_uid);
|
||||
Item::deleteForUser(['resource-id' => $photo['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
|
||||
|
||||
// Update the photo albums cache
|
||||
Photo::clearAlbumCache($page_owner_uid);
|
||||
notice('Successfully deleted the photo.');
|
||||
} else {
|
||||
notice('Failed to delete the photo.');
|
||||
$a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
|
||||
}
|
||||
|
||||
$a->internalRedirect('photos/' . $a->argv[1]);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
$a->internalRedirect('photos/' . $a->data['user']['nickname']);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
||||
// Check if the user has responded to a delete confirmation query for a single photo
|
||||
if ($a->argc > 2 && !empty($_REQUEST['canceled'])) {
|
||||
$a->internalRedirect($_SESSION['photo_return']);
|
||||
}
|
||||
|
||||
if ($a->argc > 2 && defaults($_POST, 'delete', '') === L10n::t('Delete Photo')) {
|
||||
|
||||
// same as above but remove single photo
|
||||
|
||||
// Check if we should do HTML-based delete confirmation
|
||||
if (!empty($_REQUEST['confirm'])) {
|
||||
$drop_url = $a->query_string;
|
||||
|
||||
$a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this photo?'),
|
||||
'$extra_inputs' => [],
|
||||
'$confirm' => L10n::t('Delete Photo'),
|
||||
'$confirm_url' => $drop_url,
|
||||
'$confirm_name' => 'delete', // Needed so that confirmation will bring us back into this if statement
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
|
||||
$a->error = 1; // Set $a->error so the other module functions don't execute
|
||||
return;
|
||||
}
|
||||
|
||||
if ($visitor) {
|
||||
$r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
|
||||
intval($visitor),
|
||||
intval($page_owner_uid),
|
||||
DBA::escape($a->argv[2])
|
||||
);
|
||||
} else {
|
||||
$r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
|
||||
intval(local_user()),
|
||||
DBA::escape($a->argv[2])
|
||||
);
|
||||
}
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
Photo::delete(['uid' => $page_owner_uid, 'resource-id' => $r[0]['resource-id']]);
|
||||
|
||||
Item::deleteForUser(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
|
||||
|
||||
// Update the photo albums cache
|
||||
Photo::clearAlbumCache($page_owner_uid);
|
||||
}
|
||||
|
||||
$a->internalRedirect('photos/' . $a->data['user']['nickname']);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
if ($a->argc > 2 && (!empty($_POST['desc']) || !empty($_POST['newtag']) || isset($_POST['albname']))) {
|
||||
|
@ -367,7 +318,7 @@ function photos_post(App $a)
|
|||
$str_group_deny = !empty($_POST['group_deny']) ? perms2str($_POST['group_deny']) : '';
|
||||
$str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : '';
|
||||
|
||||
$resource_id = $a->argv[2];
|
||||
$resource_id = $a->argv[3];
|
||||
|
||||
if (!strlen($albname)) {
|
||||
$albname = DateTimeFormat::localNow('Y');
|
||||
|
@ -470,10 +421,11 @@ function photos_post(App $a)
|
|||
|
||||
if ($item_id) {
|
||||
$item = Item::selectFirst(['tag', 'inform'], ['id' => $item_id, 'uid' => $page_owner_uid]);
|
||||
}
|
||||
if (DBA::isResult($item)) {
|
||||
$old_tag = $item['tag'];
|
||||
$old_inform = $item['inform'];
|
||||
|
||||
if (DBA::isResult($item)) {
|
||||
$old_tag = $item['tag'];
|
||||
$old_inform = $item['inform'];
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($rawtags)) {
|
||||
|
@ -493,6 +445,7 @@ function photos_post(App $a)
|
|||
foreach ($tags as $tag) {
|
||||
if (strpos($tag, '@') === 0) {
|
||||
$profile = '';
|
||||
$contact = null;
|
||||
$name = substr($tag,1);
|
||||
|
||||
if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
|
||||
|
@ -527,34 +480,26 @@ function photos_post(App $a)
|
|||
}
|
||||
|
||||
if ($tagcid) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($tagcid),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $tagcid, 'uid' => $page_owner_uid]);
|
||||
} else {
|
||||
$newname = str_replace('_',' ',$name);
|
||||
|
||||
//select someone from this user's contacts by name
|
||||
$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
|
||||
DBA::escape($newname),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
$contact = DBA::selectFirst('contact', [], ['name' => $newname, 'uid' => $page_owner_uid]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
//select someone by attag or nick and the name passed in
|
||||
$r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
|
||||
DBA::escape($name),
|
||||
DBA::escape($name),
|
||||
intval($page_owner_uid)
|
||||
$contact = DBA::selectFirst('contact', [],
|
||||
['(`attag` = ? OR `nick` = ?) AND `uid` = ?', $name, $name, $page_owner_uid],
|
||||
['order' => ['attag' => true]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$newname = $r[0]['name'];
|
||||
$profile = $r[0]['url'];
|
||||
if (DBA::isResult($contact)) {
|
||||
$newname = $contact['name'];
|
||||
$profile = $contact['url'];
|
||||
|
||||
$notify = 'cid:' . $r[0]['id'];
|
||||
$notify = 'cid:' . $contact['id'];
|
||||
if (strlen($inform)) {
|
||||
$inform .= ',';
|
||||
}
|
||||
|
@ -563,8 +508,8 @@ function photos_post(App $a)
|
|||
}
|
||||
|
||||
if ($profile) {
|
||||
if (substr($notify, 0, 4) === 'cid:') {
|
||||
$taginfo[] = [$newname, $profile, $notify, $r[0], '@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]'];
|
||||
if (!empty($contact)) {
|
||||
$taginfo[] = [$newname, $profile, $notify, $contact, '@[url=' . str_replace(',', '%2c', $profile) . ']' . $newname . '[/url]'];
|
||||
} else {
|
||||
$taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'];
|
||||
}
|
||||
|
@ -583,13 +528,13 @@ function photos_post(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
$newtag = $old_tag;
|
||||
$newtag = $old_tag ?? '';
|
||||
if (strlen($newtag) && strlen($str_tags)) {
|
||||
$newtag .= ',';
|
||||
}
|
||||
$newtag .= $str_tags;
|
||||
|
||||
$newinform = $old_inform;
|
||||
$newinform = $old_inform ?? '';
|
||||
if (strlen($newinform) && strlen($inform)) {
|
||||
$newinform .= ',';
|
||||
}
|
||||
|
@ -794,7 +739,7 @@ function photos_post(App $a)
|
|||
@unlink($src);
|
||||
$foo = 0;
|
||||
Hook::callAll('photo_post_end',$foo);
|
||||
exit();
|
||||
return;
|
||||
}
|
||||
|
||||
$exif = $image->orient($src);
|
||||
|
@ -820,7 +765,7 @@ function photos_post(App $a)
|
|||
if (!$r) {
|
||||
Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
|
||||
notice(L10n::t('Image upload failed.') . EOL);
|
||||
exit();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
|
@ -896,8 +841,10 @@ function photos_content(App $a)
|
|||
// photos/name/upload/xxxxx (xxxxx is album name)
|
||||
// photos/name/album/xxxxx
|
||||
// photos/name/album/xxxxx/edit
|
||||
// photos/name/album/xxxxx/drop
|
||||
// photos/name/image/xxxxx
|
||||
// photos/name/image/xxxxx/edit
|
||||
// photos/name/image/xxxxx/drop
|
||||
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
|
@ -936,7 +883,8 @@ function photos_content(App $a)
|
|||
$contact = null;
|
||||
$remote_contact = false;
|
||||
$contact_id = 0;
|
||||
$edit = false;
|
||||
$edit = '';
|
||||
$drop = '';
|
||||
|
||||
$owner_uid = $a->data['user']['uid'];
|
||||
|
||||
|
@ -954,15 +902,12 @@ function photos_content(App $a)
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($contact_id) {
|
||||
|
||||
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($owner_uid)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
if ($contact_id) {
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
|
||||
if (DBA::isResult($contact)) {
|
||||
$can_post = true;
|
||||
$contact = $r[0];
|
||||
$remote_contact = true;
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
|
@ -983,16 +928,13 @@ function photos_content(App $a)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($contact_id) {
|
||||
$groups = Group::getIdsByContactId($contact_id);
|
||||
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($owner_uid)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$contact = $r[0];
|
||||
$remote_contact = true;
|
||||
}
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
|
||||
$remote_contact = DBA::isResult($contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1012,7 +954,7 @@ function photos_content(App $a)
|
|||
|
||||
// tabs
|
||||
$is_owner = (local_user() && (local_user() == $owner_uid));
|
||||
$o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
|
||||
$o .= Profile::getTabs($a, 'photos', $is_owner, $a->data['user']['nickname']);
|
||||
|
||||
// Display upload form
|
||||
if ($datatype === 'upload') {
|
||||
|
@ -1021,7 +963,7 @@ function photos_content(App $a)
|
|||
return;
|
||||
}
|
||||
|
||||
$selname = $datum ? hex2bin($datum) : '';
|
||||
$selname = Strings::isHex($datum) ? hex2bin($datum) : '';
|
||||
|
||||
$albumselect = '';
|
||||
|
||||
|
@ -1088,6 +1030,10 @@ function photos_content(App $a)
|
|||
|
||||
// Display a single photo album
|
||||
if ($datatype === 'album') {
|
||||
// if $datum is not a valid hex, redirect to the default page
|
||||
if (!Strings::isHex($datum)) {
|
||||
$a->internalRedirect('photos/' . $a->data['user']['nickname']. '/album');
|
||||
}
|
||||
$album = hex2bin($datum);
|
||||
|
||||
$total = 0;
|
||||
|
@ -1121,6 +1067,24 @@ function photos_content(App $a)
|
|||
$pager->getItemsPerPage()
|
||||
);
|
||||
|
||||
if ($cmd === 'drop') {
|
||||
$drop_url = $a->query_string;
|
||||
|
||||
$extra_inputs = [
|
||||
['name' => 'albumname', 'value' => $_POST['albumname']],
|
||||
];
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this photo album and all its photos?'),
|
||||
'$extra_inputs' => $extra_inputs,
|
||||
'$confirm' => L10n::t('Delete Album'),
|
||||
'$confirm_url' => $drop_url,
|
||||
'$confirm_name' => 'dropalbum',
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
}
|
||||
|
||||
// edit album name
|
||||
if ($cmd === 'edit') {
|
||||
if (($album !== L10n::t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== L10n::t('Contact Photos'))) {
|
||||
|
@ -1142,6 +1106,7 @@ function photos_content(App $a)
|
|||
} else {
|
||||
if (($album !== L10n::t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== L10n::t('Contact Photos')) && $can_post) {
|
||||
$edit = [L10n::t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'];
|
||||
$drop = [L10n::t('Drop Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/drop'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,6 +1152,7 @@ function photos_content(App $a)
|
|||
'$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$drop' => $drop,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
|
@ -1204,12 +1170,7 @@ function photos_content(App $a)
|
|||
);
|
||||
|
||||
if (!DBA::isResult($ph)) {
|
||||
$ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
|
||||
LIMIT 1",
|
||||
intval($owner_uid),
|
||||
DBA::escape($datum)
|
||||
);
|
||||
if (DBA::isResult($ph)) {
|
||||
if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
|
||||
notice(L10n::t('Permission denied. Access to this item may be restricted.'));
|
||||
} else {
|
||||
notice(L10n::t('Photo not available') . EOL);
|
||||
|
@ -1217,6 +1178,20 @@ function photos_content(App $a)
|
|||
return;
|
||||
}
|
||||
|
||||
if ($cmd === 'drop') {
|
||||
$drop_url = $a->query_string;
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this photo?'),
|
||||
'$extra_inputs' => [],
|
||||
'$confirm' => L10n::t('Delete Photo'),
|
||||
'$confirm_url' => $drop_url,
|
||||
'$confirm_name' => 'delete',
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
}
|
||||
|
||||
$prevlink = '';
|
||||
$nextlink = '';
|
||||
|
||||
|
@ -1225,7 +1200,7 @@ function photos_content(App $a)
|
|||
* The query leads to a really intense used index.
|
||||
* By now we hide it if someone wants to.
|
||||
*/
|
||||
if (!Config::get('system', 'no_count', false)) {
|
||||
if ($cmd === 'view' && !Config::get('system', 'no_count', false)) {
|
||||
$order_field = defaults($_GET, 'order', '');
|
||||
|
||||
if ($order_field === 'posted') {
|
||||
|
@ -1256,12 +1231,26 @@ function photos_content(App $a)
|
|||
break;
|
||||
}
|
||||
}
|
||||
$edit_suffix = ((($cmd === 'edit') && $can_post) ? '/edit' : '');
|
||||
|
||||
if (!is_null($prv)) {
|
||||
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
|
||||
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
|
||||
}
|
||||
if (!is_null($nxt)) {
|
||||
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
|
||||
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl,[
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink
|
||||
]);
|
||||
|
||||
if ($prevlink) {
|
||||
$prevlink = [$prevlink, '<div class="icon prev"></div>'];
|
||||
}
|
||||
|
||||
if ($nextlink) {
|
||||
$nextlink = [$nextlink, '<div class="icon next"></div>'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1283,33 +1272,23 @@ function photos_content(App $a)
|
|||
$album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
|
||||
|
||||
$tools = null;
|
||||
$lock = null;
|
||||
|
||||
if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
|
||||
$tools = [
|
||||
'edit' => ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? L10n::t('View photo') : L10n::t('Edit photo'))],
|
||||
'profile'=>['profile_photo/use/'.$ph[0]['resource-id'], L10n::t('Use as profile photo')],
|
||||
];
|
||||
$tools = [];
|
||||
if ($cmd === 'edit') {
|
||||
$tools['view'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum, L10n::t('View photo')];
|
||||
} else {
|
||||
$tools['edit'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit', L10n::t('Edit photo')];
|
||||
$tools['delete'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/drop', L10n::t('Delete photo')];
|
||||
$tools['profile'] = ['profile_photo/use/'.$ph[0]['resource-id'], L10n::t('Use as profile photo')];
|
||||
}
|
||||
|
||||
// lock
|
||||
$lock = ((($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
|
||||
|| strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])))
|
||||
? L10n::t('Private Message')
|
||||
: Null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($cmd === 'edit') {
|
||||
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl,[
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink
|
||||
]);
|
||||
}
|
||||
|
||||
if ($prevlink) {
|
||||
$prevlink = [$prevlink, '<div class="icon prev"></div>'];
|
||||
if (
|
||||
$ph[0]['uid'] == local_user()
|
||||
&& (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
|
||||
) {
|
||||
$tools['lock'] = L10n::t('Private Photo');
|
||||
}
|
||||
}
|
||||
|
||||
$photo = [
|
||||
|
@ -1322,11 +1301,6 @@ function photos_content(App $a)
|
|||
'filename' => $hires['filename'],
|
||||
];
|
||||
|
||||
if ($nextlink) {
|
||||
$nextlink = [$nextlink, '<div class="icon next"></div>'];
|
||||
}
|
||||
|
||||
|
||||
// Do we have an item for this photo?
|
||||
|
||||
// FIXME! - replace following code to display the conversation with our normal
|
||||
|
@ -1431,7 +1405,7 @@ function photos_content(App $a)
|
|||
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
|
||||
$return_path = $a->cmd;
|
||||
|
||||
if ($can_post || Security::canWriteToUserWall($owner_uid)) {
|
||||
if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
|
||||
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
|
||||
$likebuttons = Renderer::replaceMacros($like_tpl, [
|
||||
'$id' => $link_item['id'],
|
||||
|
@ -1510,7 +1484,7 @@ function photos_content(App $a)
|
|||
continue;
|
||||
}
|
||||
|
||||
$profile_url = Contact::MagicLinkById($item['author-id']);
|
||||
$profile_url = Contact::magicLinkbyId($item['author-id']);
|
||||
if (strpos($profile_url, 'redir/') === 0) {
|
||||
$sparkle = ' sparkle';
|
||||
} else {
|
||||
|
@ -1537,7 +1511,7 @@ function photos_content(App $a)
|
|||
'$title' => $title_e,
|
||||
'$body' => $body_e,
|
||||
'$ago' => Temporal::getRelativeDate($item['created']),
|
||||
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
|
||||
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
|
||||
'$drop' => $drop,
|
||||
'$comment' => $comment
|
||||
]);
|
||||
|
@ -1546,7 +1520,7 @@ function photos_content(App $a)
|
|||
$comments .= Renderer::replaceMacros($cmnt_tpl, [
|
||||
'$return_path' => '',
|
||||
'$jsreload' => $return_path,
|
||||
'$id' => $item['item_id'],
|
||||
'$id' => $item['id'],
|
||||
'$parent' => $item['parent'],
|
||||
'$profile_uid' => $owner_uid,
|
||||
'$mylink' => $contact['url'],
|
||||
|
@ -1574,7 +1548,6 @@ function photos_content(App $a)
|
|||
'$id' => $ph[0]['id'],
|
||||
'$album' => [$album_link, $ph[0]['album']],
|
||||
'$tools' => $tools,
|
||||
'$lock' => $lock,
|
||||
'$photo' => $photo,
|
||||
'$prevlink' => $prevlink,
|
||||
'$nextlink' => $nextlink,
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/phpinfo.php
|
||||
*/
|
||||
|
||||
function phpinfo_content()
|
||||
{
|
||||
if (!is_site_admin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
phpinfo();
|
||||
exit();
|
||||
}
|
|
@ -313,14 +313,7 @@ function ping_init(App $a)
|
|||
usort($notifs, $sort_function);
|
||||
|
||||
if (DBA::isResult($notifs)) {
|
||||
// Are the nofications called from the regular process or via the friendica app?
|
||||
$regularnotifications = (!empty($_GET['uid']) && !empty($_GET['_']));
|
||||
|
||||
foreach ($notifs as $notif) {
|
||||
if ($a->isFriendicaApp() || !$regularnotifications) {
|
||||
$notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
|
||||
}
|
||||
|
||||
$contact = Contact::getDetailsByURL($notif['url']);
|
||||
if (isset($contact['micro'])) {
|
||||
$notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO);
|
||||
|
|
11
mod/poco.php
11
mod/poco.php
|
@ -22,7 +22,7 @@ function poco_init(App $a) {
|
|||
$system_mode = false;
|
||||
|
||||
if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) {
|
||||
System::httpExit(401);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
if ($a->argc > 1) {
|
||||
|
@ -31,7 +31,7 @@ function poco_init(App $a) {
|
|||
if (empty($nickname)) {
|
||||
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
|
||||
if (!DBA::isResult($c)) {
|
||||
System::httpExit(401);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
$system_mode = true;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ function poco_init(App $a) {
|
|||
DBA::escape($nickname)
|
||||
);
|
||||
if (! DBA::isResult($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$user = $users[0];
|
||||
|
@ -371,8 +371,9 @@ function poco_init(App $a) {
|
|||
$ret['entry'][] = [];
|
||||
}
|
||||
} else {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
|
||||
Logger::log("End of poco", Logger::DEBUG);
|
||||
|
||||
if ($format === 'xml') {
|
||||
|
@ -385,6 +386,6 @@ function poco_init(App $a) {
|
|||
echo json_encode($ret);
|
||||
exit();
|
||||
} else {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,15 +154,11 @@ function poke_content(App $a)
|
|||
$name = $contact['name'];
|
||||
$id = $contact['id'];
|
||||
|
||||
$base = System::baseUrl();
|
||||
|
||||
$head_tpl = Renderer::getMarkupTemplate('poke_head.tpl');
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($head_tpl,[
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$base' => $base
|
||||
]);
|
||||
|
||||
|
||||
$parent = (!empty($_GET['parent']) ? intval($_GET['parent']) : '0');
|
||||
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Theme;
|
||||
|
||||
function pretheme_init(App $a) {
|
||||
|
||||
if ($_REQUEST['theme']) {
|
||||
$theme = $_REQUEST['theme'];
|
||||
$info = Theme::getInfo($theme);
|
||||
if ($info) {
|
||||
// unfortunately there will be no translation for this string
|
||||
$desc = $info['description'];
|
||||
$version = $info['version'];
|
||||
$credits = $info['credits'];
|
||||
} else {
|
||||
$desc = '';
|
||||
$version = '';
|
||||
$credits = '';
|
||||
}
|
||||
echo json_encode(['img' => Theme::getScreenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/probe.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Network\Probe;
|
||||
|
||||
function probe_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
System::httpExit(403, ["title" => L10n::t("Public access denied."),
|
||||
"description" => L10n::t("Only logged in users are permitted to perform a probing.")]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$o = '<div class="generic-page-wrapper">';
|
||||
$o .= '<h3>Probe Diagnostic</h3>';
|
||||
|
||||
$o .= '<form action="probe" method="get">';
|
||||
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . defaults($_GET, 'addr', '') . '" />';
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
if (!empty($_GET['addr'])) {
|
||||
$addr = trim($_GET['addr']);
|
||||
$res = Probe::uri($addr, "", 0, false);
|
||||
$o .= '<pre>';
|
||||
$o .= str_replace("\n", '<br />', print_r($res, true));
|
||||
$o .= '</pre>';
|
||||
}
|
||||
$o .= '</div>';
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -12,10 +12,9 @@ use Friendica\Core\System;
|
|||
function hub_return($valid, $body)
|
||||
{
|
||||
if ($valid) {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . ' 200 OK');
|
||||
echo $body;
|
||||
} else {
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
@ -24,7 +23,7 @@ function hub_return($valid, $body)
|
|||
|
||||
function hub_post_return()
|
||||
{
|
||||
System::httpExit(200);
|
||||
throw new \Friendica\Network\HTTPException\OKException();
|
||||
}
|
||||
|
||||
function pubsub_init(App $a)
|
||||
|
|
|
@ -17,7 +17,7 @@ function pubsubhubbub_init(App $a) {
|
|||
// PuSH subscription must be considered "public" so just block it
|
||||
// if public access isn't enabled.
|
||||
if (Config::get('system', 'block_public')) {
|
||||
System::httpExit(403);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
// Subscription request from subscriber
|
||||
|
@ -44,7 +44,7 @@ function pubsubhubbub_init(App $a) {
|
|||
$subscribe = 0;
|
||||
} else {
|
||||
Logger::log("Invalid hub_mode=$hub_mode, ignoring.");
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
|
||||
|
@ -61,7 +61,7 @@ function pubsubhubbub_init(App $a) {
|
|||
|
||||
if (!$nick) {
|
||||
Logger::log('Bad hub_topic=$hub_topic, ignoring.');
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// fetch user from database given the nickname
|
||||
|
@ -69,13 +69,13 @@ function pubsubhubbub_init(App $a) {
|
|||
$owner = DBA::selectFirst('user', ['uid', 'hidewall', 'nickname'], $condition);
|
||||
if (!DBA::isResult($owner)) {
|
||||
Logger::log('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// abort if user's wall is supposed to be private
|
||||
if ($owner['hidewall']) {
|
||||
Logger::log('Local user ' . $nick . 'has chosen to hide wall, ignoring.');
|
||||
System::httpExit(403);
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
// get corresponding row from contact table
|
||||
|
@ -84,7 +84,7 @@ function pubsubhubbub_init(App $a) {
|
|||
$contact = DBA::selectFirst('contact', ['poll'], $condition);
|
||||
if (!DBA::isResult($contact)) {
|
||||
Logger::log('Self contact for user ' . $owner['uid'] . ' not found.');
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// sanity check that topic URLs are the same
|
||||
|
@ -93,7 +93,7 @@ function pubsubhubbub_init(App $a) {
|
|||
|
||||
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
|
||||
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// do subscriber verification according to the PuSH protocol
|
||||
|
@ -121,19 +121,19 @@ function pubsubhubbub_init(App $a) {
|
|||
// give up if the HTTP return code wasn't a success (2xx)
|
||||
if ($ret < 200 || $ret > 299) {
|
||||
Logger::log("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring.");
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
// check that the correct hub_challenge code was echoed back
|
||||
if (trim($body) !== $hub_challenge) {
|
||||
Logger::log("Subscriber did not echo back hub.challenge, ignoring.");
|
||||
Logger::log("\"$hub_challenge\" != \"".trim($body)."\"");
|
||||
System::httpExit(404);
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
PushSubscriber::renew($owner['uid'], $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret);
|
||||
|
||||
System::httpExit(202);
|
||||
throw new \Friendica\Network\HTTPException\AcceptedException();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/randprof.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
|
||||
function randprof_init(App $a)
|
||||
{
|
||||
$x = GContact::getRandomUrl();
|
||||
|
||||
if ($x) {
|
||||
$link = Contact::magicLink($x);
|
||||
$a->redirect($link);
|
||||
}
|
||||
|
||||
$a->internalRedirect('profile');
|
||||
}
|
|
@ -22,7 +22,7 @@ function receive_post(App $a)
|
|||
$enabled = intval(Config::get('system', 'diaspora_enabled'));
|
||||
if (!$enabled) {
|
||||
Logger::log('mod-diaspora: disabled');
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
|
||||
if (($a->argc == 2) && ($a->argv[1] === 'public')) {
|
||||
|
@ -32,13 +32,13 @@ function receive_post(App $a)
|
|||
$public = false;
|
||||
|
||||
if ($a->argc != 3 || $a->argv[1] !== 'users') {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
$guid = $a->argv[2];
|
||||
|
||||
$importer = DBA::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
|
||||
if (!DBA::isResult($importer)) {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ function receive_post(App $a)
|
|||
if (empty($_POST['xml'])) {
|
||||
$postdata = file_get_contents("php://input");
|
||||
if ($postdata == '') {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
|
||||
Logger::log('mod-diaspora: message is in the new format', Logger::DEBUG);
|
||||
|
@ -71,7 +71,7 @@ function receive_post(App $a)
|
|||
Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), Logger::DATA);
|
||||
|
||||
if (!is_array($msg)) {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
|
||||
Logger::log('mod-diaspora: dispatching', Logger::DEBUG);
|
||||
|
@ -83,6 +83,9 @@ function receive_post(App $a)
|
|||
$ret = Diaspora::dispatch($importer, $msg);
|
||||
}
|
||||
|
||||
System::httpExit(($ret) ? 200 : 500);
|
||||
// NOTREACHED
|
||||
if ($ret) {
|
||||
throw new \Friendica\Network\HTTPException\OKException();
|
||||
} else {
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function redir_init(App $a) {
|
||||
|
||||
|
@ -70,7 +71,9 @@ function redir_init(App $a) {
|
|||
&& is_array($_SESSION['remote']))
|
||||
{
|
||||
foreach ($_SESSION['remote'] as $v) {
|
||||
if ($v['uid'] == $_SESSION['visitor_visiting'] && $v['cid'] == $_SESSION['visitor_id']) {
|
||||
if (!empty($v['uid']) && !empty($v['cid']) &&
|
||||
$v['uid'] == Session::get('visitor_visiting') &&
|
||||
$v['cid'] == Session::get('visitor_id')) {
|
||||
// Remote user is already authenticated.
|
||||
$target_url = defaults($url, $contact_url);
|
||||
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/robots_text.php
|
||||
* @brief Module which returns the default robots.txt
|
||||
* @version 0.1.2
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
|
||||
/**
|
||||
* @brief Return default robots.txt when init
|
||||
* @param App $a
|
||||
* @return void
|
||||
*/
|
||||
function robots_txt_init(App $a)
|
||||
{
|
||||
$allDisalloweds = [
|
||||
'/settings/',
|
||||
'/admin/',
|
||||
'/message/',
|
||||
];
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
echo 'User-agent: *' . PHP_EOL;
|
||||
foreach ($allDisalloweds as $disallowed) {
|
||||
echo 'Disallow: ' . $disallowed . PHP_EOL;
|
||||
}
|
||||
exit();
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
|
||||
function rsd_xml_content(App $a)
|
||||
{
|
||||
header ("Content-Type: text/xml");
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
|
||||
<service>
|
||||
<engineName>Friendica</engineName>
|
||||
<engineLink>http://friendica.com/</engineLink>
|
||||
<apis>
|
||||
<api name="Twitter" preferred="true" apiLink="'.System::baseUrl().'/api/" blogID="">
|
||||
<settings>
|
||||
<docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
|
||||
<setting name="OAuth">false</setting>
|
||||
</settings>
|
||||
</api>
|
||||
</apis>
|
||||
</service>
|
||||
</rsd>';
|
||||
|
||||
exit();
|
||||
}
|
|
@ -28,7 +28,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
DBA::escape($nick)
|
||||
);
|
||||
if (! DBA::isResult($r)) {
|
||||
System::httpExit(500);
|
||||
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
|
||||
}
|
||||
|
||||
$importer = $r[0];
|
||||
|
@ -49,7 +49,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
|
||||
if (empty($base)) {
|
||||
Logger::log('unable to locate salmon data in xml ');
|
||||
System::httpExit(400);
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// Stash the signature away for now. We have to find their key or it won't be good for anything.
|
||||
|
@ -87,7 +87,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
|
||||
if(! $author_link) {
|
||||
Logger::log('Could not retrieve author URI.');
|
||||
System::httpExit(400);
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// Once we have the author URI, go to the web and try to find their public key
|
||||
|
@ -98,7 +98,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
|
||||
if(! $key) {
|
||||
Logger::log('Could not retrieve author key.');
|
||||
System::httpExit(400);
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
$key_info = explode('.',$key);
|
||||
|
@ -130,7 +130,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
|
||||
if (! $verify) {
|
||||
Logger::log('Message did not verify. Discarding.');
|
||||
System::httpExit(400);
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
Logger::log('Message verified with mode '.$mode);
|
||||
|
@ -177,8 +177,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
//if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
|
||||
if (DBA::isResult($r) && $r[0]['blocked']) {
|
||||
Logger::log('Ignoring this author.');
|
||||
System::httpExit(202);
|
||||
// NOTREACHED
|
||||
throw new \Friendica\Network\HTTPException\AcceptedException();
|
||||
}
|
||||
|
||||
// Placeholder for hub discovery.
|
||||
|
@ -188,5 +187,5 @@ function salmon_post(App $a, $xml = '') {
|
|||
|
||||
OStatus::import($data, $importer, $contact_rec, $hub);
|
||||
|
||||
System::httpExit(200);
|
||||
throw new \Friendica\Network\HTTPException\OKException();
|
||||
}
|
||||
|
|
|
@ -12,13 +12,11 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Module\BaseSearchModule;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
require_once 'mod/dirfind.php';
|
||||
|
||||
function search_saved_searches() {
|
||||
|
||||
$o = '';
|
||||
|
@ -98,12 +96,9 @@ function search_content(App $a) {
|
|||
}
|
||||
|
||||
if (Config::get('system','local_search') && !local_user() && !remote_user()) {
|
||||
System::httpExit(403,
|
||||
["title" => L10n::t("Public access denied."),
|
||||
"description" => L10n::t("Only logged in users are permitted to perform a search.")]);
|
||||
exit();
|
||||
//notice(L10n::t('Public access denied.').EOL);
|
||||
//return;
|
||||
$e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a search."));
|
||||
$e->httpdesc = L10n::t("Public access denied.");
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
|
||||
|
@ -123,10 +118,7 @@ function search_content(App $a) {
|
|||
if (!is_null($result)) {
|
||||
$resultdata = json_decode($result);
|
||||
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
|
||||
System::httpExit(429,
|
||||
["title" => L10n::t("Too Many Requests"),
|
||||
"description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
|
||||
exit();
|
||||
throw new \Friendica\Network\HTTPException\TooManyRequestsException(L10n::t("Only one search per minute is permitted for not logged in users."));
|
||||
}
|
||||
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
|
||||
} else
|
||||
|
@ -156,10 +148,10 @@ function search_content(App $a) {
|
|||
$search = substr($search,1);
|
||||
}
|
||||
if (strpos($search,'@') === 0) {
|
||||
return dirfind_content($a);
|
||||
return BaseSearchModule::performSearch();
|
||||
}
|
||||
if (strpos($search,'!') === 0) {
|
||||
return dirfind_content($a);
|
||||
return BaseSearchModule::performSearch();
|
||||
}
|
||||
|
||||
if (!empty($_GET['search-option']))
|
||||
|
@ -170,11 +162,9 @@ function search_content(App $a) {
|
|||
$tag = true;
|
||||
break;
|
||||
case 'contacts':
|
||||
return dirfind_content($a, "@");
|
||||
break;
|
||||
return BaseSearchModule::performSearch('@');
|
||||
case 'forums':
|
||||
return dirfind_content($a, "!");
|
||||
break;
|
||||
return BaseSearchModule::performSearch('!');
|
||||
}
|
||||
|
||||
if (!$search)
|
||||
|
|
|
@ -27,9 +27,12 @@ use Friendica\Protocol\Email;
|
|||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
function get_theme_config_file($theme)
|
||||
{
|
||||
$theme = Strings::sanitizeFilePathItem($theme);
|
||||
|
||||
$a = \get_app();
|
||||
$base_theme = defaults($a->theme_info, 'extends');
|
||||
|
||||
|
@ -65,6 +68,13 @@ function settings_init(App $a)
|
|||
],
|
||||
];
|
||||
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Two-factor authentication'),
|
||||
'url' => 'settings/2fa',
|
||||
'selected' => (($a->argc > 1) && ($a->argv[1] === '2fa') ? 'active' : ''),
|
||||
'accesskey' => 'o',
|
||||
];
|
||||
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Profiles'),
|
||||
'url' => 'profiles',
|
||||
|
@ -380,7 +390,7 @@ function settings_post(App $a)
|
|||
BaseModule::checkFormSecurityTokenRedirectOnError('/settings', 'settings');
|
||||
|
||||
if (!empty($_POST['resend_relocate'])) {
|
||||
Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', local_user());
|
||||
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
|
||||
info(L10n::t("Relocate message has been send to your contacts"));
|
||||
$a->internalRedirect('settings');
|
||||
}
|
||||
|
@ -877,40 +887,30 @@ function settings_content(App $a)
|
|||
$default_mobile_theme = 'none';
|
||||
}
|
||||
|
||||
$allowed_themes_str = Config::get('system', 'allowed_themes');
|
||||
$allowed_themes_raw = explode(',', $allowed_themes_str);
|
||||
$allowed_themes = [];
|
||||
if (count($allowed_themes_raw)) {
|
||||
foreach ($allowed_themes_raw as $x) {
|
||||
if (strlen(trim($x)) && is_dir("view/theme/$x")) {
|
||||
$allowed_themes[] = trim($x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
|
||||
$themes = [];
|
||||
$mobile_themes = ["---" => L10n::t('No special theme for mobile devices')];
|
||||
if ($allowed_themes) {
|
||||
foreach ($allowed_themes as $theme) {
|
||||
$is_experimental = file_exists('view/theme/' . $theme . '/experimental');
|
||||
$is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
|
||||
$is_mobile = file_exists('view/theme/' . $theme . '/mobile');
|
||||
if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) {
|
||||
$theme_name = ucfirst($theme);
|
||||
if ($is_unsupported) {
|
||||
$theme_name = L10n::t("%s - \x28Unsupported\x29", $theme_name);
|
||||
} elseif ($is_experimental) {
|
||||
$theme_name = L10n::t("%s - \x28Experimental\x29", $theme_name);
|
||||
}
|
||||
if ($is_mobile) {
|
||||
$mobile_themes[$theme] = $theme_name;
|
||||
} else {
|
||||
$themes[$theme] = $theme_name;
|
||||
}
|
||||
foreach ($allowed_themes as $theme) {
|
||||
$is_experimental = file_exists('view/theme/' . $theme . '/experimental');
|
||||
$is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
|
||||
$is_mobile = file_exists('view/theme/' . $theme . '/mobile');
|
||||
if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) {
|
||||
$theme_name = ucfirst($theme);
|
||||
if ($is_unsupported) {
|
||||
$theme_name = L10n::t('%s - (Unsupported)', $theme_name);
|
||||
} elseif ($is_experimental) {
|
||||
$theme_name = L10n::t('%s - (Experimental)', $theme_name);
|
||||
}
|
||||
|
||||
if ($is_mobile) {
|
||||
$mobile_themes[$theme] = $theme_name;
|
||||
} else {
|
||||
$themes[$theme] = $theme_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$theme_selected = defaults($_SESSION, 'theme' , $default_theme);
|
||||
$mobile_theme_selected = defaults($_SESSION, 'mobile-theme', $default_mobile_theme);
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/smilies.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Smilies;
|
||||
use Friendica\Core\System;
|
||||
|
||||
/**
|
||||
* @param App $a App
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
function smilies_content(App $a)
|
||||
{
|
||||
$smilies = Smilies::getList();
|
||||
if (!empty($a->argv[1]) && ($a->argv[1] === "json")) {
|
||||
$results = [];
|
||||
for ($i = 0; $i < count($smilies['texts']); $i++) {
|
||||
$results[] = ['text' => $smilies['texts'][$i], 'icon' => $smilies['icons'][$i]];
|
||||
}
|
||||
System::jsonExit($results);
|
||||
} else {
|
||||
$s = '<div class="smiley-sample">';
|
||||
for ($x = 0; $x < count($smilies['texts']); $x ++) {
|
||||
$s .= '<dl><dt>' . $smilies['texts'][$x] . '</dt><dd>' . $smilies['icons'][$x] . '</dd></dl>';
|
||||
}
|
||||
$s .= '</div>';
|
||||
|
||||
return $s;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/starred.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
function starred_init(App $a) {
|
||||
$starred = 0;
|
||||
$message_id = null;
|
||||
|
||||
if (!local_user()) {
|
||||
exit();
|
||||
}
|
||||
if ($a->argc > 1) {
|
||||
$message_id = intval($a->argv[1]);
|
||||
}
|
||||
if (!$message_id) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $message_id]);
|
||||
if (!DBA::isResult($item)) {
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!intval($item['starred'])) {
|
||||
$starred = 1;
|
||||
}
|
||||
|
||||
Item::update(['starred' => $starred], ['id' => $message_id]);
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
$return_path = defaults($_REQUEST, 'return', '');
|
||||
if ($return_path) {
|
||||
$rand = '_=' . time();
|
||||
if (strpos($return_path, '?')) {
|
||||
$rand = "&$rand";
|
||||
} else {
|
||||
$rand = "?$rand";
|
||||
}
|
||||
|
||||
$a->internalRedirect($return_path . $rand);
|
||||
}
|
||||
|
||||
// the json doesn't really matter, it will either be 0 or 1
|
||||
|
||||
echo json_encode($starred);
|
||||
exit();
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/statistics_json.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
|
||||
function statistics_json_init(App $a) {
|
||||
|
||||
if (!Config::get("system", "nodeinfo")) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$registration_open =
|
||||
intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED
|
||||
&& ! Config::get('config', 'invitation_only');
|
||||
|
||||
$statistics = [
|
||||
"name" => Config::get('config', 'sitename'),
|
||||
"network" => FRIENDICA_PLATFORM,
|
||||
"version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
|
||||
"registrations_open" => $registration_open,
|
||||
"total_users" => Config::get('nodeinfo', 'total_users'),
|
||||
"active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
|
||||
"active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),
|
||||
"local_posts" => Config::get('nodeinfo', 'local_posts')
|
||||
];
|
||||
|
||||
$statistics["services"] = [];
|
||||
$statistics["services"]["appnet"] = Addon::isEnabled("appnet");
|
||||
$statistics["services"]["blogger"] = Addon::isEnabled("blogger");
|
||||
$statistics["services"]["buffer"] = Addon::isEnabled("buffer");
|
||||
$statistics["services"]["dreamwidth"] = Addon::isEnabled("dwpost");
|
||||
$statistics["services"]["gnusocial"] = Addon::isEnabled("statusnet");
|
||||
$statistics["services"]["libertree"] = Addon::isEnabled("libertree");
|
||||
$statistics["services"]["livejournal"] = Addon::isEnabled("ljpost");
|
||||
$statistics["services"]["pumpio"] = Addon::isEnabled("pumpio");
|
||||
$statistics["services"]["twitter"] = Addon::isEnabled("twitter");
|
||||
$statistics["services"]["tumblr"] = Addon::isEnabled("tumblr");
|
||||
$statistics["services"]["wordpress"] = Addon::isEnabled("wppost");
|
||||
|
||||
$statistics["appnet"] = $statistics["services"]["appnet"];
|
||||
$statistics["blogger"] = $statistics["services"]["blogger"];
|
||||
$statistics["buffer"] = $statistics["services"]["buffer"];
|
||||
$statistics["dreamwidth"] = $statistics["services"]["dreamwidth"];
|
||||
$statistics["gnusocial"] = $statistics["services"]["gnusocial"];
|
||||
$statistics["libertree"] = $statistics["services"]["libertree"];
|
||||
$statistics["livejournal"] = $statistics["services"]["livejournal"];
|
||||
$statistics["pumpio"] = $statistics["services"]["pumpio"];
|
||||
$statistics["twitter"] = $statistics["services"]["twitter"];
|
||||
$statistics["tumblr"] = $statistics["services"]["tumblr"];
|
||||
$statistics["wordpress"] = $statistics["services"]["wordpress"];
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
Logger::log("statistics_init: printed " . print_r($statistics, true), Logger::DATA);
|
||||
exit();
|
||||
}
|
|
@ -87,7 +87,7 @@ function subthread_content(App $a) {
|
|||
|
||||
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
|
||||
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
|
||||
$link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
|
||||
$link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $item['guid'] . '" />' . "\n");
|
||||
$body = $item['body'];
|
||||
|
||||
$obj = <<< EOT
|
||||
|
@ -128,7 +128,7 @@ EOT;
|
|||
|
||||
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
||||
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||
$plink = '[url=' . System::baseUrl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
|
||||
$plink = '[url=' . System::baseUrl() . '/display/' . $item['guid'] . ']' . $post_type . '[/url]';
|
||||
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
|
||||
|
||||
$arr['verb'] = $activity;
|
||||
|
|
|
@ -19,39 +19,16 @@ function suggest_init(App $a)
|
|||
if (! local_user()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['ignore'])) {
|
||||
// Check if we should do HTML-based delete confirmation
|
||||
if ($_REQUEST['confirm']) {
|
||||
// <form> can't take arguments in its "action" parameter
|
||||
// so add any arguments as hidden inputs
|
||||
$query = explode_querystring($a->query_string);
|
||||
$inputs = [];
|
||||
foreach ($query['args'] as $arg) {
|
||||
if (strpos($arg, 'confirm=') === false) {
|
||||
$arg_parts = explode('=', $arg);
|
||||
$inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
|
||||
}
|
||||
}
|
||||
|
||||
$a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'get',
|
||||
'$message' => L10n::t('Do you really want to delete this suggestion?'),
|
||||
'$extra_inputs' => $inputs,
|
||||
'$confirm' => L10n::t('Yes'),
|
||||
'$confirm_url' => $query['base'],
|
||||
'$confirm_name' => 'confirmed',
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
$a->error = 1; // Set $a->error so the other module functions don't execute
|
||||
return;
|
||||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!$_REQUEST['canceled']) {
|
||||
DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
|
||||
}
|
||||
function suggest_post(App $a)
|
||||
{
|
||||
if (!empty($_POST['ignore']) && !empty($_POST['confirm'])) {
|
||||
DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_POST['ignore']]);
|
||||
notice(L10n::t('Contact suggestion successfully ignored.'));
|
||||
}
|
||||
|
||||
$a->internalRedirect('suggest');
|
||||
}
|
||||
|
||||
function suggest_content(App $a)
|
||||
|
@ -76,11 +53,34 @@ function suggest_content(App $a)
|
|||
return $o;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($_GET['ignore'])) {
|
||||
// <form> can't take arguments in its "action" parameter
|
||||
// so add any arguments as hidden inputs
|
||||
$query = explode_querystring($a->query_string);
|
||||
$inputs = [];
|
||||
foreach ($query['args'] as $arg) {
|
||||
if (strpos($arg, 'confirm=') === false) {
|
||||
$arg_parts = explode('=', $arg);
|
||||
$inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
|
||||
}
|
||||
}
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this suggestion?'),
|
||||
'$extra_inputs' => $inputs,
|
||||
'$confirm' => L10n::t('Yes'),
|
||||
'$confirm_url' => $query['base'],
|
||||
'$confirm_name' => 'confirm',
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
]);
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
$entries = [];
|
||||
|
||||
foreach ($r as $rr) {
|
||||
|
||||
$connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
|
||||
$ignlnk = System::baseUrl() . '/suggest?ignore=' . $rr['id'];
|
||||
$photo_menu = [
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
function tagger_content(App $a) {
|
||||
|
||||
|
@ -40,14 +41,12 @@ function tagger_content(App $a) {
|
|||
}
|
||||
|
||||
$owner_uid = $item['uid'];
|
||||
$owner_nick = '';
|
||||
$blocktags = 0;
|
||||
|
||||
$r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
|
||||
$r = q("select `blocktags` from user where uid = %d limit 1",
|
||||
intval($owner_uid)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$owner_nick = $r[0]['nickname'];
|
||||
$blocktags = $r[0]['blocktags'];
|
||||
}
|
||||
|
||||
|
@ -69,12 +68,7 @@ function tagger_content(App $a) {
|
|||
$xterm = XML::escape($term);
|
||||
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
|
||||
$targettype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
|
||||
|
||||
if ($owner_nick) {
|
||||
$href = System::baseUrl() . '/display/' . $owner_nick . '/' . $item['id'];
|
||||
} else {
|
||||
$href = System::baseUrl() . '/display/' . $item['guid'];
|
||||
}
|
||||
$href = System::baseUrl() . '/display/' . $item['guid'];
|
||||
|
||||
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
|
||||
|
||||
|
@ -201,7 +195,7 @@ EOT;
|
|||
|
||||
Hook::callAll('post_local_end', $arr);
|
||||
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "tag", $post_id);
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post_id);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
|
||||
function toggle_mobile_init(App $a) {
|
||||
|
||||
if (isset($_GET['off'])) {
|
||||
$_SESSION['show-mobile'] = false;
|
||||
} else {
|
||||
$_SESSION['show-mobile'] = true;
|
||||
}
|
||||
|
||||
if (isset($_GET['address'])) {
|
||||
$address = $_GET['address'];
|
||||
} else {
|
||||
$address = '';
|
||||
}
|
||||
|
||||
$a->redirect($address);
|
||||
}
|
|
@ -2,20 +2,27 @@
|
|||
/**
|
||||
* @file mod/uexport.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
|
||||
function uexport_init(App $a) {
|
||||
/// @todo Don't forget to move this global field as static field in src/Modules
|
||||
global $dbStructure;
|
||||
|
||||
if (!local_user()) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once("mod/settings.php");
|
||||
settings_init($a);
|
||||
|
||||
$dbStructure = DBStructure::definition($a->getBasePath());
|
||||
}
|
||||
|
||||
function uexport_content(App $a) {
|
||||
|
@ -49,20 +56,31 @@ function uexport_content(App $a) {
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate("uexport.tpl");
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$title' => L10n::t('Export personal data'),
|
||||
'$options' => $options
|
||||
]);
|
||||
}
|
||||
|
||||
function _uexport_multirow($query) {
|
||||
global $dbStructure;
|
||||
|
||||
preg_match("/\s+from\s+`?([a-z\d_]+)`?/i", $query, $match);
|
||||
$table = $match[1];
|
||||
|
||||
$result = [];
|
||||
$r = q($query);
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $rr) {
|
||||
$p = [];
|
||||
foreach ($rr as $k => $v) {
|
||||
$p[$k] = $v;
|
||||
switch ($dbStructure[$table]['fields'][$k]['type']) {
|
||||
case 'datetime':
|
||||
$p[$k] = $v ?? DBA::NULL_DATETIME;
|
||||
break;
|
||||
default:
|
||||
$p[$k] = $v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result[] = $p;
|
||||
}
|
||||
|
@ -71,12 +89,25 @@ function _uexport_multirow($query) {
|
|||
}
|
||||
|
||||
function _uexport_row($query) {
|
||||
global $dbStructure;
|
||||
|
||||
preg_match("/\s+from\s+`?([a-z\d_]+)`?/i", $query, $match);
|
||||
$table = $match[1];
|
||||
|
||||
$result = [];
|
||||
$r = q($query);
|
||||
if (DBA::isResult($r)) {
|
||||
|
||||
foreach ($r as $rr) {
|
||||
foreach ($rr as $k => $v) {
|
||||
$result[$k] = $v;
|
||||
switch ($dbStructure[$table]['fields'][$k]['type']) {
|
||||
case 'datetime':
|
||||
$result[$k] = $v ?? DBA::NULL_DATETIME;
|
||||
break;
|
||||
default:
|
||||
$result[$k] = $v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ function videos_init(App $a)
|
|||
|
||||
$account_type = Contact::getAccountType($profile);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("vcard-widget.tpl");
|
||||
$tpl = Renderer::getMarkupTemplate("widget/vcard.tpl");
|
||||
|
||||
$vcard_widget = Renderer::replaceMacros($tpl, [
|
||||
'$name' => $profile['name'],
|
||||
|
@ -67,9 +67,7 @@ function videos_init(App $a)
|
|||
$a->page['aside'] .= $vcard_widget;
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("videos_head.tpl");
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl,[
|
||||
'$baseurl' => System::baseUrl(),
|
||||
]);
|
||||
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -84,33 +82,6 @@ function videos_post(App $a)
|
|||
}
|
||||
|
||||
if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
|
||||
// Check if we should do HTML-based delete confirmation
|
||||
if (empty($_REQUEST['confirm'])) {
|
||||
if (!empty($_REQUEST['canceled'])) {
|
||||
$a->internalRedirect('videos/' . $a->data['user']['nickname']);
|
||||
}
|
||||
|
||||
$drop_url = $a->query_string;
|
||||
|
||||
$a->page['content'] = Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
|
||||
'$method' => 'post',
|
||||
'$message' => L10n::t('Do you really want to delete this video?'),
|
||||
'$extra_inputs' => [
|
||||
['name' => 'id' , 'value' => $_POST['id']],
|
||||
['name' => 'delete', 'value' => 'x']
|
||||
],
|
||||
'$confirm' => L10n::t('Delete Video'),
|
||||
'$confirm_url' => $drop_url,
|
||||
'$confirm_name' => 'confirm', // Needed so that confirmation will bring us back into this if statement
|
||||
'$cancel' => L10n::t('Cancel'),
|
||||
|
||||
]);
|
||||
|
||||
$a->error = 1; // Set $a->error so the other module functions don't execute
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$video_id = $_POST['id'];
|
||||
|
||||
if (Attach::exists(['id' => $video_id, 'uid' => local_user()])) {
|
||||
|
@ -246,7 +217,7 @@ function videos_content(App $a)
|
|||
|
||||
// tabs
|
||||
$_is_owner = (local_user() && (local_user() == $owner_uid));
|
||||
$o .= Profile::getTabs($a, $_is_owner, $a->data['user']['nickname']);
|
||||
$o .= Profile::getTabs($a, 'videos', $_is_owner, $a->data['user']['nickname']);
|
||||
|
||||
//
|
||||
// dispatch request
|
||||
|
|
23
mod/view.php
23
mod/view.php
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
|
||||
/**
|
||||
* load view/theme/$current_theme/style.php with friendica context
|
||||
*
|
||||
* @param App $a
|
||||
*/
|
||||
function view_init(App $a)
|
||||
{
|
||||
header("Content-Type: text/css");
|
||||
|
||||
if ($a->argc == 4){
|
||||
$theme = $a->argv[2];
|
||||
// set the path for later use in the theme styles
|
||||
$THEMEPATH = "view/theme/$theme";
|
||||
if(file_exists("view/theme/$theme/style.php"))
|
||||
require_once("view/theme/$theme/style.php");
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/viewcontacts.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
||||
function viewcontacts_init(App $a)
|
||||
{
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
System::httpExit(403, ["title" => L10n::t('Access denied.')]);
|
||||
}
|
||||
|
||||
if ($a->argc < 2) {
|
||||
System::httpExit(403, ["title" => L10n::t('Access denied.')]);
|
||||
}
|
||||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $a->argv[1], 'blocked' => false]);
|
||||
if (!DBA::isResult($user)) {
|
||||
System::httpExit(404, ["title" => L10n::t('Page not found.')]);
|
||||
}
|
||||
|
||||
$a->data['user'] = $user;
|
||||
$a->profile_uid = $user['uid'];
|
||||
|
||||
Profile::load($a, $a->argv[1]);
|
||||
}
|
||||
|
||||
function viewcontacts_content(App $a)
|
||||
{
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
notice(L10n::t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$is_owner = $a->profile['profile_uid'] == local_user();
|
||||
|
||||
// tabs
|
||||
$o = Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
|
||||
|
||||
if (!count($a->profile) || $a->profile['hide-friends']) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$condition = [
|
||||
'uid' => $a->profile['uid'],
|
||||
'blocked' => false,
|
||||
'pending' => false,
|
||||
'hidden' => false,
|
||||
'archive' => false,
|
||||
'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]
|
||||
];
|
||||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
|
||||
$contacts_stmt = DBA::select('contact', [], $condition, $params);
|
||||
|
||||
if (!DBA::isResult($contacts_stmt)) {
|
||||
info(L10n::t('No contacts.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$contacts = [];
|
||||
|
||||
while ($contact = DBA::fetch($contacts_stmt)) {
|
||||
/// @TODO This triggers an E_NOTICE if 'self' is not there
|
||||
if ($contact['self']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contact_details = Contact::getDetailsByURL($contact['url'], $a->profile['uid'], $contact);
|
||||
|
||||
$contacts[] = [
|
||||
'id' => $contact['id'],
|
||||
'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
|
||||
'photo_menu' => Contact::photoMenu($contact),
|
||||
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||
'name' => substr($contact_details['name'], 0, 20),
|
||||
'username' => $contact_details['name'],
|
||||
'details' => $contact_details['location'],
|
||||
'tags' => $contact_details['keywords'],
|
||||
'about' => $contact_details['about'],
|
||||
'account_type' => Contact::getAccountType($contact_details),
|
||||
'url' => Contact::magicLink($contact['url']),
|
||||
'sparkle' => '',
|
||||
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $contact['url']),
|
||||
'network' => ContactSelector::networkToName($contact['network'], $contact['url']),
|
||||
];
|
||||
}
|
||||
|
||||
DBA::close($contacts_stmt);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("viewcontact_template.tpl");
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => L10n::t('Contacts'),
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/viewsrc.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
function viewsrc_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
notice(L10n::t('Access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$o = '';
|
||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||
|
||||
if (!$item_id) {
|
||||
$a->error = 404;
|
||||
notice(L10n::t('Item not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $item_id]);
|
||||
|
||||
if (DBA::isResult($item)) {
|
||||
if ($a->isAjax()) {
|
||||
echo str_replace("\n", '<br />', $item['body']);
|
||||
exit();
|
||||
} else {
|
||||
$o .= str_replace("\n", '<br />', $item['body']);
|
||||
}
|
||||
}
|
||||
return $o;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/webfinger.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Network\Probe;
|
||||
|
||||
function webfinger_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
System::httpExit(
|
||||
403,
|
||||
[
|
||||
"title" => L10n::t("Public access denied."),
|
||||
"description" => L10n::t("Only logged in users are permitted to perform a probing.")
|
||||
]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$o = '<div class="generic-page-wrapper">';
|
||||
$o .= '<h3>Webfinger Diagnostic</h3>';
|
||||
|
||||
$o .= '<form action="webfinger" method="get">';
|
||||
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . defaults($_GET, 'addr', '') .'" />';
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
if (!empty($_GET['addr'])) {
|
||||
$addr = trim($_GET['addr']);
|
||||
$res = Probe::lrdd($addr);
|
||||
$o .= '<pre>';
|
||||
$o .= str_replace("\n", '<br />', print_r($res, true));
|
||||
$o .= '</pre>';
|
||||
}
|
||||
$o .= '</div>';
|
||||
|
||||
return $o;
|
||||
}
|
134
mod/xrd.php
134
mod/xrd.php
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/xrd.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Protocol\Salmon;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
function xrd_init(App $a)
|
||||
{
|
||||
if ($a->argv[0] == 'xrd') {
|
||||
if (empty($_GET['uri'])) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$uri = urldecode(Strings::escapeTags(trim($_GET['uri'])));
|
||||
if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/jrd+json') {
|
||||
$mode = 'json';
|
||||
} else {
|
||||
$mode = 'xml';
|
||||
}
|
||||
} else {
|
||||
if (empty($_GET['resource'])) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$uri = urldecode(Strings::escapeTags(trim($_GET['resource'])));
|
||||
if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/xrd+xml') {
|
||||
$mode = 'xml';
|
||||
} else {
|
||||
$mode = 'json';
|
||||
}
|
||||
}
|
||||
|
||||
if (substr($uri, 0, 4) === 'http') {
|
||||
$name = ltrim(basename($uri), '~');
|
||||
} else {
|
||||
$local = str_replace('acct:', '', $uri);
|
||||
if (substr($local, 0, 2) == '//') {
|
||||
$local = substr($local, 2);
|
||||
}
|
||||
|
||||
$name = substr($local, 0, strpos($local, '@'));
|
||||
}
|
||||
|
||||
$user = DBA::selectFirst('user', [], ['nickname' => $name]);
|
||||
if (!DBA::isResult($user)) {
|
||||
System::httpExit(404);
|
||||
}
|
||||
|
||||
$profile_url = System::baseUrl().'/profile/'.$user['nickname'];
|
||||
|
||||
$alias = str_replace('/profile/', '/~', $profile_url);
|
||||
|
||||
$addr = 'acct:'.$user['nickname'].'@'.$a->getHostName();
|
||||
if ($a->getURLPath()) {
|
||||
$addr .= '/'.$a->getURLPath();
|
||||
}
|
||||
|
||||
if ($mode == 'xml') {
|
||||
xrd_xml($addr, $alias, $profile_url, $user);
|
||||
} else {
|
||||
xrd_json($addr, $alias, $profile_url, $user);
|
||||
}
|
||||
}
|
||||
|
||||
function xrd_json($uri, $alias, $profile_url, $r)
|
||||
{
|
||||
$salmon_key = Salmon::salmonKey($r['spubkey']);
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: application/json; charset=utf-8");
|
||||
|
||||
$json = ['subject' => $uri,
|
||||
'aliases' => [$alias, $profile_url],
|
||||
'links' => [
|
||||
['rel' => NAMESPACE_DFRN, 'href' => $profile_url],
|
||||
['rel' => NAMESPACE_FEED, 'type' => 'application/atom+xml', 'href' => System::baseUrl().'/dfrn_poll/'.$r['nickname']],
|
||||
['rel' => 'http://webfinger.net/rel/profile-page', 'type' => 'text/html', 'href' => $profile_url],
|
||||
['rel' => 'self', 'type' => 'application/activity+json', 'href' => $profile_url],
|
||||
['rel' => 'http://microformats.org/profile/hcard', 'type' => 'text/html', 'href' => System::baseUrl().'/hcard/'.$r['nickname']],
|
||||
['rel' => NAMESPACE_POCO, 'href' => System::baseUrl().'/poco/'.$r['nickname']],
|
||||
['rel' => 'http://webfinger.net/rel/avatar', 'type' => 'image/jpeg', 'href' => System::baseUrl().'/photo/profile/'.$r['uid'].'.jpg'],
|
||||
['rel' => 'http://joindiaspora.com/seed_location', 'type' => 'text/html', 'href' => System::baseUrl()],
|
||||
['rel' => 'salmon', 'href' => System::baseUrl().'/salmon/'.$r['nickname']],
|
||||
['rel' => 'http://salmon-protocol.org/ns/salmon-replies', 'href' => System::baseUrl().'/salmon/'.$r['nickname']],
|
||||
['rel' => 'http://salmon-protocol.org/ns/salmon-mention', 'href' => System::baseUrl().'/salmon/'.$r['nickname'].'/mention'],
|
||||
['rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => System::baseUrl().'/follow?url={uri}'],
|
||||
['rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,'.$salmon_key],
|
||||
['rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-zot+json', 'href' => System::baseUrl().'/owa']
|
||||
]
|
||||
];
|
||||
|
||||
echo json_encode($json);
|
||||
exit();
|
||||
}
|
||||
|
||||
function xrd_xml($uri, $alias, $profile_url, $r)
|
||||
{
|
||||
$salmon_key = Salmon::salmonKey($r['spubkey']);
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: text/xml");
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('xrd_person.tpl');
|
||||
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$nick' => $r['nickname'],
|
||||
'$accturi' => $uri,
|
||||
'$alias' => $alias,
|
||||
'$profile_url' => $profile_url,
|
||||
'$hcard_url' => System::baseUrl() . '/hcard/' . $r['nickname'],
|
||||
'$atom' => System::baseUrl() . '/dfrn_poll/' . $r['nickname'],
|
||||
'$poco_url' => System::baseUrl() . '/poco/' . $r['nickname'],
|
||||
'$photo' => System::baseUrl() . '/photo/profile/' . $r['uid'] . '.jpg',
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$salmon' => System::baseUrl() . '/salmon/' . $r['nickname'],
|
||||
'$salmen' => System::baseUrl() . '/salmon/' . $r['nickname'] . '/mention',
|
||||
'$subscribe' => System::baseUrl() . '/follow?url={uri}',
|
||||
'$openwebauth' => System::baseUrl() . '/owa',
|
||||
'$modexp' => 'data:application/magic-public-key,' . $salmon_key]
|
||||
);
|
||||
|
||||
$arr = ['user' => $r, 'xml' => $o];
|
||||
Hook::callAll('personal_xrd', $arr);
|
||||
|
||||
echo $arr['xml'];
|
||||
exit();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue