Merge remote-tracking branch 'upstream/develop' into personal-copy

This commit is contained in:
Michael 2020-07-28 05:40:37 +00:00
commit e6cd5a4d66
165 changed files with 1879 additions and 3326 deletions

View File

@ -62,6 +62,7 @@
"npm-asset/jgrowl": "^1.4", "npm-asset/jgrowl": "^1.4",
"npm-asset/moment": "^2.24", "npm-asset/moment": "^2.24",
"npm-asset/perfect-scrollbar": "0.6.16", "npm-asset/perfect-scrollbar": "0.6.16",
"npm-asset/textcomplete": "^0.18.2",
"npm-asset/typeahead.js": "^0.11.1" "npm-asset/typeahead.js": "^0.11.1"
}, },
"repositories": [ "repositories": [

270
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ded67f7e680a122d0cd3512c2738be97", "content-hash": "7d1fe40c28d815b56d0b5cb323860b26",
"packages": [ "packages": [
{ {
"name": "asika/simple-console", "name": "asika/simple-console",
@ -1276,6 +1276,63 @@
], ],
"time": "2017-07-06T13:46:38+00:00" "time": "2017-07-06T13:46:38+00:00"
}, },
{
"name": "npm-asset/eventemitter3",
"version": "2.0.3",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
"shasum": "b5e1079b59fb5e1ba2771c0a993be060a58c99ba"
},
"type": "npm-asset-library",
"extra": {
"npm-asset-bugs": {
"url": "https://github.com/primus/eventemitter3/issues"
},
"npm-asset-main": "index.js",
"npm-asset-directories": [],
"npm-asset-repository": {
"type": "git",
"url": "git://github.com/primus/eventemitter3.git"
},
"npm-asset-scripts": {
"build": "mkdir -p umd && browserify index.js -s EventEmitter3 | uglifyjs -m -o umd/eventemitter3.min.js",
"benchmark": "find benchmarks/run -name '*.js' -exec benchmarks/start.sh {} \\;",
"test": "nyc --reporter=html --reporter=text mocha",
"test-browser": "zuul -- test.js",
"prepublish": "npm run build",
"sync": "node versions.js"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Arnout Kazemier"
}
],
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.",
"homepage": "https://github.com/primus/eventemitter3#readme",
"keywords": [
"EventEmitter",
"EventEmitter2",
"EventEmitter3",
"Events",
"addEventListener",
"addListener",
"emit",
"emits",
"emitter",
"event",
"once",
"pub/sub",
"publish",
"reactor",
"subscribe"
],
"time": "2017-03-31T14:51:09+00:00"
},
{ {
"name": "npm-asset/fullcalendar", "name": "npm-asset/fullcalendar",
"version": "3.10.2", "version": "3.10.2",
@ -1792,64 +1849,6 @@
], ],
"time": "2017-01-10T01:03:05+00:00" "time": "2017-01-10T01:03:05+00:00"
}, },
{
"name": "npm-asset/perfect-scrollbar",
"version": "0.6.16",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/perfect-scrollbar/-/perfect-scrollbar-0.6.16.tgz",
"shasum": "b1d61a5245cf3962bb9a8407a3fc669d923212fc"
},
"type": "npm-asset-library",
"extra": {
"npm-asset-bugs": {
"url": "https://github.com/noraesae/perfect-scrollbar/issues"
},
"npm-asset-files": [
"dist",
"src",
"index.js",
"jquery.js",
"perfect-scrollbar.d.ts"
],
"npm-asset-main": "./index.js",
"npm-asset-directories": [],
"npm-asset-repository": {
"type": "git",
"url": "git+https://github.com/noraesae/perfect-scrollbar.git"
},
"npm-asset-scripts": {
"test": "gulp",
"before-deploy": "gulp && gulp compress",
"release": "rm -rf dist && gulp && npm publish"
},
"npm-asset-engines": {
"node": ">= 0.12.0"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Hyunje Jun",
"email": "me@noraesae.net"
},
{
"name": "Hyunje Jun",
"email": "me@noraesae.net"
}
],
"description": "Minimalistic but perfect custom scrollbar plugin",
"homepage": "https://github.com/noraesae/perfect-scrollbar#readme",
"keywords": [
"frontend",
"jquery-plugin",
"scroll",
"scrollbar"
],
"time": "2017-01-10T01:03:05+00:00"
},
{ {
"name": "npm-asset/php-date-formatter", "name": "npm-asset/php-date-formatter",
"version": "v1.3.6", "version": "v1.3.6",
@ -1888,6 +1887,100 @@
"homepage": "https://github.com/kartik-v/php-date-formatter", "homepage": "https://github.com/kartik-v/php-date-formatter",
"time": "2020-04-14T10:16:32+00:00" "time": "2020-04-14T10:16:32+00:00"
}, },
{
"name": "npm-asset/textarea-caret",
"version": "3.1.0",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/textarea-caret/-/textarea-caret-3.1.0.tgz",
"shasum": "5d5a35bb035fd06b2ff0e25d5359e97f2655087f"
},
"type": "npm-asset-library",
"extra": {
"npm-asset-bugs": {
"url": "https://github.com/component/textarea-caret-position/issues"
},
"npm-asset-files": [
"index.js"
],
"npm-asset-main": "index.js",
"npm-asset-directories": [],
"npm-asset-repository": {
"type": "git",
"url": "git+https://github.com/component/textarea-caret-position.git"
}
},
"license": [
"MIT"
],
"description": "(x, y) coordinates of the caret in a textarea or input type='text'",
"homepage": "https://github.com/component/textarea-caret-position#readme",
"keywords": [
"caret",
"position",
"textarea"
],
"time": "2018-02-20T06:11:03+00:00"
},
{
"name": "npm-asset/textcomplete",
"version": "0.18.2",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/textcomplete/-/textcomplete-0.18.2.tgz",
"shasum": "de0d806567102f7e32daffcbcc3db05af1515eb5"
},
"require": {
"npm-asset/eventemitter3": ">=2.0.3,<3.0.0",
"npm-asset/textarea-caret": ">=3.0.1,<4.0.0",
"npm-asset/undate": ">=0.2.3,<0.3.0"
},
"type": "npm-asset-library",
"extra": {
"npm-asset-bugs": {
"url": "https://github.com/yuku-t/textcomplete/issues"
},
"npm-asset-main": "lib/index.js",
"npm-asset-directories": [],
"npm-asset-repository": {
"type": "git",
"url": "git+ssh://git@github.com/yuku-t/textcomplete.git"
},
"npm-asset-scripts": {
"build": "yarn run clean && run-p build:*",
"build:dist": "webpack && webpack --env=min && run-p print-dist-gz-size",
"build:docs": "run-p build:docs:*",
"build:docs:html": "webpack --config webpack.doc.config.js && pug -o docs src/doc/index.pug",
"build:docs:md": "documentation build src/*.js -f md -o doc/api.md",
"build:lib": "babel src -d lib -s && for js in src/*.js; do cp $js lib/${js##*/}.flow; done",
"clean": "rm -fr dist docs lib",
"format": "prettier --no-semi --trailing-comma all --write 'src/*.js' 'test/**/*.js'",
"gh-release": "npm pack textcomplete && gh-release -a textcomplete-$(cat package.json|jq -r .version).tgz",
"opener": "wait-on http://localhost:8082 && opener http://localhost:8082",
"print-dist-gz-size": "printf 'dist/textcomplete.min.js.gz: %d bytes\\n' \"$(gzip -9kc dist/textcomplete.min.js | wc -c)\"",
"start": "run-p watch opener",
"test": "run-p test:*",
"test:bundlesize": "yarn run build:dist && bundlesize",
"test:e2e": "NODE_ENV=test karma start --single-run",
"test:lint": "eslint src/*.js test/**/*.js",
"test:typecheck": "flow check",
"watch": "run-p watch:*",
"watch:webpack": "webpack-dev-server --config webpack.doc.config.js",
"watch:pug": "pug -o docs --watch src/doc/index.pug"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Yuku Takahashi"
}
],
"description": "Autocomplete for textarea elements",
"homepage": "https://github.com/yuku-t/textcomplete#readme",
"time": "2020-06-10T06:11:00+00:00"
},
{ {
"name": "npm-asset/typeahead.js", "name": "npm-asset/typeahead.js",
"version": "0.11.1", "version": "0.11.1",
@ -1940,6 +2033,48 @@
], ],
"time": "2015-04-27T04:03:42+00:00" "time": "2015-04-27T04:03:42+00:00"
}, },
{
"name": "npm-asset/undate",
"version": "0.2.4",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/undate/-/undate-0.2.4.tgz",
"shasum": "ccb2a8cf38edc035d1006fcb2909c4c6024a8400"
},
"type": "npm-asset-library",
"extra": {
"npm-asset-bugs": {
"url": "https://github.com/yuku-t/undate/issues"
},
"npm-asset-main": "lib/index.js",
"npm-asset-directories": [],
"npm-asset-repository": {
"type": "git",
"url": "git+https://github.com/yuku-t/undate.git"
},
"npm-asset-scripts": {
"build": "babel src -d lib && for js in src/*.js; do cp $js lib/${js##*/}.flow; done",
"test": "run-p test:*",
"test:eslint": "eslint src/*.js test/*.js",
"test:flow": "flow check",
"test:karma": "karma start --single-run"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Yuku Takahashi"
}
],
"description": "Undoable update for HTMLTextAreaElement",
"homepage": "https://github.com/yuku-t/undate#readme",
"keywords": [
"textarea"
],
"time": "2018-01-24T10:49:39+00:00"
},
{ {
"name": "paragonie/certainty", "name": "paragonie/certainty",
"version": "v2.6.1", "version": "v2.6.1",
@ -4669,6 +4804,20 @@
"polyfill", "polyfill",
"portable" "portable"
], ],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-05-12T16:14:59+00:00" "time": "2020-05-12T16:14:59+00:00"
}, },
{ {
@ -4801,5 +4950,6 @@
"platform-dev": [], "platform-dev": [],
"platform-overrides": { "platform-overrides": {
"php": "7.0" "php": "7.0"
} },
"plugin-api-version": "1.1.0"
} }

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2020.09-dev (Red Hot Poker) -- Friendica 2020.09-dev (Red Hot Poker)
-- DB_UPDATE_VERSION 1357 -- DB_UPDATE_VERSION 1358
-- ------------------------------------------ -- ------------------------------------------
@ -102,6 +102,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
`avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post', `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
`last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status', `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
`block_reason` text COMMENT 'Node-wide block reason', `block_reason` text COMMENT 'Node-wide block reason',
@ -342,8 +343,12 @@ CREATE TABLE IF NOT EXISTS `contact-relation` (
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with', `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
`relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact', `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
`last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction', `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
`follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
`follows` boolean NOT NULL DEFAULT '0' COMMENT '',
PRIMARY KEY(`cid`,`relation-cid`), PRIMARY KEY(`cid`,`relation-cid`),
INDEX `relation-cid` (`relation-cid`) INDEX `relation-cid` (`relation-cid`),
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
-- --
@ -517,17 +522,6 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
--
-- TABLE gfollower
--
CREATE TABLE IF NOT EXISTS `gfollower` (
`gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
`follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
`deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates that the connection has been deleted',
PRIMARY KEY(`gcid`,`follower-gcid`),
INDEX `follower-gcid` (`follower-gcid`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
-- --
-- TABLE glink -- TABLE glink
-- --

View File

@ -604,10 +604,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('post_local_end', $arr); Hook::callAll('post_local_end', $arr);
### mod/lockview.php
Hook::callAll('lockview_content', $item);
### mod/uexport.php ### mod/uexport.php
Hook::callAll('uexport_options', $options); Hook::callAll('uexport_options', $options);
@ -679,6 +675,10 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('register_account', $uid); Hook::callAll('register_account', $uid);
Hook::callAll('remove_user', $user); Hook::callAll('remove_user', $user);
### src/Module/PermissionTooltip.php
Hook::callAll('lockview_content', $item);
### src/Content/ContactBlock.php ### src/Content/ContactBlock.php
Hook::callAll('contact_block_end', $arr); Hook::callAll('contact_block_end', $arr);

View File

@ -312,10 +312,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('post_local_end', $arr); Hook::callAll('post_local_end', $arr);
### mod/lockview.php
Hook::callAll('lockview_content', $item);
### mod/uexport.php ### mod/uexport.php
Hook::callAll('uexport_options', $options); Hook::callAll('uexport_options', $options);
@ -422,6 +418,10 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('storage_instance', $data); Hook::callAll('storage_instance', $data);
### src/Module/PermissionTooltip.php
Hook::callAll('lockview_content', $item);
### src/Worker/Directory.php ### src/Worker/Directory.php
Hook::callAll('globaldir_update', $arr); Hook::callAll('globaldir_update', $arr);

View File

@ -47,12 +47,12 @@ function oauth_get_client(OAuthRequest $request)
function api_post(App $a) function api_post(App $a)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) { if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
} }
@ -107,7 +107,7 @@ function api_content(App $a)
if (!local_user()) { if (!local_user()) {
/// @TODO We need login form to redirect to this page /// @TODO We need login form to redirect to this page
notice(DI::l10n()->t('Please login to continue.') . EOL); notice(DI::l10n()->t('Please login to continue.'));
return Login::form(DI::args()->getQueryString(), false, $request->get_parameters()); return Login::form(DI::args()->getQueryString(), false, $request->get_parameters());
} }
//FKOAuth1::loginUser(4); //FKOAuth1::loginUser(4);

View File

@ -134,7 +134,7 @@ function cal_content(App $a)
$is_owner = local_user() == $a->profile['uid']; $is_owner = local_user() == $a->profile['uid'];
if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) { if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
notice(DI::l10n()->t('Access to this profile has been restricted.') . EOL); notice(DI::l10n()->t('Access to this profile has been restricted.'));
return; return;
} }

View File

@ -40,7 +40,7 @@ function common_content(App $a)
$zcid = 0; $zcid = 0;
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -103,7 +103,7 @@ function common_content(App $a)
} }
if ($total < 1) { if ($total < 1) {
notice(DI::l10n()->t('No contacts in common.') . EOL); notice(DI::l10n()->t('No contacts in common.'));
return $o; return $o;
} }

View File

@ -45,7 +45,6 @@ use Friendica\Model\User;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -76,13 +75,13 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (empty($_POST['source_url'])) { if (empty($_POST['source_url'])) {
$uid = ($handsfree['uid'] ?? 0) ?: local_user(); $uid = ($handsfree['uid'] ?? 0) ?: local_user();
if (!$uid) { if (!$uid) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
$user = DBA::selectFirst('user', [], ['uid' => $uid]); $user = DBA::selectFirst('user', [], ['uid' => $uid]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
notice(DI::l10n()->t('Profile not found.') . EOL); notice(DI::l10n()->t('Profile not found.'));
return; return;
} }
@ -137,8 +136,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
); );
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
Logger::log('Contact not found in DB.'); Logger::log('Contact not found in DB.');
notice(DI::l10n()->t('Contact not found.') . EOL); notice(DI::l10n()->t('Contact not found.'));
notice(DI::l10n()->t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL); notice(DI::l10n()->t('This may occasionally happen if contact was requested by both persons and it has already been approved.'));
return; return;
} }
@ -224,7 +223,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
* *
*/ */
$res = Network::post($dfrn_confirm, $params, [], 120)->getBody(); $res = DI::httpRequest()->post($dfrn_confirm, $params, [], 120)->getBody();
Logger::log(' Confirm: received data: ' . $res, Logger::DATA); Logger::log(' Confirm: received data: ' . $res, Logger::DATA);
@ -239,20 +238,20 @@ function dfrn_confirm_post(App $a, $handsfree = null)
// We shouldn't proceed, because the xml parser might choke, // We shouldn't proceed, because the xml parser might choke,
// and $status is going to be zero, which indicates success. // and $status is going to be zero, which indicates success.
// We can hardly call this a success. // We can hardly call this a success.
notice(DI::l10n()->t('Response from remote site was not understood.') . EOL); notice(DI::l10n()->t('Response from remote site was not understood.'));
return; return;
} }
if (strlen($leading_junk) && DI::config()->get('system', 'debugging')) { if (strlen($leading_junk) && DI::config()->get('system', 'debugging')) {
// This might be more common. Mixed error text and some XML. // This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case. // If we're configured for debugging, show the text. Proceed in either case.
notice(DI::l10n()->t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL); notice(DI::l10n()->t('Unexpected response from remote site: ') . $leading_junk);
} }
if (stristr($res, "<status") === false) { if (stristr($res, "<status") === false) {
// wrong xml! stop here! // wrong xml! stop here!
Logger::log('Unexpected response posting to ' . $dfrn_confirm); Logger::log('Unexpected response posting to ' . $dfrn_confirm);
notice(DI::l10n()->t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL); notice(DI::l10n()->t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res));
return; return;
} }
@ -261,7 +260,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$message = XML::unescape($xml->message); // human readable text of what may have gone wrong. $message = XML::unescape($xml->message); // human readable text of what may have gone wrong.
switch ($status) { switch ($status) {
case 0: case 0:
info(DI::l10n()->t("Confirmation completed successfully.") . EOL); info(DI::l10n()->t("Confirmation completed successfully."));
break; break;
case 1: case 1:
// birthday paradox - generate new dfrn-id and fall through. // birthday paradox - generate new dfrn-id and fall through.
@ -273,15 +272,15 @@ function dfrn_confirm_post(App $a, $handsfree = null)
); );
case 2: case 2:
notice(DI::l10n()->t("Temporary failure. Please wait and try again.") . EOL); notice(DI::l10n()->t("Temporary failure. Please wait and try again."));
break; break;
case 3: case 3:
notice(DI::l10n()->t("Introduction failed or was revoked.") . EOL); notice(DI::l10n()->t("Introduction failed or was revoked."));
break; break;
} }
if (strlen($message)) { if (strlen($message)) {
notice(DI::l10n()->t('Remote site reported: ') . $message . EOL); notice(DI::l10n()->t('Remote site reported: ') . $message);
} }
if (($status == 0) && $intro_id) { if (($status == 0) && $intro_id) {
@ -305,7 +304,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
* *
* We will also update the contact record with the nature and scope of the relationship. * We will also update the contact record with the nature and scope of the relationship.
*/ */
Contact::updateAvatar($contact['photo'], $uid, $contact_id); Contact::updateAvatar($contact_id, $contact['photo']);
Logger::log('dfrn_confirm: confirm - imported photos'); Logger::log('dfrn_confirm: confirm - imported photos');
@ -485,7 +484,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$photo = DI::baseUrl() . '/images/person-300.jpg'; $photo = DI::baseUrl() . '/images/person-300.jpg';
} }
Contact::updateAvatar($photo, $local_uid, $dfrn_record); Contact::updateAvatar($dfrn_record, $photo);
Logger::log('dfrn_confirm: request - photos imported'); Logger::log('dfrn_confirm: request - photos imported');

View File

@ -21,13 +21,12 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -115,7 +114,7 @@ function dfrn_poll_init(App $a)
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); $s = DI::httpRequest()->fetch($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA); Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA);
@ -133,7 +132,7 @@ function dfrn_poll_init(App $a)
Session::setVisitorsContacts(); Session::setVisitorsContacts();
if (!$quiet) { if (!$quiet) {
info(DI::l10n()->t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL); info(DI::l10n()->t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']));
} }
// Visitors get 1 day session. // Visitors get 1 day session.
@ -499,20 +498,20 @@ function dfrn_poll_content(App $a)
// URL reply // URL reply
if ($dfrn_version < 2.2) { if ($dfrn_version < 2.2) {
$s = Network::fetchUrl($r[0]['poll'] $s = DI::httpRequest()->fetch($r[0]['poll']
. '?dfrn_id=' . $encrypted_id . '?dfrn_id=' . $encrypted_id
. '&type=profile-check' . '&type=profile-check'
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&challenge=' . $challenge . '&challenge=' . $challenge
. '&sec=' . $sec . '&sec=' . $sec
); );
} else { } else {
$s = Network::post($r[0]['poll'], [ $s = DI::httpRequest()->post($r[0]['poll'], [
'dfrn_id' => $encrypted_id, 'dfrn_id' => $encrypted_id,
'type' => 'profile-check', 'type' => 'profile-check',
'dfrn_version' => DFRN_PROTOCOL_VERSION, 'dfrn_version' => DFRN_PROTOCOL_VERSION,
'challenge' => $challenge, 'challenge' => $challenge,
'sec' => $sec 'sec' => $sec
])->getBody(); ])->getBody();
} }
@ -536,7 +535,7 @@ function dfrn_poll_content(App $a)
Session::setVisitorsContacts(); Session::setVisitorsContacts();
if (!$quiet) { if (!$quiet) {
info(DI::l10n()->t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL); info(DI::l10n()->t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']));
} }
// Visitors get 1 day session. // Visitors get 1 day session.

View File

@ -29,8 +29,8 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\System;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -110,7 +110,7 @@ function dfrn_request_post(App $a)
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
if (strlen($r[0]['dfrn-id'])) { if (strlen($r[0]['dfrn-id'])) {
// We don't need to be here. It has already happened. // We don't need to be here. It has already happened.
notice(DI::l10n()->t("This introduction has already been accepted.") . EOL); notice(DI::l10n()->t("This introduction has already been accepted."));
return; return;
} else { } else {
$contact_record = $r[0]; $contact_record = $r[0];
@ -128,18 +128,18 @@ function dfrn_request_post(App $a)
$parms = Probe::profile($dfrn_url); $parms = Probe::profile($dfrn_url);
if (!count($parms)) { if (!count($parms)) {
notice(DI::l10n()->t('Profile location is not valid or does not contain profile information.') . EOL); notice(DI::l10n()->t('Profile location is not valid or does not contain profile information.'));
return; return;
} else { } else {
if (empty($parms['fn'])) { if (empty($parms['fn'])) {
notice(DI::l10n()->t('Warning: profile location has no identifiable owner name.') . EOL); notice(DI::l10n()->t('Warning: profile location has no identifiable owner name.'));
} }
if (empty($parms['photo'])) { if (empty($parms['photo'])) {
notice(DI::l10n()->t('Warning: profile location has no profile photo.') . EOL); notice(DI::l10n()->t('Warning: profile location has no profile photo.'));
} }
$invalid = Probe::validDfrn($parms); $invalid = Probe::validDfrn($parms);
if ($invalid) { if ($invalid) {
notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid));
return; return;
} }
} }
@ -177,7 +177,7 @@ function dfrn_request_post(App $a)
} }
if ($r) { if ($r) {
info(DI::l10n()->t("Introduction complete.") . EOL); info(DI::l10n()->t("Introduction complete."));
} }
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1", $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
@ -189,7 +189,7 @@ function dfrn_request_post(App $a)
Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']); Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
if (isset($photo)) { if (isset($photo)) {
Contact::updateAvatar($photo, local_user(), $r[0]["id"], true); Contact::updateAvatar($r[0]["id"], $photo, true);
} }
$forward_path = "contact/" . $r[0]['id']; $forward_path = "contact/" . $r[0]['id'];
@ -203,7 +203,7 @@ function dfrn_request_post(App $a)
} }
if (!empty($dfrn_request) && strlen($confirm_key)) { if (!empty($dfrn_request) && strlen($confirm_key)) {
Network::fetchUrl($dfrn_request . '?confirm_key=' . $confirm_key); DI::httpRequest()->fetch($dfrn_request . '?confirm_key=' . $confirm_key);
} }
// (ignore reply, nothing we can do it failed) // (ignore reply, nothing we can do it failed)
@ -213,7 +213,7 @@ function dfrn_request_post(App $a)
} }
// invalid/bogus request // invalid/bogus request
notice(DI::l10n()->t('Unrecoverable protocol error.') . EOL); notice(DI::l10n()->t('Unrecoverable protocol error.'));
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
return; // NOTREACHED return; // NOTREACHED
} }
@ -240,7 +240,7 @@ function dfrn_request_post(App $a)
* *
*/ */
if (empty($a->profile['uid'])) { if (empty($a->profile['uid'])) {
notice(DI::l10n()->t('Profile unavailable.') . EOL); notice(DI::l10n()->t('Profile unavailable.'));
return; return;
} }
@ -261,9 +261,9 @@ function dfrn_request_post(App $a)
intval($uid) intval($uid)
); );
if (DBA::isResult($r) && count($r) > $maxreq) { if (DBA::isResult($r) && count($r) > $maxreq) {
notice(DI::l10n()->t('%s has received too many connection requests today.', $a->profile['name']) . EOL); notice(DI::l10n()->t('%s has received too many connection requests today.', $a->profile['name']));
notice(DI::l10n()->t('Spam protection measures have been invoked.') . EOL); notice(DI::l10n()->t('Spam protection measures have been invoked.'));
notice(DI::l10n()->t('Friends are advised to please try again in 24 hours.') . EOL); notice(DI::l10n()->t('Friends are advised to please try again in 24 hours.'));
return; return;
} }
} }
@ -287,7 +287,7 @@ function dfrn_request_post(App $a)
$url = trim($_POST['dfrn_url']); $url = trim($_POST['dfrn_url']);
if (!strlen($url)) { if (!strlen($url)) {
notice(DI::l10n()->t("Invalid locator") . EOL); notice(DI::l10n()->t("Invalid locator"));
return; return;
} }
@ -323,10 +323,10 @@ function dfrn_request_post(App $a)
if (DBA::isResult($ret)) { if (DBA::isResult($ret)) {
if (strlen($ret[0]['issued-id'])) { if (strlen($ret[0]['issued-id'])) {
notice(DI::l10n()->t('You have already introduced yourself here.') . EOL); notice(DI::l10n()->t('You have already introduced yourself here.'));
return; return;
} elseif ($ret[0]['rel'] == Contact::FRIEND) { } elseif ($ret[0]['rel'] == Contact::FRIEND) {
notice(DI::l10n()->t('Apparently you are already friends with %s.', $a->profile['name']) . EOL); notice(DI::l10n()->t('Apparently you are already friends with %s.', $a->profile['name']));
return; return;
} else { } else {
$contact_record = $ret[0]; $contact_record = $ret[0];
@ -346,19 +346,19 @@ function dfrn_request_post(App $a)
} else { } else {
$url = Network::isUrlValid($url); $url = Network::isUrlValid($url);
if (!$url) { if (!$url) {
notice(DI::l10n()->t('Invalid profile URL.') . EOL); notice(DI::l10n()->t('Invalid profile URL.'));
DI::baseUrl()->redirect(DI::args()->getCommand()); DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED return; // NOTREACHED
} }
if (!Network::isUrlAllowed($url)) { if (!Network::isUrlAllowed($url)) {
notice(DI::l10n()->t('Disallowed profile URL.') . EOL); notice(DI::l10n()->t('Disallowed profile URL.'));
DI::baseUrl()->redirect(DI::args()->getCommand()); DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED return; // NOTREACHED
} }
if (Network::isUrlBlocked($url)) { if (Network::isUrlBlocked($url)) {
notice(DI::l10n()->t('Blocked domain') . EOL); notice(DI::l10n()->t('Blocked domain'));
DI::baseUrl()->redirect(DI::args()->getCommand()); DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED return; // NOTREACHED
} }
@ -366,18 +366,18 @@ function dfrn_request_post(App $a)
$parms = Probe::profile(($hcard) ? $hcard : $url); $parms = Probe::profile(($hcard) ? $hcard : $url);
if (!count($parms)) { if (!count($parms)) {
notice(DI::l10n()->t('Profile location is not valid or does not contain profile information.') . EOL); notice(DI::l10n()->t('Profile location is not valid or does not contain profile information.'));
DI::baseUrl()->redirect(DI::args()->getCommand()); DI::baseUrl()->redirect(DI::args()->getCommand());
} else { } else {
if (empty($parms['fn'])) { if (empty($parms['fn'])) {
notice(DI::l10n()->t('Warning: profile location has no identifiable owner name.') . EOL); notice(DI::l10n()->t('Warning: profile location has no identifiable owner name.'));
} }
if (empty($parms['photo'])) { if (empty($parms['photo'])) {
notice(DI::l10n()->t('Warning: profile location has no profile photo.') . EOL); notice(DI::l10n()->t('Warning: profile location has no profile photo.'));
} }
$invalid = Probe::validDfrn($parms); $invalid = Probe::validDfrn($parms);
if ($invalid) { if ($invalid) {
notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid));
return; return;
} }
@ -420,12 +420,12 @@ function dfrn_request_post(App $a)
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$contact_record = $r[0]; $contact_record = $r[0];
Contact::updateAvatar($photo, $uid, $contact_record["id"], true); Contact::updateAvatar($contact_record["id"], $photo, true);
} }
} }
} }
if ($r === false) { if ($r === false) {
notice(DI::l10n()->t('Failed to update contact record.') . EOL); notice(DI::l10n()->t('Failed to update contact record.'));
return; return;
} }
@ -445,7 +445,7 @@ function dfrn_request_post(App $a)
// This notice will only be seen by the requestor if the requestor and requestee are on the same server. // This notice will only be seen by the requestor if the requestor and requestee are on the same server.
if (!$failed) { if (!$failed) {
info(DI::l10n()->t('Your introduction has been sent.') . EOL); info(DI::l10n()->t('Your introduction has been sent.'));
} }
// "Homecoming" - send the requestor back to their site to record the introduction. // "Homecoming" - send the requestor back to their site to record the introduction.
@ -477,7 +477,7 @@ function dfrn_request_post(App $a)
// NOTREACHED // NOTREACHED
// END $network != Protocol::PHANTOM // END $network != Protocol::PHANTOM
} else { } else {
notice(DI::l10n()->t("Remote subscription can't be done for your network. Please subscribe directly on your system.") . EOL); notice(DI::l10n()->t("Remote subscription can't be done for your network. Please subscribe directly on your system."));
return; return;
} }
} return; } return;
@ -493,7 +493,7 @@ function dfrn_request_content(App $a)
// to send us to the post section to record the introduction. // to send us to the post section to record the introduction.
if (!empty($_GET['dfrn_url'])) { if (!empty($_GET['dfrn_url'])) {
if (!local_user()) { if (!local_user()) {
info(DI::l10n()->t("Please login to confirm introduction.") . EOL); info(DI::l10n()->t("Please login to confirm introduction."));
/* setup the return URL to come back to this page if they use openid */ /* setup the return URL to come back to this page if they use openid */
return Login::form(); return Login::form();
} }
@ -501,7 +501,7 @@ function dfrn_request_content(App $a)
// Edge case, but can easily happen in the wild. This person is authenticated, // Edge case, but can easily happen in the wild. This person is authenticated,
// but not as the person who needs to deal with this request. // but not as the person who needs to deal with this request.
if ($a->user['nickname'] != $a->argv[1]) { if ($a->user['nickname'] != $a->argv[1]) {
notice(DI::l10n()->t("Incorrect identity currently logged in. Please login to <strong>this</strong> profile.") . EOL); notice(DI::l10n()->t("Incorrect identity currently logged in. Please login to <strong>this</strong> profile."));
return Login::form(); return Login::form();
} }
@ -603,7 +603,7 @@ function dfrn_request_content(App $a)
// Normal web request. Display our user's introduction form. // Normal web request. Display our user's introduction form.
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
if (!DI::config()->get('system', 'local_block')) { if (!DI::config()->get('system', 'local_block')) {
notice(DI::l10n()->t('Public access denied.') . EOL); notice(DI::l10n()->t('Public access denied.'));
return; return;
} }
} }

View File

@ -35,14 +35,14 @@ function editpost_content(App $a)
$o = ''; $o = '';
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if (!$post_id) { if (!$post_id) {
notice(DI::l10n()->t('Item not found') . EOL); notice(DI::l10n()->t('Item not found'));
return; return;
} }
@ -52,7 +52,7 @@ function editpost_content(App $a)
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]); $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
notice(DI::l10n()->t('Item not found') . EOL); notice(DI::l10n()->t('Item not found'));
return; return;
} }

View File

@ -132,7 +132,7 @@ function events_post(App $a)
$onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986); $onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986);
if (strcmp($finish, $start) < 0 && !$nofinish) { if (strcmp($finish, $start) < 0 && !$nofinish) {
notice(DI::l10n()->t('Event can not end before it has started.') . EOL); notice(DI::l10n()->t('Event can not end before it has started.'));
if (intval($_REQUEST['preview'])) { if (intval($_REQUEST['preview'])) {
echo DI::l10n()->t('Event can not end before it has started.'); echo DI::l10n()->t('Event can not end before it has started.');
exit(); exit();
@ -141,7 +141,7 @@ function events_post(App $a)
} }
if (!$summary || ($start === DBA::NULL_DATETIME)) { if (!$summary || ($start === DBA::NULL_DATETIME)) {
notice(DI::l10n()->t('Event title and start time are required.') . EOL); notice(DI::l10n()->t('Event title and start time are required.'));
if (intval($_REQUEST['preview'])) { if (intval($_REQUEST['preview'])) {
echo DI::l10n()->t('Event title and start time are required.'); echo DI::l10n()->t('Event title and start time are required.');
exit(); exit();
@ -225,7 +225,7 @@ function events_post(App $a)
function events_content(App $a) function events_content(App $a)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return Login::form(); return Login::form();
} }
@ -583,9 +583,7 @@ function events_content(App $a)
} }
if (Item::exists(['id' => $ev[0]['itemid']])) { if (Item::exists(['id' => $ev[0]['itemid']])) {
notice(DI::l10n()->t('Failed to remove event') . EOL); notice(DI::l10n()->t('Failed to remove event'));
} else {
info(DI::l10n()->t('Event removed') . EOL);
} }
DI::baseUrl()->redirect('events'); DI::baseUrl()->redirect('events');

View File

@ -62,7 +62,7 @@ function follow_post(App $a)
DI::baseUrl()->redirect('contact/' . $result['cid']); DI::baseUrl()->redirect('contact/' . $result['cid']);
} }
info(DI::l10n()->t('The contact could not be added.')); notice(DI::l10n()->t('The contact could not be added.'));
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
// NOTREACHED // NOTREACHED

View File

@ -333,7 +333,7 @@ function item_post(App $a) {
System::jsonExit(['preview' => '']); System::jsonExit(['preview' => '']);
} }
info(DI::l10n()->t('Empty post discarded.')); notice(DI::l10n()->t('Empty post discarded.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -703,7 +703,6 @@ function item_post(App $a) {
// update filetags in pconfig // update filetags in pconfig
FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category'); FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category');
info(DI::l10n()->t('Post updated.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -725,7 +724,7 @@ function item_post(App $a) {
$post_id = Item::insert($datarray); $post_id = Item::insert($datarray);
if (!$post_id) { if (!$post_id) {
info(DI::l10n()->t('Item wasn\'t stored.')); notice(DI::l10n()->t('Item wasn\'t stored.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -826,7 +825,6 @@ function item_post(App $a) {
return $post_id; return $post_id;
} }
info(DI::l10n()->t('Post published.'));
item_post_return(DI::baseUrl(), $api_source, $return_path); item_post_return(DI::baseUrl(), $api_source, $return_path);
// NOTREACHED // NOTREACHED
} }
@ -890,7 +888,7 @@ function drop_item(int $id, string $return = '')
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]); $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
notice(DI::l10n()->t('Item not found.') . EOL); notice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network'); DI::baseUrl()->redirect('network');
} }

View File

@ -1,161 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Group;
use Friendica\Model\Item;
function lockview_content(App $a)
{
$type = (($a->argc > 1) ? $a->argv[1] : 0);
if (is_numeric($type)) {
$item_id = intval($type);
$type = 'item';
} else {
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
}
if (!$item_id) {
exit();
}
if (!in_array($type, ['item','photo','event'])) {
exit();
}
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$condition = ['id' => $item_id];
if ($type != 'item') {
$item = DBA::selectFirst($type, $fields, $condition);
} else {
$fields[] = 'private';
$item = Item::selectFirst($fields, $condition);
}
if (!DBA::isResult($item)) {
exit();
}
Hook::callAll('lockview_content', $item);
if ($item['uid'] != local_user()) {
echo DI::l10n()->t('Remote privacy information not available.') . '<br />';
exit();
}
if (isset($item['private'])
&& $item['private'] == Item::PRIVATE
&& empty($item['allow_cid'])
&& empty($item['allow_gid'])
&& empty($item['deny_cid'])
&& empty($item['deny_gid']))
{
echo DI::l10n()->t('Remote privacy information not available.') . '<br />';
exit();
}
$aclFormatter = DI::aclFormatter();
$allowed_users = $aclFormatter->expand($item['allow_cid']);
$allowed_groups = $aclFormatter->expand($item['allow_gid']);
$deny_users = $aclFormatter->expand($item['deny_cid']);
$deny_groups = $aclFormatter->expand($item['deny_gid']);
$o = DI::l10n()->t('Visible to:') . '<br />';
$l = [];
if (count($allowed_groups)) {
$key = array_search(Group::FOLLOWERS, $allowed_groups);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
unset($allowed_groups[$key]);
}
$key = array_search(Group::MUTUALS, $allowed_groups);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
unset($allowed_groups[$key]);
}
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $allowed_groups))
);
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<b>' . $rr['name'] . '</b>';
}
}
}
if (count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $allowed_users))
);
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = $rr['name'];
}
}
}
if (count($deny_groups)) {
$key = array_search(Group::FOLLOWERS, $deny_groups);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
unset($deny_groups[$key]);
}
$key = array_search(Group::MUTUALS, $deny_groups);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
unset($deny_groups[$key]);
}
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $deny_groups))
);
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
}
}
}
if (count($deny_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $deny_users))
);
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<strike>' . $rr['name'] . '</strike>';
}
}
}
echo $o . implode(', ', $l);
exit();
}

View File

@ -37,7 +37,7 @@ function lostpass_post(App $a)
$condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame]; $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition); $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
notice(DI::l10n()->t('No valid account found.') . EOL); notice(DI::l10n()->t('No valid account found.'));
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
} }
@ -49,7 +49,7 @@ function lostpass_post(App $a)
]; ];
$result = DBA::update('user', $fields, ['uid' => $user['uid']]); $result = DBA::update('user', $fields, ['uid' => $user['uid']]);
if ($result) { if ($result) {
info(DI::l10n()->t('Password reset request issued. Check your email.') . EOL); info(DI::l10n()->t('Password reset request issued. Check your email.'));
} }
$sitename = DI::config()->get('config', 'sitename'); $sitename = DI::config()->get('config', 'sitename');
@ -152,7 +152,7 @@ function lostpass_generate_password($user)
'$newpass' => $new_password, '$newpass' => $new_password,
]); ]);
info("Your password has been reset." . EOL); info(DI::l10n()->t("Your password has been reset."));
$sitename = DI::config()->get('config', 'sitename'); $sitename = DI::config()->get('config', 'sitename');
$preamble = Strings::deindent(DI::l10n()->t(' $preamble = Strings::deindent(DI::l10n()->t('

View File

@ -27,7 +27,6 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
/** /**
@ -60,7 +59,7 @@ function match_content(App $a)
return ''; return '';
} }
if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) { if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) {
notice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.') . EOL); notice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.'));
return ''; return '';
} }
@ -76,7 +75,7 @@ function match_content(App $a)
$host = DI::baseUrl(); $host = DI::baseUrl();
} }
$msearch_json = Network::post($host . '/msearch', $params)->getBody(); $msearch_json = DI::httpRequest()->post($host . '/msearch', $params)->getBody();
$msearch = json_decode($msearch_json); $msearch = json_decode($msearch_json);
@ -141,7 +140,7 @@ function match_content(App $a)
} }
if (empty($entries)) { if (empty($entries)) {
info(DI::l10n()->t('No matches') . EOL); info(DI::l10n()->t('No matches'));
} }
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');

View File

@ -68,7 +68,7 @@ function message_init(App $a)
function message_post(App $a) function message_post(App $a)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -82,20 +82,18 @@ function message_post(App $a)
switch ($ret) { switch ($ret) {
case -1: case -1:
notice(DI::l10n()->t('No recipient selected.') . EOL); notice(DI::l10n()->t('No recipient selected.'));
$norecip = true; $norecip = true;
break; break;
case -2: case -2:
notice(DI::l10n()->t('Unable to locate contact information.') . EOL); notice(DI::l10n()->t('Unable to locate contact information.'));
break; break;
case -3: case -3:
notice(DI::l10n()->t('Message could not be sent.') . EOL); notice(DI::l10n()->t('Message could not be sent.'));
break; break;
case -4: case -4:
notice(DI::l10n()->t('Message collection failure.') . EOL); notice(DI::l10n()->t('Message collection failure.'));
break; break;
default:
info(DI::l10n()->t('Message sent.') . EOL);
} }
// fake it to go back to the input form if no recipient listed // fake it to go back to the input form if no recipient listed
@ -113,7 +111,7 @@ function message_content(App $a)
Nav::setSelected('messages'); Nav::setSelected('messages');
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return Login::form(); return Login::form();
} }
@ -178,17 +176,16 @@ function message_content(App $a)
if ($cmd === 'drop') { if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); $message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){ if(!DBA::isResult($message)){
info(DI::l10n()->t('Conversation not found.') . EOL); notice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { if (!DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
info(DI::l10n()->t('Message deleted.') . EOL); notice(DI::l10n()->t('Message was not deleted.'));
} }
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]); $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
if(!DBA::isResult($conversation)){ if(!DBA::isResult($conversation)){
info(DI::l10n()->t('Conversation removed.') . EOL);
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
@ -201,8 +198,8 @@ function message_content(App $a)
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$parent = $r[0]['parent-uri']; $parent = $r[0]['parent-uri'];
if (DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
info(DI::l10n()->t('Conversation removed.') . EOL); notice(DI::l10n()->t('Conversation was not removed.'));
} }
} }
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
@ -301,7 +298,7 @@ function message_content(App $a)
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage()); $r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
info(DI::l10n()->t('No messages.') . EOL); notice(DI::l10n()->t('No messages.'));
return $o; return $o;
} }
@ -358,7 +355,7 @@ function message_content(App $a)
} }
if (!DBA::isResult($messages)) { if (!DBA::isResult($messages)) {
notice(DI::l10n()->t('Message not available.') . EOL); notice(DI::l10n()->t('Message not available.'));
return $o; return $o;
} }

View File

@ -47,7 +47,7 @@ use Friendica\Util\Strings;
function network_init(App $a) function network_init(App $a)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -305,7 +305,7 @@ function network_content(App $a, $update = 0, $parent = 0)
} }
if ($o === '') { if ($o === '') {
info("No items found"); notice(DI::l10n()->t("No items found"));
} }
return $o; return $o;
@ -548,7 +548,7 @@ function networkThreadedView(App $a, $update, $parent)
if ($update) { if ($update) {
exit(); exit();
} }
notice(DI::l10n()->t('No such group') . EOL); notice(DI::l10n()->t('No such group'));
DI::baseUrl()->redirect('network/0'); DI::baseUrl()->redirect('network/0');
// NOTREACHED // NOTREACHED
} }
@ -569,7 +569,7 @@ function networkThreadedView(App $a, $update, $parent)
$sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '" . Strings::protectSprintf('%<' . intval($gid) . '>%') . "' AND `temp1`.`private`))"; $sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '" . Strings::protectSprintf('%<' . intval($gid) . '>%') . "' AND `temp1`.`private`))";
} else { } else {
$sql_extra3 .= " AND false "; $sql_extra3 .= " AND false ";
info(DI::l10n()->t('Group is empty')); notice(DI::l10n()->t('Group is empty'));
} }
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [
@ -598,7 +598,7 @@ function networkThreadedView(App $a, $update, $parent)
'id' => 'network', 'id' => 'network',
]) . $o; ]) . $o;
} else { } else {
notice(DI::l10n()->t('Invalid contact.') . EOL); notice(DI::l10n()->t('Invalid contact.'));
DI::baseUrl()->redirect('network'); DI::baseUrl()->redirect('network');
// NOTREACHED // NOTREACHED
} }

View File

@ -40,7 +40,7 @@ function notes_init(App $a)
function notes_content(App $a, $update = false) function notes_content(App $a, $update = false)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }

View File

@ -23,7 +23,6 @@ use Friendica\App;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function oexchange_init(App $a) { function oexchange_init(App $a) {
@ -45,7 +44,6 @@ function oexchange_content(App $a) {
} }
if (($a->argc > 1) && $a->argv[1] === 'done') { if (($a->argc > 1) && $a->argv[1] === 'done') {
info(DI::l10n()->t('Post successful.') . EOL);
return; return;
} }
@ -58,7 +56,7 @@ function oexchange_content(App $a) {
$tags = ((!empty($_REQUEST['tags'])) $tags = ((!empty($_REQUEST['tags']))
? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : ''); ? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : '');
$s = Network::fetchUrl(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags); $s = DI::httpRequest()->fetch(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
if (!strlen($s)) { if (!strlen($s)) {
return; return;

View File

@ -23,12 +23,11 @@ use Friendica\App;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\Network;
function ostatus_subscribe_content(App $a) function ostatus_subscribe_content(App $a)
{ {
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_subscribe'); DI::baseUrl()->redirect('ostatus_subscribe');
// NOTREACHED // NOTREACHED
} }
@ -55,7 +54,7 @@ function ostatus_subscribe_content(App $a)
$api = $contact['baseurl'] . '/api/'; $api = $contact['baseurl'] . '/api/';
// Fetching friends // Fetching friends
$curlResult = Network::curl($api . 'statuses/friends.json?screen_name=' . $contact['nick']); $curlResult = DI::httpRequest()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact'); DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');

View File

@ -28,7 +28,7 @@ use Friendica\Content\PageInfo;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Util\Network; use Friendica\DI;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -85,7 +85,7 @@ function parse_url_content(App $a)
// Check if the URL is an image, video or audio file. If so format // Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag // the URL with the corresponding BBCode media tag
// Fetch the header of the URL // Fetch the header of the URL
$curlResponse = Network::curl($url, false, ['novalidate' => true, 'nobody' => true]); $curlResponse = DI::httpRequest()->get($url, false, ['novalidate' => true, 'nobody' => true]);
if ($curlResponse->isSuccess()) { if ($curlResponse->isSuccess()) {
// Convert the header fields into an array // Convert the header fields into an array

View File

@ -175,14 +175,14 @@ function photos_post(App $a)
} }
if (!$can_post) { if (!$can_post) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
exit(); exit();
} }
$owner_record = User::getOwnerDataById($page_owner_uid); $owner_record = User::getOwnerDataById($page_owner_uid);
if (!$owner_record) { if (!$owner_record) {
notice(DI::l10n()->t('Contact information unavailable') . EOL); notice(DI::l10n()->t('Contact information unavailable'));
Logger::log('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); Logger::log('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
exit(); exit();
} }
@ -204,7 +204,7 @@ function photos_post(App $a)
); );
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
notice(DI::l10n()->t('Album not found.') . EOL); notice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
return; // NOTREACHED return; // NOTREACHED
} }
@ -295,9 +295,8 @@ function photos_post(App $a)
// Update the photo albums cache // Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid); Photo::clearAlbumCache($page_owner_uid);
notice('Successfully deleted the photo.');
} else { } else {
notice('Failed to delete the photo.'); notice(DI::l10n()->t('Failed to delete the photo.'));
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]); DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
} }
@ -676,21 +675,21 @@ function photos_post(App $a)
if ($error !== UPLOAD_ERR_OK) { if ($error !== UPLOAD_ERR_OK) {
switch ($error) { switch ($error) {
case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_INI_SIZE:
notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL); notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
break; break;
case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_FORM_SIZE:
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL); notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
break; break;
case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_PARTIAL:
notice(DI::l10n()->t('Image upload didn\'t complete, please try again') . EOL); notice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
break; break;
case UPLOAD_ERR_NO_FILE: case UPLOAD_ERR_NO_FILE:
notice(DI::l10n()->t('Image file is missing') . EOL); notice(DI::l10n()->t('Image file is missing'));
break; break;
case UPLOAD_ERR_NO_TMP_DIR: case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_CANT_WRITE:
case UPLOAD_ERR_EXTENSION: case UPLOAD_ERR_EXTENSION:
notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator') . EOL); notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
break; break;
} }
@unlink($src); @unlink($src);
@ -706,7 +705,7 @@ function photos_post(App $a)
$maximagesize = DI::config()->get('system', 'maximagesize'); $maximagesize = DI::config()->get('system', 'maximagesize');
if ($maximagesize && ($filesize > $maximagesize)) { if ($maximagesize && ($filesize > $maximagesize)) {
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL); notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
@unlink($src); @unlink($src);
$foo = 0; $foo = 0;
Hook::callAll('photo_post_end', $foo); Hook::callAll('photo_post_end', $foo);
@ -714,7 +713,7 @@ function photos_post(App $a)
} }
if (!$filesize) { if (!$filesize) {
notice(DI::l10n()->t('Image file is empty.') . EOL); notice(DI::l10n()->t('Image file is empty.'));
@unlink($src); @unlink($src);
$foo = 0; $foo = 0;
Hook::callAll('photo_post_end', $foo); Hook::callAll('photo_post_end', $foo);
@ -729,7 +728,7 @@ function photos_post(App $a)
if (!$image->isValid()) { if (!$image->isValid()) {
Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG); Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG);
notice(DI::l10n()->t('Unable to process image.') . EOL); notice(DI::l10n()->t('Unable to process image.'));
@unlink($src); @unlink($src);
$foo = 0; $foo = 0;
Hook::callAll('photo_post_end',$foo); Hook::callAll('photo_post_end',$foo);
@ -758,7 +757,7 @@ function photos_post(App $a)
if (!$r) { if (!$r) {
Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG); Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
notice(DI::l10n()->t('Image upload failed.') . EOL); notice(DI::l10n()->t('Image upload failed.'));
return; return;
} }
@ -841,12 +840,12 @@ function photos_content(App $a)
// photos/name/image/xxxxx/drop // photos/name/image/xxxxx/drop
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.') . EOL); notice(DI::l10n()->t('Public access denied.'));
return; return;
} }
if (empty($a->data['user'])) { if (empty($a->data['user'])) {
notice(DI::l10n()->t('No photos selected') . EOL); notice(DI::l10n()->t('No photos selected'));
return; return;
} }
@ -912,7 +911,7 @@ function photos_content(App $a)
} }
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
notice(DI::l10n()->t('Access to this item is restricted.') . EOL); notice(DI::l10n()->t('Access to this item is restricted.'));
return; return;
} }
@ -1137,7 +1136,7 @@ function photos_content(App $a)
if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) { if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.')); notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.'));
} else { } else {
notice(DI::l10n()->t('Photo not available') . EOL); notice(DI::l10n()->t('Photo not available'));
} }
return; return;
} }

View File

@ -24,7 +24,6 @@ use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\PushSubscriber; use Friendica\Model\PushSubscriber;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function post_var($name) { function post_var($name) {
@ -126,7 +125,7 @@ function pubsubhubbub_init(App $a) {
$hub_callback = rtrim($hub_callback, ' ?&#'); $hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&'; $separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
$fetchResult = Network::fetchUrlFull($hub_callback . $separator . $params); $fetchResult = DI::httpRequest()->fetchFull($hub_callback . $separator . $params);
$body = $fetchResult->getBody(); $body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode(); $ret = $fetchResult->getReturnCode();

View File

@ -27,7 +27,6 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function redir_init(App $a) { function redir_init(App $a) {
@ -171,7 +170,7 @@ function redir_magic($a, $cid, $url)
} }
// Test for magic auth on the target system // Test for magic auth on the target system
$serverret = Network::curl($basepath . '/magic'); $serverret = DI::httpRequest()->get($basepath . '/magic');
if ($serverret->isSuccess()) { if ($serverret->isSuccess()) {
$separator = strpos($target_url, '?') ? '&' : '?'; $separator = strpos($target_url, '?') ? '&' : '?';
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url); $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);

View File

@ -28,7 +28,7 @@ use Friendica\Model\Contact;
function repair_ostatus_content(App $a) { function repair_ostatus_content(App $a) {
if (! local_user()) { if (! local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_repair'); DI::baseUrl()->redirect('ostatus_repair');
// NOTREACHED // NOTREACHED
} }

View File

@ -63,7 +63,7 @@ function settings_post(App $a)
} }
if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) { if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -198,13 +198,10 @@ function settings_post(App $a)
unset($dcrpass); unset($dcrpass);
if (!$mbox) { if (!$mbox) {
$failed = true; $failed = true;
notice(DI::l10n()->t('Failed to connect with email account using the settings provided.') . EOL); notice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
} }
} }
} }
if (!$failed) {
info(DI::l10n()->t('Email settings updated.') . EOL);
}
} }
} }
@ -219,7 +216,6 @@ function settings_post(App $a)
DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0)); DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
} }
} }
info(DI::l10n()->t('Features updated') . EOL);
return; return;
} }
@ -231,7 +227,7 @@ function settings_post(App $a)
// was there an error // was there an error
if ($_FILES['importcontact-filename']['error'] > 0) { if ($_FILES['importcontact-filename']['error'] > 0) {
Logger::notice('Contact CSV file upload error'); Logger::notice('Contact CSV file upload error');
info(DI::l10n()->t('Contact CSV file upload error')); notice(DI::l10n()->t('Contact CSV file upload error'));
} else { } else {
$csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name'])); $csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
// import contacts // import contacts
@ -424,10 +420,10 @@ function settings_post(App $a)
$hidewall = 1; $hidewall = 1;
if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) { if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
if ($def_gid) { if ($def_gid) {
info(DI::l10n()->t('Private forum has no privacy permissions. Using default privacy group.'). EOL); info(DI::l10n()->t('Private forum has no privacy permissions. Using default privacy group.'));
$str_group_allow = '<' . $def_gid . '>'; $str_group_allow = '<' . $def_gid . '>';
} else { } else {
notice(DI::l10n()->t('Private forum has no privacy permissions and no default privacy group.') . EOL); notice(DI::l10n()->t('Private forum has no privacy permissions and no default privacy group.'));
} }
} }
} }
@ -443,8 +439,8 @@ function settings_post(App $a)
$fields['openidserver'] = ''; $fields['openidserver'] = '';
} }
if (DBA::update('user', $fields, ['uid' => local_user()])) { if (!DBA::update('user', $fields, ['uid' => local_user()])) {
info(DI::l10n()->t('Settings updated.') . EOL); notice(DI::l10n()->t('Settings were not updated.'));
} }
// clear session language // clear session language
@ -489,12 +485,12 @@ function settings_content(App $a)
Nav::setSelected('settings'); Nav::setSelected('settings');
if (!local_user()) { if (!local_user()) {
//notice(DI::l10n()->t('Permission denied.') . EOL); //notice(DI::l10n()->t('Permission denied.'));
return Login::form(); return Login::form();
} }
if (!empty($_SESSION['submanage'])) { if (!empty($_SESSION['submanage'])) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -722,7 +718,7 @@ function settings_content(App $a)
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]); $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) { if (!DBA::isResult($profile)) {
notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.') . EOL); notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return; return;
} }

View File

@ -51,7 +51,7 @@ function suggest_content(App $a)
$o = ''; $o = '';
if (! local_user()) { if (! local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }

View File

@ -44,7 +44,6 @@ function tagrm_post(App $a)
$item_id = $_POST['item'] ?? 0; $item_id = $_POST['item'] ?? 0;
update_tags($item_id, $tags); update_tags($item_id, $tags);
info(DI::l10n()->t('Tag(s) removed') . EOL);
DI::baseUrl()->redirect($_SESSION['photo_return']); DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED // NOTREACHED

View File

@ -29,7 +29,7 @@ use Friendica\DI;
function uimport_post(App $a) function uimport_post(App $a)
{ {
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -42,7 +42,7 @@ function uimport_post(App $a)
function uimport_content(App $a) function uimport_content(App $a)
{ {
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) { if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.') . EOL); notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.'));
return; return;
} }
@ -51,7 +51,7 @@ function uimport_content(App $a)
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
if ($r && $r[0]['total'] >= $max_dailies) { if ($r && $r[0]['total'] >= $max_dailies) {
Logger::log('max daily registrations exceeded.'); Logger::log('max daily registrations exceeded.');
notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
return; return;
} }
} }

View File

@ -79,7 +79,6 @@ function unfollow_post(App $a)
$return_path = $base_return_path . '/' . $contact['id']; $return_path = $base_return_path . '/' . $contact['id'];
} }
info(DI::l10n()->t('Contact unfollowed'));
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
// NOTREACHED // NOTREACHED
} }

View File

@ -126,7 +126,7 @@ function videos_content(App $a)
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.') . EOL); notice(DI::l10n()->t('Public access denied.'));
return; return;
} }
@ -179,7 +179,7 @@ function videos_content(App $a)
} }
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
notice(DI::l10n()->t('Access to this item is restricted.') . EOL); notice(DI::l10n()->t('Access to this item is restricted.'));
return; return;
} }

View File

@ -106,7 +106,7 @@ function wall_attach_post(App $a) {
if ($r_json) { if ($r_json) {
echo json_encode(['error' => $msg]); echo json_encode(['error' => $msg]);
} else { } else {
notice($msg . EOL); notice($msg);
} }
@unlink($src); @unlink($src);
exit(); exit();

View File

@ -99,7 +99,7 @@ function wall_upload_post(App $a, $desktopmode = true)
echo json_encode(['error' => DI::l10n()->t('Permission denied.')]); echo json_encode(['error' => DI::l10n()->t('Permission denied.')]);
exit(); exit();
} }
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
exit(); exit();
} }
@ -159,7 +159,7 @@ function wall_upload_post(App $a, $desktopmode = true)
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]); echo json_encode(['error' => DI::l10n()->t('Invalid request.')]);
exit(); exit();
} }
notice(DI::l10n()->t('Invalid request.').EOL); notice(DI::l10n()->t('Invalid request.'));
exit(); exit();
} }

View File

@ -32,7 +32,7 @@ function wallmessage_post(App $a) {
$replyto = Profile::getMyURL(); $replyto = Profile::getMyURL();
if (!$replyto) { if (!$replyto) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -56,7 +56,7 @@ function wallmessage_post(App $a) {
$user = $r[0]; $user = $r[0];
if (! intval($user['unkmail'])) { if (! intval($user['unkmail'])) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -73,19 +73,17 @@ function wallmessage_post(App $a) {
switch ($ret) { switch ($ret) {
case -1: case -1:
notice(DI::l10n()->t('No recipient selected.') . EOL); notice(DI::l10n()->t('No recipient selected.'));
break; break;
case -2: case -2:
notice(DI::l10n()->t('Unable to check your home location.') . EOL); notice(DI::l10n()->t('Unable to check your home location.'));
break; break;
case -3: case -3:
notice(DI::l10n()->t('Message could not be sent.') . EOL); notice(DI::l10n()->t('Message could not be sent.'));
break; break;
case -4: case -4:
notice(DI::l10n()->t('Message collection failure.') . EOL); notice(DI::l10n()->t('Message collection failure.'));
break; break;
default:
info(DI::l10n()->t('Message sent.') . EOL);
} }
DI::baseUrl()->redirect('profile/'.$user['nickname']); DI::baseUrl()->redirect('profile/'.$user['nickname']);
@ -95,14 +93,14 @@ function wallmessage_post(App $a) {
function wallmessage_content(App $a) { function wallmessage_content(App $a) {
if (!Profile::getMyURL()) { if (!Profile::getMyURL()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }
$recipient = (($a->argc > 1) ? $a->argv[1] : ''); $recipient = (($a->argc > 1) ? $a->argv[1] : '');
if (!$recipient) { if (!$recipient) {
notice(DI::l10n()->t('No recipient.') . EOL); notice(DI::l10n()->t('No recipient.'));
return; return;
} }
@ -111,7 +109,7 @@ function wallmessage_content(App $a) {
); );
if (! DBA::isResult($r)) { if (! DBA::isResult($r)) {
notice(DI::l10n()->t('No recipient.') . EOL); notice(DI::l10n()->t('No recipient.'));
Logger::log('wallmessage: no recipient'); Logger::log('wallmessage: no recipient');
return; return;
} }
@ -119,7 +117,7 @@ function wallmessage_content(App $a) {
$user = $r[0]; $user = $r[0];
if (!intval($user['unkmail'])) { if (!intval($user['unkmail'])) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }

View File

@ -240,22 +240,6 @@ class App
} }
} }
/**
* Returns the current UserAgent as a String
*
* @return string the UserAgent as a String
* @throws HTTPException\InternalServerErrorException
*/
public function getUserAgent()
{
return
FRIENDICA_PLATFORM . " '" .
FRIENDICA_CODENAME . "' " .
FRIENDICA_VERSION . '-' .
DB_UPDATE_VERSION . '; ' .
$this->baseURL->get();
}
/** /**
* Returns the current theme name. May be overriden by the mobile theme name. * Returns the current theme name. May be overriden by the mobile theme name.
* *

View File

@ -207,7 +207,7 @@ class Authentication
// if it's an email address or doesn't resolve to a URL, fail. // if it's an email address or doesn't resolve to a URL, fail.
if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) { if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) {
notice($this->l10n->t('Login failed.') . EOL); notice($this->l10n->t('Login failed.'));
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }
@ -270,7 +270,7 @@ class Authentication
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]); $this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
info($this->l10n->t('Login failed. Please check your credentials.' . EOL)); notice($this->l10n->t('Login failed. Please check your credentials.'));
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }
@ -389,8 +389,6 @@ class Authentication
info($this->l10n->t('Welcome %s', $user_record['username'])); info($this->l10n->t('Welcome %s', $user_record['username']));
info($this->l10n->t('Please upload a profile photo.')); info($this->l10n->t('Please upload a profile photo.'));
$this->baseUrl->redirect('settings/profile/photo/new'); $this->baseUrl->redirect('settings/profile/photo/new');
} else {
info($this->l10n->t("Welcome back %s", $user_record['username']));
} }
} }

View File

@ -237,7 +237,7 @@ class Module
public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post) public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post)
{ {
if ($this->printNotAllowedAddon) { if ($this->printNotAllowedAddon) {
info($l10n->t("You must be logged in to use addons. ")); notice($l10n->t("You must be logged in to use addons. "));
} }
/* The URL provided does not resolve to a valid module. /* The URL provided does not resolve to a valid module.

View File

@ -26,6 +26,8 @@ use FastRoute\DataGenerator\GroupCountBased;
use FastRoute\Dispatcher; use FastRoute\Dispatcher;
use FastRoute\RouteCollector; use FastRoute\RouteCollector;
use FastRoute\RouteParser\Std; use FastRoute\RouteParser\Std;
use Friendica\Core\Cache\Duration;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -66,14 +68,24 @@ class Router
/** @var L10n */ /** @var L10n */
private $l10n; private $l10n;
/** @var ICache */
private $cache;
/** @var string */
private $baseRoutesFilepath;
/** /**
* @param array $server The $_SERVER variable * @param array $server The $_SERVER variable
* @param L10n $l10n * @param string $baseRoutesFilepath The path to a base routes file to leverage cache, can be empty
* @param RouteCollector|null $routeCollector Optional the loaded Route collector * @param L10n $l10n
* @param ICache $cache
* @param RouteCollector|null $routeCollector
*/ */
public function __construct(array $server, L10n $l10n, RouteCollector $routeCollector = null) public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICache $cache, RouteCollector $routeCollector = null)
{ {
$this->baseRoutesFilepath = $baseRoutesFilepath;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->cache = $cache;
$httpMethod = $server['REQUEST_METHOD'] ?? self::GET; $httpMethod = $server['REQUEST_METHOD'] ?? self::GET;
$this->httpMethod = in_array($httpMethod, self::ALLOWED_METHODS) ? $httpMethod : self::GET; $this->httpMethod = in_array($httpMethod, self::ALLOWED_METHODS) ? $httpMethod : self::GET;
@ -84,6 +96,9 @@ class Router
} }
/** /**
* This will be called either automatically if a base routes file path was submitted,
* or can be called manually with a custom route array.
*
* @param array $routes The routes to add to the Router * @param array $routes The routes to add to the Router
* *
* @return self The router instance with the loaded routes * @return self The router instance with the loaded routes
@ -100,6 +115,9 @@ class Router
$this->routeCollector = $routeCollector; $this->routeCollector = $routeCollector;
// Add routes from addons
Hook::callAll('route_collection', $this->routeCollector);
return $this; return $this;
} }
@ -191,12 +209,9 @@ class Router
*/ */
public function getModuleClass($cmd) public function getModuleClass($cmd)
{ {
// Add routes from addons
Hook::callAll('route_collection', $this->routeCollector);
$cmd = '/' . ltrim($cmd, '/'); $cmd = '/' . ltrim($cmd, '/');
$dispatcher = new Dispatcher\GroupCountBased($this->routeCollector->getData()); $dispatcher = new Dispatcher\GroupCountBased($this->getCachedDispatchData());
$moduleClass = null; $moduleClass = null;
$this->parameters = []; $this->parameters = [];
@ -223,4 +238,51 @@ class Router
{ {
return $this->parameters; return $this->parameters;
} }
/**
* If a base routes file path has been provided, we can load routes from it if the cache misses.
*
* @return array
* @throws HTTPException\InternalServerErrorException
*/
private function getDispatchData()
{
$dispatchData = [];
if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) {
$dispatchData = require $this->baseRoutesFilepath;
if (!is_array($dispatchData)) {
throw new HTTPException\InternalServerErrorException('Invalid base routes file');
}
}
$this->loadRoutes($dispatchData);
return $this->routeCollector->getData();
}
/**
* We cache the dispatch data for speed, as computing the current routes (version 2020.09)
* takes about 850ms for each requests.
*
* The cached "routerDispatchData" lasts for a day, and must be cleared manually when there
* is any changes in the enabled addons list.
*
* @return array|mixed
* @throws HTTPException\InternalServerErrorException
*/
private function getCachedDispatchData()
{
$routerDispatchData = $this->cache->get('routerDispatchData');
if ($routerDispatchData) {
return $routerDispatchData;
}
$routerDispatchData = $this->getDispatchData();
$this->cache->set('routerDispatchData', $routerDispatchData, Duration::DAY);
return $routerDispatchData;
}
} }

View File

@ -95,7 +95,7 @@ class OEmbed
if (!in_array($ext, $noexts)) { if (!in_array($ext, $noexts)) {
// try oembed autodiscovery // try oembed autodiscovery
$html_text = Network::fetchUrl($embedurl, false, 15, 'text/*'); $html_text = DI::httpRequest()->fetch($embedurl, false, 15, 'text/*');
if ($html_text) { if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text); $dom = @DOMDocument::loadHTML($html_text);
if ($dom) { if ($dom) {
@ -103,14 +103,14 @@ class OEmbed
$entries = $xpath->query("//link[@type='application/json+oembed']"); $entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) { foreach ($entries as $e) {
$href = $e->getAttributeNode('href')->nodeValue; $href = $e->getAttributeNode('href')->nodeValue;
$json_string = Network::fetchUrl($href . '&maxwidth=' . $a->videowidth); $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth);
break; break;
} }
$entries = $xpath->query("//link[@type='text/json+oembed']"); $entries = $xpath->query("//link[@type='text/json+oembed']");
foreach ($entries as $e) { foreach ($entries as $e) {
$href = $e->getAttributeNode('href')->nodeValue; $href = $e->getAttributeNode('href')->nodeValue;
$json_string = Network::fetchUrl($href . '&maxwidth=' . $a->videowidth); $json_string = DI::httpRequest()->fetch($href . '&maxwidth=' . $a->videowidth);
break; break;
} }
} }

View File

@ -38,12 +38,10 @@ use Friendica\Model\Contact;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -487,7 +485,7 @@ class BBCode
continue; continue;
} }
$curlResult = Network::curl($mtch[1], true); $curlResult = DI::httpRequest()->get($mtch[1], true);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
continue; continue;
} }
@ -1096,11 +1094,11 @@ class BBCode
$ch = @curl_init($match[1]); $ch = @curl_init($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent()); @curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
@curl_exec($ch); @curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);
DI::profiler()->saveTimestamp($stamp1, "network", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "network");
if (substr($curl_info['content_type'], 0, 6) == 'image/') { if (substr($curl_info['content_type'], 0, 6) == 'image/') {
$text = "[url=" . $match[1] . ']' . $match[1] . "[/url]"; $text = "[url=" . $match[1] . ']' . $match[1] . "[/url]";
@ -1108,7 +1106,7 @@ class BBCode
$text = "[url=" . $match[2] . ']' . $match[2] . "[/url]"; $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
// if its not a picture then look if its a page that contains a picture link // if its not a picture then look if its a page that contains a picture link
$body = Network::fetchUrl($match[1]); $body = DI::httpRequest()->fetch($match[1]);
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($body); @$doc->loadHTML($body);
@ -1170,11 +1168,11 @@ class BBCode
$ch = @curl_init($match[1]); $ch = @curl_init($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent()); @curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
@curl_exec($ch); @curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);
DI::profiler()->saveTimestamp($stamp1, "network", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "network");
// if its a link to a picture then embed this picture // if its a link to a picture then embed this picture
if (substr($curl_info['content_type'], 0, 6) == 'image/') { if (substr($curl_info['content_type'], 0, 6) == 'image/') {
@ -1187,7 +1185,7 @@ class BBCode
} }
// if its not a picture then look if its a page that contains a picture link // if its not a picture then look if its a page that contains a picture link
$body = Network::fetchUrl($match[1]); $body = DI::httpRequest()->fetch($match[1]);
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($body); @$doc->loadHTML($body);
@ -2047,7 +2045,7 @@ class BBCode
// Now convert HTML to Markdown // Now convert HTML to Markdown
$text = HTML::toMarkdown($text); $text = HTML::toMarkdown($text);
DI::profiler()->saveTimestamp($stamp1, "parser", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "parser");
// Libertree has a problem with escaped hashtags. // Libertree has a problem with escaped hashtags.
$text = str_replace(['\#'], ['#'], $text); $text = str_replace(['\#'], ['#'], $text);

View File

@ -57,7 +57,7 @@ class Markdown
$html = $MarkdownParser->transform($text); $html = $MarkdownParser->transform($text);
DI::profiler()->saveTimestamp($stamp1, "parser", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "parser");
return $html; return $html;
} }

View File

@ -136,7 +136,7 @@ class Addon
$func(); $func();
} }
DBA::delete('hook', ['file' => 'addon/' . $addon . '/' . $addon . '.php']); Hook::delete(['file' => 'addon/' . $addon . '/' . $addon . '.php']);
unset(self::$addons[array_search($addon, self::$addons)]); unset(self::$addons[array_search($addon, self::$addons)]);
} }
@ -204,17 +204,9 @@ class Addon
} }
Logger::notice("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $addon['name']]); Logger::notice("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $addon['name']]);
@include_once($fname);
if (function_exists($addonname . '_uninstall')) { self::uninstall($fname);
$func = $addonname . '_uninstall'; self::install($fname);
$func(DI::app());
}
if (function_exists($addonname . '_install')) {
$func = $addonname . '_install';
$func(DI::app());
}
DBA::update('addon', ['timestamp' => $t], ['id' => $addon['id']]);
} }
} }
@ -256,7 +248,7 @@ class Addon
$stamp1 = microtime(true); $stamp1 = microtime(true);
$f = file_get_contents("addon/$addon/$addon.php"); $f = file_get_contents("addon/$addon/$addon.php");
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "file");
$r = preg_match("|/\*.*\*/|msU", $f, $m); $r = preg_match("|/\*.*\*/|msU", $f, $m);

View File

@ -56,7 +56,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->getAllKeys($prefix); $return = $this->cache->getAllKeys($prefix);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} }
@ -70,7 +70,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->get($key); $return = $this->cache->get($key);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} }
@ -84,7 +84,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->set($key, $value, $ttl); $return = $this->cache->set($key, $value, $ttl);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} }
@ -98,7 +98,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->delete($key); $return = $this->cache->delete($key);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} }
@ -112,7 +112,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->clear($outdated); $return = $this->cache->clear($outdated);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} }
@ -127,7 +127,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->add($key, $value, $ttl); $return = $this->cache->add($key, $value, $ttl);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} else { } else {
@ -145,7 +145,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl); $return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} else { } else {
@ -163,7 +163,7 @@ class ProfilerCache implements ICache, IMemoryCache
$return = $this->cache->compareDelete($key, $value); $return = $this->cache->compareDelete($key, $value);
$this->profiler->saveTimestamp($time, 'cache', System::callstack()); $this->profiler->saveTimestamp($time, 'cache');
return $return; return $return;
} else { } else {

View File

@ -99,9 +99,7 @@ class Hook
return true; return true;
} }
$result = DBA::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]); return self::insert(['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
return $result;
} }
/** /**
@ -119,10 +117,10 @@ class Hook
// This here is only needed for fixing a problem that existed on the develop branch // This here is only needed for fixing a problem that existed on the develop branch
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
DBA::delete('hook', $condition); self::delete($condition);
$condition = ['hook' => $hook, 'file' => $relative_file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $relative_file, 'function' => $function];
$result = DBA::delete('hook', $condition); $result = self::delete($condition);
return $result; return $result;
} }
@ -220,7 +218,7 @@ class Hook
} else { } else {
// remove orphan hooks // remove orphan hooks
$condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]]; $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
DBA::delete('hook', $condition, ['cascade' => false]); self::delete($condition, ['cascade' => false]);
} }
} }
@ -245,4 +243,45 @@ class Hook
return false; return false;
} }
/**
* Deletes one or more hook records
*
* We have to clear the cached routerDispatchData because addons can provide routes
*
* @param array $condition
* @param array $options
* @return bool
* @throws \Exception
*/
public static function delete(array $condition, array $options = [])
{
$result = DBA::delete('hook', $condition, $options);
if ($result) {
DI::cache()->delete('routerDispatchData');
}
return $result;
}
/**
* Inserts a hook record
*
* We have to clear the cached routerDispatchData because addons can provide routes
*
* @param array $condition
* @return bool
* @throws \Exception
*/
private static function insert(array $condition)
{
$result = DBA::insert('hook', $condition);
if ($result) {
DI::cache()->delete('routerDispatchData');
}
return $result;
}
} }

View File

@ -28,7 +28,6 @@ use Friendica\Database\Database;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/** /**
@ -548,11 +547,11 @@ class Installer
$help = ""; $help = "";
$error_msg = ""; $error_msg = "";
if (function_exists('curl_init')) { if (function_exists('curl_init')) {
$fetchResult = Network::fetchUrlFull($baseurl . "/install/testrewrite"); $fetchResult = DI::httpRequest()->fetchFull($baseurl . "/install/testrewrite");
$url = Strings::normaliseLink($baseurl . "/install/testrewrite"); $url = Strings::normaliseLink($baseurl . "/install/testrewrite");
if ($fetchResult->getReturnCode() != 204) { if ($fetchResult->getReturnCode() != 204) {
$fetchResult = Network::fetchUrlFull($url); $fetchResult = DI::httpRequest()->fetchFull($url);
} }
if ($fetchResult->getReturnCode() != 204) { if ($fetchResult->getReturnCode() != 204) {

View File

@ -21,7 +21,7 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\Util\Network; use Friendica\DI;
/** /**
* Manage compatibility with federated networks * Manage compatibility with federated networks
@ -91,7 +91,6 @@ class Protocol
* @param string $profile_url * @param string $profile_url
* @param array $matches preg_match return array: [0] => Full match [1] => hostname [2] => username * @param array $matches preg_match return array: [0] => Full match [1] => hostname [2] => username
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function matchByProfileUrl($profile_url, &$matches = []) public static function matchByProfileUrl($profile_url, &$matches = [])
{ {
@ -123,7 +122,7 @@ class Protocol
if (preg_match('=https?://(.*)/user/(.*)=ism', $profile_url, $matches)) { if (preg_match('=https?://(.*)/user/(.*)=ism', $profile_url, $matches)) {
$statusnet_host = $matches[1]; $statusnet_host = $matches[1];
$statusnet_user = $matches[2]; $statusnet_user = $matches[2];
$UserData = Network::fetchUrl('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user); $UserData = DI::httpRequest()->fetch('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
$user = json_decode($UserData); $user = json_decode($UserData);
if ($user) { if ($user) {
$matches[2] = $user->screen_name; $matches[2] = $user->screen_name;

View File

@ -92,7 +92,7 @@ class Renderer
throw new InternalServerErrorException($message); throw new InternalServerErrorException($message);
} }
DI::profiler()->saveTimestamp($stamp1, "rendering", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "rendering");
return $output; return $output;
} }
@ -121,7 +121,7 @@ class Renderer
throw new InternalServerErrorException($message); throw new InternalServerErrorException($message);
} }
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "file");
return $template; return $template;
} }

View File

@ -123,7 +123,7 @@ class Search
$searchUrl .= '&page=' . $page; $searchUrl .= '&page=' . $page;
} }
$resultJson = Network::fetchUrl($searchUrl, false, 0, 'application/json'); $resultJson = DI::httpRequest()->fetch($searchUrl, false, 0, 'application/json');
$results = json_decode($resultJson, true); $results = json_decode($resultJson, true);
@ -284,7 +284,7 @@ class Search
$return = GContact::searchByName($search, $mode); $return = GContact::searchByName($search, $mode);
} else { } else {
$p = $page > 1 ? 'p=' . $page : ''; $p = $page > 1 ? 'p=' . $page : '';
$curlResult = Network::curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']); $curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$searchResult = json_decode($curlResult->getBody(), true); $searchResult = json_decode($curlResult->getBody(), true);
if (!empty($searchResult['profiles'])) { if (!empty($searchResult['profiles'])) {

View File

@ -33,22 +33,23 @@ class System
/** /**
* Returns a string with a callstack. Can be used for logging. * Returns a string with a callstack. Can be used for logging.
* *
* @param integer $depth optional, default 4 * @param integer $depth How many calls to include in the stacks after filtering
* @param int $offset How many calls to shave off the top of the stack, for example if
* this is called from a centralized method that isn't relevant to the callstack
* @return string * @return string
*/ */
public static function callstack($depth = 4) public static function callstack(int $depth = 4, int $offset = 0)
{ {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
// We remove the first two items from the list since they contain data that we don't need. // We remove at least the first two items from the list since they contain data that we don't need.
array_shift($trace); $trace = array_slice($trace, 2 + $offset);
array_shift($trace);
$callstack = []; $callstack = [];
$previous = ['class' => '', 'function' => '', 'database' => false]; $previous = ['class' => '', 'function' => '', 'database' => false];
// The ignore list contains all functions that are only wrapper functions // The ignore list contains all functions that are only wrapper functions
$ignore = ['fetchUrl', 'call_user_func_array']; $ignore = ['call_user_func_array'];
while ($func = array_pop($trace)) { while ($func = array_pop($trace)) {
if (!empty($func['class'])) { if (!empty($func['class'])) {

View File

@ -90,7 +90,7 @@ class Theme
$stamp1 = microtime(true); $stamp1 = microtime(true);
$theme_file = file_get_contents("view/theme/$theme/theme.php"); $theme_file = file_get_contents("view/theme/$theme/theme.php");
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack()); DI::profiler()->saveTimestamp($stamp1, "file");
$result = preg_match("|/\*.*\*/|msU", $theme_file, $matches); $result = preg_match("|/\*.*\*/|msU", $theme_file, $matches);
@ -158,6 +158,8 @@ class Theme
if (function_exists($func)) { if (function_exists($func)) {
$func(); $func();
} }
Hook::delete(['file' => "view/theme/$theme/theme.php"]);
} }
$allowed_themes = Theme::getAllowedList(); $allowed_themes = Theme::getAllowedList();

View File

@ -271,7 +271,7 @@ class UserImport
if ($r === false) { if ($r === false) {
Logger::log("uimport:insert profile: ERROR : " . DBA::errorMessage(), Logger::INFO); Logger::log("uimport:insert profile: ERROR : " . DBA::errorMessage(), Logger::INFO);
info(DI::l10n()->t("User profile creation error")); notice(DI::l10n()->t("User profile creation error"));
DBA::delete('user', ['uid' => $newuid]); DBA::delete('user', ['uid' => $newuid]);
DBA::delete('profile_field', ['uid' => $newuid]); DBA::delete('profile_field', ['uid' => $newuid]);
return; return;

View File

@ -26,7 +26,6 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Process; use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
/** /**
* Contains the class for the worker background job processing * Contains the class for the worker background job processing
@ -997,7 +996,7 @@ class Worker
} }
$url = DI::baseUrl() . '/worker'; $url = DI::baseUrl() . '/worker';
Network::fetchUrl($url, false, 1); DI::httpRequest()->fetch($url, false, 1);
} }
/** /**

View File

@ -323,6 +323,18 @@ abstract class DI
return self::$dice->create(Model\Storage\IStorage::class); return self::$dice->create(Model\Storage\IStorage::class);
} }
//
// "Network" namespace
//
/**
* @return Network\IHTTPRequest
*/
public static function httpRequest()
{
return self::$dice->create(Network\IHTTPRequest::class);
}
// //
// "Repository" namespace // "Repository" namespace
// //

View File

@ -699,7 +699,7 @@ class Database
$this->errorno = $errorno; $this->errorno = $errorno;
} }
$this->profiler->saveTimestamp($stamp1, 'database', System::callstack()); $this->profiler->saveTimestamp($stamp1, 'database');
if ($this->configCache->get('system', 'db_log')) { if ($this->configCache->get('system', 'db_log')) {
$stamp2 = microtime(true); $stamp2 = microtime(true);
@ -783,7 +783,7 @@ class Database
$this->errorno = $errorno; $this->errorno = $errorno;
} }
$this->profiler->saveTimestamp($stamp, "database_write", System::callstack()); $this->profiler->saveTimestamp($stamp, "database_write");
return $retval; return $retval;
} }
@ -964,7 +964,7 @@ class Database
} }
} }
$this->profiler->saveTimestamp($stamp1, 'database', System::callstack()); $this->profiler->saveTimestamp($stamp1, 'database');
return $columns; return $columns;
} }
@ -1644,7 +1644,7 @@ class Database
break; break;
} }
$this->profiler->saveTimestamp($stamp1, 'database', System::callstack()); $this->profiler->saveTimestamp($stamp1, 'database');
return $ret; return $ret;
} }

View File

@ -85,7 +85,7 @@ class SessionFactory
$session = new Session\Native($baseURL, $handler); $session = new Session\Native($baseURL, $handler);
} }
} finally { } finally {
$profiler->saveTimestamp($stamp1, 'parser', System::callstack()); $profiler->saveTimestamp($stamp1, 'parser');
return $session; return $session;
} }
} }

View File

@ -24,15 +24,13 @@ namespace Friendica\Model;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\ActivityNamespace;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\JsonLD;
use Friendica\Util\Network;
class APContact class APContact
{ {

View File

@ -1418,7 +1418,6 @@ class Contact
'poll' => $data['poll'] ?? '', 'poll' => $data['poll'] ?? '',
'name' => $data['name'] ?? '', 'name' => $data['name'] ?? '',
'nick' => $data['nick'] ?? '', 'nick' => $data['nick'] ?? '',
'photo' => $data['photo'] ?? '',
'keywords' => $data['keywords'] ?? '', 'keywords' => $data['keywords'] ?? '',
'location' => $data['location'] ?? '', 'location' => $data['location'] ?? '',
'about' => $data['about'] ?? '', 'about' => $data['about'] ?? '',
@ -1464,7 +1463,7 @@ class Contact
} }
if (!empty($data['photo']) && ($data['network'] != Protocol::FEED)) { if (!empty($data['photo']) && ($data['network'] != Protocol::FEED)) {
self::updateAvatar($data['photo'], $uid, $contact_id); self::updateAvatar($contact_id, $data['photo']);
} }
if (in_array($data["network"], array_merge(Protocol::NATIVE_SUPPORT, [Protocol::PUMPIO]))) { if (in_array($data["network"], array_merge(Protocol::NATIVE_SUPPORT, [Protocol::PUMPIO]))) {
@ -1474,14 +1473,6 @@ class Contact
} else { } else {
// Else do a direct update // Else do a direct update
self::updateFromProbe($contact_id, '', false); self::updateFromProbe($contact_id, '', false);
// Update the gcontact entry
if ($uid == 0) {
GContact::updateFromPublicContactID($contact_id);
if (($data['network'] == Protocol::ACTIVITYPUB) && in_array(DI::config()->get('system', 'gcontact_discovery'), [GContact::DISCOVERY_DIRECT, GContact::DISCOVERY_RECURSIVE])) {
GContact::discoverFollowers($data['url']);
}
}
} }
} else { } else {
$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl', 'gsid']; $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl', 'gsid'];
@ -1775,12 +1766,80 @@ class Contact
return $return; return $return;
} }
/**
* Ensure that cached avatar exist
*
* @param integer $cid
*/
public static function checkAvatarCache(int $cid)
{
$contact = DBA::selectFirst('contact', ['url', 'avatar', 'photo', 'thumb', 'micro'], ['id' => $cid, 'uid' => 0, 'self' => false]);
if (!DBA::isResult($contact)) {
return;
}
if (empty($contact['avatar']) || (!empty($contact['photo']) && !empty($contact['thumb']) && !empty($contact['micro']))) {
return;
}
Logger::info('Adding avatar cache', ['id' => $cid, 'contact' => $contact]);
self::updateAvatar($cid, $contact['avatar'], true);
}
/**
* Check the given contact array for avatar cache fields
*
* @param array $contact
* @return array contact array with avatar cache fields
*/
public static function checkAvatarCacheByArray(array $contact)
{
$update = false;
$contact_fields = [];
$fields = ['photo', 'thumb', 'micro'];
foreach ($fields as $field) {
if (isset($contact[$field])) {
$contact_fields[] = $field;
}
if (isset($contact[$field]) && empty($contact[$field])) {
$update = true;
}
}
if (!$update) {
return $contact;
}
if (!empty($contact['id']) && !empty($contact['avatar'])) {
self::updateAvatar($contact['id'], $contact['avatar'], true);
$new_contact = self::getById($contact['id'], $contact_fields);
if (DBA::isResult($new_contact)) {
// We only update the cache fields
$contact = array_merge($contact, $new_contact);
}
}
/// add the default avatars if the fields aren't filled
if (isset($contact['photo']) && empty($contact['photo'])) {
$contact['photo'] = DI::baseUrl() . '/images/person-300.jpg';
}
if (isset($contact['thumb']) && empty($contact['thumb'])) {
$contact['thumb'] = DI::baseUrl() . '/images/person-80.jpg';
}
if (isset($contact['micro']) && empty($contact['micro'])) {
$contact['micro'] = DI::baseUrl() . '/images/person-48.jpg';
}
return $contact;
}
/** /**
* Updates the avatar links in a contact only if needed * Updates the avatar links in a contact only if needed
* *
* @param string $avatar Link to avatar picture
* @param int $uid User id of contact owner
* @param int $cid Contact id * @param int $cid Contact id
* @param string $avatar Link to avatar picture
* @param bool $force force picture update * @param bool $force force picture update
* *
* @return void * @return void
@ -1788,41 +1847,51 @@ class Contact
* @throws HTTPException\NotFoundException * @throws HTTPException\NotFoundException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function updateAvatar($avatar, $uid, $cid, $force = false) public static function updateAvatar(int $cid, string $avatar, bool $force = false)
{ {
$contact = DBA::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid, 'self' => false]); $contact = DBA::selectFirst('contact', ['uid', 'avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid, 'self' => false]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
return; return;
} }
$uid = $contact['uid'];
// Only update the cached photo links of public contacts when they already are cached
if (($uid == 0) && !$force && empty($contact['thumb']) && empty($contact['micro'])) {
if ($contact['avatar'] != $avatar) {
DBA::update('contact', ['avatar' => $avatar], ['id' => $cid]);
Logger::info('Only update the avatar', ['id' => $cid, 'avatar' => $avatar, 'contact' => $contact]);
}
return;
}
$data = [ $data = [
$contact['photo'] ?? '', $contact['photo'] ?? '',
$contact['thumb'] ?? '', $contact['thumb'] ?? '',
$contact['micro'] ?? '', $contact['micro'] ?? '',
]; ];
foreach ($data as $image_uri) { $update = ($contact['avatar'] != $avatar) || $force;
$image_rid = Photo::ridFromURI($image_uri);
if ($image_rid && !Photo::exists(['resource-id' => $image_rid, 'uid' => $uid])) { if (!$update) {
Logger::info('Regenerating avatar', ['contact uid' => $uid, 'cid' => $cid, 'missing photo' => $image_rid, 'avatar' => $contact['avatar']]); foreach ($data as $image_uri) {
$force = true; $image_rid = Photo::ridFromURI($image_uri);
if ($image_rid && !Photo::exists(['resource-id' => $image_rid, 'uid' => $uid])) {
Logger::info('Regenerating avatar', ['contact uid' => $uid, 'cid' => $cid, 'missing photo' => $image_rid, 'avatar' => $contact['avatar']]);
$update = true;
}
} }
} }
if (($contact["avatar"] != $avatar) || $force) { if ($update) {
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true); $photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
if ($photos) { if ($photos) {
$fields = ['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()]; $fields = ['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()];
DBA::update('contact', $fields, ['id' => $cid]); DBA::update('contact', $fields, ['id' => $cid]);
} elseif (empty($contact['avatar'])) {
// Update the public contact (contact id = 0) // Ensure that the avatar field is set
if ($uid != 0) { DBA::update('contact', ['avatar' => $avatar], ['id' => $cid]);
$pcontact = DBA::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]); Logger::info('Failed profile import', ['id' => $cid, 'force' => $force, 'avatar' => $avatar, 'contact' => $contact]);
if (DBA::isResult($pcontact)) {
DBA::update('contact', $fields, ['id' => $pcontact['id']]);
}
}
} }
} }
} }
@ -2006,6 +2075,13 @@ class Contact
$new_pubkey = $ret['pubkey']; $new_pubkey = $ret['pubkey'];
// Update the gcontact entry
if ($uid == 0) {
GContact::updateFromPublicContactID($id);
}
ContactRelation::discoverByUrl($ret['url']);
$update = false; $update = false;
// make sure to not overwrite existing values with blank entries except some technical fields // make sure to not overwrite existing values with blank entries except some technical fields
@ -2021,7 +2097,7 @@ class Contact
} }
if (!empty($ret['photo']) && ($ret['network'] != Protocol::FEED)) { if (!empty($ret['photo']) && ($ret['network'] != Protocol::FEED)) {
self::updateAvatar($ret['photo'], $uid, $id, $update || $force); self::updateAvatar($id, $ret['photo'], $update || $force);
} }
if (!$update) { if (!$update) {
@ -2311,7 +2387,7 @@ class Contact
Group::addMember(User::getDefaultGroup($user['uid'], $contact["network"]), $contact_id); Group::addMember(User::getDefaultGroup($user['uid'], $contact["network"]), $contact_id);
// Update the avatar // Update the avatar
self::updateAvatar($ret['photo'], $user['uid'], $contact_id); self::updateAvatar($contact_id, $ret['photo']);
// pull feed and consume it, which should subscribe to the hub. // pull feed and consume it, which should subscribe to the hub.
@ -2479,7 +2555,6 @@ class Contact
'nurl' => Strings::normaliseLink($url), 'nurl' => Strings::normaliseLink($url),
'name' => $name, 'name' => $name,
'nick' => $nick, 'nick' => $nick,
'photo' => $photo,
'network' => $network, 'network' => $network,
'rel' => self::FOLLOWER, 'rel' => self::FOLLOWER,
'blocked' => 0, 'blocked' => 0,
@ -2493,7 +2568,7 @@ class Contact
// Ensure to always have the correct network type, independent from the connection request method // Ensure to always have the correct network type, independent from the connection request method
self::updateFromProbe($contact_id, '', true); self::updateFromProbe($contact_id, '', true);
Contact::updateAvatar($photo, $importer["uid"], $contact_id, true); self::updateAvatar($contact_id, $photo, true);
$contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]); $contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]);

View File

@ -0,0 +1,171 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Model;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
class ContactRelation
{
/**
* No discovery of followers/followings
*/
const DISCOVERY_NONE = 0;
/**
* Discover followers/followings of local contacts
*/
const DISCOVERY_LOCAL = 1;
/**
* Discover followers/followings of local contacts and contacts that visibly interacted on the system
*/
const DISCOVERY_INTERACTOR = 2;
/**
* Discover followers/followings of all contacts
*/
const DISCOVERY_ALL = 3;
public static function store(int $target, int $actor, string $interaction_date)
{
if ($actor == $target) {
return;
}
DBA::update('contact-relation', ['last-interaction' => $interaction_date], ['cid' => $target, 'relation-cid' => $actor], true);
}
/**
* Fetches the followers of a given profile and adds them
*
* @param string $url URL of a profile
* @return void
*/
public static function discoverByUrl(string $url)
{
$contact_discovery = DI::config()->get('system', 'contact_discovery');
if ($contact_discovery == self::DISCOVERY_NONE) {
return;
}
$contact = Contact::getByURL($url);
if (empty($contact)) {
return;
}
if ($contact['last-discovery'] > DateTimeFormat::utc('now - 1 month')) {
Logger::info('No discovery - Last was less than a month ago.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['last-discovery']]);
return;
}
if ($contact_discovery != self::DISCOVERY_ALL) {
$local = DBA::exists('contact', ["`nurl` = ? AND `uid` != ?", Strings::normaliseLink($url), 0]);
if (($contact_discovery == self::DISCOVERY_LOCAL) && !$local) {
Logger::info('No discovery - This contact is not followed/following locally.', ['id' => $contact['id'], 'url' => $url]);
return;
}
if ($contact_discovery == self::DISCOVERY_INTERACTOR) {
$interactor = DBA::exists('contact-relation', ["`relation-cid` = ? AND `last-interaction` > ?", $contact['id'], DBA::NULL_DATETIME]);
if (!$local && !$interactor) {
Logger::info('No discovery - This contact is not interacting locally.', ['id' => $contact['id'], 'url' => $url]);
return;
}
}
} elseif ($contact['created'] > DateTimeFormat::utc('now - 1 day')) {
// Newly created contacts are not discovered to avoid DDoS attacks
Logger::info('No discovery - Contact record is less than a day old.', ['id' => $contact['id'], 'url' => $url, 'discovery' => $contact['created']]);
return;
}
if (in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS])) {
// The contact is (most likely) speaking AP, so updating is allowed
$apcontact = APContact::getByURL($url);
} else {
// The contact isn't obviously speaking AP, so we don't allow updating
$apcontact = APContact::getByURL($url, false);
}
if (!empty($apcontact['followers']) && is_string($apcontact['followers'])) {
$followers = ActivityPub::fetchItems($apcontact['followers']);
} else {
$followers = [];
}
if (!empty($apcontact['following']) && is_string($apcontact['following'])) {
$followings = ActivityPub::fetchItems($apcontact['following']);
} else {
$followings = [];
}
if (empty($followers) && empty($followings)) {
return;
}
$target = $contact['id'];
if (!empty($followers)) {
// Clear the follower list, since it will be recreated in the next step
DBA::update('contact-relation', ['follows' => false], ['cid' => $target]);
}
$contacts = [];
foreach (array_merge($followers, $followings) as $contact) {
if (is_string($contact)) {
$contacts[] = $contact;
} elseif (!empty($contact['url']) && is_string($contact['url'])) {
$contacts[] = $contact['url'];
}
}
$contacts = array_unique($contacts);
Logger::info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
foreach ($contacts as $contact) {
$actor = Contact::getIdForURL($contact);
if (!empty($actor)) {
$fields = [];
if (in_array($contact, $followers)) {
$fields = ['cid' => $target, 'relation-cid' => $actor];
} elseif (in_array($contact, $followings)) {
$fields = ['cid' => $actor, 'relation-cid' => $target];
} else {
continue;
}
DBA::update('contact-relation', ['follows' => true, 'follow-updated' => DateTimeFormat::utcNow()], $fields, true);
}
}
if (!empty($followers)) {
// Delete all followers that aren't followers anymore (and aren't interacting)
DBA::delete('contact-relation', ['cid' => $target, 'follows' => false, 'last-interaction' => DBA::NULL_DATETIME]);
}
DBA::update('contact', ['last-discovery' => DateTimeFormat::utcNow()], ['id' => $target]);
Logger::info('Contacts discovery finished, "last-discovery" set', ['id' => $target, 'url' => $url]);
return;
}
}

View File

@ -271,8 +271,6 @@ class FileTag
if (!strlen($saved) || !stristr($saved, '[' . self::encode($file) . ']')) { if (!strlen($saved) || !stristr($saved, '[' . self::encode($file) . ']')) {
DI::pConfig()->set($uid, 'system', 'filetags', $saved . '[' . self::encode($file) . ']'); DI::pConfig()->set($uid, 'system', 'filetags', $saved . '[' . self::encode($file) . ']');
} }
info(DI::l10n()->t('Item filed'));
} }
return true; return true;

View File

@ -26,8 +26,8 @@ use DOMXPath;
use Exception; use Exception;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -43,19 +43,6 @@ use Friendica\Util\Strings;
*/ */
class GContact class GContact
{ {
/**
* No discovery of followers/followings
*/
const DISCOVERY_NONE = 0;
/**
* Only discover followers/followings from direct contacts
*/
const DISCOVERY_DIRECT = 1;
/**
* Recursive discovery of followers/followings
*/
const DISCOVERY_RECURSIVE = 2;
/** /**
* Search global contact table by nick or name * Search global contact table by nick or name
* *
@ -537,7 +524,7 @@ class GContact
$done[] = DI::baseUrl() . '/poco'; $done[] = DI::baseUrl() . '/poco';
if (strlen(DI::config()->get('system', 'directory'))) { if (strlen(DI::config()->get('system', 'directory'))) {
$x = Network::fetchUrl(Search::getGlobalDirectory() . '/pubsites'); $x = DI::httpRequest()->fetch(Search::getGlobalDirectory() . '/pubsites');
if (!empty($x)) { if (!empty($x)) {
$j = json_decode($x); $j = json_decode($x);
if (!empty($j->entries)) { if (!empty($j->entries)) {
@ -845,7 +832,7 @@ class GContact
return false; return false;
} }
$curlResult = Network::curl($gserver['noscrape'] . '/' . $data['nick']); $curlResult = DI::httpRequest()->get($gserver['noscrape'] . '/' . $data['nick']);
if ($curlResult->isSuccess() && !empty($curlResult->getBody())) { if ($curlResult->isSuccess() && !empty($curlResult->getBody())) {
$noscrape = json_decode($curlResult->getBody(), true); $noscrape = json_decode($curlResult->getBody(), true);
@ -927,7 +914,7 @@ class GContact
private static function updateFromFeed(array $data) private static function updateFromFeed(array $data)
{ {
// Search for the newest entry in the feed // Search for the newest entry in the feed
$curlResult = Network::curl($data['poll']); $curlResult = DI::httpRequest()->get($data['poll']);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()]; $fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]); DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
@ -1205,7 +1192,7 @@ class GContact
$url = $server . '/main/statistics'; $url = $server . '/main/statistics';
$curlResult = Network::curl($url); $curlResult = DI::httpRequest()->get($url);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return false; return false;
} }
@ -1288,129 +1275,6 @@ class GContact
} }
} }
/**
* Fetches the followers of a given profile and adds them
*
* @param string $url URL of a profile
* @return void
*/
public static function discoverFollowers(string $url)
{
$gcontact = DBA::selectFirst('gcontact', ['id', 'last_discovery'], ['nurl' => Strings::normaliseLink(($url))]);
if (!DBA::isResult($gcontact)) {
return;
}
if ($gcontact['last_discovery'] > DateTimeFormat::utc('now - 1 month')) {
Logger::info('Last discovery was less then a month before.', ['url' => $url, 'discovery' => $gcontact['last_discovery']]);
return;
}
$gcid = $gcontact['id'];
$apcontact = APContact::getByURL($url);
if (!empty($apcontact['followers']) && is_string($apcontact['followers'])) {
$followers = ActivityPub::fetchItems($apcontact['followers']);
} else {
$followers = [];
}
if (!empty($apcontact['following']) && is_string($apcontact['following'])) {
$followings = ActivityPub::fetchItems($apcontact['following']);
} else {
$followings = [];
}
if (!empty($followers) || !empty($followings)) {
if (!empty($followers)) {
// Clear the follower list, since it will be recreated in the next step
DBA::update('gfollower', ['deleted' => true], ['gcid' => $gcid]);
}
$contacts = [];
foreach (array_merge($followers, $followings) as $contact) {
if (is_string($contact)) {
$contacts[] = $contact;
} elseif (!empty($contact['url']) && is_string($contact['url'])) {
$contacts[] = $contact['url'];
}
}
$contacts = array_unique($contacts);
Logger::info('Discover AP contacts', ['url' => $url, 'contacts' => count($contacts)]);
foreach ($contacts as $contact) {
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(($contact))]);
if (DBA::isResult($gcontact)) {
$fields = [];
if (in_array($contact, $followers)) {
$fields = ['gcid' => $gcid, 'follower-gcid' => $gcontact['id']];
} elseif (in_array($contact, $followings)) {
$fields = ['gcid' => $gcontact['id'], 'follower-gcid' => $gcid];
}
if (!empty($fields)) {
Logger::info('Set relation between contacts', $fields);
DBA::update('gfollower', ['deleted' => false], $fields, true);
continue;
}
}
if (!Network::isUrlBlocked($contact)) {
Logger::info('Discover new AP contact', ['url' => $contact]);
Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact, 'nodiscover');
} else {
Logger::info('No discovery, the URL is blocked.', ['url' => $contact]);
}
}
if (!empty($followers)) {
// Delete all followers that aren't undeleted
DBA::delete('gfollower', ['gcid' => $gcid, 'deleted' => true]);
}
DBA::update('gcontact', ['last_discovery' => DateTimeFormat::utcNow()], ['id' => $gcid]);
Logger::info('AP contacts discovery finished, last discovery set', ['url' => $url]);
return;
}
$data = Probe::uri($url);
if (empty($data['poco'])) {
return;
}
$curlResult = Network::curl($data['poco']);
if (!$curlResult->isSuccess()) {
return;
}
$poco = json_decode($curlResult->getBody(), true);
if (empty($poco['entry'])) {
return;
}
Logger::info('PoCo Discovery started', ['url' => $url, 'contacts' => count($poco['entry'])]);
foreach ($poco['entry'] as $entries) {
if (!empty($entries['urls'])) {
foreach ($entries['urls'] as $entry) {
if ($entry['type'] == 'profile') {
if (DBA::exists('gcontact', ['nurl' => Strings::normaliseLink(($entry['value']))])) {
continue;
}
if (!Network::isUrlBlocked($entry['value'])) {
Logger::info('Discover new PoCo contact', ['url' => $entry['value']]);
Worker::add(PRIORITY_LOW, 'UpdateGContact', $entry['value'], 'nodiscover');
} else {
Logger::info('No discovery, the URL is blocked.', ['url' => $entry['value']]);
}
}
}
}
}
DBA::update('gcontact', ['last_discovery' => DateTimeFormat::utcNow()], ['id' => $gcid]);
Logger::info('PoCo Discovery finished', ['url' => $url]);
}
/** /**
* Returns a random, global contact of the current node * Returns a random, global contact of the current node
* *

View File

@ -23,20 +23,20 @@ namespace Friendica\Model;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Network\CurlResult; use Friendica\Network\CurlResult;
use Friendica\Util\Network; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Diaspora;
/** /**
* This class handles GServer related functions * This class handles GServer related functions
@ -309,7 +309,7 @@ class GServer
// When a nodeinfo is present, we don't need to dig further // When a nodeinfo is present, we don't need to dig further
$xrd_timeout = DI::config()->get('system', 'xrd_timeout'); $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
$curlResult = Network::curl($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]); $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
if ($curlResult->isTimeout()) { if ($curlResult->isTimeout()) {
self::setFailure($url); self::setFailure($url);
return false; return false;
@ -342,7 +342,7 @@ class GServer
$basedata = ['detection-method' => self::DETECT_MANUAL]; $basedata = ['detection-method' => self::DETECT_MANUAL];
} }
$curlResult = Network::curl($baseurl, false, ['timeout' => $xrd_timeout]); $curlResult = DI::httpRequest()->get($baseurl, false, ['timeout' => $xrd_timeout]);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$basedata = self::analyseRootHeader($curlResult, $basedata); $basedata = self::analyseRootHeader($curlResult, $basedata);
$basedata = self::analyseRootBody($curlResult, $basedata, $baseurl); $basedata = self::analyseRootBody($curlResult, $basedata, $baseurl);
@ -359,7 +359,7 @@ class GServer
// When the base path doesn't seem to contain a social network we try the complete path. // When the base path doesn't seem to contain a social network we try the complete path.
// Most detectable system have to be installed in the root directory. // Most detectable system have to be installed in the root directory.
// We checked the base to avoid false positives. // We checked the base to avoid false positives.
$curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout]); $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout]);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$urldata = self::analyseRootHeader($curlResult, $serverdata); $urldata = self::analyseRootHeader($curlResult, $serverdata);
$urldata = self::analyseRootBody($curlResult, $urldata, $url); $urldata = self::analyseRootBody($curlResult, $urldata, $url);
@ -498,7 +498,7 @@ class GServer
{ {
Logger::info('Discover relay data', ['server' => $server_url]); Logger::info('Discover relay data', ['server' => $server_url]);
$curlResult = Network::curl($server_url . '/.well-known/x-social-relay'); $curlResult = DI::httpRequest()->get($server_url . '/.well-known/x-social-relay');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return; return;
} }
@ -579,7 +579,7 @@ class GServer
*/ */
private static function fetchStatistics(string $url) private static function fetchStatistics(string $url)
{ {
$curlResult = Network::curl($url . '/statistics.json'); $curlResult = DI::httpRequest()->get($url . '/statistics.json');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return []; return [];
} }
@ -689,7 +689,8 @@ class GServer
*/ */
private static function parseNodeinfo1(string $nodeinfo_url) private static function parseNodeinfo1(string $nodeinfo_url)
{ {
$curlResult = Network::curl($nodeinfo_url); $curlResult = DI::httpRequest()->get($nodeinfo_url);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return []; return [];
} }
@ -765,7 +766,7 @@ class GServer
*/ */
private static function parseNodeinfo2(string $nodeinfo_url) private static function parseNodeinfo2(string $nodeinfo_url)
{ {
$curlResult = Network::curl($nodeinfo_url); $curlResult = DI::httpRequest()->get($nodeinfo_url);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return []; return [];
} }
@ -842,7 +843,7 @@ class GServer
*/ */
private static function fetchSiteinfo(string $url, array $serverdata) private static function fetchSiteinfo(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/siteinfo.json'); $curlResult = DI::httpRequest()->get($url . '/siteinfo.json');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return $serverdata; return $serverdata;
} }
@ -911,7 +912,7 @@ class GServer
private static function validHostMeta(string $url) private static function validHostMeta(string $url)
{ {
$xrd_timeout = DI::config()->get('system', 'xrd_timeout'); $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
$curlResult = Network::curl($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]); $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return false; return false;
} }
@ -1007,7 +1008,7 @@ class GServer
{ {
$serverdata['poco'] = ''; $serverdata['poco'] = '';
$curlResult = Network::curl($url. '/poco'); $curlResult = DI::httpRequest()->get($url . '/poco');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return $serverdata; return $serverdata;
} }
@ -1037,7 +1038,7 @@ class GServer
*/ */
public static function checkMastodonDirectory(string $url, array $serverdata) public static function checkMastodonDirectory(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/api/v1/directory?limit=1'); $curlResult = DI::httpRequest()->get($url . '/api/v1/directory?limit=1');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return $serverdata; return $serverdata;
} }
@ -1064,7 +1065,8 @@ class GServer
*/ */
private static function detectNextcloud(string $url, array $serverdata) private static function detectNextcloud(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/status.php'); $curlResult = DI::httpRequest()->get($url . '/status.php');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata; return $serverdata;
} }
@ -1097,7 +1099,8 @@ class GServer
*/ */
private static function detectMastodonAlikes(string $url, array $serverdata) private static function detectMastodonAlikes(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/api/v1/instance'); $curlResult = DI::httpRequest()->get($url . '/api/v1/instance');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata; return $serverdata;
} }
@ -1162,7 +1165,7 @@ class GServer
*/ */
private static function detectHubzilla(string $url, array $serverdata) private static function detectHubzilla(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/api/statusnet/config.json'); $curlResult = DI::httpRequest()->get($url . '/api/statusnet/config.json');
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata; return $serverdata;
} }
@ -1260,7 +1263,7 @@ class GServer
private static function detectGNUSocial(string $url, array $serverdata) private static function detectGNUSocial(string $url, array $serverdata)
{ {
// Test for GNU Social // Test for GNU Social
$curlResult = Network::curl($url . '/api/gnusocial/version.json'); $curlResult = DI::httpRequest()->get($url . '/api/gnusocial/version.json');
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') && if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) { ($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
$serverdata['platform'] = 'gnusocial'; $serverdata['platform'] = 'gnusocial';
@ -1278,7 +1281,7 @@ class GServer
} }
// Test for Statusnet // Test for Statusnet
$curlResult = Network::curl($url . '/api/statusnet/version.json'); $curlResult = DI::httpRequest()->get($url . '/api/statusnet/version.json');
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') && if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) { ($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
@ -1314,9 +1317,9 @@ class GServer
*/ */
private static function detectFriendica(string $url, array $serverdata) private static function detectFriendica(string $url, array $serverdata)
{ {
$curlResult = Network::curl($url . '/friendica/json'); $curlResult = DI::httpRequest()->get($url . '/friendica/json');
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
$curlResult = Network::curl($url . '/friendika/json'); $curlResult = DI::httpRequest()->get($url . '/friendika/json');
$friendika = true; $friendika = true;
$platform = 'Friendika'; $platform = 'Friendika';
} else { } else {
@ -1631,7 +1634,7 @@ class GServer
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus']; $protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
foreach ($protocols as $protocol) { foreach ($protocols as $protocol) {
$query = '{nodes(protocol:"' . $protocol . '"){host}}'; $query = '{nodes(protocol:"' . $protocol . '"){host}}';
$curlResult = Network::fetchUrl('https://the-federation.info/graphql?query=' . urlencode($query)); $curlResult = DI::httpRequest()->fetch('https://the-federation.info/graphql?query=' . urlencode($query));
if (!empty($curlResult)) { if (!empty($curlResult)) {
$data = json_decode($curlResult, true); $data = json_decode($curlResult, true);
if (!empty($data['data']['nodes'])) { if (!empty($data['data']['nodes'])) {
@ -1649,7 +1652,8 @@ class GServer
if (!empty($accesstoken)) { if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0'; $api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = ['Authorization: Bearer '.$accesstoken]; $header = ['Authorization: Bearer '.$accesstoken];
$curlResult = Network::curl($api, false, ['headers' => $header]); $curlResult = DI::httpRequest()->get($api, false, ['headers' => $header]);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$servers = json_decode($curlResult->getBody(), true); $servers = json_decode($curlResult->getBody(), true);

View File

@ -89,7 +89,7 @@ class Group
$group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]); $group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
if (DBA::isResult($group) && $group['deleted']) { if (DBA::isResult($group) && $group['deleted']) {
DBA::update('group', ['deleted' => 0], ['id' => $gid]); DBA::update('group', ['deleted' => 0], ['id' => $gid]);
notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL); notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
} }
return true; return true;
} }

View File

@ -1554,9 +1554,7 @@ class Item
} }
// Update the contact relations // Update the contact relations
if ($item['author-id'] != $parent['author-id']) { ContactRelation::store($parent['author-id'], $item['author-id'], $item['created']);
DBA::update('contact-relation', ['last-interaction' => $item['created']], ['cid' => $parent['author-id'], 'relation-cid' => $item['author-id']], true);
}
} }
return $item; return $item;
@ -1703,6 +1701,10 @@ class Item
'photo' => $item['owner-avatar'], 'network' => $item['network']]; 'photo' => $item['owner-avatar'], 'network' => $item['network']];
$item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default); $item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default);
// Ensure that there is an avatar cache
Contact::checkAvatarCache($item['author-id']);
Contact::checkAvatarCache($item['owner-id']);
// The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes // The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
$item["contact-id"] = self::contactId($item); $item["contact-id"] = self::contactId($item);
@ -3696,7 +3698,7 @@ class Item
* *
* @return integer item id * @return integer item id
*/ */
public static function fetchByLink($uri, $uid = 0) public static function fetchByLink(string $uri, int $uid = 0)
{ {
$item_id = self::searchByLink($uri, $uid); $item_id = self::searchByLink($uri, $uid);
if (!empty($item_id)) { if (!empty($item_id)) {
@ -3749,7 +3751,7 @@ class Item
* *
* @return array item array with data from the original item * @return array item array with data from the original item
*/ */
public static function addShareDataFromOriginal($item) public static function addShareDataFromOriginal(array $item)
{ {
$shared = self::getShareArray($item); $shared = self::getShareArray($item);
if (empty($shared)) { if (empty($shared)) {
@ -3771,9 +3773,9 @@ class Item
} }
// Otherwhise try to find (and possibly fetch) the item via the link. This should work for Diaspora and ActivityPub posts // Otherwhise try to find (and possibly fetch) the item via the link. This should work for Diaspora and ActivityPub posts
$id = self::fetchByLink($shared['link'], $uid); $id = self::fetchByLink($shared['link'] ?? '', $uid);
if (empty($id)) { if (empty($id)) {
Logger::info('Original item not found', ['url' => $shared['link'], 'callstack' => System::callstack()]); Logger::info('Original item not found', ['url' => $shared['link'] ?? '', 'callstack' => System::callstack()]);
return $item; return $item;
} }

View File

@ -31,7 +31,6 @@ use Friendica\Model\Storage\SystemResource;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Network;
use Friendica\Util\Security; use Friendica\Util\Security;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -421,7 +420,7 @@ class Photo
$filename = basename($image_url); $filename = basename($image_url);
if (!empty($image_url)) { if (!empty($image_url)) {
$ret = Network::curl($image_url, true); $ret = DI::httpRequest()->get($image_url, true);
$img_str = $ret->getBody(); $img_str = $ret->getBody();
$type = $ret->getContentType(); $type = $ret->getContentType();
} else { } else {

View File

@ -737,7 +737,7 @@ class Profile
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request; $magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
// We have to check if the remote server does understand /magic without invoking something // We have to check if the remote server does understand /magic without invoking something
$serverret = Network::curl($basepath . '/magic'); $serverret = DI::httpRequest()->get($basepath . '/magic');
if ($serverret->isSuccess()) { if ($serverret->isSuccess()) {
Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG); Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG);
System::externalRedirect($magic_path); System::externalRedirect($magic_path);

View File

@ -823,7 +823,7 @@ class User
$photo_failure = false; $photo_failure = false;
$filename = basename($photo); $filename = basename($photo);
$curlResult = Network::curl($photo, true); $curlResult = DI::httpRequest()->get($photo, true);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$img_str = $curlResult->getBody(); $img_str = $curlResult->getBody();
$type = $curlResult->getContentType(); $type = $curlResult->getContentType();

View File

@ -39,7 +39,7 @@ class Index extends BaseAdmin
switch ($_GET['action']) { switch ($_GET['action']) {
case 'reload': case 'reload':
Addon::reload(); Addon::reload();
info('Addons reloaded'); info(DI::l10n()->t('Addons reloaded'));
break; break;
case 'toggle' : case 'toggle' :
@ -50,7 +50,7 @@ class Index extends BaseAdmin
} elseif (Addon::install($addon)) { } elseif (Addon::install($addon)) {
info(DI::l10n()->t('Addon %s enabled.', $addon)); info(DI::l10n()->t('Addon %s enabled.', $addon));
} else { } else {
info(DI::l10n()->t('Addon %s failed to install.', $addon)); notice(DI::l10n()->t('Addon %s failed to install.', $addon));
} }
break; break;

View File

@ -46,7 +46,7 @@ class Server extends BaseAdmin
'reason' => Strings::escapeTags(trim($_POST['newentry_reason'])) 'reason' => Strings::escapeTags(trim($_POST['newentry_reason']))
]; ];
DI::config()->set('system', 'blocklist', $blocklist); DI::config()->set('system', 'blocklist', $blocklist);
info(DI::l10n()->t('Server domain pattern added to blocklist.') . EOL); info(DI::l10n()->t('Server domain pattern added to blocklist.'));
} else { } else {
// Edit the entries from blocklist // Edit the entries from blocklist
$blocklist = []; $blocklist = [];
@ -62,7 +62,6 @@ class Server extends BaseAdmin
} }
} }
DI::config()->set('system', 'blocklist', $blocklist); DI::config()->set('system', 'blocklist', $blocklist);
info(DI::l10n()->t('Site blocklist updated.') . EOL);
} }
DI::baseUrl()->redirect('admin/blocklist/server'); DI::baseUrl()->redirect('admin/blocklist/server');

View File

@ -47,7 +47,7 @@ class DBSync extends BaseAdmin
if (intval($curr) == $update) { if (intval($curr) == $update) {
DI::config()->set('system', 'build', intval($curr) + 1); DI::config()->set('system', 'build', intval($curr) + 1);
} }
info(DI::l10n()->t('Update has been marked successful') . EOL); info(DI::l10n()->t('Update has been marked successful'));
} }
DI::baseUrl()->redirect('admin/dbsync'); DI::baseUrl()->redirect('admin/dbsync');
} }

View File

@ -51,7 +51,7 @@ class Delete extends BaseAdmin
Item::markForDeletion(['guid' => $guid]); Item::markForDeletion(['guid' => $guid]);
} }
info(DI::l10n()->t('Item marked for deletion.') . EOL); info(DI::l10n()->t('Item marked for deletion.'));
DI::baseUrl()->redirect('admin/item/delete'); DI::baseUrl()->redirect('admin/item/delete');
} }

View File

@ -51,7 +51,6 @@ class Settings extends BaseAdmin
DI::config()->set('system', 'loglevel', $loglevel); DI::config()->set('system', 'loglevel', $loglevel);
} }
info(DI::l10n()->t("Log settings updated."));
DI::baseUrl()->redirect('admin/logs'); DI::baseUrl()->redirect('admin/logs');
} }

View File

@ -28,7 +28,7 @@ use Friendica\Core\Theme;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\GContact; use Friendica\Model\ContactRelation;
use Friendica\Module\BaseAdmin; use Friendica\Module\BaseAdmin;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
@ -122,7 +122,7 @@ class Site extends BaseAdmin
} }
DBA::close($usersStmt); DBA::close($usersStmt);
info("Relocation started. Could take a while to complete."); info(DI::l10n()->t("Relocation started. Could take a while to complete."));
DI::baseUrl()->redirect('admin/site'); DI::baseUrl()->redirect('admin/site');
} }
@ -178,8 +178,8 @@ class Site extends BaseAdmin
$min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0); $min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0);
$optimize_max_tablesize = (!empty($_POST['optimize_max_tablesize']) ? intval(trim($_POST['optimize_max_tablesize'])) : 100); $optimize_max_tablesize = (!empty($_POST['optimize_max_tablesize']) ? intval(trim($_POST['optimize_max_tablesize'])) : 100);
$optimize_fragmentation = (!empty($_POST['optimize_fragmentation']) ? intval(trim($_POST['optimize_fragmentation'])) : 30); $optimize_fragmentation = (!empty($_POST['optimize_fragmentation']) ? intval(trim($_POST['optimize_fragmentation'])) : 30);
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : ContactRelation::DISCOVERY_NONE);
$poco_completion = (!empty($_POST['poco_completion']) ? intval(trim($_POST['poco_completion'])) : false); $poco_completion = (!empty($_POST['poco_completion']) ? intval(trim($_POST['poco_completion'])) : false);
$gcontact_discovery = (!empty($_POST['gcontact_discovery']) ? intval(trim($_POST['gcontact_discovery'])) : GContact::DISCOVERY_NONE);
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7); $poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : PortableContact::DISABLED); $poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : PortableContact::DISABLED);
$poco_discovery_since = (!empty($_POST['poco_discovery_since']) ? intval(trim($_POST['poco_discovery_since'])) : 30); $poco_discovery_since = (!empty($_POST['poco_discovery_since']) ? intval(trim($_POST['poco_discovery_since'])) : 30);
@ -250,7 +250,7 @@ class Site extends BaseAdmin
DI::baseUrl()->redirect('admin/site' . $active_panel); DI::baseUrl()->redirect('admin/site' . $active_panel);
} }
} else { } else {
info(DI::l10n()->t('Invalid storage backend setting value.')); notice(DI::l10n()->t('Invalid storage backend setting value.'));
} }
// Has the directory url changed? If yes, then resubmit the existing profiles there // Has the directory url changed? If yes, then resubmit the existing profiles there
@ -308,7 +308,7 @@ class Site extends BaseAdmin
DI::config()->set('system', 'optimize_max_tablesize', $optimize_max_tablesize); DI::config()->set('system', 'optimize_max_tablesize', $optimize_max_tablesize);
DI::config()->set('system', 'optimize_fragmentation', $optimize_fragmentation); DI::config()->set('system', 'optimize_fragmentation', $optimize_fragmentation);
DI::config()->set('system', 'poco_completion' , $poco_completion); DI::config()->set('system', 'poco_completion' , $poco_completion);
DI::config()->set('system', 'gcontact_discovery' , $gcontact_discovery); DI::config()->set('system', 'contact_discovery' , $contact_discovery);
DI::config()->set('system', 'poco_requery_days' , $poco_requery_days); DI::config()->set('system', 'poco_requery_days' , $poco_requery_days);
DI::config()->set('system', 'poco_discovery' , $poco_discovery); DI::config()->set('system', 'poco_discovery' , $poco_discovery);
DI::config()->set('system', 'poco_discovery_since' , $poco_discovery_since); DI::config()->set('system', 'poco_discovery_since' , $poco_discovery_since);
@ -433,8 +433,6 @@ class Site extends BaseAdmin
DI::config()->set('system', 'rino_encrypt' , $rino); DI::config()->set('system', 'rino_encrypt' , $rino);
info(DI::l10n()->t('Site settings updated.') . EOL);
DI::baseUrl()->redirect('admin/site' . $active_panel); DI::baseUrl()->redirect('admin/site' . $active_panel);
} }
@ -553,9 +551,11 @@ class Site extends BaseAdmin
]; ];
$discovery_choices = [ $discovery_choices = [
GContact::DISCOVERY_NONE => DI::l10n()->t('none'), ContactRelation::DISCOVERY_NONE => DI::l10n()->t('none'),
GContact::DISCOVERY_DIRECT => DI::l10n()->t('Direct contacts'), ContactRelation::DISCOVERY_LOCAL => DI::l10n()->t('Local contacts'),
GContact::DISCOVERY_RECURSIVE => DI::l10n()->t('Contacts of contacts') ContactRelation::DISCOVERY_INTERACTOR => DI::l10n()->t('Interactors'),
// "All" is deactivated until we are sure not to put too much stress on the fediverse with this
// ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'),
]; ];
$diaspora_able = (DI::baseUrl()->getUrlPath() == ''); $diaspora_able = (DI::baseUrl()->getUrlPath() == '');
@ -679,8 +679,13 @@ class Site extends BaseAdmin
'$optimize_max_tablesize' => ['optimize_max_tablesize', DI::l10n()->t('Maximum table size for optimization'), $optimize_max_tablesize, DI::l10n()->t('Maximum table size (in MB) for the automatic optimization. Enter -1 to disable it.')], '$optimize_max_tablesize' => ['optimize_max_tablesize', DI::l10n()->t('Maximum table size for optimization'), $optimize_max_tablesize, DI::l10n()->t('Maximum table size (in MB) for the automatic optimization. Enter -1 to disable it.')],
'$optimize_fragmentation' => ['optimize_fragmentation', DI::l10n()->t('Minimum level of fragmentation'), DI::config()->get('system', 'optimize_fragmentation', 30), DI::l10n()->t('Minimum fragmenation level to start the automatic optimization - default value is 30%.')], '$optimize_fragmentation' => ['optimize_fragmentation', DI::l10n()->t('Minimum level of fragmentation'), DI::config()->get('system', 'optimize_fragmentation', 30), DI::l10n()->t('Minimum fragmenation level to start the automatic optimization - default value is 30%.')],
'$contact_discovery' => ['contact_discovery', DI::l10n()->t('Discover followers/followings from contacts'), DI::config()->get('system', 'contact_discovery'), DI::l10n()->t('If enabled, contacts are checked for their followers and following contacts.') . '<ul>' .
'<li>' . DI::l10n()->t('None - deactivated') . '</li>' .
'<li>' . DI::l10n()->t('Local contacts - contacts of our local contacts are discovered for their followers/followings.') . '</li>' .
'<li>' . DI::l10n()->t('Interactors - contacts of our local contacts and contacts who interacted on locally visible postings are discovered for their followers/followings.') . '</li></ul>',
$discovery_choices],
'$poco_completion' => ['poco_completion', DI::l10n()->t('Periodical check of global contacts'), DI::config()->get('system', 'poco_completion'), DI::l10n()->t('If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.')], '$poco_completion' => ['poco_completion', DI::l10n()->t('Periodical check of global contacts'), DI::config()->get('system', 'poco_completion'), DI::l10n()->t('If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.')],
'$gcontact_discovery' => ['gcontact_discovery', DI::l10n()->t('Discover followers/followings from global contacts'), DI::config()->get('system', 'gcontact_discovery'), DI::l10n()->t('If enabled, the global contacts are checked for new contacts among their followers and following contacts. This option will create huge masses of jobs, so it should only be activated on powerful machines.'), $discovery_choices],
'$poco_requery_days' => ['poco_requery_days', DI::l10n()->t('Days between requery'), DI::config()->get('system', 'poco_requery_days'), DI::l10n()->t('Number of days after which a server is requeried for his contacts.')], '$poco_requery_days' => ['poco_requery_days', DI::l10n()->t('Days between requery'), DI::config()->get('system', 'poco_requery_days'), DI::l10n()->t('Number of days after which a server is requeried for his contacts.')],
'$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts. You can choose between "Users": the users on the remote system, "Global Contacts": active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren\'t available. The fallback increases the server load, so the recommended setting is "Users, Global Contacts".'), $poco_discovery_choices], '$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts. You can choose between "Users": the users on the remote system, "Global Contacts": active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren\'t available. The fallback increases the server load, so the recommended setting is "Users, Global Contacts".'), $poco_discovery_choices],
'$poco_discovery_since' => ['poco_discovery_since', DI::l10n()->t('Timeframe for fetching global contacts'), DI::config()->get('system', 'poco_discovery_since'), DI::l10n()->t('When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers.'), $poco_discovery_since_choices], '$poco_discovery_since' => ['poco_discovery_since', DI::l10n()->t('Timeframe for fetching global contacts'), DI::config()->get('system', 'poco_discovery_since'), DI::l10n()->t('When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers.'), $poco_discovery_since_choices],

View File

@ -31,12 +31,9 @@ use Friendica\Database\DBStructure;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Register; use Friendica\Model\Register;
use Friendica\Module\BaseAdmin; use Friendica\Module\BaseAdmin;
use Friendica\Module\Update\Profile;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Render\FriendicaSmarty;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
class Summary extends BaseAdmin class Summary extends BaseAdmin
{ {
@ -249,7 +246,7 @@ class Summary extends BaseAdmin
private static function checkSelfHostMeta() private static function checkSelfHostMeta()
{ {
// Fetch the host-meta to check if this really is a vital server // Fetch the host-meta to check if this really is a vital server
return Network::curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess(); return DI::httpRequest()->get(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
} }
} }

View File

@ -48,8 +48,6 @@ class Details extends BaseAdmin
} }
} }
info(DI::l10n()->t('Theme settings updated.'));
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
return; return;
} }
@ -91,7 +89,7 @@ class Details extends BaseAdmin
} elseif (Theme::install($theme)) { } elseif (Theme::install($theme)) {
info(DI::l10n()->t('Theme %s successfully enabled.', $theme)); info(DI::l10n()->t('Theme %s successfully enabled.', $theme));
} else { } else {
info(DI::l10n()->t('Theme %s failed to install.', $theme)); notice(DI::l10n()->t('Theme %s failed to install.', $theme));
} }
DI::baseUrl()->redirect('admin/themes/' . $theme); DI::baseUrl()->redirect('admin/themes/' . $theme);

View File

@ -62,8 +62,6 @@ class Embed extends BaseAdmin
} }
} }
info(DI::l10n()->t('Theme settings updated.'));
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
return; return;
} }

View File

@ -48,7 +48,7 @@ class Index extends BaseAdmin
} }
Theme::setAllowedList($allowed_themes); Theme::setAllowedList($allowed_themes);
info('Themes reloaded'); info(DI::l10n()->t('Themes reloaded'));
break; break;
case 'toggle' : case 'toggle' :
@ -66,7 +66,7 @@ class Index extends BaseAdmin
} elseif (Theme::install($theme)) { } elseif (Theme::install($theme)) {
info(DI::l10n()->t('Theme %s successfully enabled.', $theme)); info(DI::l10n()->t('Theme %s successfully enabled.', $theme));
} else { } else {
info(DI::l10n()->t('Theme %s failed to install.', $theme)); notice(DI::l10n()->t('Theme %s failed to install.', $theme));
} }
} }

View File

@ -45,8 +45,6 @@ class Tos extends BaseAdmin
DI::config()->set('system', 'tosprivstatement', $displayprivstatement); DI::config()->set('system', 'tosprivstatement', $displayprivstatement);
DI::config()->set('system', 'tostext', $tostext); DI::config()->set('system', 'tostext', $tostext);
info(DI::l10n()->t('The Terms of Service settings have been updated.'));
DI::baseUrl()->redirect('admin/tos'); DI::baseUrl()->redirect('admin/tos');
} }

View File

@ -109,7 +109,7 @@ class Users extends BaseAdmin
$uid = $a->argv[3]; $uid = $a->argv[3];
$user = User::getById($uid, ['username', 'blocked']); $user = User::getById($uid, ['username', 'blocked']);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
notice('User not found' . EOL); notice(DI::l10n()->t('User not found'));
DI::baseUrl()->redirect('admin/users'); DI::baseUrl()->redirect('admin/users');
return ''; // NOTREACHED return ''; // NOTREACHED
} }

View File

@ -44,7 +44,7 @@ class Apps extends BaseModule
$apps = Nav::getAppMenu(); $apps = Nav::getAppMenu();
if (count($apps) == 0) { if (count($apps) == 0) {
notice(DI::l10n()->t('No installed applications.') . EOL); notice(DI::l10n()->t('No installed applications.'));
} }
$tpl = Renderer::getMarkupTemplate('apps.tpl'); $tpl = Renderer::getMarkupTemplate('apps.tpl');

View File

@ -116,7 +116,7 @@ class BaseSearch extends BaseModule
protected static function printResult(ResultList $results, Pager $pager, $header = '') protected static function printResult(ResultList $results, Pager $pager, $header = '')
{ {
if ($results->getTotal() == 0) { if ($results->getTotal() == 0) {
info(DI::l10n()->t('No matches')); notice(DI::l10n()->t('No matches'));
return ''; return '';
} }

View File

@ -36,6 +36,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Model\Contact as ModelContact;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\NotFoundException; use Friendica\Network\HTTPException\NotFoundException;
@ -112,7 +113,7 @@ class Contact extends BaseModule
} }
if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) { if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false])) {
notice(DI::l10n()->t('Could not access contact record.') . EOL); notice(DI::l10n()->t('Could not access contact record.'));
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');
return; // NOTREACHED return; // NOTREACHED
} }
@ -144,10 +145,8 @@ class Contact extends BaseModule
['id' => $contact_id, 'uid' => local_user()] ['id' => $contact_id, 'uid' => local_user()]
); );
if (DBA::isResult($r)) { if (!DBA::isResult($r)) {
info(DI::l10n()->t('Contact updated.') . EOL); notice(DI::l10n()->t('Failed to update contact record.'));
} else {
notice(DI::l10n()->t('Failed to update contact record.') . EOL);
} }
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
@ -280,6 +279,8 @@ class Contact extends BaseModule
if ($contact['network'] == Protocol::PHANTOM) { if ($contact['network'] == Protocol::PHANTOM) {
$contact = false; $contact = false;
} }
$contact = ModelContact::checkAvatarCacheByArray($contact);
} }
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
@ -366,7 +367,7 @@ class Contact extends BaseModule
Nav::setSelected('contact'); Nav::setSelected('contact');
if (!local_user()) { if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return Login::form(); return Login::form();
} }
@ -400,7 +401,7 @@ class Contact extends BaseModule
self::blockContact($contact_id); self::blockContact($contact_id);
$blocked = Model\Contact::isBlockedByUser($contact_id, local_user()); $blocked = Model\Contact::isBlockedByUser($contact_id, local_user());
info(($blocked ? DI::l10n()->t('Contact has been blocked') : DI::l10n()->t('Contact has been unblocked')) . EOL); info(($blocked ? DI::l10n()->t('Contact has been blocked') : DI::l10n()->t('Contact has been unblocked')));
DI::baseUrl()->redirect('contact/' . $contact_id); DI::baseUrl()->redirect('contact/' . $contact_id);
// NOTREACHED // NOTREACHED
@ -410,7 +411,7 @@ class Contact extends BaseModule
self::ignoreContact($contact_id); self::ignoreContact($contact_id);
$ignored = Model\Contact::isIgnoredByUser($contact_id, local_user()); $ignored = Model\Contact::isIgnoredByUser($contact_id, local_user());
info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored')) . EOL); info(($ignored ? DI::l10n()->t('Contact has been ignored') : DI::l10n()->t('Contact has been unignored')));
DI::baseUrl()->redirect('contact/' . $contact_id); DI::baseUrl()->redirect('contact/' . $contact_id);
// NOTREACHED // NOTREACHED
@ -420,7 +421,7 @@ class Contact extends BaseModule
$r = self::archiveContact($contact_id, $orig_record); $r = self::archiveContact($contact_id, $orig_record);
if ($r) { if ($r) {
$archived = (($orig_record['archive']) ? 0 : 1); $archived = (($orig_record['archive']) ? 0 : 1);
info((($archived) ? DI::l10n()->t('Contact has been archived') : DI::l10n()->t('Contact has been unarchived')) . EOL); info((($archived) ? DI::l10n()->t('Contact has been archived') : DI::l10n()->t('Contact has been unarchived')));
} }
DI::baseUrl()->redirect('contact/' . $contact_id); DI::baseUrl()->redirect('contact/' . $contact_id);
@ -461,7 +462,7 @@ class Contact extends BaseModule
} }
self::dropContact($orig_record); self::dropContact($orig_record);
info(DI::l10n()->t('Contact has been removed.') . EOL); info(DI::l10n()->t('Contact has been removed.'));
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');
// NOTREACHED // NOTREACHED

View File

@ -87,13 +87,11 @@ class Advanced extends BaseModule
if ($photo) { if ($photo) {
DI::logger()->notice('Updating photo.', ['photo' => $photo]); DI::logger()->notice('Updating photo.', ['photo' => $photo]);
Model\Contact::updateAvatar($photo, local_user(), $contact['id'], true); Model\Contact::updateAvatar($contact['id'], $photo, true);
} }
if ($r) { if (!$r) {
info(DI::l10n()->t('Contact settings applied.') . EOL); notice(DI::l10n()->t('Contact update failed.'));
} else {
notice(DI::l10n()->t('Contact update failed.') . EOL);
} }
return; return;

View File

@ -110,9 +110,7 @@ class Poke extends BaseModule
*/ */
private static function postReturn(bool $success) private static function postReturn(bool $success)
{ {
if ($success) { if (!$success) {
info(DI::l10n()->t('Poke successfully sent.'));
} else {
notice(DI::l10n()->t('Error while sending poke, please retry.')); notice(DI::l10n()->t('Error while sending poke, please retry.'));
} }

View File

@ -81,7 +81,7 @@ class Community extends BaseModule
$items = self::getItems(); $items = self::getItems();
if (!DBA::isResult($items)) { if (!DBA::isResult($items)) {
info(DI::l10n()->t('No results.')); notice(DI::l10n()->t('No results.'));
return $o; return $o;
} }

View File

@ -26,7 +26,6 @@ use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Protocol; use Friendica\Protocol;
use Friendica\Util\Network;
/** /**
* Tests a given feed of a contact * Tests a given feed of a contact
@ -36,7 +35,7 @@ class Feed extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
if (!local_user()) { if (!local_user()) {
info(DI::l10n()->t('You must be logged in to use this module')); notice(DI::l10n()->t('You must be logged in to use this module'));
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
} }
} }
@ -49,7 +48,7 @@ class Feed extends BaseModule
$contact = Model\Contact::getByURLForUser($url, local_user(), false); $contact = Model\Contact::getByURLForUser($url, local_user(), false);
$xml = Network::fetchUrl($contact['poll']); $xml = DI::httpRequest()->fetch($contact['poll']);
$import_result = Protocol\Feed::import($xml); $import_result = Protocol\Feed::import($xml);

View File

@ -75,7 +75,7 @@ class Directory extends BaseModule
$profiles = Profile::searchProfiles($pager->getStart(), $pager->getItemsPerPage(), $search); $profiles = Profile::searchProfiles($pager->getStart(), $pager->getItemsPerPage(), $search);
if ($profiles['total'] === 0) { if ($profiles['total'] === 0) {
info(DI::l10n()->t('No entries (some entries may be hidden).') . EOL); notice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else { } else {
if (in_array('small', $app->argv)) { if (in_array('small', $app->argv)) {
$photo = 'thumb'; $photo = 'thumb';

View File

@ -59,11 +59,11 @@ class RemoveTag extends BaseModule
]); ]);
if ($item_id && strlen($term)) { if ($item_id && strlen($term)) {
if (FileTag::unsaveFile(local_user(), $item_id, $term, $category)) { if (!FileTag::unsaveFile(local_user(), $item_id, $term, $category)) {
info('Item removed'); notice(DI::l10n()->t('Item was not removed'));
} }
} else { } else {
info('Item was not deleted'); notice(DI::l10n()->t('Item was not deleted'));
} }
DI::baseUrl()->redirect('network?file=' . rawurlencode($term)); DI::baseUrl()->redirect('network?file=' . rawurlencode($term));

View File

@ -35,7 +35,7 @@ class SaveTag extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
if (!local_user()) { if (!local_user()) {
info(DI::l10n()->t('You must be logged in to use this module')); notice(DI::l10n()->t('You must be logged in to use this module'));
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
} }
} }
@ -54,7 +54,6 @@ class SaveTag extends BaseModule
if ($item_id && strlen($term)) { if ($item_id && strlen($term)) {
// file item // file item
Model\FileTag::saveFile(local_user(), $item_id, $term); Model\FileTag::saveFile(local_user(), $item_id, $term);
info(DI::l10n()->t('Filetag %s saved to item', $term));
} }
// return filer dialog // return filer dialog

View File

@ -13,7 +13,7 @@ class FollowConfirm extends BaseModule
{ {
$uid = local_user(); $uid = local_user();
if (!$uid) { if (!$uid) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return; return;
} }

View File

@ -53,7 +53,6 @@ class Group extends BaseModule
$name = Strings::escapeTags(trim($_POST['groupname'])); $name = Strings::escapeTags(trim($_POST['groupname']));
$r = Model\Group::create(local_user(), $name); $r = Model\Group::create(local_user(), $name);
if ($r) { if ($r) {
info(DI::l10n()->t('Group created.'));
$r = Model\Group::getIdByName(local_user(), $name); $r = Model\Group::getIdByName(local_user(), $name);
if ($r) { if ($r) {
DI::baseUrl()->redirect('group/' . $r); DI::baseUrl()->redirect('group/' . $r);
@ -75,8 +74,8 @@ class Group extends BaseModule
} }
$groupname = Strings::escapeTags(trim($_POST['groupname'])); $groupname = Strings::escapeTags(trim($_POST['groupname']));
if (strlen($groupname) && ($groupname != $group['name'])) { if (strlen($groupname) && ($groupname != $group['name'])) {
if (Model\Group::update($group['id'], $groupname)) { if (!Model\Group::update($group['id'], $groupname)) {
info(DI::l10n()->t('Group name changed.')); notice(DI::l10n()->t('Group name was not changed.'));
} }
} }
} }
@ -216,9 +215,7 @@ class Group extends BaseModule
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');
} }
if (Model\Group::remove($a->argv[2])) { if (!Model\Group::remove($a->argv[2])) {
info(DI::l10n()->t('Group removed.'));
} else {
notice(DI::l10n()->t('Unable to remove group.')); notice(DI::l10n()->t('Unable to remove group.'));
} }
} }

View File

@ -75,7 +75,7 @@ class Invite extends BaseModule
$recipient = trim($recipient); $recipient = trim($recipient);
if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) { if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
notice(DI::l10n()->t('%s : Not a valid email address.', $recipient) . EOL); notice(DI::l10n()->t('%s : Not a valid email address.', $recipient));
continue; continue;
} }
@ -111,15 +111,15 @@ class Invite extends BaseModule
$current_invites++; $current_invites++;
DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites); DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites);
if ($current_invites > $max_invites) { if ($current_invites > $max_invites) {
notice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.') . EOL); notice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
return; return;
} }
} else { } else {
notice(DI::l10n()->t('%s : Message delivery failed.', $recipient) . EOL); notice(DI::l10n()->t('%s : Message delivery failed.', $recipient));
} }
} }
notice(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total) . EOL); notice(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total));
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])

View File

@ -28,7 +28,6 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/** /**
@ -101,7 +100,7 @@ class Magic extends BaseModule
); );
// Try to get an authentication token from the other instance. // Try to get an authentication token from the other instance.
$curlResult = Network::curl($basepath . '/owa', false, ['headers' => $headers]); $curlResult = DI::httpRequest()->get($basepath . '/owa', false, ['headers' => $headers]);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true); $j = json_decode($curlResult->getBody(), true);

View File

@ -191,7 +191,7 @@ class Introductions extends BaseNotifications
} }
if (count($notifications['notifications']) == 0) { if (count($notifications['notifications']) == 0) {
info(DI::l10n()->t('No introductions.') . EOL); notice(DI::l10n()->t('No introductions.'));
$notificationNoContent = DI::l10n()->t('No more %s notifications.', $notifications['ident']); $notificationNoContent = DI::l10n()->t('No more %s notifications.', $notifications['ident']);
} }

View File

@ -0,0 +1,120 @@
<?php
namespace Friendica\Module;
use Friendica\Core\Hook;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Group;
use Friendica\Network\HTTPException;
/**
* Outputs the permission tooltip HTML content for the provided item, photo or event id.
*/
class PermissionTooltip extends \Friendica\BaseModule
{
public static function rawContent(array $parameters = [])
{
$type = $parameters['type'];
$referenceId = $parameters['id'];
$expectedTypes = ['item', 'photo', 'event'];
if (!in_array($type, $expectedTypes)) {
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
}
$condition = ['id' => $referenceId];
if ($type == 'item') {
$fields = ['uid', 'psid', 'private'];
$model = Item::selectFirst($fields, $condition);
} else {
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$model = DBA::selectFirst($type, $fields, $condition);
}
if (!DBA::isResult($model)) {
throw new HttpException\NotFoundException(DI::l10n()->t('Model not found'));
}
if (isset($model['psid'])) {
$permissionSet = DI::permissionSet()->selectFirst(['id' => $model['psid']]);
$model['allow_cid'] = $permissionSet->allow_cid;
$model['allow_gid'] = $permissionSet->allow_gid;
$model['deny_cid'] = $permissionSet->deny_cid;
$model['deny_gid'] = $permissionSet->deny_gid;
}
// Kept for backwards compatiblity
Hook::callAll('lockview_content', $model);
if ($model['uid'] != local_user() ||
isset($model['private'])
&& $model['private'] == Item::PRIVATE
&& empty($model['allow_cid'])
&& empty($model['allow_gid'])
&& empty($model['deny_cid'])
&& empty($model['deny_gid']))
{
echo DI::l10n()->t('Remote privacy information not available.');
exit;
}
$aclFormatter = DI::aclFormatter();
$allowed_users = $aclFormatter->expand($model['allow_cid']);
$allowed_groups = $aclFormatter->expand($model['allow_gid']);
$deny_users = $aclFormatter->expand($model['deny_cid']);
$deny_groups = $aclFormatter->expand($model['deny_gid']);
$o = DI::l10n()->t('Visible to:') . '<br />';
$l = [];
if (count($allowed_groups)) {
$key = array_search(Group::FOLLOWERS, $allowed_groups);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
unset($allowed_groups[$key]);
}
$key = array_search(Group::MUTUALS, $allowed_groups);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
unset($allowed_groups[$key]);
}
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
$l[] = '<b>' . $group['name'] . '</b>';
}
}
foreach (DI::dba()->selectToArray('contact', ['name'], ['id' => $allowed_users]) as $contact) {
$l[] = $contact['name'];
}
if (count($deny_groups)) {
$key = array_search(Group::FOLLOWERS, $deny_groups);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
unset($deny_groups[$key]);
}
$key = array_search(Group::MUTUALS, $deny_groups);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
unset($deny_groups[$key]);
}
foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
$l[] = '<b><strike>' . $group['name'] . '</strike></b>';
}
}
foreach (DI::dba()->selectToArray('contact', ['name'], ['id' => $deny_users]) as $contact) {
$l[] = '<strike>' . $contact['name'] . '</strike>';
}
echo $o . implode(', ', $l);
exit();
}
}

View File

@ -64,7 +64,7 @@ class Contacts extends BaseProfile
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname); $o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
if (!count($a->profile) || $a->profile['hide-friends']) { if (!count($a->profile) || $a->profile['hide-friends']) {
notice(DI::l10n()->t('Permission denied.') . EOL); notice(DI::l10n()->t('Permission denied.'));
return $o; return $o;
} }
@ -92,7 +92,7 @@ class Contacts extends BaseProfile
$contacts_stmt = DBA::select('contact', [], $condition, $params); $contacts_stmt = DBA::select('contact', [], $condition, $params);
if (!DBA::isResult($contacts_stmt)) { if (!DBA::isResult($contacts_stmt)) {
info(DI::l10n()->t('No contacts.') . EOL); notice(DI::l10n()->t('No contacts.'));
return $o; return $o;
} }

View File

@ -102,7 +102,7 @@ class Status extends BaseProfile
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact; $last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact;
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) { if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
notice(DI::l10n()->t('Access to this profile has been restricted.') . EOL); notice(DI::l10n()->t('Access to this profile has been restricted.'));
return ''; return '';
} }

View File

@ -176,7 +176,7 @@ class Index extends BaseSearch
} }
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
info(DI::l10n()->t('No results.')); notice(DI::l10n()->t('No results.'));
return $o; return $o;
} }

Some files were not shown because too many files have changed in this diff Show More