Compare commits

..

5 Commits

485 changed files with 14865 additions and 17570 deletions

View File

@ -1,58 +1,10 @@
Version 2022.12 (unreleased)
Version 2022.09 (unreleased)
Friendica Core
Friendica Addons
BREAKING: The functions from the boot.php file have been moved into better fitting classes
this may break your custom addons. See the pull requests #1293 and #1294 in the
addon repository about the needed changes to your addons.
Closed Issues
Version 2022.10 (2022-10-14)
Friendica Core
Added GD translation, updates to the translations AR, DE, FR, HU, PL, SV, ZH CN
Added a check for too long passwords (due Blowfish hashing algorithm) [MrPetovan]
Added an API endpoint to create events [MrPetovan, pankraz]
Added the possibility to store profile avatars in a separate directory [annando]
Added an option to not fetch parent postings [annando]
Added an option to reject postings by language received by the relay [annando]
Added a notification mail to all users when the server block list is updated [MrPetovan]
Added a download link to the CSV file of the server block list on the about page [MrPetovan]
Added support for youtube short URLs [annando]
Updates to the themes (frio, smoothly) [AlessandroLorenzi, HankG, MrPetovan, tobiasd]
General code cleanup [annando, fabrixxm, Quix0r, tobiasd]
Enhanced the performance (cache, database, rendering) [annando, Quix0r]
Enhanced the language detection [annando]
Enhanced the display of the reason why a posting is shown to a user [annando]
Enhanced the fetching of missing postings [annando]
Enhanced the server detection [annando]
Enhanced the UI for 2FA logins [nupplaphil]
Enhanced the Woodpecker integration [nupplaphil]
Enhanced integration with ejabberd [nupplaphil]
Fixed a federation problem with Diaspora* during the author signature check [annando]
Fixed a problem with Forwarded-For headers [nupplaphil]
Fixed a problem with the encoding of mails send [MrPetovan]
Fixed a problem with weird formatted date notations [annando, MrPetovan]
Fixed a problem following some RSS feeds [mexon]
Fixed a problem with quoted reshares from Twitter [annando]
Updated dependencies [MrPetovan]
Replace SFTP-publish with docker-publish [nupplaphil]
Removed the poke functionality [MrPetovan]
Friendica Addons
Added GD translation, updates to the translation AR, FR
Removed the addons: morechoice, morepokes
Marked the addon whindowsphonepush as unsupported
twitter:
Valid post body can be empty [MrPetovan]
Support of Twitter threads was added [annando]
Closed Issues
11177, 11317, 11458, 11471, 11566, 11614, 11625, 11635, 11636, 11638,
11651, 11661, 11666, 11695, 11700, 11704, 11706, 11708, 11712, 11716,
11722, 11723, 11724, 11726, 11731, 11732, 11751, 11765, 11775, 11778,
11779, 11794, 11798, 11799, 11800, 11824, 11826, 11851, 11861, 11870,
11909, 11920, 11931, 11938, 11943, 11952, 11953, 11969, 11975
Version 2022.06 (2022-06-11)
Friendica Core

View File

@ -10,7 +10,6 @@ Aditoo
AgnesElisa
Albert
Aleksandr "M.O.Z.G" Dikov
Alessandro Lorenzi
Alex
Alexander An
Alexander Fortin
@ -67,7 +66,6 @@ Christian Vogeley
Christian Wiwie
Cohan Robinson
Colby Sollars
Copiis
Copiis Praeesse
CrystalStiletto
Cyboulette
@ -122,7 +120,6 @@ Gregory Smith
gudzpoz
guzzisti
Haakon Meland Eriksen
Hank Grabowski
Hans Meine
Hauke
Hauke Altmann
@ -202,7 +199,6 @@ mpanhans
mytbk
nathilia-peirce
Nicola Spanti
Nicolas Derive
nobody
nupplaPhil
Olaf Conradi
@ -212,7 +208,6 @@ Olivier Mehani
Olivier Migeot
ominds
ozero dien
pankraz
Paolo Wave
Pascal
Pascal Deklerck
@ -315,7 +310,6 @@ Valvin
Vasudev Kamath
Vasya Novikov
very-ape
Viktor Nilsson
Vinzenz Vietzke
vislav
vladimir N
@ -324,10 +318,8 @@ VVelox
Vít Šesták 'v6ak'
Waldemar Stoczkowski
Walter Bulbazor
Wanting Chen
Wil Tur
Wouter Broers
Xiaofei Xu
XMPPはいいぞ
Yasen Pramatarov
Yasmine A

View File

@ -1,4 +1,4 @@
INPUT = README.md index.php update.php bin/ mod/ view/ src/ VERSION
INPUT = README.md index.php boot.php update.php bin/ mod/ include/ view/ src/ VERSION
RECURSIVE = YES
PROJECT_NAME = "Friendica"
PROJECT_LOGO = images/friendica-64.png

View File

@ -1 +1 @@
2022.12-dev
2022.09-dev

2
Vagrantfile vendored
View File

@ -1,5 +1,5 @@
server_ip = "192.168.56.10"
server_ip = "192.168.22.10"
server_memory = "2048" # MB
server_timezone = "UTC"

View File

@ -26,7 +26,6 @@ if (php_sapi_name() !== 'cli') {
}
use Dice\Dice;
use Friendica\DI;
use Psr\Log\LoggerInterface;
require dirname(__DIR__) . '/vendor/autoload.php';
@ -34,8 +33,6 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['console']]);
/// @fixme Necessary until Hooks inside the Logger can get loaded without the DI-class
DI::init($dice);
\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
(new Friendica\Core\Console($dice, $argv))->execute();

View File

@ -45,7 +45,7 @@ $longopts = ['foreground'];
$options = getopt($shortopts, $longopts);
// Ensure that daemon.php is executed from the base path of the installation
if (!file_exists('index.php') && (sizeof($_SERVER['argv']) != 0)) {
if (!file_exists('boot.php') && (sizeof($_SERVER['argv']) != 0)) {
$directory = dirname($_SERVER['argv'][0]);
if (substr($directory, 0, 1) != '/') {

View File

@ -45,13 +45,13 @@ apt-get install -qq apache2
a2enmod rewrite actions ssl
cp /vagrant/bin/dev/vagrant_vhost.sh /usr/local/bin/vhost
chmod guo+x /usr/local/bin/vhost
vhost -s 192.168.56.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.local
vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.local
a2dissite 000-default
service apache2 restart
#Install php
echo ">>> Installing PHP7"
apt-get install -qq php libapache2-mod-php php-cli php-mysql php-curl php-gd php-mbstring php-xml imagemagick php-imagick php-zip php-gmp
apt-get install -qq php libapache2-mod-php php-cli php-mysql php-curl php-gd php-mbstring php-xml imagemagick php-imagick php-zip
systemctl restart apache2
echo ">>> Installing PHP8"
@ -59,7 +59,7 @@ apt-get install -qq -y lsb-release ca-certificates apt-transport-https software-
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
apt update
apt-get install -qq php8.0 php8.0-cli php8.0-mysql php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml php8.0-imagick php8.0-zip php8.0-gmp
apt-get install -qq php8.0 php8.0-cli php8.0-mysql php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml php8.0-imagick php8.0-zip
systemctl restart apache2
#Install mysql

View File

@ -40,7 +40,7 @@ $longopts = ['spawn', 'no_cron'];
$options = getopt($shortopts, $longopts);
// Ensure that worker.php is executed from the base path of the installation
if (!file_exists("index.php") && (sizeof($_SERVER["argv"]) != 0)) {
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
if (substr($directory, 0, 1) != '/') {

194
boot.php Normal file
View File

@ -0,0 +1,194 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @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/>.
*
* Friendica is a communications platform for integrated social communications
* utilising decentralised communications and linkage to several indie social
* projects - as well as popular mainstream providers.
*
* Our mission is to free our friends and families from the clutches of
* data-harvesting corporations, and pave the way to a future where social
* communications are free and open and flow between alternate providers as
* easily as email does today.
*/
use Friendica\Model\Contact;
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Giant Rhubarb');
define('FRIENDICA_VERSION', '2022.09-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
define('NEW_TABLE_STRUCTURE_VERSION', 1288);
/**
* Constant with a HTML line break.
*
* Contains a HTML line break (br) element and a real carriage return with line
* feed for the source.
* This can be used in HTML and JavaScript where needed a line break.
*/
define('EOL', "<br />\r\n");
/**
* @name CP
*
* Type of the community page
* @{
*/
define('CP_NO_INTERNAL_COMMUNITY', -2);
define('CP_NO_COMMUNITY_PAGE', -1);
define('CP_USERS_ON_SERVER', 0);
define('CP_GLOBAL_COMMUNITY', 1);
define('CP_USERS_AND_GLOBAL', 2);
/**
* @}
*/
/**
* @name Gravity
*
* Item weight for query ordering
* @{
*/
define('GRAVITY_PARENT', 0);
define('GRAVITY_ACTIVITY', 3);
define('GRAVITY_COMMENT', 6);
define('GRAVITY_UNKNOWN', 9);
/* @}*/
/**
* @name Priority
*
* Process priority for the worker
* @{
*/
define('PRIORITY_UNDEFINED', 0);
define('PRIORITY_CRITICAL', 10);
define('PRIORITY_HIGH', 20);
define('PRIORITY_MEDIUM', 30);
define('PRIORITY_LOW', 40);
define('PRIORITY_NEGLIGIBLE', 50);
define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
/* @}*/
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined('SIGTERM')) {
define('SIGTERM', 15);
}
/**
* Depending on the PHP version this constant does exist - or not.
* See here: http://php.net/manual/en/curl.constants.php#117928
*/
if (!defined('CURLE_OPERATION_TIMEDOUT')) {
define('CURLE_OPERATION_TIMEDOUT', CURLE_OPERATION_TIMEOUTED);
}
if (!function_exists('exif_imagetype')) {
function exif_imagetype($file)
{
$size = getimagesize($file);
return $size[2];
}
}
/**
* Returns the user id of locally logged in user or false.
*
* @return int|bool user id or false
*/
function local_user()
{
if (!empty($_SESSION['authenticated']) && !empty($_SESSION['uid'])) {
return intval($_SESSION['uid']);
}
return false;
}
/**
* Returns the public contact id of logged in user or false.
*
* @return int|bool public contact id or false
*/
function public_contact()
{
static $public_contact_id = false;
if (!$public_contact_id && !empty($_SESSION['authenticated'])) {
if (!empty($_SESSION['my_address'])) {
// Local user
$public_contact_id = intval(Contact::getIdForURL($_SESSION['my_address'], 0, false));
} elseif (!empty($_SESSION['visitor_home'])) {
// Remote user
$public_contact_id = intval(Contact::getIdForURL($_SESSION['visitor_home'], 0, false));
}
} elseif (empty($_SESSION['authenticated'])) {
$public_contact_id = false;
}
return $public_contact_id;
}
/**
* Returns public contact id of authenticated site visitor or false
*
* @return int|bool visitor_id or false
*/
function remote_user()
{
if (empty($_SESSION['authenticated'])) {
return false;
}
if (!empty($_SESSION['visitor_id'])) {
return intval($_SESSION['visitor_id']);
}
return false;
}
/**
* Show an error message to user.
*
* This function save text in session, to be shown to the user at next page load
*
* @param string $s - Text of notice
*
* @return void
* @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead
*/
function notice(string $s)
{
\Friendica\DI::sysmsg()->addNotice($s);
}
/**
* Show an info message to user.
*
* This function save text in session, to be shown to the user at next page load
*
* @param string $s - Text of notice
*
* @return void
* @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead
*/
function info(string $s)
{
\Friendica\DI::sysmsg()->addInfo($s);
}

View File

@ -41,6 +41,7 @@
"michelf/php-markdown": "^1.7",
"minishlink/web-push": "^6.0",
"mobiledetect/mobiledetectlib": "^2.8",
"monolog/monolog": "^1.25",
"nikic/fast-route": "^1.3",
"paragonie/hidden-string": "^1.0",
"patrickschur/language-detection": "^5.0.0",
@ -49,7 +50,6 @@
"pragmarx/google2fa": "^5.0",
"pragmarx/recovery": "^0.2",
"psr/container": "^1.0",
"psr/log": "^1.1",
"seld/cli-prompt": "^1.0",
"smarty/smarty": "^4",
"ua-parser/uap-php": "^3.9",
@ -59,6 +59,7 @@
"bower-asset/chart-js": "^2.8",
"bower-asset/dompurify": "^1.0",
"bower-asset/fork-awesome": "^1.1",
"bower-asset/vue": "^2.6",
"npm-asset/cropperjs": "1.2.2",
"npm-asset/es-jquery-sortable": "^0.9.13",
"npm-asset/fullcalendar": "^3.10",
@ -82,7 +83,10 @@
"psr-4": {
"Friendica\\": "src/",
"Friendica\\Addon\\": "addon/"
}
},
"files": [
"boot.php"
]
},
"autoload-dev": {
"psr-4": {

759
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2022.12-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1486
-- Friendica 2022.09-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1479
-- ------------------------------------------
@ -9,8 +9,8 @@
--
CREATE TABLE IF NOT EXISTS `gserver` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`info` text COMMENT '',
@ -22,8 +22,8 @@ CREATE TABLE IF NOT EXISTS `gserver` (
`local-posts` int unsigned COMMENT 'Number of local posts',
`local-comments` int unsigned COMMENT 'Number of local comments',
`directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
`poco` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`noscrape` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
`protocol` tinyint unsigned COMMENT 'The protocol of the server',
`platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS `user` (
--
CREATE TABLE IF NOT EXISTS `item-uri` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
`uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
`guid` varbinary(255) COMMENT 'A unique identifier for an item',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri` (`uri`),
@ -127,28 +127,26 @@ CREATE TABLE IF NOT EXISTS `contact` (
`keywords` text COMMENT 'public keywords (interests) of the contact',
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
`matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
`avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`header` varbinary(383) COMMENT 'Header picture',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`header` varchar(255) COMMENT 'Header picture',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
`addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`pubkey` text COMMENT 'RSA public key 4096 bit',
`prvkey` text COMMENT 'RSA private key 4096 bit',
`batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`notify` varbinary(383) COMMENT '',
`poll` varbinary(383) COMMENT '',
`subscribe` varbinary(383) COMMENT '',
`batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`notify` varchar(255) COMMENT '',
`poll` varchar(255) COMMENT '',
`subscribe` varchar(255) COMMENT '',
`last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
`next-update` datetime COMMENT 'Next connection request',
`success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
`failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
`failed` boolean COMMENT 'Connection failed',
`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-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
`local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
`blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
`block_reason` text COMMENT 'Node-wide block reason',
`readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
@ -157,7 +155,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
`unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
`sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
`baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
`baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
`gsid` int unsigned COMMENT 'Global Server ID',
`bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
`reason` text COMMENT '',
@ -166,7 +164,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
`rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
`protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
`subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
`hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
`attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -177,15 +175,15 @@ CREATE TABLE IF NOT EXISTS `contact` (
`notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
`fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`ffi_keyword_denylist` text COMMENT '',
`photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
`thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
`micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
`photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
`thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
`micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
`name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`uri-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 '',
`request` varbinary(383) COMMENT '',
`confirm` varbinary(383) COMMENT '',
`poco` varbinary(383) COMMENT '',
`request` varchar(255) COMMENT '',
`confirm` varchar(255) COMMENT '',
`poco` varchar(255) COMMENT '',
`writable` boolean NOT NULL DEFAULT '0' COMMENT '',
`forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
`prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
@ -193,8 +191,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
`site-pubkey` text COMMENT 'Deprecated',
`gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
@ -215,14 +213,12 @@ CREATE TABLE IF NOT EXISTS `contact` (
INDEX `attag_uid` (`attag`(96),`uid`),
INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
INDEX `next-update` (`next-update`),
INDEX `local-data-next-update` (`local-data`,`next-update`),
INDEX `uid_lastitem` (`uid`,`last-item`),
INDEX `baseurl` (`baseurl`(64)),
INDEX `uid_contact-type` (`uid`,`contact-type`),
INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
INDEX `self_network_uid` (`self`,`network`,`uid`),
INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
INDEX `gsid` (`gsid`),
INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
@ -235,7 +231,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
CREATE TABLE IF NOT EXISTS `tag` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
PRIMARY KEY(`id`),
UNIQUE INDEX `type_name_url` (`name`,`url`),
@ -309,20 +305,6 @@ CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
--
-- TABLE account-user
--
CREATE TABLE IF NOT EXISTS `account-user` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
INDEX `uid_uri-id` (`uid`,`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
--
-- TABLE addon
--
@ -343,17 +325,17 @@ CREATE TABLE IF NOT EXISTS `addon` (
-- TABLE apcontact
--
CREATE TABLE IF NOT EXISTS `apcontact` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
`url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
`uuid` varbinary(255) COMMENT '',
`uuid` varchar(255) COMMENT '',
`type` varchar(20) NOT NULL COMMENT '',
`following` varbinary(383) COMMENT '',
`followers` varbinary(383) COMMENT '',
`inbox` varbinary(383) NOT NULL COMMENT '',
`outbox` varbinary(383) COMMENT '',
`sharedinbox` varbinary(383) COMMENT '',
`featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
`featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
`following` varchar(255) COMMENT '',
`followers` varchar(255) COMMENT '',
`inbox` varchar(255) NOT NULL COMMENT '',
`outbox` varchar(255) COMMENT '',
`sharedinbox` varchar(255) COMMENT '',
`featured` varchar(255) COMMENT 'Address for the collection of featured posts',
`featured-tags` varchar(255) COMMENT 'Address for the collection of featured tags',
`manually-approve` boolean COMMENT '',
`discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
`suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
@ -362,13 +344,13 @@ CREATE TABLE IF NOT EXISTS `apcontact` (
`about` text COMMENT '',
`xmpp` varchar(255) COMMENT 'XMPP address',
`matrix` varchar(255) COMMENT 'Matrix address',
`photo` varbinary(383) COMMENT '',
`header` varbinary(383) COMMENT 'Header picture',
`photo` varchar(255) COMMENT '',
`header` varchar(255) COMMENT 'Header picture',
`addr` varchar(255) COMMENT '',
`alias` varbinary(383) COMMENT '',
`alias` varchar(255) COMMENT '',
`pubkey` text COMMENT '',
`subscribe` varbinary(383) COMMENT '',
`baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
`subscribe` varchar(255) COMMENT '',
`baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
`gsid` int unsigned COMMENT 'Global Server ID',
`generator` varchar(255) COMMENT 'Name of the contact\'s system',
`following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
@ -395,8 +377,8 @@ CREATE TABLE IF NOT EXISTS `application` (
`client_id` varchar(64) NOT NULL COMMENT '',
`client_secret` varchar(64) NOT NULL COMMENT '',
`name` varchar(255) NOT NULL COMMENT '',
`redirect_uri` varbinary(383) NOT NULL COMMENT '',
`website` varbinary(383) COMMENT '',
`redirect_uri` varchar(255) NOT NULL COMMENT '',
`website` varchar(255) COMMENT '',
`scopes` varchar(255) COMMENT '',
`read` boolean COMMENT 'Read scope',
`write` boolean COMMENT 'Write scope',
@ -413,7 +395,7 @@ CREATE TABLE IF NOT EXISTS `application-marker` (
`application-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
`timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
`last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
`last_read_id` varchar(255) COMMENT 'Marker id for the timeline',
`version` smallint unsigned COMMENT 'Version number',
`updated_at` datetime COMMENT 'creation time',
PRIMARY KEY(`application-id`,`uid`,`timeline`),
@ -510,7 +492,7 @@ CREATE TABLE IF NOT EXISTS `contact-relation` (
--
CREATE TABLE IF NOT EXISTS `conv` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
`recips` text COMMENT 'sender_handle;recipient_handle',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
@ -552,7 +534,7 @@ CREATE TABLE IF NOT EXISTS `workerqueue` (
--
CREATE TABLE IF NOT EXISTS `delayed-post` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
`uri` varchar(255) COMMENT 'URI of the post that will be distributed later',
`uid` mediumint unsigned COMMENT 'Owner User id',
`delayed` datetime COMMENT 'delay time',
`wid` int unsigned COMMENT 'Workerqueue id',
@ -577,7 +559,7 @@ CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
-- TABLE endpoint
--
CREATE TABLE IF NOT EXISTS `endpoint` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
`url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
`type` varchar(20) NOT NULL COMMENT '',
`owner-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
PRIMARY KEY(`url`),
@ -590,10 +572,10 @@ CREATE TABLE IF NOT EXISTS `endpoint` (
--
CREATE TABLE IF NOT EXISTS `event` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
`uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the event uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
@ -623,23 +605,22 @@ CREATE TABLE IF NOT EXISTS `event` (
--
CREATE TABLE IF NOT EXISTS `fcontact` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'unique id',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the fcontact url',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`notify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`poll` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`confirm` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
`alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`pubkey` text COMMENT '',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
`interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
@ -656,7 +637,7 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
--
CREATE TABLE IF NOT EXISTS `fetch-entry` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`url` varbinary(383) COMMENT 'url that awaiting to be fetched',
`url` varbinary(255) COMMENT 'url that awaiting to be fetched',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of the fetch request',
`wid` int unsigned COMMENT 'Workerqueue id',
PRIMARY KEY(`id`),
@ -674,9 +655,9 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`request` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`note` text COMMENT '',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
PRIMARY KEY(`id`),
@ -747,10 +728,10 @@ CREATE TABLE IF NOT EXISTS `hook` (
--
CREATE TABLE IF NOT EXISTS `inbox-entry` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`activity-id` varbinary(383) COMMENT 'id of the incoming activity',
`object-id` varbinary(383) COMMENT '',
`in-reply-to-id` varbinary(383) COMMENT '',
`conversation` varbinary(383) COMMENT '',
`activity-id` varbinary(255) COMMENT 'id of the incoming activity',
`object-id` varbinary(255) COMMENT '',
`in-reply-to-id` varbinary(255) COMMENT '',
`conversation` varbinary(255) COMMENT '',
`type` varchar(64) COMMENT 'Type of the activity',
`object-type` varchar(64) COMMENT 'Type of the object activity',
`object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity',
@ -784,7 +765,7 @@ CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` (
-- TABLE inbox-status
--
CREATE TABLE IF NOT EXISTS `inbox-status` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the inbox',
`url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
`uri-id` int unsigned COMMENT 'Item-uri id of inbox url',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
`success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
@ -809,7 +790,7 @@ CREATE TABLE IF NOT EXISTS `intro` (
`knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
`duplex` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
`note` text COMMENT '',
`hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
@ -841,11 +822,11 @@ CREATE TABLE IF NOT EXISTS `locks` (
CREATE TABLE IF NOT EXISTS `mail` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
`guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
`from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
`from-photo` varbinary(383) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
`from-url` varbinary(383) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
`contact-id` varbinary(255) COMMENT 'contact.id',
`from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
`from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
`contact-id` varchar(255) COMMENT 'contact.id',
`author-id` int unsigned COMMENT 'Link to the contact table with uid=0 of the author of the mail',
`convid` int unsigned COMMENT 'conv.id',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -854,11 +835,11 @@ CREATE TABLE IF NOT EXISTS `mail` (
`reply` boolean NOT NULL DEFAULT '0' COMMENT '',
`replied` boolean NOT NULL DEFAULT '0' COMMENT '',
`unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
`uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Item-uri id of the related mail',
`parent-uri` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related mail',
`thr-parent` varbinary(383) COMMENT '',
`thr-parent` varchar(255) COMMENT '',
`thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
PRIMARY KEY(`id`),
@ -935,7 +916,6 @@ CREATE TABLE IF NOT EXISTS `notification` (
INDEX `target-uri-id` (`target-uri-id`),
INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `seen_uid` (`seen`,`uid`),
INDEX `uid_type_parent-uri-id_actor-id` (`uid`,`type`,`parent-uri-id`,`actor-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`actor-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
@ -950,12 +930,12 @@ CREATE TABLE IF NOT EXISTS `notify` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`msg` mediumtext COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`link` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`iid` int unsigned COMMENT '',
`parent` int unsigned COMMENT '',
`uri-id` int unsigned COMMENT 'Item-uri id of the related post',
@ -999,7 +979,7 @@ CREATE TABLE IF NOT EXISTS `notify-threads` (
-- TABLE oembed
--
CREATE TABLE IF NOT EXISTS `oembed` (
`url` varbinary(383) NOT NULL COMMENT 'page url',
`url` varbinary(255) NOT NULL COMMENT 'page url',
`maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
`content` mediumtext COMMENT 'OEmbed data of the page',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
@ -1169,12 +1149,9 @@ CREATE TABLE IF NOT EXISTS `post-category` (
CREATE TABLE IF NOT EXISTS `post-collection` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0 - Featured',
`author-id` int unsigned COMMENT 'Author of the featured post',
PRIMARY KEY(`uri-id`,`type`),
INDEX `type` (`type`),
INDEX `author-id` (`author-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Collection of posts';
--
@ -1186,7 +1163,6 @@ CREATE TABLE IF NOT EXISTS `post-content` (
`content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`body` mediumtext COMMENT 'item body content',
`raw-body` mediumtext COMMENT 'Body without embedded media links',
`quote-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the quoted uri',
`location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
`coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
`language` text COMMENT 'Language information about this post',
@ -1198,14 +1174,12 @@ CREATE TABLE IF NOT EXISTS `post-content` (
`target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
`target` text COMMENT 'JSON encoded target structure if used',
`resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
`plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
`plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
PRIMARY KEY(`uri-id`),
INDEX `plink` (`plink`(191)),
INDEX `resource-id` (`resource-id`),
FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
INDEX `quote-uri-id` (`quote-uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`quote-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
--
@ -1267,7 +1241,7 @@ CREATE TABLE IF NOT EXISTS `post-history` (
`target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
`target` text COMMENT 'JSON encoded target structure if used',
`resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
`plink` varbinary(383) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
`plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
PRIMARY KEY(`uri-id`,`edited`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Post history';
@ -1292,7 +1266,6 @@ CREATE TABLE IF NOT EXISTS `post-media` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`url` varbinary(1024) NOT NULL COMMENT 'Media URL',
`media-uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the activities uri-id',
`type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
`mimetype` varchar(60) COMMENT '',
`height` smallint unsigned COMMENT 'Height of the media',
@ -1303,18 +1276,16 @@ CREATE TABLE IF NOT EXISTS `post-media` (
`preview-width` smallint unsigned COMMENT 'Width of the preview picture',
`description` text COMMENT '',
`name` varchar(255) COMMENT 'Name of the media',
`author-url` varbinary(383) COMMENT 'URL of the author of the media',
`author-url` varbinary(255) COMMENT 'URL of the author of the media',
`author-name` varchar(255) COMMENT 'Name of the author of the media',
`author-image` varbinary(383) COMMENT 'Image of the author of the media',
`publisher-url` varbinary(383) COMMENT 'URL of the publisher of the media',
`author-image` varbinary(255) COMMENT 'Image of the author of the media',
`publisher-url` varbinary(255) COMMENT 'URL of the publisher of the media',
`publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
`publisher-image` varbinary(383) COMMENT 'Image of the publisher of the media',
`publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
INDEX `uri-id-id` (`uri-id`,`id`),
INDEX `media-uri-id` (`media-uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`media-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
--
@ -1437,7 +1408,6 @@ CREATE TABLE IF NOT EXISTS `post-user` (
INDEX `author-id_uid` (`author-id`,`uid`),
INDEX `author-id_received` (`author-id`,`received`),
INDEX `parent-uri-id_uid` (`parent-uri-id`,`uid`),
INDEX `uid_wall_received` (`uid`,`wall`,`received`),
INDEX `uid_contactid` (`uid`,`contact-id`),
INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
INDEX `uid_unseen` (`uid`,`unseen`),
@ -1579,8 +1549,8 @@ CREATE TABLE IF NOT EXISTS `profile` (
`homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
`matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`thumb` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
`net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
PRIMARY KEY(`id`),
@ -1615,7 +1585,7 @@ CREATE TABLE IF NOT EXISTS `profile_field` (
CREATE TABLE IF NOT EXISTS `push_subscriber` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`callback_url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
@ -1634,7 +1604,7 @@ CREATE TABLE IF NOT EXISTS `push_subscriber` (
--
CREATE TABLE IF NOT EXISTS `register` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`hash` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
`hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@ -1734,7 +1704,7 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
`fetch_further_information` tinyint unsigned COMMENT '',
`ffi_keyword_denylist` text COMMENT '',
`subhub` boolean COMMENT '',
`hub-verify` varbinary(383) COMMENT '',
`hub-verify` varchar(255) COMMENT '',
`protocol` char(4) COMMENT 'Protocol of the contact',
`rating` tinyint COMMENT 'Automatically detected feed poll frequency',
`priority` tinyint unsigned COMMENT 'Feed poll priority',
@ -1750,7 +1720,7 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
-- TABLE arrived-activity
--
CREATE TABLE IF NOT EXISTS `arrived-activity` (
`object-id` varbinary(383) NOT NULL COMMENT 'object id of the incoming activity',
`object-id` varbinary(255) NOT NULL COMMENT 'object id of the incoming activity',
`received` datetime COMMENT 'Receiving date',
PRIMARY KEY(`object-id`)
) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of arrived activities';
@ -1759,7 +1729,7 @@ CREATE TABLE IF NOT EXISTS `arrived-activity` (
-- TABLE fetched-activity
--
CREATE TABLE IF NOT EXISTS `fetched-activity` (
`object-id` varbinary(383) NOT NULL COMMENT 'object id of fetched activity',
`object-id` varbinary(255) NOT NULL COMMENT 'object id of fetched activity',
`received` datetime COMMENT 'Receiving date',
PRIMARY KEY(`object-id`)
) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Id of fetched activities';
@ -1813,8 +1783,6 @@ CREATE VIEW `post-user-view` AS SELECT
`post-user`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`,
`post-thread-user`.`conversation-id` AS `conversation-id`,
`quote-item-uri`.`uri` AS `quote-uri`,
`post-content`.`quote-uri-id` AS `quote-uri-id`,
`item-uri`.`guid` AS `guid`,
`post-user`.`wall` AS `wall`,
`post-user`.`gravity` AS `gravity`,
@ -1970,7 +1938,6 @@ CREATE VIEW `post-user-view` AS SELECT
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
@ -1994,8 +1961,6 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`post-user`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`,
`post-thread-user`.`conversation-id` AS `conversation-id`,
`quote-item-uri`.`uri` AS `quote-uri`,
`post-content`.`quote-uri-id` AS `quote-uri-id`,
`item-uri`.`guid` AS `guid`,
`post-thread-user`.`wall` AS `wall`,
`post-user`.`gravity` AS `gravity`,
@ -2149,7 +2114,6 @@ CREATE VIEW `post-thread-user-view` AS SELECT
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
@ -2169,8 +2133,6 @@ CREATE VIEW `post-view` AS SELECT
`post`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`,
`post-thread`.`conversation-id` AS `conversation-id`,
`quote-item-uri`.`uri` AS `quote-uri`,
`post-content`.`quote-uri-id` AS `quote-uri-id`,
`item-uri`.`guid` AS `guid`,
`post`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`,
@ -2293,7 +2255,6 @@ CREATE VIEW `post-view` AS SELECT
LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post`.`uri-id`
LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post`.`uri-id`
LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@ -2311,8 +2272,6 @@ CREATE VIEW `post-thread-view` AS SELECT
`post`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`,
`post-thread`.`conversation-id` AS `conversation-id`,
`quote-item-uri`.`uri` AS `quote-uri`,
`post-content`.`quote-uri-id` AS `quote-uri-id`,
`item-uri`.`guid` AS `guid`,
`post`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`,
@ -2435,7 +2394,6 @@ CREATE VIEW `post-thread-view` AS SELECT
LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `item-uri` AS `quote-item-uri` ON `quote-item-uri`.`id` = `post-content`.`quote-uri-id`
LEFT JOIN `post-question` ON `post-question`.`uri-id` = `post-thread`.`uri-id`
LEFT JOIN `post` AS `parent-post` ON `parent-post`.`uri-id` = `post`.`parent-uri-id`
LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@ -2461,7 +2419,7 @@ DROP VIEW IF EXISTS `collection-view`;
CREATE VIEW `collection-view` AS SELECT
`post-collection`.`uri-id` AS `uri-id`,
`post-collection`.`type` AS `type`,
`post-collection`.`author-id` AS `cid`,
`post`.`author-id` AS `cid`,
`post`.`received` AS `received`,
`post`.`created` AS `created`,
`post-thread`.`commented` AS `commented`,
@ -2469,7 +2427,7 @@ CREATE VIEW `collection-view` AS SELECT
`post`.`visible` AS `visible`,
`post`.`deleted` AS `deleted`,
`post`.`thr-parent-id` AS `thr-parent-id`,
`post-collection`.`author-id` AS `author-id`,
`post`.`author-id` AS `author-id`,
`post`.`gravity` AS `gravity`
FROM `post-collection`
INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`

View File

@ -410,13 +410,13 @@ Ex: Wed May 23 06:01:13 +0000 2007
</tr>
<tr>
<td><code>start_time</code></td>
<td><code>startTime</code></td>
<td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
<td></td>
</tr>
<tr>
<td><code>end_time</code></td>
<td><code>endTime</code></td>
<td>String (UTC <code>YYYY-MM-DD HH:II:SS)</code>)</td>
<td>Optional (null date is <code>0001-01-01 00:00:00</code></td>
</tr>

View File

@ -24,32 +24,6 @@ Returns a list of [Event](help/API-Entities#Event) entities for the current logg
- `since_id`: (optional) minimum event id for pagination
- `count`: maximum number of items returned, default 20
### POST api/friendica/event_create
Create a new event for the current logged in user.
#### Parameters
- `id` : (optional) id of event, event will be amended if supplied
- `name` : name of the event (required)
- `start_time` : start of the event (ISO), required
- `end_time` : (optional) end of the event, event is open end, if not supplied
- `desc` : (optional) description of the event
- `place` : (optional) location of the event
- `publish` : (optional) create message for event
- `allow_cid` : (optional) ACL-formatted list of allowed contact ids if private event
- `allow_gid` : (optional) ACL-formatted list of disallowed contact ids if private event
- `deny_cid` : (optional) ACL-formatted list of allowed group ids if private event
- `deny_gid` : (optional) ACL-formatted list of disallowed group ids if private event
### POST api/friendica/event_delete
Delete event from calendar (not the message)
#### Parameters
- `id` : id of event to be deleted
### GET api/externalprofile/show
Returns a [Contact](help/API-Entities#Contact) entity for the provided profile URL.

View File

@ -281,7 +281,7 @@ $data = [
'submit' => [
'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'),
'catavatar-morecat' => DI::l10n()->t('Another random Cat!'),
'catavatar-emailcat' => DI::pConfig()->get(Session::getLocalUser(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
'catavatar-emailcat' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
],
];
```
@ -919,10 +919,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('block', $hook_data);
Hook::callAll('unblock', $hook_data);
### src/Core/Logger/Factory.php
Hook::callAll('logger_instance', $data);
### src/Core/StorageManager
Hook::callAll('storage_instance', $data);

View File

@ -6,7 +6,7 @@ Using Composer
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
* [Class autoloading](help/autoloader)

View File

@ -30,7 +30,7 @@ function doSomething(array $intros)
}
}
$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => Session::getLocalUser()]);
$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => local_user()]);
doSomething($intros);
```
@ -47,7 +47,7 @@ function doSomething(\Friendica\Contact\Introductions\Collection\Introductions $
}
/** @var $intros \Friendica\Contact\Introductions\Collection\Introductions */
$intros = \Friendica\DI::intro()->selecForUser(Session::getLocalUser());
$intros = \Friendica\DI::intro()->selecForUser(local_user());
doSomething($intros);
```

View File

@ -47,7 +47,7 @@ Friendica uses an implementation of [Domain-Driven-Design](help/Developer-Domain
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
If you want to have git automatically update the dependencies with composer, you can use the `post-merge` [git-hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) with a script similar to this one:

View File

@ -34,7 +34,7 @@ Due to the large variety of operating systems and PHP platforms in existence we
* The POSIX module of PHP needs to be activated (e.g. [RHEL, CentOS](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) have disabled it)
* Some form of email server or email gateway such that PHP mail() works.
If you cannot set up your own email server, you can use the [phpmailer](https://github.com/friendica/friendica-addons/tree/develop/phpmailer) addon and use a remote SMTP server.
* MySQL with support of InnoDB and Barracuda (we suggest a MariaDB server as all development is done using these, but alternatives like MySQL or Percona Server etc. might work as well)
* MySQL 5.6+ or an equivalent alternative for MySQL (MariaDB, Percona Server etc.)
* ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows)
* installation into a top-level domain or sub-domain (without a directory/path component in the URL) is RECOMMENDED. Directory paths will not be as convenient to use and have not been thoroughly tested. This is REQUIRED if you wish to communicate with the Diaspora network.

View File

@ -10,7 +10,7 @@ Getting started
No need to setup up a webserver, database etc. before actually starting.
Vagrant creates a virtual machine for you that you can just run inside VirtualBox and start to work directly on Friendica.
It brings an Debian Bullseye with PHP 8.0 and MariaDB 10.5.11.
It brings an Debian Bullseye with PHP 7.4 and MariaDB 10.5.11.
What you need to do:
@ -24,7 +24,7 @@ This will start the virtual machine.
Be patient: When it runs for the first time, it downloads a Debian Server image and installs Friendica.
4. Run `vagrant ssh` to log into the virtual machine to log in to the VM in case you need to debug something on the server.
5. Open you test installation in a browser.
Go to friendica.local (or 192.168.56.10).
Go to friendica.local (or 192.168.22.10).
friendica.local is using a self-signed TLS certificate, so you will need to add an exception to trust the certificate the first time you are visiting the page.
The mysql database is called "friendica", the mysql user and password both are "friendica".
6. Work on Friendica's code in your git clone on your machine (not in the VM).
@ -66,4 +66,4 @@ On the next Vagrant up, the version problem should be fixed.
If `friendica.local` is not resolved, you may need to add an entry to the `/etc/hosts` file (or similar configuration depending on the OS you are using).
For further documentation of vagrant, please see [the vagrant*docs*](https://docs.vagrantup.com/v2/).
For further documentation of vagrant, please see [the vagrant*docs*](https://docs.vagrantup.com/v2/).

View File

@ -6,7 +6,7 @@ Autoloader with Composer
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application.
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
* [Using Composer](help/Composer)
@ -39,6 +39,7 @@ Namespaces are useful to keep classes separated and avoid names conflicts (could
Let's say now that you need to load some items in a view, maybe in a fictional `mod/network.php`.
In order for the Composer autoloader to work, it must first be included.
In Friendica this is already done at the top of `boot.php`, with `require_once('vendor/autoload.php');`.
The code will be something like:

View File

@ -8,7 +8,6 @@ Database Tables
| [2fa_app_specific_password](help/database/db_2fa_app_specific_password) | Two-factor app-specific _password |
| [2fa_recovery_codes](help/database/db_2fa_recovery_codes) | Two-factor authentication recovery codes |
| [2fa_trusted_browser](help/database/db_2fa_trusted_browser) | Two-factor authentication trusted browsers |
| [account-user](help/database/db_account-user) | Remote and local accounts |
| [addon](help/database/db_addon) | registered addons |
| [apcontact](help/database/db_apcontact) | ActivityPub compatible contacts - used in the ActivityPub implementation |
| [application](help/database/db_application) | OAuth application |

View File

@ -1,32 +0,0 @@
Table account-user
===========
Remote and local accounts
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------ | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uri-id | Id of the item-uri table entry that contains the account url | int unsigned | NO | | NULL | |
| uid | User ID | mediumint unsigned | NO | | NULL | |
Indexes
------------
| Name | Fields |
| ---------- | ------------------- |
| PRIMARY | id |
| uri-id_uid | UNIQUE, uri-id, uid |
| uid_uri-id | uid, uri-id |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| uid | [user](help/database/db_user) | uid |
Return to [database documentation](help/database)

View File

@ -8,17 +8,17 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ---------------- | ------------------------------------------------------------------- | -------------- | ---- | --- | ------------------- | ----- |
| url | URL of the contact | varbinary(383) | NO | PRI | NULL | |
| url | URL of the contact | varbinary(255) | NO | PRI | NULL | |
| uri-id | Id of the item-uri table entry that contains the apcontact url | int unsigned | YES | | NULL | |
| uuid | | varbinary(255) | YES | | NULL | |
| uuid | | varchar(255) | YES | | NULL | |
| type | | varchar(20) | NO | | NULL | |
| following | | varbinary(383) | YES | | NULL | |
| followers | | varbinary(383) | YES | | NULL | |
| inbox | | varbinary(383) | NO | | NULL | |
| outbox | | varbinary(383) | YES | | NULL | |
| sharedinbox | | varbinary(383) | YES | | NULL | |
| featured | Address for the collection of featured posts | varbinary(383) | YES | | NULL | |
| featured-tags | Address for the collection of featured tags | varbinary(383) | YES | | NULL | |
| following | | varchar(255) | YES | | NULL | |
| followers | | varchar(255) | YES | | NULL | |
| inbox | | varchar(255) | NO | | NULL | |
| outbox | | varchar(255) | YES | | NULL | |
| sharedinbox | | varchar(255) | YES | | NULL | |
| featured | Address for the collection of featured posts | varchar(255) | YES | | NULL | |
| featured-tags | Address for the collection of featured tags | varchar(255) | YES | | NULL | |
| manually-approve | | boolean | YES | | NULL | |
| discoverable | Mastodon extension: true if profile is published in their directory | boolean | YES | | NULL | |
| suspended | Mastodon extension: true if profile is suspended | boolean | YES | | NULL | |
@ -27,13 +27,13 @@ Fields
| about | | text | YES | | NULL | |
| xmpp | XMPP address | varchar(255) | YES | | NULL | |
| matrix | Matrix address | varchar(255) | YES | | NULL | |
| photo | | varbinary(383) | YES | | NULL | |
| header | Header picture | varbinary(383) | YES | | NULL | |
| photo | | varchar(255) | YES | | NULL | |
| header | Header picture | varchar(255) | YES | | NULL | |
| addr | | varchar(255) | YES | | NULL | |
| alias | | varbinary(383) | YES | | NULL | |
| alias | | varchar(255) | YES | | NULL | |
| pubkey | | text | YES | | NULL | |
| subscribe | | varbinary(383) | YES | | NULL | |
| baseurl | baseurl of the ap contact | varbinary(383) | YES | | NULL | |
| subscribe | | varchar(255) | YES | | NULL | |
| baseurl | baseurl of the ap contact | varchar(255) | YES | | NULL | |
| gsid | Global Server ID | int unsigned | YES | | NULL | |
| generator | Name of the contact's system | varchar(255) | YES | | NULL | |
| following_count | Number of following contacts | int unsigned | YES | | 0 | |

View File

@ -11,7 +11,7 @@ Fields
| application-id | | int unsigned | NO | PRI | NULL | |
| uid | Owner User id | mediumint unsigned | NO | PRI | NULL | |
| timeline | Marker (home, notifications) | varchar(64) | NO | PRI | NULL | |
| last_read_id | Marker id for the timeline | varbinary(383) | YES | | NULL | |
| last_read_id | Marker id for the timeline | varchar(255) | YES | | NULL | |
| version | Version number | smallint unsigned | YES | | NULL | |
| updated_at | creation time | datetime | YES | | NULL | |

View File

@ -6,19 +6,19 @@ OAuth application
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------------- | --------------- | -------------- | ---- | --- | ------- | -------------- |
| id | generated index | int unsigned | NO | PRI | NULL | auto_increment |
| client_id | | varchar(64) | NO | | NULL | |
| client_secret | | varchar(64) | NO | | NULL | |
| name | | varchar(255) | NO | | NULL | |
| redirect_uri | | varbinary(383) | NO | | NULL | |
| website | | varbinary(383) | YES | | NULL | |
| scopes | | varchar(255) | YES | | NULL | |
| read | Read scope | boolean | YES | | NULL | |
| write | Write scope | boolean | YES | | NULL | |
| follow | Follow scope | boolean | YES | | NULL | |
| push | Push scope | boolean | YES | | NULL | |
| Field | Description | Type | Null | Key | Default | Extra |
| ------------- | --------------- | ------------ | ---- | --- | ------- | -------------- |
| id | generated index | int unsigned | NO | PRI | NULL | auto_increment |
| client_id | | varchar(64) | NO | | NULL | |
| client_secret | | varchar(64) | NO | | NULL | |
| name | | varchar(255) | NO | | NULL | |
| redirect_uri | | varchar(255) | NO | | NULL | |
| website | | varchar(255) | YES | | NULL | |
| scopes | | varchar(255) | YES | | NULL | |
| read | Read scope | boolean | YES | | NULL | |
| write | Write scope | boolean | YES | | NULL | |
| follow | Follow scope | boolean | YES | | NULL | |
| push | Push scope | boolean | YES | | NULL | |
Indexes
------------

View File

@ -8,7 +8,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| --------- | ---------------------------------- | -------------- | ---- | --- | ------- | ----- |
| object-id | object id of the incoming activity | varbinary(383) | NO | PRI | NULL | |
| object-id | object id of the incoming activity | varbinary(255) | NO | PRI | NULL | |
| received | Receiving date | datetime | YES | | NULL | |
Indexes

View File

@ -20,28 +20,26 @@ Fields
| keywords | public keywords (interests) of the contact | text | YES | | NULL | |
| xmpp | XMPP address | varchar(255) | NO | | | |
| matrix | Matrix address | varchar(255) | NO | | | |
| avatar | | varbinary(383) | NO | | | |
| header | Header picture | varbinary(383) | YES | | NULL | |
| url | | varbinary(383) | NO | | | |
| nurl | | varbinary(383) | NO | | | |
| avatar | | varchar(255) | NO | | | |
| header | Header picture | varchar(255) | YES | | NULL | |
| url | | varchar(255) | NO | | | |
| nurl | | varchar(255) | NO | | | |
| uri-id | Id of the item-uri table entry that contains the contact url | int unsigned | YES | | NULL | |
| addr | | varchar(255) | NO | | | |
| alias | | varbinary(383) | NO | | | |
| alias | | varchar(255) | NO | | | |
| pubkey | RSA public key 4096 bit | text | YES | | NULL | |
| prvkey | RSA private key 4096 bit | text | YES | | NULL | |
| batch | | varbinary(383) | NO | | | |
| notify | | varbinary(383) | YES | | NULL | |
| poll | | varbinary(383) | YES | | NULL | |
| subscribe | | varbinary(383) | YES | | NULL | |
| batch | | varchar(255) | NO | | | |
| notify | | varchar(255) | YES | | NULL | |
| poll | | varchar(255) | YES | | NULL | |
| subscribe | | varchar(255) | YES | | NULL | |
| last-update | Date of the last try to update the contact info | datetime | NO | | 0001-01-01 00:00:00 | |
| next-update | Next connection request | datetime | YES | | NULL | |
| success_update | Date of the last successful contact update | datetime | NO | | 0001-01-01 00:00:00 | |
| failure_update | Date of the last failed update | datetime | NO | | 0001-01-01 00:00:00 | |
| failed | Connection failed | boolean | YES | | NULL | |
| term-date | | datetime | NO | | 0001-01-01 00:00:00 | |
| last-item | date of the last post | datetime | NO | | 0001-01-01 00:00:00 | |
| last-discovery | date of the last follower discovery | datetime | NO | | 0001-01-01 00:00:00 | |
| local-data | Is true when there are posts with this contact on the system | boolean | YES | | NULL | |
| blocked | Node-wide block status | boolean | NO | | 1 | |
| block_reason | Node-wide block reason | text | YES | | NULL | |
| readonly | posts of the contact are readonly | boolean | NO | | 0 | |
@ -50,7 +48,7 @@ Fields
| archive | | boolean | NO | | 0 | |
| unsearchable | Contact prefers to not be searchable | boolean | NO | | 0 | |
| sensitive | Contact posts sensitive content | boolean | NO | | 0 | |
| baseurl | baseurl of the contact | varbinary(383) | YES | | | |
| baseurl | baseurl of the contact | varchar(255) | YES | | | |
| gsid | Global Server ID | int unsigned | YES | | NULL | |
| bd | | date | NO | | 0001-01-01 | |
| reason | | text | YES | | NULL | |
@ -59,7 +57,7 @@ Fields
| rel | The kind of the relation between the user and the contact | tinyint unsigned | NO | | 0 | |
| protocol | Protocol of the contact | char(4) | NO | | | |
| subhub | | boolean | NO | | 0 | |
| hub-verify | | varbinary(383) | NO | | | |
| hub-verify | | varchar(255) | NO | | | |
| rating | Automatically detected feed poll frequency | tinyint | NO | | 0 | |
| priority | Feed poll priority | tinyint unsigned | NO | | 0 | |
| attag | | varchar(255) | NO | | | |
@ -70,15 +68,15 @@ Fields
| notify_new_posts | | boolean | NO | | 0 | |
| fetch_further_information | | tinyint unsigned | NO | | 0 | |
| ffi_keyword_denylist | | text | YES | | NULL | |
| photo | Link to the profile photo of the contact | varbinary(383) | YES | | | |
| thumb | Link to the profile photo (thumb size) | varbinary(383) | YES | | | |
| micro | Link to the profile photo (micro size) | varbinary(383) | YES | | | |
| photo | Link to the profile photo of the contact | varchar(255) | YES | | | |
| thumb | Link to the profile photo (thumb size) | varchar(255) | YES | | | |
| micro | Link to the profile photo (micro size) | varchar(255) | YES | | | |
| name-date | | datetime | NO | | 0001-01-01 00:00:00 | |
| uri-date | | datetime | NO | | 0001-01-01 00:00:00 | |
| avatar-date | | datetime | NO | | 0001-01-01 00:00:00 | |
| request | | varbinary(383) | YES | | NULL | |
| confirm | | varbinary(383) | YES | | NULL | |
| poco | | varbinary(383) | YES | | NULL | |
| request | | varchar(255) | YES | | NULL | |
| confirm | | varchar(255) | YES | | NULL | |
| poco | | varchar(255) | YES | | NULL | |
| writable | | boolean | NO | | 0 | |
| forum | contact is a forum. Deprecated, use 'contact-type' = 'community' and 'manually-approve' = false instead | boolean | NO | | 0 | |
| prv | contact is a private group. Deprecated, use 'contact-type' = 'community' and 'manually-approve' = true instead | boolean | NO | | 0 | |
@ -86,8 +84,8 @@ Fields
| site-pubkey | Deprecated | text | YES | | NULL | |
| gender | Deprecated | varchar(32) | NO | | | |
| duplex | Deprecated | boolean | NO | | 0 | |
| issued-id | Deprecated | varbinary(383) | NO | | | |
| dfrn-id | Deprecated | varbinary(383) | NO | | | |
| issued-id | Deprecated | varchar(255) | NO | | | |
| dfrn-id | Deprecated | varchar(255) | NO | | | |
| aes_allow | Deprecated | boolean | NO | | 0 | |
| ret-aes | Deprecated | boolean | NO | | 0 | |
| usehub | Deprecated | boolean | NO | | 0 | |
@ -114,14 +112,12 @@ Indexes
| attag_uid | attag(96), uid |
| network_uid_lastupdate | network, uid, last-update |
| uid_network_self_lastupdate | uid, network, self, last-update |
| next-update | next-update |
| local-data-next-update | local-data, next-update |
| uid_lastitem | uid, last-item |
| baseurl | baseurl(64) |
| uid_contact-type | uid, contact-type |
| uid_self_contact-type | uid, self, contact-type |
| self_network_uid | self, network, uid |
| gsid_uid_failed | gsid, uid, failed |
| gsid | gsid |
| uri-id | uri-id |
Foreign Keys

View File

@ -9,7 +9,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------- | ----------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| guid | A unique identifier for this conversation | varbinary(255) | NO | | | |
| guid | A unique identifier for this conversation | varchar(255) | NO | | | |
| recips | sender_handle;recipient_handle | text | YES | | NULL | |
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
| creator | handle of creator | varchar(255) | NO | | | |

View File

@ -9,7 +9,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------- | ---------------------------------------------- | ------------------ | ---- | --- | ------- | -------------- |
| id | | int unsigned | NO | PRI | NULL | auto_increment |
| uri | URI of the post that will be distributed later | varbinary(383) | YES | | NULL | |
| uri | URI of the post that will be distributed later | varchar(255) | YES | | NULL | |
| uid | Owner User id | mediumint unsigned | YES | | NULL | |
| delayed | delay time | datetime | YES | | NULL | |
| wid | Workerqueue id | int unsigned | YES | | NULL | |

View File

@ -8,7 +8,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------------ | -------------------------------------------------------------- | -------------- | ---- | --- | ------- | ----- |
| url | URL of the contact | varbinary(383) | NO | PRI | NULL | |
| url | URL of the contact | varbinary(255) | NO | PRI | NULL | |
| type | | varchar(20) | NO | | NULL | |
| owner-uri-id | Id of the item-uri table entry that contains the apcontact url | int unsigned | YES | | NULL | |

View File

@ -9,10 +9,10 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| --------- | ---------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| guid | | varbinary(255) | NO | | | |
| guid | | varchar(255) | NO | | | |
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
| cid | contact_id (ID of the contact in contact table) | int unsigned | NO | | 0 | |
| uri | | varbinary(383) | NO | | | |
| uri | | varchar(255) | NO | | | |
| uri-id | Id of the item-uri table entry that contains the event uri | int unsigned | YES | | NULL | |
| created | creation time | datetime | NO | | 0001-01-01 00:00:00 | |
| edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | |

View File

@ -9,23 +9,22 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ----------------- | ------------------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| guid | unique id | varbinary(255) | NO | | | |
| url | | varbinary(383) | NO | | | |
| guid | unique id | varchar(255) | NO | | | |
| url | | varchar(255) | NO | | | |
| uri-id | Id of the item-uri table entry that contains the fcontact url | int unsigned | YES | | NULL | |
| name | | varchar(255) | NO | | | |
| photo | | varbinary(383) | NO | | | |
| request | | varbinary(383) | NO | | | |
| photo | | varchar(255) | NO | | | |
| request | | varchar(255) | NO | | | |
| nick | | varchar(255) | NO | | | |
| addr | | varchar(255) | NO | | | |
| batch | | varbinary(383) | NO | | | |
| notify | | varbinary(383) | NO | | | |
| poll | | varbinary(383) | NO | | | |
| confirm | | varbinary(383) | NO | | | |
| batch | | varchar(255) | NO | | | |
| notify | | varchar(255) | NO | | | |
| poll | | varchar(255) | NO | | | |
| confirm | | varchar(255) | NO | | | |
| priority | | tinyint unsigned | NO | | 0 | |
| network | | char(4) | NO | | | |
| alias | | varbinary(383) | NO | | | |
| alias | | varchar(255) | NO | | | |
| pubkey | | text | YES | | NULL | |
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
| interacting_count | Number of contacts this contact interactes with | int unsigned | YES | | 0 | |
| interacted_count | Number of contacts that interacted with this contact | int unsigned | YES | | 0 | |

View File

@ -9,7 +9,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------- | ---------------------------------- | -------------- | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| url | url that awaiting to be fetched | varbinary(383) | YES | | NULL | |
| url | url that awaiting to be fetched | varbinary(255) | YES | | NULL | |
| created | Creation date of the fetch request | datetime | NO | | 0001-01-01 00:00:00 | |
| wid | Workerqueue id | int unsigned | YES | | NULL | |

View File

@ -8,7 +8,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| --------- | ----------------------------- | -------------- | ---- | --- | ------- | ----- |
| object-id | object id of fetched activity | varbinary(383) | NO | PRI | NULL | |
| object-id | object id of fetched activity | varbinary(255) | NO | PRI | NULL | |
| received | Receiving date | datetime | YES | | NULL | |
Indexes

View File

@ -12,9 +12,9 @@ Fields
| uid | User id | mediumint unsigned | NO | | 0 | |
| cid | | int unsigned | NO | | 0 | |
| name | | varchar(255) | NO | | | |
| url | | varbinary(383) | NO | | | |
| request | | varbinary(383) | NO | | | |
| photo | | varbinary(383) | NO | | | |
| url | | varchar(255) | NO | | | |
| request | | varchar(255) | NO | | | |
| photo | | varchar(255) | NO | | | |
| note | | text | YES | | NULL | |
| created | | datetime | NO | | 0001-01-01 00:00:00 | |

View File

@ -9,8 +9,8 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| --------------------- | -------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| url | | varbinary(383) | NO | | | |
| nurl | | varbinary(383) | NO | | | |
| url | | varchar(255) | NO | | | |
| nurl | | varchar(255) | NO | | | |
| version | | varchar(255) | NO | | | |
| site_name | | varchar(255) | NO | | | |
| info | | text | YES | | NULL | |
@ -22,8 +22,8 @@ Fields
| local-posts | Number of local posts | int unsigned | YES | | NULL | |
| local-comments | Number of local comments | int unsigned | YES | | NULL | |
| directory-type | Type of directory service (Poco, Mastodon) | tinyint | YES | | 0 | |
| poco | | varbinary(383) | NO | | | |
| noscrape | | varbinary(383) | NO | | | |
| poco | | varchar(255) | NO | | | |
| noscrape | | varchar(255) | NO | | | |
| network | | char(4) | NO | | | |
| protocol | The protocol of the server | tinyint unsigned | YES | | NULL | |
| platform | | varchar(255) | NO | | | |

View File

@ -9,10 +9,10 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------------------ | -------------------------------------- | -------------- | ---- | --- | ------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| activity-id | id of the incoming activity | varbinary(383) | YES | | NULL | |
| object-id | | varbinary(383) | YES | | NULL | |
| in-reply-to-id | | varbinary(383) | YES | | NULL | |
| conversation | | varbinary(383) | YES | | NULL | |
| activity-id | id of the incoming activity | varbinary(255) | YES | | NULL | |
| object-id | | varbinary(255) | YES | | NULL | |
| in-reply-to-id | | varbinary(255) | YES | | NULL | |
| conversation | | varbinary(255) | YES | | NULL | |
| type | Type of the activity | varchar(64) | YES | | NULL | |
| object-type | Type of the object activity | varchar(64) | YES | | NULL | |
| object-object-type | Type of the object's object activity | varchar(64) | YES | | NULL | |

View File

@ -8,7 +8,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| -------- | ------------------------------------ | -------------- | ---- | --- | ------------------- | ----- |
| url | URL of the inbox | varbinary(383) | NO | PRI | NULL | |
| url | URL of the inbox | varbinary(255) | NO | PRI | NULL | |
| uri-id | Item-uri id of inbox url | int unsigned | YES | | NULL | |
| created | Creation date of this entry | datetime | NO | | 0001-01-01 00:00:00 | |
| success | Date of the last successful delivery | datetime | NO | | 0001-01-01 00:00:00 | |

View File

@ -16,7 +16,7 @@ Fields
| knowyou | | boolean | NO | | 0 | |
| duplex | deprecated | boolean | NO | | 0 | |
| note | | text | YES | | NULL | |
| hash | | varbinary(255) | NO | | | |
| hash | | varchar(255) | NO | | | |
| datetime | | datetime | NO | | 0001-01-01 00:00:00 | |
| blocked | deprecated | boolean | NO | | 0 | |
| ignore | | boolean | NO | | 0 | |

View File

@ -9,7 +9,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ----- | ------------------------------- | -------------- | ---- | --- | ------- | -------------- |
| id | | int unsigned | NO | PRI | NULL | auto_increment |
| uri | URI of an item | varbinary(383) | NO | | NULL | |
| uri | URI of an item | varbinary(255) | NO | | NULL | |
| guid | A unique identifier for an item | varbinary(255) | YES | | NULL | |
Indexes

View File

@ -10,11 +10,11 @@ Fields
| ------------- | -------------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
| guid | A unique identifier for this private message | varbinary(255) | NO | | | |
| guid | A unique identifier for this private message | varchar(255) | NO | | | |
| from-name | name of the sender | varchar(255) | NO | | | |
| from-photo | contact photo link of the sender | varbinary(383) | NO | | | |
| from-url | profile linke of the sender | varbinary(383) | NO | | | |
| contact-id | contact.id | varbinary(255) | YES | | NULL | |
| from-photo | contact photo link of the sender | varchar(255) | NO | | | |
| from-url | profile linke of the sender | varchar(255) | NO | | | |
| contact-id | contact.id | varchar(255) | YES | | NULL | |
| author-id | Link to the contact table with uid=0 of the author of the mail | int unsigned | YES | | NULL | |
| convid | conv.id | int unsigned | YES | | NULL | |
| title | | varchar(255) | NO | | | |
@ -23,11 +23,11 @@ Fields
| reply | | boolean | NO | | 0 | |
| replied | | boolean | NO | | 0 | |
| unknown | if sender not in the contact table this is 1 | boolean | NO | | 0 | |
| uri | | varbinary(383) | NO | | | |
| uri | | varchar(255) | NO | | | |
| uri-id | Item-uri id of the related mail | int unsigned | YES | | NULL | |
| parent-uri | | varbinary(383) | NO | | | |
| parent-uri | | varchar(255) | NO | | | |
| parent-uri-id | Item-uri id of the parent of the related mail | int unsigned | YES | | NULL | |
| thr-parent | | varbinary(383) | YES | | NULL | |
| thr-parent | | varchar(255) | YES | | NULL | |
| thr-parent-id | Id of the item-uri table that contains the thread parent uri | int unsigned | YES | | NULL | |
| created | creation time of the private message | datetime | NO | | 0001-01-01 00:00:00 | |

View File

@ -31,7 +31,6 @@ Indexes
| target-uri-id | target-uri-id |
| parent-uri-id | parent-uri-id |
| seen_uid | seen, uid |
| uid_type_parent-uri-id_actor-id | uid, type, parent-uri-id, actor-id |
Foreign Keys
------------

View File

@ -11,12 +11,12 @@ Fields
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| type | | smallint unsigned | NO | | 0 | |
| name | | varchar(255) | NO | | | |
| url | | varbinary(383) | NO | | | |
| photo | | varbinary(383) | NO | | | |
| url | | varchar(255) | NO | | | |
| photo | | varchar(255) | NO | | | |
| date | | datetime | NO | | 0001-01-01 00:00:00 | |
| msg | | mediumtext | YES | | NULL | |
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
| link | | varbinary(383) | NO | | | |
| link | | varchar(255) | NO | | | |
| iid | | int unsigned | YES | | NULL | |
| parent | | int unsigned | YES | | NULL | |
| uri-id | Item-uri id of the related post | int unsigned | YES | | NULL | |

View File

@ -8,7 +8,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| -------- | ------------------------------ | ------------------ | ---- | --- | ------------------- | ----- |
| url | page url | varbinary(383) | NO | PRI | NULL | |
| url | page url | varbinary(255) | NO | PRI | NULL | |
| maxwidth | Maximum width passed to Oembed | mediumint unsigned | NO | PRI | NULL | |
| content | OEmbed data of the page | mediumtext | YES | | NULL | |
| created | datetime of creation | datetime | NO | | 0001-01-01 00:00:00 | |

View File

@ -6,20 +6,18 @@ Collection of posts
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| --------- | --------------------------------------------------------- | ---------------- | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| type | 0 - Featured | tinyint unsigned | NO | PRI | 0 | |
| author-id | Author of the featured post | int unsigned | YES | | NULL | |
| Field | Description | Type | Null | Key | Default | Extra |
| ------ | --------------------------------------------------------- | ---------------- | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| type | 0 - Featured | tinyint unsigned | NO | PRI | 0 | |
Indexes
------------
| Name | Fields |
| --------- | ------------ |
| PRIMARY | uri-id, type |
| type | type |
| author-id | author-id |
| Name | Fields |
| ------- | ------------ |
| PRIMARY | uri-id, type |
| type | type |
Foreign Keys
------------
@ -27,6 +25,5 @@ Foreign Keys
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| author-id | [contact](help/database/db_contact) | id |
Return to [database documentation](help/database)

View File

@ -6,26 +6,25 @@ Content for all posts
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------- | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| title | item title | varchar(255) | NO | | | |
| content-warning | | varchar(255) | NO | | | |
| body | item body content | mediumtext | YES | | NULL | |
| raw-body | Body without embedded media links | mediumtext | YES | | NULL | |
| quote-uri-id | Id of the item-uri table that contains the quoted uri | int unsigned | YES | | NULL | |
| location | text location where this item originated | varchar(255) | NO | | | |
| coord | longitude/latitude pair representing location where this item originated | varchar(255) | NO | | | |
| language | Language information about this post | text | YES | | NULL | |
| app | application which generated this item | varchar(255) | NO | | | |
| rendered-hash | | varchar(32) | NO | | | |
| rendered-html | item.body converted to html | mediumtext | YES | | NULL | |
| object-type | ActivityStreams object type | varchar(100) | NO | | | |
| object | JSON encoded object structure unless it is an implied object (normal post) | text | YES | | NULL | |
| target-type | ActivityStreams target type if applicable (URI) | varchar(100) | NO | | | |
| target | JSON encoded target structure if used | text | YES | | NULL | |
| resource-id | Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type | varchar(32) | NO | | | |
| plink | permalink or URL to a displayable copy of the message at its source | varbinary(383) | NO | | | |
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------ | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| title | item title | varchar(255) | NO | | | |
| content-warning | | varchar(255) | NO | | | |
| body | item body content | mediumtext | YES | | NULL | |
| raw-body | Body without embedded media links | mediumtext | YES | | NULL | |
| location | text location where this item originated | varchar(255) | NO | | | |
| coord | longitude/latitude pair representing location where this item originated | varchar(255) | NO | | | |
| language | Language information about this post | text | YES | | NULL | |
| app | application which generated this item | varchar(255) | NO | | | |
| rendered-hash | | varchar(32) | NO | | | |
| rendered-html | item.body converted to html | mediumtext | YES | | NULL | |
| object-type | ActivityStreams object type | varchar(100) | NO | | | |
| object | JSON encoded object structure unless it is an implied object (normal post) | text | YES | | NULL | |
| target-type | ActivityStreams target type if applicable (URI) | varchar(100) | NO | | | |
| target | JSON encoded target structure if used | text | YES | | NULL | |
| resource-id | Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type | varchar(32) | NO | | | |
| plink | permalink or URL to a displayable copy of the message at its source | varchar(255) | NO | | | |
Indexes
------------
@ -36,7 +35,6 @@ Indexes
| plink | plink(191) |
| resource-id | resource-id |
| title-content-warning-body | FULLTEXT, title, content-warning, body |
| quote-uri-id | quote-uri-id |
Foreign Keys
------------
@ -44,6 +42,5 @@ Foreign Keys
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| quote-uri-id | [item-uri](help/database/db_item-uri) | id |
Return to [database documentation](help/database)

View File

@ -6,26 +6,26 @@ Post history
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------- | ---- | --- | ------------------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| edited | Date of edit | datetime | NO | PRI | 0001-01-01 00:00:00 | |
| title | item title | varchar(255) | NO | | | |
| content-warning | | varchar(255) | NO | | | |
| body | item body content | mediumtext | YES | | NULL | |
| raw-body | Body without embedded media links | mediumtext | YES | | NULL | |
| location | text location where this item originated | varchar(255) | NO | | | |
| coord | longitude/latitude pair representing location where this item originated | varchar(255) | NO | | | |
| language | Language information about this post | text | YES | | NULL | |
| app | application which generated this item | varchar(255) | NO | | | |
| rendered-hash | | varchar(32) | NO | | | |
| rendered-html | item.body converted to html | mediumtext | YES | | NULL | |
| object-type | ActivityStreams object type | varchar(100) | NO | | | |
| object | JSON encoded object structure unless it is an implied object (normal post) | text | YES | | NULL | |
| target-type | ActivityStreams target type if applicable (URI) | varchar(100) | NO | | | |
| target | JSON encoded target structure if used | text | YES | | NULL | |
| resource-id | Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type | varchar(32) | NO | | | |
| plink | permalink or URL to a displayable copy of the message at its source | varbinary(383) | NO | | | |
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------ | ---- | --- | ------------------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| edited | Date of edit | datetime | NO | PRI | 0001-01-01 00:00:00 | |
| title | item title | varchar(255) | NO | | | |
| content-warning | | varchar(255) | NO | | | |
| body | item body content | mediumtext | YES | | NULL | |
| raw-body | Body without embedded media links | mediumtext | YES | | NULL | |
| location | text location where this item originated | varchar(255) | NO | | | |
| coord | longitude/latitude pair representing location where this item originated | varchar(255) | NO | | | |
| language | Language information about this post | text | YES | | NULL | |
| app | application which generated this item | varchar(255) | NO | | | |
| rendered-hash | | varchar(32) | NO | | | |
| rendered-html | item.body converted to html | mediumtext | YES | | NULL | |
| object-type | ActivityStreams object type | varchar(100) | NO | | | |
| object | JSON encoded object structure unless it is an implied object (normal post) | text | YES | | NULL | |
| target-type | ActivityStreams target type if applicable (URI) | varchar(100) | NO | | | |
| target | JSON encoded target structure if used | text | YES | | NULL | |
| resource-id | Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type | varchar(32) | NO | | | |
| plink | permalink or URL to a displayable copy of the message at its source | varchar(255) | NO | | | |
Indexes
------------

View File

@ -6,38 +6,36 @@ Attached media
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | ------------------------------------------------------------------ | ----------------- | ---- | --- | ------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | | NULL | |
| url | Media URL | varbinary(1024) | NO | | NULL | |
| media-uri-id | Id of the item-uri table entry that contains the activities uri-id | int unsigned | YES | | NULL | |
| type | Media type | tinyint unsigned | NO | | 0 | |
| mimetype | | varchar(60) | YES | | NULL | |
| height | Height of the media | smallint unsigned | YES | | NULL | |
| width | Width of the media | smallint unsigned | YES | | NULL | |
| size | Media size | bigint unsigned | YES | | NULL | |
| preview | Preview URL | varbinary(512) | YES | | NULL | |
| preview-height | Height of the preview picture | smallint unsigned | YES | | NULL | |
| preview-width | Width of the preview picture | smallint unsigned | YES | | NULL | |
| description | | text | YES | | NULL | |
| name | Name of the media | varchar(255) | YES | | NULL | |
| author-url | URL of the author of the media | varbinary(383) | YES | | NULL | |
| author-name | Name of the author of the media | varchar(255) | YES | | NULL | |
| author-image | Image of the author of the media | varbinary(383) | YES | | NULL | |
| publisher-url | URL of the publisher of the media | varbinary(383) | YES | | NULL | |
| publisher-name | Name of the publisher of the media | varchar(255) | YES | | NULL | |
| publisher-image | Image of the publisher of the media | varbinary(383) | YES | | NULL | |
| Field | Description | Type | Null | Key | Default | Extra |
| --------------- | --------------------------------------------------------- | ----------------- | ---- | --- | ------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | | NULL | |
| url | Media URL | varbinary(1024) | NO | | NULL | |
| type | Media type | tinyint unsigned | NO | | 0 | |
| mimetype | | varchar(60) | YES | | NULL | |
| height | Height of the media | smallint unsigned | YES | | NULL | |
| width | Width of the media | smallint unsigned | YES | | NULL | |
| size | Media size | bigint unsigned | YES | | NULL | |
| preview | Preview URL | varbinary(512) | YES | | NULL | |
| preview-height | Height of the preview picture | smallint unsigned | YES | | NULL | |
| preview-width | Width of the preview picture | smallint unsigned | YES | | NULL | |
| description | | text | YES | | NULL | |
| name | Name of the media | varchar(255) | YES | | NULL | |
| author-url | URL of the author of the media | varbinary(255) | YES | | NULL | |
| author-name | Name of the author of the media | varchar(255) | YES | | NULL | |
| author-image | Image of the author of the media | varbinary(255) | YES | | NULL | |
| publisher-url | URL of the publisher of the media | varbinary(255) | YES | | NULL | |
| publisher-name | Name of the publisher of the media | varchar(255) | YES | | NULL | |
| publisher-image | Image of the publisher of the media | varbinary(255) | YES | | NULL | |
Indexes
------------
| Name | Fields |
| ------------ | ------------------------ |
| PRIMARY | id |
| uri-id-url | UNIQUE, uri-id, url(512) |
| uri-id-id | uri-id, id |
| media-uri-id | media-uri-id |
| Name | Fields |
| ---------- | ------------------------ |
| PRIMARY | id |
| uri-id-url | UNIQUE, uri-id, url(512) |
| uri-id-id | uri-id, id |
Foreign Keys
------------
@ -45,6 +43,5 @@ Foreign Keys
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| media-uri-id | [item-uri](help/database/db_item-uri) | id |
Return to [database documentation](help/database)

View File

@ -60,7 +60,6 @@ Indexes
| author-id_uid | author-id, uid |
| author-id_received | author-id, received |
| parent-uri-id_uid | parent-uri-id, uid |
| uid_wall_received | uid, wall, received |
| uid_contactid | uid, contact-id |
| uid_unseen_contactid | uid, unseen, contact-id |
| uid_unseen | uid, unseen |

View File

@ -47,8 +47,8 @@ Fields
| homepage | | varchar(255) | NO | | | |
| xmpp | XMPP address | varchar(255) | NO | | | |
| matrix | Matrix address | varchar(255) | NO | | | |
| photo | | varbinary(383) | NO | | | |
| thumb | | varbinary(383) | NO | | | |
| photo | | varchar(255) | NO | | | |
| thumb | | varchar(255) | NO | | | |
| publish | publish default profile in local directory | boolean | NO | | 0 | |
| net-publish | publish profile in global directory | boolean | NO | | 0 | |

View File

@ -10,7 +10,7 @@ Fields
| ------------ | --------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uid | User id | mediumint unsigned | NO | | 0 | |
| callback_url | | varbinary(383) | NO | | | |
| callback_url | | varchar(255) | NO | | | |
| topic | | varchar(255) | NO | | | |
| nickname | | varchar(255) | NO | | | |
| push | Retrial counter | tinyint | NO | | 0 | |

View File

@ -9,7 +9,7 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| -------- | ------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| hash | | varbinary(255) | NO | | | |
| hash | | varchar(255) | NO | | | |
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
| uid | User id | mediumint unsigned | NO | | 0 | |
| password | | varchar(255) | NO | | | |

View File

@ -10,7 +10,7 @@ Fields
| ----- | ----------------------------------------------------------------------------- | ---------------- | ---- | --- | ------- | -------------- |
| id | | int unsigned | NO | PRI | NULL | auto_increment |
| name | | varchar(96) | NO | | | |
| url | | varbinary(383) | NO | | | |
| url | | varbinary(255) | NO | | | |
| type | Type of the tag (Unknown, General Collection, Follower Collection or Account) | tinyint unsigned | YES | | NULL | |
Indexes

View File

@ -24,7 +24,7 @@ Fields
| fetch_further_information | | tinyint unsigned | YES | | NULL | |
| ffi_keyword_denylist | | text | YES | | NULL | |
| subhub | | boolean | YES | | NULL | |
| hub-verify | | varbinary(383) | YES | | NULL | |
| hub-verify | | varchar(255) | YES | | NULL | |
| protocol | Protocol of the contact | char(4) | YES | | NULL | |
| rating | Automatically detected feed poll frequency | tinyint | YES | | NULL | |
| priority | Feed poll priority | tinyint unsigned | YES | | NULL | |

View File

@ -405,10 +405,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('block', $hook_data);
Hook::callAll('unblock', $hook_data);
### src/Core/Logger/Factory.php
Hook::callAll('logger_instance', $data);
### src/Core/StorageManager
Hook::callAll('storage_instance', $data);

View File

@ -31,7 +31,7 @@ Requirements
* Das POSIX Modul muss aktiviert sein ([CentOS, RHEL](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) haben dies z.B. deaktiviert)
* Einen E-Mail Server, so dass PHP `mail()` funktioniert.
Wenn kein eigener E-Mail Server zur Verfügung steht, kann alternativ das [phpmailer](https://github.com/friendica/friendica-addons/tree/develop/phpmailer) Addon mit einem externen SMTP Account verwendet werden.
* Mysql Server mit Unterstützung vom InnoDB und Barracuda (wir empfehlen MariaDB da die Entwicklung mit solchen Server erfolgt, aber Alternativen wie MySQL, Percona Server etc. sollten auch funktionieren)
* Mysql 5.6+ (oder eine äquivalente Alternative: MariaDB, Percona Server etc.)
* die Möglichkeit, wiederkehrende Aufgaben mit cron (Linux/Mac) oder "Scheduled Tasks" einzustellen (Windows) [Beachte: andere Optionen sind in Abschnitt 7 dieser Dokumentation zu finden]
* Installation in einer Top-Level-Domain oder Subdomain (ohne eine Verzeichnis/Pfad-Komponente in der URL) wird bevorzugt. Verzeichnispfade sind für diesen Zweck nicht so günstig und wurden auch nicht ausführlich getestet.

View File

@ -123,13 +123,13 @@ The selected 1st part will be saved in the database by the theme_post function.
function theme_post(App $a){
// non local users shall not pass
if (!Session::getLocalUser()) {
if (! local_user()) {
return;
}
// if the one specific submit button was pressed then proceed
if (isset($_POST['duepuntozero-settings-submit'])){
// and save the selection key into the personal config of the user
DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
@ -137,7 +137,7 @@ Now that this information is set in the database, what should friendica do with
For this, have a look at the theme.php file of the *duepunto zero*.
There you'll find somethink alike
$colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero','colorset');
$colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset');
if ($colorset) {

View File

@ -27,6 +27,7 @@ use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -41,7 +42,7 @@ use Friendica\Util\Temporal;
function cal_init(App $a)
{
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
@ -111,14 +112,14 @@ function cal_content(App $a)
$owner_uid = intval($owner['uid']);
$nick = $owner['nickname'];
$contact_id = DI::userSession()->getRemoteContactID($owner['uid']);
$contact_id = Session::getRemoteContactID($owner['uid']);
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
$is_owner = DI::userSession()->getLocalUserId() == $owner['uid'];
$is_owner = local_user() == $owner['uid'];
if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.'));
notice(DI::l10n()->t('Access to this profile has been restricted.'));
return;
}
@ -261,7 +262,7 @@ function cal_content(App $a)
if ($mode == 'export') {
if (!$owner_uid) {
DI::sysmsg()->addNotice(DI::l10n()->t('User not found'));
notice(DI::l10n()->t('User not found'));
return;
}
@ -270,14 +271,14 @@ function cal_content(App $a)
if (!$evexport["success"]) {
if ($evexport["content"]) {
DI::sysmsg()->addNotice(DI::l10n()->t('This calendar format is not supported'));
notice(DI::l10n()->t('This calendar format is not supported'));
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('No exportable data found'));
notice(DI::l10n()->t('No exportable data found'));
}
// If it the own calendar return to the events page
// otherwise to the profile calendar page
if (DI::userSession()->getLocalUserId() === $owner_uid) {
if (local_user() === $owner_uid) {
$return_path = "events";
} else {
$return_path = "cal/" . $nick;

View File

@ -24,6 +24,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -45,14 +46,14 @@ function display_init(App $a)
(new Objects(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), $_SERVER, ['guid' => DI::args()->getArgv()[1] ?? null]))->run();
}
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
$nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
$item = null;
$item_user = DI::userSession()->getLocalUserId();
$item_user = local_user();
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
@ -61,18 +62,18 @@ function display_init(App $a)
$nick = '';
// Does the local user have this item?
if (DI::userSession()->getLocalUserId()) {
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, ['guid' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId()]);
if (local_user()) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'uid' => local_user()]);
if (DBA::isResult($item)) {
$nick = $a->getLoggedInUserNickname();
}
}
// Is this item private but could be visible to the remove visitor?
if (!DBA::isResult($item) && DI::userSession()->getRemoteUserId()) {
if (!DBA::isResult($item) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item)) {
if (!Contact::isFollower(DI::userSession()->getRemoteUserId(), $item['uid'])) {
if (!Contact::isFollower(remote_user(), $item['uid'])) {
$item = null;
} else {
$item_user = $item['uid'];
@ -82,14 +83,14 @@ function display_init(App $a)
// Is it an item with uid=0?
if (!DBA::isResult($item)) {
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, ['guid' => DI::args()->getArgv()[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
}
} elseif (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
$uri_id = DI::args()->getArgv()[2];
if (substr($uri_id, -5) == '.atom') {
$uri_id = substr($uri_id, 0, -5);
}
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, ['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
$item = Post::selectFirstForUser(local_user(), $fields, ['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
}
if (!DBA::isResult($item)) {
@ -101,11 +102,11 @@ function display_init(App $a)
}
if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
Logger::debug('Directly serving XML', ['uri-id' => $item['uri-id']]);
Logger::info('Directly serving XML for uri-id '.$item['uri-id']);
displayShowFeed($item['uri-id'], $item['uid'], false);
}
if ($item['gravity'] != Item::GRAVITY_PARENT) {
if ($item['gravity'] != GRAVITY_PARENT) {
$parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [0, $item_user], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid' => true]]);
$item = $parent ?: $item;
}
@ -122,9 +123,11 @@ function display_init(App $a)
function display_fetchauthor($item)
{
$shared = DI::contentItem()->getSharedPost($item, ['author-link']);
if (!empty($shared) && empty($shared['comment'])) {
$contact = Contact::getByURLForUser($shared['post']['author-link'], DI::userSession()->getLocalUserId());
if (Diaspora::isReshare($item['body'], true)) {
$shared = Item::getShareArray($item);
if (!empty($shared['profile'])) {
$contact = Contact::getByURLForUser($shared['profile'], local_user());
}
}
if (empty($contact)) {
@ -136,7 +139,7 @@ function display_fetchauthor($item)
function display_content(App $a, $update = false, $update_uid = 0)
{
if (DI::config()->get('system','block_public') && !DI::userSession()->isAuthenticated()) {
if (DI::config()->get('system','block_public') && !Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
@ -178,18 +181,18 @@ function display_content(App $a, $update = false, $update_uid = 0)
if (DI::args()->getArgc() == 2) {
$fields = ['uri-id', 'parent-uri-id', 'uid'];
if (DI::userSession()->getLocalUserId()) {
$condition = ['guid' => DI::args()->getArgv()[1], 'uid' => [0, DI::userSession()->getLocalUserId()]];
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, $condition, ['order' => ['uid' => true]]);
if (local_user()) {
$condition = ['guid' => DI::args()->getArgv()[1], 'uid' => [0, local_user()]];
$item = Post::selectFirstForUser(local_user(), $fields, $condition, ['order' => ['uid' => true]]);
if (DBA::isResult($item)) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
}
}
if (($parent_uri_id == 0) && DI::userSession()->getRemoteUserId()) {
if (($parent_uri_id == 0) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(DI::userSession()->getRemoteUserId(), $item['uid'])) {
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
}
@ -197,7 +200,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
if ($parent_uri_id == 0) {
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => DI::args()->getArgv()[1], 'uid' => 0];
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, $condition);
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
@ -210,9 +213,9 @@ function display_content(App $a, $update = false, $update_uid = 0)
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
}
if (!DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
DI::notification()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['parent-uri-id' => $item['parent-uri-id']]);
DI::notify()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['parent-uri-id' => $item['parent-uri-id']]);
if (!DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
DI::notification()->setAllSeenForUser(local_user(), ['parent-uri-id' => $item['parent-uri-id']]);
DI::notify()->setAllSeenForUser(local_user(), ['parent-uri-id' => $item['parent-uri-id']]);
}
// We are displaying an "alternate" link if that post was public. See issue 2864
@ -231,17 +234,17 @@ function display_content(App $a, $update = false, $update_uid = 0)
'$conversation' => $conversation]);
$is_remote_contact = false;
$item_uid = DI::userSession()->getLocalUserId();
$item_uid = local_user();
$page_uid = 0;
$parent = null;
if (!DI::userSession()->getLocalUserId() && !empty($parent_uri_id)) {
if (!local_user() && !empty($parent_uri_id)) {
$parent = Post::selectFirst(['uid'], ['uri-id' => $parent_uri_id, 'wall' => true]);
}
if (DBA::isResult($parent)) {
$page_uid = $page_uid ?? 0 ?: $parent['uid'];
$is_remote_contact = DI::userSession()->getRemoteContactID($page_uid);
$is_remote_contact = Session::getRemoteContactID($page_uid);
if ($is_remote_contact) {
$item_uid = $parent['uid'];
}
@ -249,11 +252,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
$page_uid = $item['uid'];
}
if (!empty($page_uid) && ($page_uid != DI::userSession()->getLocalUserId())) {
if (!empty($page_uid) && ($page_uid != local_user())) {
$page_user = User::getById($page_uid);
}
$is_owner = DI::userSession()->getLocalUserId() && (in_array($page_uid, [DI::userSession()->getLocalUserId(), 0]));
$is_owner = local_user() && (in_array($page_uid, [local_user(), 0]));
if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
@ -265,8 +268,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
}
$sql_extra = Item::getPermissionsSQLByUserId($page_uid);
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_uid)) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => DI::userSession()->getLocalUserId(), 'unseen' => true];
if (local_user() && (local_user() == $page_uid)) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true];
$unseen = Post::exists($condition);
} else {
$unseen = false;
@ -287,11 +290,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
$item['uri-id'] = $item['parent-uri-id'];
if ($unseen) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => DI::userSession()->getLocalUserId(), 'unseen' => true];
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true];
Item::update(['unseen' => false], $condition);
}
if (!$update && DI::userSession()->getLocalUserId()) {
if (!$update && local_user()) {
$o .= "<script> var netargs = '?uri_id=" . $item['uri-id'] . "'; </script>";
}

View File

@ -34,29 +34,29 @@ function editpost_content(App $a)
{
$o = '';
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
$post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$post_id) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found'));
notice(DI::l10n()->t('Item not found'));
return;
}
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'body', 'title', 'uri-id', 'wall', 'post-type', 'guid'];
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), $fields, ['id' => $post_id, 'uid' => DI::userSession()->getLocalUserId()]);
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found'));
notice(DI::l10n()->t('Item not found'));
return;
}
$user = User::getById(DI::userSession()->getLocalUserId());
$user = User::getById(local_user());
$geotag = '';
@ -118,8 +118,8 @@ function editpost_content(App $a)
'$jotnets' => $jotnets,
'$title' => $item['title'],
'$placeholdertitle' => DI::l10n()->t('Set title'),
'$category' => Post\Category::getCSVByURIId($item['uri-id'], DI::userSession()->getLocalUserId(), Post\Category::CATEGORY),
'$placeholdercategory' => (Feature::isEnabled(DI::userSession()->getLocalUserId(),'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : ''),
'$category' => Post\Category::getCSVByURIId($item['uri-id'], local_user(), Post\Category::CATEGORY),
'$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : ''),
'$emtitle' => DI::l10n()->t('Example: bob@example.com, mary@example.com'),
'$lockstate' => $lockstate,
'$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),

View File

@ -46,7 +46,7 @@ use Friendica\Worker\Delivery;
function events_init(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
return;
}
@ -54,7 +54,7 @@ function events_init(App $a)
DI::page()['aside'] = '';
}
$cal_widget = CalendarExport::getHTML(DI::userSession()->getLocalUserId());
$cal_widget = CalendarExport::getHTML(local_user());
DI::page()['aside'] .= $cal_widget;
@ -64,13 +64,13 @@ function events_init(App $a)
function events_post(App $a)
{
Logger::debug('post', ['request' => $_REQUEST]);
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
return;
}
$event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
$finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
@ -121,7 +121,7 @@ function events_post(App $a)
$onerror_path = 'events/' . $action . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986);
if (strcmp($finish, $start) < 0 && !$nofinish) {
DI::sysmsg()->addNotice(DI::l10n()->t('Event can not end before it has started.'));
notice(DI::l10n()->t('Event can not end before it has started.'));
if (intval($_REQUEST['preview'])) {
System::httpExit(DI::l10n()->t('Event can not end before it has started.'));
}
@ -129,7 +129,7 @@ function events_post(App $a)
}
if (!$summary || ($start === DBA::NULL_DATETIME)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Event title and start time are required.'));
notice(DI::l10n()->t('Event title and start time are required.'));
if (intval($_REQUEST['preview'])) {
System::httpExit(DI::l10n()->t('Event title and start time are required.'));
}
@ -173,23 +173,22 @@ function events_post(App $a)
$private_event = true;
}
$datarray = [
'start' => $start,
'finish' => $finish,
'summary' => $summary,
'desc' => $desc,
'location' => $location,
'type' => $type,
'nofinish' => $nofinish,
'uid' => $uid,
'cid' => $cid,
'allow_cid' => $str_contact_allow,
'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny,
'deny_gid' => $str_group_deny,
'private' => $private_event,
'id' => $event_id,
];
$datarray = [];
$datarray['start'] = $start;
$datarray['finish'] = $finish;
$datarray['summary'] = $summary;
$datarray['desc'] = $desc;
$datarray['location'] = $location;
$datarray['type'] = $type;
$datarray['nofinish'] = $nofinish;
$datarray['uid'] = $uid;
$datarray['cid'] = $cid;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private_event;
$datarray['id'] = $event_id;
if (intval($_REQUEST['preview'])) {
System::httpExit(Event::getHTML($datarray));
@ -206,7 +205,7 @@ function events_post(App $a)
}
if (!$cid && $uri_id) {
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
}
DI::baseUrl()->redirect('events');
@ -214,8 +213,8 @@ function events_post(App $a)
function events_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
@ -224,11 +223,11 @@ function events_content(App $a)
}
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) {
DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
}
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) {
DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
}
if ($a->getThemeInfoValue('events_in_profile')) {
@ -323,9 +322,9 @@ function events_content(App $a)
// get events by id or by date
if ($event_params['event_id']) {
$r = Event::getListById(DI::userSession()->getLocalUserId(), $event_params['event_id']);
$r = Event::getListById(local_user(), $event_params['event_id']);
} else {
$r = Event::getListByDate(DI::userSession()->getLocalUserId(), $event_params);
$r = Event::getListByDate(local_user(), $event_params);
}
$links = [];
@ -396,7 +395,7 @@ function events_content(App $a)
}
if (($mode === 'edit' || $mode === 'copy') && $event_id) {
$orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => DI::userSession()->getLocalUserId()]);
$orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => local_user()]);
}
// Passed parameters overrides anything found in the DB
@ -405,8 +404,8 @@ function events_content(App $a)
$share_disabled = '';
if (empty($orig_event)) {
$orig_event = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
} elseif ($orig_event['allow_cid'] !== '<' . DI::userSession()->getLocalUserId() . '>'
$orig_event = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
} elseif ($orig_event['allow_cid'] !== '<' . local_user() . '>'
|| $orig_event['allow_gid']
|| $orig_event['deny_cid']
|| $orig_event['deny_gid']) {
@ -524,15 +523,15 @@ function events_content(App $a)
// Remove an event from the calendar and its related items
if ($mode === 'drop' && $event_id) {
$ev = Event::getListById(DI::userSession()->getLocalUserId(), $event_id);
$ev = Event::getListById(local_user(), $event_id);
// Delete only real events (no birthdays)
if (DBA::isResult($ev) && $ev[0]['type'] == 'event') {
Item::deleteForUser(['id' => $ev[0]['itemid']], DI::userSession()->getLocalUserId());
Item::deleteForUser(['id' => $ev[0]['itemid']], local_user());
}
if (Post::exists(['id' => $ev[0]['itemid']])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Failed to remove event'));
notice(DI::l10n()->t('Failed to remove event'));
}
DI::baseUrl()->redirect('events');

View File

@ -38,7 +38,7 @@ use Friendica\Util\Strings;
*/
function fbrowser_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
System::exit();
}
@ -65,7 +65,7 @@ function fbrowser_content(App $a)
if (DI::args()->getArgc() == 2) {
$photos = DBA::toArray(DBA::p("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)",
DI::userSession()->getLocalUserId(),
local_user(),
Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER
));
@ -84,7 +84,7 @@ function fbrowser_content(App $a)
min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created`
FROM `photo` WHERE `uid` = ? $sql_extra AND NOT `photo-type` IN (?, ?)
GROUP BY `resource-id` $sql_extra2",
DI::userSession()->getLocalUserId(),
local_user(),
Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER
));
@ -103,8 +103,7 @@ function fbrowser_content(App $a)
return [
DI::baseUrl() . '/photos/' . $a->getLoggedInUserNickname() . '/image/' . $rr['resource-id'],
$filename_e,
DI::baseUrl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext,
$rr['desc']
DI::baseUrl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
];
}
$files = array_map("_map_files1", $r);
@ -124,7 +123,7 @@ function fbrowser_content(App $a)
break;
case "file":
if (DI::args()->getArgc()==2) {
$files = DBA::selectToArray('attach', ['id', 'filename', 'filetype'], ['uid' => DI::userSession()->getLocalUserId()]);
$files = DBA::selectToArray('attach', ['id', 'filename', 'filetype'], ['uid' => local_user()]);
function _map_files2($rr)
{

View File

@ -35,7 +35,7 @@ use Friendica\Util\Strings;
function follow_post(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
@ -52,13 +52,13 @@ function follow_content(App $a)
{
$return_path = 'contact';
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$url = Probe::cleanURI(trim($_REQUEST['url'] ?? ''));
@ -81,7 +81,7 @@ function follow_content(App $a)
if (DBA::isResult($user_contact)) {
if ($user_contact['pending']) {
DI::sysmsg()->addNotice(DI::l10n()->t('You already added this contact.'));
notice(DI::l10n()->t('You already added this contact.'));
$submit = '';
}
}
@ -97,7 +97,7 @@ function follow_content(App $a)
// Possibly it is a remote item and not an account
follow_remote_item($url);
DI::sysmsg()->addNotice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added."));
notice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added."));
$submit = '';
$contact = ['url' => $url, 'network' => Protocol::PHANTOM, 'name' => $url, 'keywords' => ''];
}
@ -105,12 +105,12 @@ function follow_content(App $a)
$protocol = Contact::getProtocol($contact['url'], $contact['network']);
if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) {
DI::sysmsg()->addNotice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added."));
notice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added."));
$submit = '';
}
if (($protocol == Protocol::OSTATUS) && DI::config()->get('system', 'ostatus_disabled')) {
DI::sysmsg()->addNotice(DI::l10n()->t("OStatus support is disabled. Contact can't be added."));
notice(DI::l10n()->t("OStatus support is disabled. Contact can't be added."));
$submit = '';
}
@ -127,7 +127,7 @@ function follow_content(App $a)
$owner = User::getOwnerDataById($uid);
if (empty($owner)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
@ -181,21 +181,21 @@ function follow_process(App $a, string $url)
follow_remote_item($url);
if ($result['message']) {
DI::sysmsg()->addNotice($result['message']);
notice($result['message']);
}
DI::baseUrl()->redirect($return_path);
} elseif ($result['cid']) {
DI::baseUrl()->redirect('contact/' . $result['cid']);
}
DI::sysmsg()->addNotice(DI::l10n()->t('The contact could not be added.'));
notice(DI::l10n()->t('The contact could not be added.'));
DI::baseUrl()->redirect($return_path);
}
function follow_remote_item($url)
{
$item_id = Item::fetchByLink($url, DI::userSession()->getLocalUserId());
$item_id = Item::fetchByLink($url, local_user());
if (!$item_id) {
// If the user-specific search failed, we search and probe a public post
$item_id = Item::fetchByLink($url);

View File

@ -34,8 +34,8 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach;
@ -57,11 +57,11 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\ParseUrl;
function item_post(App $a) {
if (!DI::userSession()->isAuthenticated()) {
if (!Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException();
}
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
if (!empty($_REQUEST['dropitems'])) {
$arr_drop = explode(',', $_REQUEST['dropitems']);
@ -89,7 +89,7 @@ function item_post(App $a) {
*/
if (!$preview && !empty($_REQUEST['post_id_random'])) {
if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
Logger::warning('duplicate post');
Logger::info('item post: duplicate post');
item_post_return(DI::baseUrl(), $api_source, $return_path);
} else {
$_SESSION['post-random'] = $_REQUEST['post_id_random'];
@ -106,7 +106,7 @@ function item_post(App $a) {
$toplevel_user_id = null;
$objecttype = null;
$profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: DI::userSession()->getLocalUserId();
$profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user();
$posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
if ($parent_item_id || $thr_parent_uri) {
@ -122,13 +122,13 @@ function item_post(App $a) {
$thr_parent_uri = $parent_item['uri'];
$toplevel_item = $parent_item;
if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
if ($parent_item['gravity'] != GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
}
}
if (!DBA::isResult($toplevel_item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
notice(DI::l10n()->t('Unable to locate original post.'));
if ($return_path) {
DI::baseUrl()->redirect($return_path);
}
@ -138,7 +138,7 @@ function item_post(App $a) {
// When commenting on a public post then store the post for the current user
// This enables interaction like starring and saving into folders
if ($toplevel_item['uid'] == 0) {
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], DI::userSession()->getLocalUserId(), ['post-reason' => Item::PR_ACTIVITY]);
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], local_user(), ['post-reason' => Item::PR_ACTIVITY]);
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
if ($stored) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]);
@ -168,17 +168,17 @@ function item_post(App $a) {
}
// Ensure that the user id in a thread always stay the same
if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [DI::userSession()->getLocalUserId(), 0])) {
if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [local_user(), 0])) {
$profile_uid = $toplevel_user_id;
}
// Allow commenting if it is an answer to a public post
$allow_comment = DI::userSession()->getLocalUserId() && $toplevel_item_id && in_array($toplevel_item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($toplevel_item['network'], Protocol::FEDERATED);
$allow_comment = local_user() && $toplevel_item_id && in_array($toplevel_item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($toplevel_item['network'], Protocol::FEDERATED);
// Now check that valid personal details have been provided
if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
Logger::notice('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
notice(DI::l10n()->t('Permission denied.'));
if ($return_path) {
DI::baseUrl()->redirect($return_path);
}
@ -307,7 +307,7 @@ function item_post(App $a) {
// for non native networks use the network of the original post as network of the item
if (($toplevel_item['network'] != Protocol::DIASPORA)
&& ($toplevel_item['network'] != Protocol::OSTATUS)
&& ($network == '')) {
&& ($network == "")) {
$network = $toplevel_item['network'];
}
@ -323,9 +323,9 @@ function item_post(App $a) {
$pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
// if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == DI::userSession()->getLocalUserId() && !$private) {
if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) {
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
$pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", DI::userSession()->getLocalUserId(), '']);
$pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']);
}
}
@ -334,7 +334,7 @@ function item_post(App $a) {
System::jsonExit(['preview' => '']);
}
DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.'));
notice(DI::l10n()->t('Empty post discarded.'));
if ($return_path) {
DI::baseUrl()->redirect($return_path);
}
@ -362,11 +362,11 @@ function item_post(App $a) {
$self = false;
$contact_id = 0;
if (DI::userSession()->getLocalUserId() && ((DI::userSession()->getLocalUserId() == $profile_uid) || $allow_comment)) {
if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) {
$self = true;
$author = DBA::selectFirst('contact', [], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
} elseif (!empty(DI::userSession()->getRemoteContactID($profile_uid))) {
$author = DBA::selectFirst('contact', [], ['id' => DI::userSession()->getRemoteContactID($profile_uid)]);
$author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
} elseif (!empty(Session::getRemoteContactID($profile_uid))) {
$author = DBA::selectFirst('contact', [], ['id' => Session::getRemoteContactID($profile_uid)]);
}
if (DBA::isResult($author)) {
@ -374,7 +374,7 @@ function item_post(App $a) {
}
// get contact info for owner
if ($profile_uid == DI::userSession()->getLocalUserId() || $allow_comment) {
if ($profile_uid == local_user() || $allow_comment) {
$contact_record = $author ?: [];
} else {
$contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: [];
@ -384,8 +384,8 @@ function item_post(App $a) {
if ($posttype != Item::PT_PERSONAL_NOTE) {
// Look for any tags and linkify them
$item = [
'uid' => DI::userSession()->getLocalUserId() ? DI::userSession()->getLocalUserId() : $profile_uid,
'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
'uid' => local_user() ? local_user() : $profile_uid,
'gravity' => $toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT,
'network' => $network,
'body' => $body,
'postopts' => $postopts,
@ -401,7 +401,7 @@ function item_post(App $a) {
$body = $item['body'];
$inform = $item['inform'];
$postopts = $item['postopts'];
$private = $item['private'];
$private = $item['private'];
$str_contact_allow = $item['allow_cid'];
$str_group_allow = $item['allow_gid'];
$str_contact_deny = $item['deny_cid'];
@ -462,7 +462,7 @@ function item_post(App $a) {
$data = BBCode::getAttachmentData($body);
$match = [];
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data['type']))
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
$objecttype = Activity\ObjectType::BOOKMARK;
@ -477,11 +477,11 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::NOTE; // Default value
$objectdata = BBCode::getAttachedData($body);
if ($objectdata['type'] == 'link') {
if ($objectdata["type"] == "link") {
$objecttype = Activity\ObjectType::BOOKMARK;
} elseif ($objectdata['type'] == 'video') {
} elseif ($objectdata["type"] == "video") {
$objecttype = Activity\ObjectType::VIDEO;
} elseif ($objectdata['type'] == 'photo') {
} elseif ($objectdata["type"] == "photo") {
$objecttype = Activity\ObjectType::IMAGE;
}
@ -509,11 +509,11 @@ function item_post(App $a) {
$verb = Activity::POST;
}
if ($network == '') {
if ($network == "") {
$network = Protocol::DFRN;
}
$gravity = ($toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
$gravity = ($toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT);
// even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability.
@ -532,67 +532,77 @@ function item_post(App $a) {
$thr_parent_uri = $uri;
}
$datarray = [
'uid' => $profile_uid,
'wall' => $wall,
'gravity' => $gravity,
'network' => $network,
'contact-id' => $contact_id,
'owner-name' => $contact_record['name'] ?? '',
'owner-link' => $contact_record['url'] ?? '',
'owner-avatar' => $contact_record['thumb'] ?? '',
'author-name' => $author['name'],
'author-link' => $author['url'],
'author-avatar' => $author['thumb'],
'created' => empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'],
'received' => DateTimeFormat::utcNow(),
'extid' => $extid,
'guid' => $guid,
'uri' => $uri,
'title' => $title,
'body' => $body,
'app' => $app,
'location' => $location,
'coord' => $coord,
'file' => $categories,
'inform' => $inform,
'verb' => $verb,
'post-type' => $posttype,
'object-type' => $objecttype,
'allow_cid' => $str_contact_allow,
'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny,
'deny_gid' => $str_group_deny,
'private' => $private,
'pubmail' => $pubmail_enabled,
'attach' => $attachments,
'thr-parent' => $thr_parent_uri,
'postopts' => $postopts,
'origin' => $origin,
'object' => $object,
'attachments' => $_REQUEST['attachments'] ?? [],
/*
* These fields are for the convenience of addons...
* 'self' if true indicates the owner is posting on their own wall
* If parent is 0 it is a top-level post.
*/
'parent' => $toplevel_item_id,
'self' => $self,
// This triggers posts via API and the mirror functions
'api_source' => $api_source,
// This field is for storing the raw conversation data
'protocol' => Conversation::PARCEL_DIRECT,
'direction' => Conversation::PUSH,
];
$datarray = [];
$datarray['uid'] = $profile_uid;
$datarray['wall'] = $wall;
$datarray['gravity'] = $gravity;
$datarray['network'] = $network;
$datarray['contact-id'] = $contact_id;
$datarray['owner-name'] = $contact_record['name'] ?? '';
$datarray['owner-link'] = $contact_record['url'] ?? '';
$datarray['owner-avatar'] = $contact_record['thumb'] ?? '';
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-name'] = $author['name'];
$datarray['author-link'] = $author['url'];
$datarray['author-avatar'] = $author['thumb'];
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['created'] = empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'];
$datarray['edited'] = $datarray['created'];
$datarray['commented'] = $datarray['created'];
$datarray['changed'] = $datarray['created'];
$datarray['received'] = DateTimeFormat::utcNow();
$datarray['extid'] = $extid;
$datarray['guid'] = $guid;
$datarray['uri'] = $uri;
$datarray['title'] = $title;
$datarray['body'] = $body;
$datarray['app'] = $app;
$datarray['location'] = $location;
$datarray['coord'] = $coord;
$datarray['file'] = $categories;
$datarray['inform'] = $inform;
$datarray['verb'] = $verb;
$datarray['post-type'] = $posttype;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enabled;
$datarray['attach'] = $attachments;
// These cannot be part of above initialization ...
$datarray['edited'] = $datarray['created'];
$datarray['commented'] = $datarray['created'];
$datarray['changed'] = $datarray['created'];
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['thr-parent'] = $thr_parent_uri;
$datarray['edit'] = $orig_post;
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['object'] = $object;
$datarray['attachments'] = $_REQUEST['attachments'] ?? [];
/*
* These fields are for the convenience of addons...
* 'self' if true indicates the owner is posting on their own wall
* If parent is 0 it is a top-level post.
*/
$datarray['parent'] = $toplevel_item_id;
$datarray['self'] = $self;
// This triggers posts via API and the mirror functions
$datarray['api_source'] = $api_source;
// This field is for storing the raw conversation data
$datarray['protocol'] = Conversation::PARCEL_DIRECT;
$datarray['direction'] = Conversation::PUSH;
if ($orig_post) {
$datarray['edit'] = true;
} else {
// If this was a share, add missing data here
$datarray = Item::addShareDataFromOriginal($datarray);
$datarray['edit'] = false;
}
// Check for hashtags in the body and repair or add hashtag links
if ($preview || $orig_post) {
@ -603,16 +613,14 @@ function item_post(App $a) {
if ($preview) {
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
$datarray['id'] = -1;
$datarray['uri-id'] = -1;
$datarray['author-network'] = Protocol::DFRN;
$datarray['author-updated'] = '';
$datarray['author-gsid'] = 0;
$datarray['author-uri-id'] = ItemURI::getIdByURI($datarray['author-link']);
$datarray['owner-updated'] = '';
$datarray['has-media'] = false;
$datarray['quote-uri-id'] = Item::getQuoteUriId($datarray['body'], $datarray['uid']);
$datarray['body'] = BBCode::removeSharedData($datarray['body']);
$datarray["id"] = -1;
$datarray["uri-id"] = -1;
$datarray["author-network"] = Protocol::DFRN;
$datarray["author-updated"] = '';
$datarray["author-gsid"] = 0;
$datarray["author-uri-id"] = ItemURI::getIdByURI($datarray["author-link"]);
$datarray["owner-updated"] = '';
$datarray["has-media"] = false;
$o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
@ -633,7 +641,7 @@ function item_post(App $a) {
unset($datarray['self']);
unset($datarray['api_source']);
Post\Delayed::add($datarray['uri'], $datarray, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
Post\Delayed::add($datarray['uri'], $datarray, PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
item_post_return(DI::baseUrl(), $api_source, $return_path);
}
}
@ -654,19 +662,13 @@ function item_post(App $a) {
$datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
$quote_uri_id = Item::getQuoteUriId($datarray['body'], $datarray['uid']);
if (!empty($quote_uri_id)) {
$datarray['quote-uri-id'] = $quote_uri_id;
$datarray['body'] = BBCode::removeSharedData($datarray['body']);
}
if ($orig_post) {
if ($orig_post) {
$fields = [
'title' => $datarray['title'],
'body' => $datarray['body'],
'attach' => $datarray['attach'],
'file' => $datarray['file'],
'edited' => DateTimeFormat::utcNow(),
'title' => $datarray['title'],
'body' => $datarray['body'],
'attach' => $datarray['attach'],
'file' => $datarray['file'],
'edited' => DateTimeFormat::utcNow(),
'changed' => DateTimeFormat::utcNow()
];
@ -687,7 +689,7 @@ function item_post(App $a) {
$post_id = Item::insert($datarray);
if (!$post_id) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
notice(DI::l10n()->t('Item wasn\'t stored.'));
if ($return_path) {
DI::baseUrl()->redirect($return_path);
}
@ -708,7 +710,7 @@ function item_post(App $a) {
Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == Item::GRAVITY_COMMENT)) {
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == GRAVITY_COMMENT)) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
}
@ -739,7 +741,7 @@ function item_post(App $a) {
Hook::callAll('post_local_end', $datarray);
if (strlen($emailcc) && $profile_uid == DI::userSession()->getLocalUserId()) {
if (strlen($emailcc) && $profile_uid == local_user()) {
$recipients = explode(',', $emailcc);
if (count($recipients)) {
foreach ($recipients as $recipient) {
@ -753,7 +755,7 @@ function item_post(App $a) {
}
}
Logger::debug('post_complete');
Logger::info('post_complete');
if ($api_source) {
return $post_id;
@ -778,14 +780,14 @@ function item_post_return($baseurl, $api_source, $return_path)
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
}
Logger::debug('post_json', ['json' => $json]);
Logger::info('post_json', ['json' => $json]);
System::jsonExit($json);
}
function item_content(App $a)
{
if (!DI::userSession()->isAuthenticated()) {
if (!Session::isAuthenticated()) {
throw new HTTPException\UnauthorizedException();
}
@ -799,9 +801,9 @@ function item_content(App $a)
switch ($args->get(1)) {
case 'drop':
if (DI::mode()->isAjax()) {
Item::deleteForUser(['id' => $args->get(2)], DI::userSession()->getLocalUserId());
Item::deleteForUser(['id' => $args->get(2)], local_user());
// ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
System::jsonExit([intval($args->get(2)), local_user()]);
} else {
if (!empty($args->get(3))) {
$o = drop_item($args->get(2), $args->get(3));
@ -810,18 +812,17 @@ function item_content(App $a)
}
}
break;
case 'block':
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
$item = Post::selectFirstForUser(local_user(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
if (empty($item['author-id'])) {
throw new HTTPException\NotFoundException('Item not found');
}
Contact\User::setBlocked($item['author-id'], DI::userSession()->getLocalUserId(), true);
Contact\User::setBlocked($item['author-id'], local_user(), true);
if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
System::jsonExit([intval($args->get(2)), local_user()]);
} else {
item_redirect_after_action($item, $args->get(3));
}
@ -837,15 +838,15 @@ function item_content(App $a)
* @return string
* @throws HTTPException\InternalServerErrorException
*/
function drop_item(int $id, string $return = ''): string
function drop_item(int $id, string $return = '')
{
// Locate item to be deleted
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
// locate item to be deleted
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'];
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
notice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network');
//NOTREACHED
}
if ($item['deleted']) {
@ -855,19 +856,18 @@ function drop_item(int $id, string $return = ''): string
$contact_id = 0;
// check if logged in user is either the author or owner of this item
if (DI::userSession()->getRemoteContactID($item['uid']) == $item['contact-id']) {
if (Session::getRemoteContactID($item['uid']) == $item['contact-id']) {
$contact_id = $item['contact-id'];
}
if ((DI::userSession()->getLocalUserId() == $item['uid']) || $contact_id) {
if ((local_user() == $item['uid']) || $contact_id) {
// delete the item
Item::deleteForUser(['id' => $item['id']], DI::userSession()->getLocalUserId());
Item::deleteForUser(['id' => $item['id']], local_user());
item_redirect_after_action($item, $return);
//NOTREACHED
} else {
Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'uid' => $item['uid'], 'cid' => $contact_id]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
Logger::notice('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('display/' . $item['guid']);
//NOTREACHED
}
@ -875,17 +875,17 @@ function drop_item(int $id, string $return = ''): string
return '';
}
function item_redirect_after_action(array $item, string $returnUrlHex)
function item_redirect_after_action($item, $returnUrlHex)
{
$return_url = hex2bin($returnUrlHex);
// removes update_* from return_url to ignore Ajax refresh
$return_url = str_replace('update_', '', $return_url);
$return_url = str_replace("update_", "", $return_url);
// Check if delete a comment
if ($item['gravity'] == Item::GRAVITY_COMMENT) {
if ($item['gravity'] == GRAVITY_COMMENT) {
if (!empty($item['parent'])) {
$parentitem = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid'], ['id' => $item['parent']]);
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
}
// Return to parent guid

View File

@ -37,7 +37,7 @@ function lostpass_post(App $a)
$condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition);
if (!DBA::isResult($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No valid account found.'));
notice(DI::l10n()->t('No valid account found.'));
DI::baseUrl()->redirect();
}
@ -49,7 +49,7 @@ function lostpass_post(App $a)
];
$result = DBA::update('user', $fields, ['uid' => $user['uid']]);
if ($result) {
DI::sysmsg()->addInfo(DI::l10n()->t('Password reset request issued. Check your email.'));
info(DI::l10n()->t('Password reset request issued. Check your email.'));
}
$sitename = DI::config()->get('config', 'sitename');
@ -97,7 +97,7 @@ function lostpass_content(App $a)
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'pwdreset_time', 'language'], ['pwdreset' => hash('sha256', $pwdreset_token)]);
if (!DBA::isResult($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."));
notice(DI::l10n()->t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."));
return lostpass_form();
}
@ -110,7 +110,7 @@ function lostpass_content(App $a)
];
DBA::update('user', $fields, ['uid' => $user['uid']]);
DI::sysmsg()->addNotice(DI::l10n()->t('Request has expired, please make a new one.'));
notice(DI::l10n()->t('Request has expired, please make a new one.'));
return lostpass_form();
}
@ -152,7 +152,7 @@ function lostpass_generate_password($user)
'$newpass' => $new_password,
]);
DI::sysmsg()->addInfo(DI::l10n()->t("Your password has been reset."));
info(DI::l10n()->t("Your password has been reset."));
$sitename = DI::config()->get('config', 'sitename');
$preamble = Strings::deindent(DI::l10n()->t('

View File

@ -44,7 +44,7 @@ use Friendica\Module\Contact as ModuleContact;
*/
function match_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
return '';
}
@ -53,13 +53,13 @@ function match_content(App $a)
$_SESSION['return_path'] = DI::args()->getCommand();
$profile = Profile::getByUID(DI::userSession()->getLocalUserId());
$profile = Profile::getByUID(local_user());
if (!DBA::isResult($profile)) {
return '';
}
if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.'));
notice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.'));
return '';
}
@ -67,10 +67,10 @@ function match_content(App $a)
$tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']);
if (DI::mode()->isMobile()) {
$limit = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$limit = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -90,7 +90,7 @@ function match_content(App $a)
}
if (empty($entries)) {
DI::sysmsg()->addInfo(DI::l10n()->t('No matches'));
info(DI::l10n()->t('No matches'));
}
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
@ -114,12 +114,12 @@ function match_get_contacts($msearch, $entries, $limit)
}
// Already known contact
$contact = Contact::getByURL($profile->url, null, ['rel'], DI::userSession()->getLocalUserId());
$contact = Contact::getByURL($profile->url, null, ['rel'], local_user());
if (!empty($contact) && in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
continue;
}
$contact = Contact::getByURLForUser($profile->url, DI::userSession()->getLocalUserId());
$contact = Contact::getByURLForUser($profile->url, local_user());
if (!empty($contact)) {
$entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact);
}

View File

@ -39,34 +39,34 @@ function message_init(App $a)
$tabs = '';
if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) {
$tabs = render_messages(get_messages(DI::userSession()->getLocalUserId(), 0, 5), 'mail_list.tpl');
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl');
}
$new = [
'label' => DI::l10n()->t('New Message'),
'url' => 'message/new',
'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
'label' => DI::l10n()->t('New Message'),
'url' => 'message/new',
'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
'accesskey' => 'm',
];
$tpl = Renderer::getMarkupTemplate('message_side.tpl');
DI::page()['aside'] = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
'$new' => $new,
'$new' => $new,
]);
$base = DI::baseUrl();
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$baseurl' => DI::baseUrl()->get(true),
'$base' => $base
'$base' => $base
]);
}
function message_post(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -80,20 +80,17 @@ function message_post(App $a)
switch ($ret) {
case -1:
DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.'));
notice(DI::l10n()->t('No recipient selected.'));
$norecip = true;
break;
case -2:
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.'));
notice(DI::l10n()->t('Unable to locate contact information.'));
break;
case -3:
DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.'));
notice(DI::l10n()->t('Message could not be sent.'));
break;
case -4:
DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.'));
notice(DI::l10n()->t('Message collection failure.'));
break;
}
@ -110,8 +107,8 @@ function message_content(App $a)
$o = '';
Nav::setSelected('messages');
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
@ -121,20 +118,20 @@ function message_content(App $a)
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
$button = [
'label' => DI::l10n()->t('Discard'),
'url' => '/message',
'sel' => 'close',
'url' => '/message',
'sel' => 'close',
];
} else {
$button = [
'label' => DI::l10n()->t('New Message'),
'url' => '/message/new',
'sel' => 'new',
'label' => DI::l10n()->t('New Message'),
'url' => '/message/new',
'sel' => 'new',
'accesskey' => 'm',
];
}
$header = Renderer::replaceMacros($tpl, [
'$messages' => DI::l10n()->t('Messages'),
'$button' => $button,
'$button' => $button,
]);
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) {
@ -144,29 +141,29 @@ function message_content(App $a)
$cmd = DI::args()->getArgv()[1];
if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
$message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){
DI::sysmsg()->addNotice(DI::l10n()->t('Conversation not found.'));
notice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message');
}
if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Message was not deleted.'));
if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) {
notice(DI::l10n()->t('Message was not deleted.'));
}
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => DI::userSession()->getLocalUserId()]);
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
if(!DBA::isResult($conversation)){
DI::baseUrl()->redirect('message');
}
DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else {
$parentmail = DBA::selectFirst('mail', ['parent-uri'], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
$parentmail = DBA::selectFirst('mail', ['parent-uri'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
if (DBA::isResult($parentmail)) {
$parent = $parentmail['parent-uri'];
if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => DI::userSession()->getLocalUserId()])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Conversation was not removed.'));
if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
notice(DI::l10n()->t('Conversation was not removed.'));
}
}
DI::baseUrl()->redirect('message');
@ -189,19 +186,19 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('prv_message.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$header' => DI::l10n()->t('Send Private Message'),
'$to' => DI::l10n()->t('To:'),
'$subject' => DI::l10n()->t('Subject:'),
'$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage' => DI::l10n()->t('Your message:'),
'$select' => $select,
'$parent' => '',
'$upload' => DI::l10n()->t('Upload photo'),
'$insert' => DI::l10n()->t('Insert web link'),
'$wait' => DI::l10n()->t('Please wait'),
'$submit' => DI::l10n()->t('Submit')
'$header' => DI::l10n()->t('Send Private Message'),
'$to' => DI::l10n()->t('To:'),
'$subject' => DI::l10n()->t('Subject:'),
'$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> DI::l10n()->t('Your message:'),
'$select' => $select,
'$parent' => '',
'$upload' => DI::l10n()->t('Upload photo'),
'$insert' => DI::l10n()->t('Insert web link'),
'$wait' => DI::l10n()->t('Please wait'),
'$submit' => DI::l10n()->t('Submit')
]);
return $o;
}
@ -215,14 +212,14 @@ function message_content(App $a)
$o .= $header;
$total = DBA::count('mail', ['uid' => DI::userSession()->getLocalUserId()], ['distinct' => true, 'expression' => 'parent-uri']);
$total = DBA::count('mail', ['uid' => local_user()], ['distinct' => true, 'expression' => 'parent-uri']);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$r = get_messages(DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage());
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
if (!DBA::isResult($r)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No messages.'));
notice(DI::l10n()->t('No messages.'));
return $o;
}
@ -243,14 +240,14 @@ function message_content(App $a)
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
LIMIT 1",
DI::userSession()->getLocalUserId(),
local_user(),
DI::args()->getArgv()[1]
);
if (DBA::isResult($message)) {
$contact_id = $message['contact-id'];
$params = [
DI::userSession()->getLocalUserId(),
local_user(),
$message['parent-uri']
];
@ -272,13 +269,13 @@ function message_content(App $a)
$messages = DBA::toArray($messages_stmt);
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => DI::userSession()->getLocalUserId()]);
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]);
} else {
$messages = false;
}
if (!DBA::isResult($messages)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Message not available.'));
notice(DI::l10n()->t('Message not available.'));
return $o;
}
@ -315,18 +312,18 @@ function message_content(App $a)
$from_photo = Contact::getThumb($contact);
$mails[] = [
'id' => $message['id'],
'from_name' => $from_name_e,
'from_url' => $from_url,
'from_addr' => $contact['addr'] ?? $from_url,
'sparkle' => $sparkle,
'id' => $message['id'],
'from_name' => $from_name_e,
'from_url' => $from_url,
'from_addr' => $contact['addr'] ?? $from_url,
'sparkle' => $sparkle,
'from_photo' => $from_photo,
'subject' => $subject_e,
'body' => $body_e,
'delete' => DI::l10n()->t('Delete message'),
'to_name' => $to_name_e,
'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
'ago' => Temporal::getRelativeDate($message['created']),
'subject' => $subject_e,
'body' => $body_e,
'delete' => DI::l10n()->t('Delete message'),
'to_name' => $to_name_e,
'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
'ago' => Temporal::getRelativeDate($message['created']),
];
$seen = $message['seen'];
@ -337,27 +334,28 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('mail_display.tpl');
$o = Renderer::replaceMacros($tpl, [
'$thread_id' => DI::args()->getArgv()[1],
'$thread_id' => DI::args()->getArgv()[1],
'$thread_subject' => $message['title'],
'$thread_seen' => $seen,
'$delete' => DI::l10n()->t('Delete conversation'),
'$canreply' => (($unknown) ? false : '1'),
'$unknown_text' => DI::l10n()->t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
'$mails' => $mails,
'$thread_seen' => $seen,
'$delete' => DI::l10n()->t('Delete conversation'),
'$canreply' => (($unknown) ? false : '1'),
'$unknown_text' => DI::l10n()->t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
'$mails' => $mails,
// reply
'$header' => DI::l10n()->t('Send Reply'),
'$to' => DI::l10n()->t('To:'),
'$subject' => DI::l10n()->t('Subject:'),
'$subjtxt' => $message['title'],
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
'$yourmessage' => DI::l10n()->t('Your message:'),
'$text' => '',
'$select' => $select,
'$parent' => $parent,
'$upload' => DI::l10n()->t('Upload photo'),
'$insert' => DI::l10n()->t('Insert web link'),
'$submit' => DI::l10n()->t('Submit'),
'$wait' => DI::l10n()->t('Please wait')
'$header' => DI::l10n()->t('Send Reply'),
'$to' => DI::l10n()->t('To:'),
'$subject' => DI::l10n()->t('Subject:'),
'$subjtxt' => $message['title'],
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
'$yourmessage' => DI::l10n()->t('Your message:'),
'$text' => '',
'$select' => $select,
'$parent' => $parent,
'$upload' => DI::l10n()->t('Upload photo'),
'$insert' => DI::l10n()->t('Insert web link'),
'$submit' => DI::l10n()->t('Submit'),
'$wait' => DI::l10n()->t('Please wait')
]);
return $o;
@ -370,7 +368,7 @@ function message_content(App $a)
* @param int $limit
* @return array
*/
function get_messages(int $uid, int $start, int $limit): array
function get_messages(int $uid, int $start, int $limit)
{
return DBA::toArray(DBA::p('SELECT
m.`id`,
@ -394,21 +392,21 @@ function get_messages(int $uid, int $start, int $limit): array
c.`url`,
c.`thumb`,
c.`network`,
m2.`count`,
m2.`mailcreated`,
m2.`mailseen`
FROM `mail` m
JOIN (
SELECT
`parent-uri`,
MIN(`id`) AS `id`,
COUNT(*) AS `count`,
MAX(`created`) AS `mailcreated`,
MIN(`seen`) AS `mailseen`
FROM `mail`
WHERE `uid` = ?
GROUP BY `parent-uri`
) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
m2.`count`,
m2.`mailcreated`,
m2.`mailseen`
FROM `mail` m
JOIN (
SELECT
`parent-uri`,
MIN(`id`) AS `id`,
COUNT(*) AS `count`,
MAX(`created`) AS `mailcreated`,
MIN(`seen`) AS `mailseen`
FROM `mail`
WHERE `uid` = ?
GROUP BY `parent-uri`
) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
LEFT JOIN `contact` c ON m.`contact-id` = c.`id`
WHERE m.`uid` = ?
ORDER BY m2.`mailcreated` DESC
@ -416,7 +414,7 @@ function get_messages(int $uid, int $start, int $limit): array
, $uid, $uid, $start, $limit));
}
function render_messages(array $msg, string $t): string
function render_messages(array $msg, $t)
{
$a = DI::app();
@ -446,20 +444,20 @@ function render_messages(array $msg, string $t): string
$from_photo = Contact::getThumb($contact);
$rslt .= Renderer::replaceMacros($tpl, [
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
'$from_addr' => $contact['addr'] ?? '',
'$sparkle' => ' sparkle',
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
'$from_addr' => $contact['addr'] ?? '',
'$sparkle' => ' sparkle',
'$from_photo' => $from_photo,
'$subject' => $rr['title'],
'$delete' => DI::l10n()->t('Delete conversation'),
'$body' => $body_e,
'$to_name' => $to_name_e,
'$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
'$ago' => Temporal::getRelativeDate($rr['mailcreated']),
'$seen' => $rr['mailseen'],
'$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
'$subject' => $rr['title'],
'$delete' => DI::l10n()->t('Delete conversation'),
'$body' => $body_e,
'$to_name' => $to_name_e,
'$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
'$ago' => Temporal::getRelativeDate($rr['mailcreated']),
'$seen' => $rr['mailseen'],
'$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
]);
}

View File

@ -30,7 +30,7 @@ use Friendica\Module\BaseProfile;
function notes_init(App $a)
{
if (! DI::userSession()->getLocalUserId()) {
if (! local_user()) {
return;
}
@ -38,10 +38,10 @@ function notes_init(App $a)
}
function notes_content(App $a, bool $update = false)
function notes_content(App $a, $update = false)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -52,7 +52,7 @@ function notes_content(App $a, bool $update = false)
$x = [
'lockstate' => 'lock',
'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(DI::userSession()->getLocalUserId(), DI::l10n()->t('Personal notes are visible only by yourself.')),
'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(local_user(), DI::l10n()->t('Personal notes are visible only by yourself.')),
'button' => DI::l10n()->t('Save'),
'acl_data' => '',
];
@ -60,14 +60,14 @@ function notes_content(App $a, bool $update = false)
$o .= DI::conversation()->statusEditor($x, $a->getContactId());
}
$condition = ['uid' => DI::userSession()->getLocalUserId(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'contact-id'=> $a->getContactId()];
if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -75,7 +75,7 @@ function notes_content(App $a, bool $update = false)
$params = ['order' => ['created' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$r = Post::selectThreadForUser(DI::userSession()->getLocalUserId(), ['uri-id'], $condition, $params);
$r = Post::selectThreadForUser(local_user(), ['uri-id'], $condition, $params);
$count = 0;

View File

@ -20,84 +20,25 @@
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
use Friendica\Util\XML;
function oexchange_init(App $a)
{
if ((DI::args()->getArgc() <= 1) || (DI::args()->getArgv()[1] != 'xrd')) {
return;
function oexchange_init(App $a) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'xrd')) {
$tpl = Renderer::getMarkupTemplate('oexchange_xrd.tpl');
$o = Renderer::replaceMacros($tpl, ['$base' => DI::baseUrl()]);
System::httpExit($o, Response::TYPE_XML, 'application/xrd+xml');
}
$baseURL = DI::baseUrl()->get();
$xml = null;
XML::fromArray([
'XRD' => [
'@attributes' => [
'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
],
'Subject' => $baseURL,
'1:Property' => [
'@attributes' => [
'type' => 'http://www.oexchange.org/spec/0.8/prop/vendor',
],
'Friendica'
],
'2:Property' => [
'@attributes' => [
'type' => 'http://www.oexchange.org/spec/0.8/prop/title',
],
'Friendica Social Network'
],
'3:Property' => [
'@attributes' => [
'type' => 'http://www.oexchange.org/spec/0.8/prop/name',
],
'Friendica'
],
'4:Property' => [
'@attributes' => [
'type' => 'http://www.oexchange.org/spec/0.8/prop/prompt',
],
'Send to Friendica'
],
'1:link' => [
'@attributes' => [
'rel' => 'icon',
'type' => 'image/png',
'href' => $baseURL . '/images/friendica-16.png'
]
],
'2:link' => [
'@attributes' => [
'rel' => 'icon32',
'type' => 'image/png',
'href' => $baseURL . '/images/friendica-32.png'
]
],
'3:link' => [
'@attributes' => [
'rel' => 'http://www.oexchange.org/spec/0.8/rel/offer',
'type' => 'text/html',
'href' => $baseURL . '/oexchange'
]
],
],
], $xml);
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
function oexchange_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
function oexchange_content(App $a) {
if (!local_user()) {
$o = Login::form();
return $o;
}
@ -111,7 +52,7 @@ function oexchange_content(App $a)
$description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : '';
$tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : '';
$s = BBCode::embedURL($url, true, $title, $description, $tags);
$s = \Friendica\Content\Text\BBCode::embedURL($url, true, $title, $description, $tags);
if (!strlen($s)) {
return;
@ -119,11 +60,11 @@ function oexchange_content(App $a)
$post = [];
$post['profile_uid'] = DI::userSession()->getLocalUserId();
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done';
$post['body'] = HTML::toBBCode($s);
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
$_REQUEST = $post;
require_once 'mod/item.php';
require_once('mod/item.php');
item_post($a);
}

View File

@ -27,21 +27,22 @@ use Friendica\Model\Contact;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\ActivityPub;
function ostatus_subscribe_content(App $a): string
function ostatus_subscribe_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_subscribe');
// NOTREACHED
}
$o = '<h2>' . DI::l10n()->t('Subscribing to contacts') . '</h2>';
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$counter = intval($_REQUEST['counter'] ?? 0);
if (DI::pConfig()->get($uid, 'ostatus', 'legacy_friends') == '') {
if ($_REQUEST['url'] == '') {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('No contact provided.');

View File

@ -30,6 +30,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -54,9 +55,9 @@ use Friendica\Util\Temporal;
use Friendica\Util\XML;
use Friendica\Network\HTTPException;
function photos_init(App $a)
{
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
function photos_init(App $a) {
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
@ -68,11 +69,11 @@ function photos_init(App $a)
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner['uid']));
$is_owner = (local_user() && (local_user() == $owner['uid']));
$albums = Photo::getAlbums($owner['uid']);
$albums_visible = ((intval($owner['hidewall']) && !DI::userSession()->isAuthenticated()) ? false : true);
$albums_visible = ((intval($owner['hidewall']) && !Session::isAuthenticated()) ? false : true);
// add various encodings to the array so we can just loop through and pick them out in a template
$ret = ['success' => false];
@ -95,7 +96,7 @@ function photos_init(App $a)
}
}
if (DI::userSession()->getLocalUserId() && $owner['uid'] == DI::userSession()->getLocalUserId()) {
if (local_user() && $owner['uid'] == local_user()) {
$can_post = true;
} else {
$can_post = false;
@ -147,23 +148,23 @@ function photos_post(App $a)
$page_owner_uid = intval($user['uid']);
$community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid);
$can_post = true;
$visitor = $contact_id;
}
if (!$can_post) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
System::exit();
}
$owner_record = User::getOwnerDataById($page_owner_uid);
if (!$owner_record) {
DI::sysmsg()->addNotice(DI::l10n()->t('Contact information unavailable'));
notice(DI::l10n()->t('Contact information unavailable'));
DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
System::exit();
}
@ -192,7 +193,7 @@ function photos_post(App $a)
$album = hex2bin(DI::args()->getArgv()[3]);
if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid, 'photo-type' => Photo::DEFAULT])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Album not found.'));
notice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
return; // NOTREACHED
}
@ -228,7 +229,7 @@ function photos_post(App $a)
));
} else {
$r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
DI::userSession()->getLocalUserId(),
local_user(),
$album
));
}
@ -246,9 +247,9 @@ function photos_post(App $a)
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
DI::sysmsg()->addNotice(DI::l10n()->t('Album successfully deleted'));
notice(DI::l10n()->t('Album successfully deleted'));
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Album was empty.'));
notice(DI::l10n()->t('Album was empty.'));
}
}
@ -267,7 +268,7 @@ function photos_post(App $a)
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
} else {
$condition = ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => DI::args()->getArgv()[3]];
$condition = ['uid' => local_user(), 'resource-id' => DI::args()->getArgv()[3]];
}
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
@ -280,7 +281,7 @@ function photos_post(App $a)
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Failed to delete the photo.'));
notice(DI::l10n()->t('Failed to delete the photo.'));
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
}
@ -303,7 +304,7 @@ function photos_post(App $a)
}
if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) {
Logger::debug('rotate');
Logger::notice('rotate');
$photo = Photo::getPhotoForUser($page_owner_uid, $resource_id);
@ -525,40 +526,44 @@ function photos_post(App $a)
foreach ($taginfo as $tagged) {
$uri = Item::newURI();
$arr = [
'guid' => System::createUUID(),
'uid' => $page_owner_uid,
'uri' => $uri,
'wall' => 1,
'contact-id' => $owner_record['id'],
'owner-name' => $owner_record['name'],
'owner-link' => $owner_record['url'],
'owner-avatar' => $owner_record['thumb'],
'author-name' => $owner_record['name'],
'author-link' => $owner_record['url'],
'author-avatar' => $owner_record['thumb'],
'title' => '',
'allow_cid' => $photo['allow_cid'],
'allow_gid' => $photo['allow_gid'],
'deny_cid' => $photo['deny_cid'],
'deny_gid' => $photo['deny_gid'],
'visible' => 0,
'verb' => Activity::TAG,
'gravity' => Item::GRAVITY_PARENT,
'object-type' => Activity\ObjectType::PERSON,
'target-type' => Activity\ObjectType::IMAGE,
'inform' => $tagged[2],
'origin' => 1,
'body' => DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') . "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n",
'object' => '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n"),
'target' => '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id><link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>',
];
$arr = [];
$arr['guid'] = System::createUUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['wall'] = 1;
$arr['contact-id'] = $owner_record['id'];
$arr['owner-name'] = $owner_record['name'];
$arr['owner-link'] = $owner_record['url'];
$arr['owner-avatar'] = $owner_record['thumb'];
$arr['author-name'] = $owner_record['name'];
$arr['author-link'] = $owner_record['url'];
$arr['author-avatar'] = $owner_record['thumb'];
$arr['title'] = '';
$arr['allow_cid'] = $photo['allow_cid'];
$arr['allow_gid'] = $photo['allow_gid'];
$arr['deny_cid'] = $photo['deny_cid'];
$arr['deny_gid'] = $photo['deny_gid'];
$arr['visible'] = 0;
$arr['verb'] = Activity::TAG;
$arr['gravity'] = GRAVITY_PARENT;
$arr['object-type'] = Activity\ObjectType::PERSON;
$arr['target-type'] = Activity\ObjectType::IMAGE;
$arr['inform'] = $tagged[2];
$arr['origin'] = 1;
$arr['body'] = DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
$arr['body'] .= "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
$arr['object'] = '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
if ($tagged[3]) {
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
}
$arr['object'] .= '</link></object>' . "\n";
$arr['target'] = '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
. DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
Item::insert($arr);
}
}
@ -575,7 +580,7 @@ function photos_post(App $a)
$album = trim($_REQUEST['album'] ?? '');
$newalbum = trim($_REQUEST['newalbum'] ?? '');
Logger::debug('album= ' . $album . ' newalbum= ' . $newalbum);
Logger::info('album= ' . $album . ' newalbum= ' . $newalbum);
if (!strlen($album)) {
if (strlen($newalbum)) {
@ -628,21 +633,21 @@ function photos_post(App $a)
if ($error !== UPLOAD_ERR_OK) {
switch ($error) {
case UPLOAD_ERR_INI_SIZE:
DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
break;
case UPLOAD_ERR_FORM_SIZE:
DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
break;
case UPLOAD_ERR_PARTIAL:
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
notice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
break;
case UPLOAD_ERR_NO_FILE:
DI::sysmsg()->addNotice(DI::l10n()->t('Image file is missing'));
notice(DI::l10n()->t('Image file is missing'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
case UPLOAD_ERR_EXTENSION:
DI::sysmsg()->addNotice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
break;
}
@unlink($src);
@ -658,7 +663,7 @@ function photos_post(App $a)
$maximagesize = DI::config()->get('system', 'maximagesize');
if ($maximagesize && ($filesize > $maximagesize)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
@ -666,22 +671,22 @@ function photos_post(App $a)
}
if (!$filesize) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image file is empty.'));
notice(DI::l10n()->t('Image file is empty.'));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
return;
}
Logger::debug('loading contents', ['src' => $src]);
Logger::info('loading the contents of ' . $src);
$imagedata = @file_get_contents($src);
$image = new Image($imagedata, $type);
if (!$image->isValid()) {
Logger::notice('unable to process image');
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image.'));
Logger::info('unable to process image');
notice(DI::l10n()->t('Unable to process image.'));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end',$foo);
@ -706,8 +711,8 @@ function photos_post(App $a)
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0 , Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if (!$r) {
Logger::warning('image store failed');
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
Logger::info('image store failed');
notice(DI::l10n()->t('Image upload failed.'));
return;
}
@ -793,13 +798,13 @@ function photos_content(App $a)
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.'));
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.'));
return;
}
if (empty($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No photos selected'));
notice(DI::l10n()->t('No photos selected'));
return;
}
@ -839,10 +844,10 @@ function photos_content(App $a)
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)) {
if (local_user() && (local_user() == $owner_uid)) {
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
} elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) {
$contact_id = Session::getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
if (DBA::isResult($contact)) {
@ -853,22 +858,22 @@ function photos_content(App $a)
}
// perhaps they're visiting - but not a community page, so they wouldn't have write access
if (!empty(DI::userSession()->getRemoteContactID($owner_uid)) && !$visitor) {
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) {
$contact_id = Session::getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
$remote_contact = DBA::isResult($contact);
}
if (!$remote_contact && DI::userSession()->getLocalUserId()) {
if (!$remote_contact && local_user()) {
$contact_id = $_SESSION['cid'];
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
}
if ($user['hidewall'] && (DI::userSession()->getLocalUserId() != $owner_uid) && !$remote_contact) {
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.'));
if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
notice(DI::l10n()->t('Access to this item is restricted.'));
return;
}
@ -877,13 +882,13 @@ function photos_content(App $a)
$o = "";
// tabs
$is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid));
$is_owner = (local_user() && (local_user() == $owner_uid));
$o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']);
// Display upload form
if ($datatype === 'upload') {
if (!$can_post) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -1083,9 +1088,9 @@ function photos_content(App $a)
if (!DBA::isResult($ph)) {
if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
DI::sysmsg()->addNotice(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 {
DI::sysmsg()->addNotice(DI::l10n()->t('Photo not available'));
notice(DI::l10n()->t('Photo not available'));
}
return;
}
@ -1196,7 +1201,7 @@ function photos_content(App $a)
}
if (
$ph[0]['uid'] == DI::userSession()->getLocalUserId()
$ph[0]['uid'] == local_user()
&& (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
) {
$tools['lock'] = DI::l10n()->t('Private Photo');
@ -1228,7 +1233,7 @@ function photos_content(App $a)
$link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]);
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], GRAVITY_COMMENT];
$total = Post::count($condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
@ -1236,7 +1241,7 @@ function photos_content(App $a)
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
if (local_user() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
}
}
@ -1314,7 +1319,7 @@ function photos_content(App $a)
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
@ -1345,7 +1350,7 @@ function photos_content(App $a)
'attendmaybe' => []
];
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']);
}
@ -1370,7 +1375,7 @@ function photos_content(App $a)
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
@ -1399,7 +1404,7 @@ function photos_content(App $a)
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
($item['gravity'] != Item::GRAVITY_PARENT)) {
($item['gravity'] != GRAVITY_PARENT)) {
continue;
}
@ -1412,29 +1417,29 @@ function photos_content(App $a)
$sparkle = '';
}
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()));
$drop = [
'dropping' => $dropping,
'pagedrop' => false,
'select' => DI::l10n()->t('Select'),
'delete' => DI::l10n()->t('Delete'),
'select' => DI::l10n()->t('Select'),
'delete' => DI::l10n()->t('Delete'),
];
$title_e = $item['title'];
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
$comments .= Renderer::replaceMacros($template,[
'$id' => $item['id'],
'$id' => $item['id'],
'$profile_url' => $profile_url,
'$name' => $item['author-name'],
'$thumb' => $item['author-avatar'],
'$sparkle' => $sparkle,
'$title' => $title_e,
'$body' => $body_e,
'$ago' => Temporal::getRelativeDate($item['created']),
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
'$drop' => $drop,
'$comment' => $comment
'$name' => $item['author-name'],
'$thumb' => $item['author-avatar'],
'$sparkle' => $sparkle,
'$title' => $title_e,
'$body' => $body_e,
'$ago' => Temporal::getRelativeDate($item['created']),
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
'$drop' => $drop,
'$comment' => $comment
]);
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
@ -1444,7 +1449,7 @@ function photos_content(App $a)
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
@ -1483,7 +1488,7 @@ function photos_content(App $a)
'$dislike' => DI::l10n()->t('Dislike'),
'$wait' => DI::l10n()->t('Please wait'),
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
'$hide_dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike'),
'$responses' => $responses,
'$return_path' => DI::args()->getQueryString(),
]);

View File

@ -24,10 +24,13 @@ use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML;
function poco_init(App $a) {
if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
@ -226,9 +229,12 @@ function poco_init(App $a) {
Logger::info("End of poco");
if ($format === 'xml') {
System::httpExit(Renderer::replaceMacros(Renderer::getMarkupTemplate('poco_xml.tpl'), XML::arrayEscape(['$response' => $ret])), Response::TYPE_XML);
}
if ($format === 'json') {
System::jsonExit($ret);
} else {
throw new \Friendica\Network\HTTPException\UnsupportedMediaTypeException();
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
}

View File

@ -145,7 +145,7 @@ function pubsub_post(App $a)
}
// We only import feeds from OStatus here
if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS])) {
if ($contact['network'] != Protocol::OSTATUS) {
Logger::warning('Unexpected network', ['contact' => $contact]);
hub_post_return();
}

View File

@ -21,6 +21,7 @@
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -31,7 +32,7 @@ use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Util\Strings;
function redir_init(App $a) {
if (!DI::userSession()->isAuthenticated()) {
if (!Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
@ -51,7 +52,7 @@ function redir_init(App $a) {
}
$fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, DI::userSession()->getLocalUserId()]]);
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
if (!DBA::isResult($contact)) {
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
}
@ -64,10 +65,10 @@ function redir_init(App $a) {
$a->redirect($url ?: $contact_url);
}
if ($contact['uid'] == 0 && DI::userSession()->getLocalUserId()) {
if ($contact['uid'] == 0 && local_user()) {
// Let's have a look if there is an established connection
// between the public contact we have found and the local user.
$contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => DI::userSession()->getLocalUserId()]);
$contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
@ -82,7 +83,7 @@ function redir_init(App $a) {
}
}
if (DI::userSession()->getRemoteUserId()) {
if (remote_user()) {
$host = substr(DI::baseUrl()->getUrlPath() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''), strpos(DI::baseUrl()->getUrlPath(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
@ -90,7 +91,7 @@ function redir_init(App $a) {
// with the local contact. Otherwise the local user would ask the local contact
// for authentification everytime he/she is visiting a profile page of the local
// contact.
if (($host == $remotehost) && (DI::userSession()->getRemoteContactID(DI::session()->get('visitor_visiting')) == DI::session()->get('visitor_id'))) {
if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
// Remote user is already authenticated.
redir_check_url($contact_url, $url);
$target_url = $url ?: $contact_url;

View File

@ -28,11 +28,11 @@ use Friendica\Util\Strings;
function removeme_post(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
return;
}
if (DI::userSession()->getSubManagedUserId()) {
if (!empty($_SESSION['submanage'])) {
return;
}
@ -64,7 +64,7 @@ function removeme_post(App $a)
->withMessage(
$l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('User deleted their account'),
$l10n->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
$l10n->t('The user id is %d', DI::userSession()->getLocalUserId()))
$l10n->t('The user id is %d', local_user()))
->forUser($admin)
->withRecipient($admin['email'])
->build();
@ -83,7 +83,7 @@ function removeme_post(App $a)
function removeme_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
DI::baseUrl()->redirect();
}

View File

@ -27,15 +27,15 @@ use Friendica\Model\Contact;
function repair_ostatus_content(App $a) {
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_repair');
// NOTREACHED
}
$o = '<h2>' . DI::l10n()->t('Resubscribing to OStatus contacts') . '</h2>';
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$counter = intval($_REQUEST['counter'] ?? 0);
@ -43,7 +43,7 @@ function repair_ostatus_content(App $a) {
$total = DBA::count('contact', $condition);
if (!$total) {
return ($o . DI::l10n()->tt('Error', 'Errors', 1));
return ($o . DI::l10n()->t('Error'));
}
$contact = Contact::selectToArray(['url'], $condition, ['order' => ['url'], 'limit' => [$counter++, 1]]);

View File

@ -36,8 +36,8 @@ use Friendica\Protocol\Email;
function settings_init(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -47,11 +47,11 @@ function settings_init(App $a)
function settings_post(App $a)
{
if (!$a->isLoggedIn()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
return;
}
if (DI::userSession()->getSubManagedUserId()) {
if (!empty($_SESSION['submanage'])) {
return;
}
@ -69,12 +69,13 @@ function settings_post(App $a)
BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors');
if (!empty($_POST['general-submit'])) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', !intval($_POST['enable_cw']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'simple_shortening', intval($_POST['simple_shortening']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'attach_link_title', intval($_POST['attach_link_title']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
DI::pConfig()->set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer']));
DI::pConfig()->set(local_user(), 'system', 'disable_cw', !intval($_POST['enable_cw']));
DI::pConfig()->set(local_user(), 'system', 'enable_cw_self', intval($_POST['enable_cw_self']));
DI::pConfig()->set(local_user(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening']));
DI::pConfig()->set(local_user(), 'system', 'simple_shortening', intval($_POST['simple_shortening']));
DI::pConfig()->set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title']));
DI::pConfig()->set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif (!empty($_POST['mail-submit'])) {
$mail_server = $_POST['mail_server'] ?? '';
$mail_port = $_POST['mail_port'] ?? '';
@ -87,13 +88,13 @@ function settings_post(App $a)
$mail_pubmail = $_POST['mail_pubmail'] ?? '';
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
if (!DBA::exists('mailacct', ['uid' => DI::userSession()->getLocalUserId()])) {
DBA::insert('mailacct', ['uid' => DI::userSession()->getLocalUserId()]);
if (!DBA::exists('mailacct', ['uid' => local_user()])) {
DBA::insert('mailacct', ['uid' => local_user()]);
}
if (strlen($mail_pass)) {
$pass = '';
openssl_public_encrypt($mail_pass, $pass, $user['pubkey']);
DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => DI::userSession()->getLocalUserId()]);
DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
}
$r = DBA::update('mailacct', [
@ -106,10 +107,10 @@ function settings_post(App $a)
'mailbox' => 'INBOX',
'reply_to' => $mail_replyto,
'pubmail' => $mail_pubmail
], ['uid' => DI::userSession()->getLocalUserId()]);
], ['uid' => local_user()]);
Logger::debug('updating mailaccount', ['response' => $r]);
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]);
Logger::notice('updating mailaccount', ['response' => $r]);
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
if (DBA::isResult($mailacct)) {
$mb = Email::constructMailboxName($mailacct);
@ -119,7 +120,7 @@ function settings_post(App $a)
$mbox = Email::connect($mb, $mail_user, $dcrpass);
unset($dcrpass);
if (!$mbox) {
DI::sysmsg()->addNotice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
notice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
}
}
}
@ -135,7 +136,7 @@ function settings_post(App $a)
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
}
}
return;
@ -147,13 +148,13 @@ function settings_content(App $a)
$o = '';
Nav::setSelected('settings');
if (!DI::userSession()->getLocalUserId()) {
//DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
//notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
if (DI::userSession()->getSubManagedUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!empty($_SESSION['submanage'])) {
notice(DI::l10n()->t('Permission denied.'));
return '';
}
@ -161,12 +162,12 @@ function settings_content(App $a)
if ((DI::args()->getArgc() > 3) && (DI::args()->getArgv()[2] === 'delete')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => DI::userSession()->getLocalUserId()]);
DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]);
DI::baseUrl()->redirect('settings/oauth/', true);
return '';
}
$applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => DI::userSession()->getLocalUserId()]);
$applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => local_user()]);
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
$o .= Renderer::replaceMacros($tpl, [
@ -225,7 +226,7 @@ function settings_content(App $a)
$arr[$fname] = [];
$arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(DI::userSession()->getLocalUserId(), $f[0]), $f[2]];
$arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(local_user(), $f[0]), $f[2]];
}
}
@ -240,12 +241,13 @@ function settings_content(App $a)
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) {
$accept_only_sharer = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accept_only_sharer'));
$enable_cw = !intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw'));
$enable_smart_shortening = !intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_intelligent_shortening'));
$simple_shortening = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'simple_shortening'));
$attach_link_title = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'attach_link_title'));
$legacy_contact = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ostatus', 'legacy_contact');
$accept_only_sharer = intval(DI::pConfig()->get(local_user(), 'system', 'accept_only_sharer'));
$enable_cw = !intval(DI::pConfig()->get(local_user(), 'system', 'disable_cw'));
$enable_cw_self = intval(DI::pConfig()->get(local_user(), 'system', 'enable_cw_self'));
$enable_smart_shortening = !intval(DI::pConfig()->get(local_user(), 'system', 'no_intelligent_shortening'));
$simple_shortening = intval(DI::pConfig()->get(local_user(), 'system', 'simple_shortening'));
$attach_link_title = intval(DI::pConfig()->get(local_user(), 'system', 'attach_link_title'));
$legacy_contact = DI::pConfig()->get(local_user(), 'ostatus', 'legacy_contact');
if (!empty($legacy_contact)) {
/// @todo Isn't it supposed to be a $a->internalRedirect() call?
@ -279,7 +281,7 @@ function settings_content(App $a)
$mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1);
if (!$mail_disabled) {
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]);
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
} else {
$mailacct = null;
}
@ -326,6 +328,7 @@ function settings_content(App $a)
]
],
'$enable_cw' => ['enable_cw', DI::l10n()->t('Enable Content Warning'), $enable_cw, DI::l10n()->t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This enables the automatic collapsing instead of setting the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')],
'$enable_cw_self' => ['enable_cw_self', DI::l10n()->t('Show content warnings on own posts'), $enable_cw_self, DI::l10n()->t('Normally Friendica only displays content warnings on posts created by other users. If this option is enabled it will also display content warnings on your own posts.')],
'$enable_smart_shortening' => ['enable_smart_shortening', DI::l10n()->t('Enable intelligent shortening'), $enable_smart_shortening, DI::l10n()->t('Normally the system tries to find the best link to add to shortened posts. If disabled, every shortened post will always point to the original friendica post.')],
'$simple_shortening' => ['simple_shortening', DI::l10n()->t('Enable simple text shortening'), $simple_shortening, DI::l10n()->t('Normally the system shortens posts at the next line feed. If this option is enabled then the system will shorten the text at the maximum character limit.')],
'$attach_link_title' => ['attach_link_title', DI::l10n()->t('Attach the link title'), $attach_link_title, DI::l10n()->t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')],

View File

@ -30,22 +30,32 @@ use Friendica\Model\Post;
function share_init(App $a) {
$post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$post_id || !DI::userSession()->getLocalUserId()) {
if (!$post_id || !local_user()) {
System::exit();
}
$fields = ['private', 'body', 'uri'];
$fields = ['private', 'body', 'author-name', 'author-link', 'author-avatar',
'guid', 'created', 'plink', 'title'];
$item = Post::selectFirst($fields, ['id' => $post_id]);
if (!DBA::isResult($item) || $item['private'] == Item::PRIVATE) {
System::exit();
}
$shared = DI::contentItem()->getSharedPost($item, ['uri']);
if (!empty($shared) && empty($shared['comment'])) {
$content = '[share]' . $shared['post']['uri'] . '[/share]';
if (strpos($item['body'], "[/share]") !== false) {
$pos = strpos($item['body'], "[share");
$o = substr($item['body'], $pos);
} else {
$content = '[share]' . $item['uri'] . '[/share]';
$o = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
if ($item['title']) {
$o .= '[h3]'.$item['title'].'[/h3]'."\n";
}
$o .= $item['body'];
$o .= "[/share]";
}
System::httpExit($content);
echo $o;
System::exit();
}

View File

@ -30,7 +30,7 @@ use Friendica\Network\HTTPException;
function suggest_content(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
@ -39,7 +39,7 @@ function suggest_content(App $a)
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
$contacts = Contact\Relation::getSuggestions(DI::userSession()->getLocalUserId());
$contacts = Contact\Relation::getSuggestions(local_user());
if (!DBA::isResult($contacts)) {
return DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.');
}

View File

@ -22,6 +22,7 @@
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -34,9 +35,9 @@ use Friendica\Protocol\Activity;
use Friendica\Util\XML;
use Friendica\Worker\Delivery;
function tagger_content(App $a)
{
if (!DI::userSession()->isAuthenticated()) {
function tagger_content(App $a) {
if (!Session::isAuthenticated()) {
return;
}
@ -50,7 +51,7 @@ function tagger_content(App $a)
$item_id = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : 0);
Logger::info('tagger: tag', ['term' => $term, 'item' => $item_id]);
Logger::notice('tagger: tag ' . $term . ' item ' . $item_id);
$item = Post::selectFirst([], ['id' => $item_id]);
@ -62,13 +63,13 @@ function tagger_content(App $a)
$owner_uid = $item['uid'];
if (DI::userSession()->getLocalUserId() != $owner_uid) {
if (local_user() != $owner_uid) {
return;
}
$contact = Contact::selectFirst([], ['self' => true, 'uid' => DI::userSession()->getLocalUserId()]);
$contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]);
if (!DBA::isResult($contact)) {
Logger::warning('Self contact not found.', ['uid' => DI::userSession()->getLocalUserId()]);
Logger::notice('tagger: no contact_id');
return;
}
@ -115,41 +116,41 @@ EOT;
$termlink = html_entity_decode('&#x2317;') . '[url=' . DI::baseUrl() . '/search?tag=' . $term . ']'. $term . '[/url]';
$arr = [];
$arr['guid'] = System::createUUID();
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr['wall'] = $item['wall'];
$arr['gravity'] = GRAVITY_COMMENT;
$arr['parent'] = $item['id'];
$arr['thr-parent'] = $item['uri'];
$arr['owner-name'] = $item['author-name'];
$arr['owner-link'] = $item['author-link'];
$arr['owner-avatar'] = $item['author-avatar'];
$arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink );
$arr = [
'guid' => System::createUUID(),
'uri' => $uri,
'uid' => $owner_uid,
'contact-id' => $contact['id'],
'wall' => $item['wall'],
'gravity' => Item::GRAVITY_COMMENT,
'parent' => $item['id'],
'thr-parent' => $item['uri'],
'owner-name' => $item['author-name'],
'owner-link' => $item['author-link'],
'owner-avatar' => $item['author-avatar'],
'author-name' => $contact['name'],
'author-link' => $contact['url'],
'author-avatar' => $contact['thumb'],
'body' => sprintf($bodyverb, $ulink, $alink, $plink, $termlink),
'verb' => Activity::TAG,
'target-type' => $targettype,
'target' => $target,
'object-type' => $objtype,
'object' => $obj,
'private' => $item['private'],
'allow_cid' => $item['allow_cid'],
'allow_gid' => $item['allow_gid'],
'deny_cid' => $item['deny_cid'],
'deny_gid' => $item['deny_gid'],
'visible' => 1,
'unseen' => 1,
'origin' => 1,
];
$arr['verb'] = Activity::TAG;
$arr['target-type'] = $targettype;
$arr['target'] = $target;
$arr['object-type'] = $objtype;
$arr['object'] = $obj;
$arr['private'] = $item['private'];
$arr['allow_cid'] = $item['allow_cid'];
$arr['allow_gid'] = $item['allow_gid'];
$arr['deny_cid'] = $item['deny_cid'];
$arr['deny_gid'] = $item['deny_gid'];
$arr['visible'] = 1;
$arr['unseen'] = 1;
$arr['origin'] = 1;
$post_id = Item::insert($arr);
@ -165,6 +166,6 @@ EOT;
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
System::exit();
}

View File

@ -28,7 +28,7 @@ use Friendica\Model\Tag;
function tagrm_post(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
@ -61,7 +61,7 @@ function update_tags($item_id, $tags)
return;
}
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => DI::userSession()->getLocalUserId()]);
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
return;
}
@ -81,7 +81,7 @@ function tagrm_content(App $a)
$photo_return = $_SESSION['photo_return'] ?? '';
if (!DI::userSession()->getLocalUserId()) {
if (!local_user()) {
DI::baseUrl()->redirect($photo_return);
// NOTREACHED
}
@ -97,7 +97,7 @@ function tagrm_content(App $a)
// NOTREACHED
}
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => DI::userSession()->getLocalUserId()]);
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
DI::baseUrl()->redirect($photo_return);
}

View File

@ -30,7 +30,7 @@ use Friendica\DI;
function uimport_post(App $a)
{
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
return;
}
@ -43,7 +43,7 @@ function uimport_post(App $a)
function uimport_content(App $a)
{
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
DI::sysmsg()->addNotice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.'));
notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.'));
return;
}
@ -52,7 +52,7 @@ function uimport_content(App $a)
$total = DBA::count('user', ["`register_date` > UTC_TIMESTAMP - INTERVAL 1 DAY"]);
if ($total >= $max_dailies) {
Logger::notice('max daily registrations exceeded.');
DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
return;
}
}

View File

@ -31,8 +31,8 @@ use Friendica\Util\Strings;
function unfollow_post(App $a)
{
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login');
// NOTREACHED
}
@ -46,29 +46,29 @@ function unfollow_content(App $a)
{
$base_return_path = 'contact';
if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login');
// NOTREACHED
}
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$url = trim($_REQUEST['url']);
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
DI::userSession()->getLocalUserId(), Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
local_user(), Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
Strings::normaliseLink($url), $url];
$contact = DBA::selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition);
if (!DBA::isResult($contact)) {
DI::sysmsg()->addNotice(DI::l10n()->t("You aren't following this contact."));
notice(DI::l10n()->t("You aren't following this contact."));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
if (!Protocol::supportsFollow($contact['network'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Unfollowing is currently not supported by your network.'));
notice(DI::l10n()->t('Unfollowing is currently not supported by your network.'));
DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']);
// NOTREACHED
}
@ -79,7 +79,7 @@ function unfollow_content(App $a)
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
@ -118,7 +118,7 @@ function unfollow_process(string $url)
{
$base_return_path = 'contact';
$uid = DI::userSession()->getLocalUserId();
$uid = local_user();
$owner = User::getOwnerDataById($uid);
if (!$owner) {
@ -131,7 +131,7 @@ function unfollow_process(string $url)
$contact = DBA::selectFirst('contact', [], $condition);
if (!DBA::isResult($contact)) {
DI::sysmsg()->addNotice(DI::l10n()->t("You aren't following this contact."));
notice(DI::l10n()->t("You aren't following this contact."));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
@ -146,6 +146,6 @@ function unfollow_process(string $url)
$notice_message = DI::l10n()->t('Unable to unfollow this contact, please contact your administrator');
}
DI::sysmsg()->addNotice($notice_message);
notice($notice_message);
DI::baseUrl()->redirect($return_path);
}

View File

@ -30,7 +30,7 @@ use Friendica\Model\Contact;
function update_contact_content(App $a)
{
if (!empty(DI::args()->get(1)) && (!empty($_GET['force']) || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update'))) {
if (!empty(DI::args()->get(1)) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) {
$contact = Contact::getById(DI::args()->get(1), ['id', 'deleted']);
if (DBA::isResult($contact) && empty($contact['deleted'])) {
DI::page()['aside'] = '';

View File

@ -24,11 +24,11 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\DI;
require_once 'mod/notes.php';
require_once("mod/notes.php");
function update_notes_content(App $a)
{
$profile_uid = intval($_GET['p']);
function update_notes_content(App $a) {
$profile_uid = intval($_GET["p"]);
/**
*

View File

@ -20,7 +20,7 @@
*/
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -28,109 +28,104 @@ use Friendica\Model\Attach;
use Friendica\Model\User;
use Friendica\Util\Strings;
function wall_attach_post(App $a)
{
$isJson = (!empty($_GET['response']) && $_GET['response'] == 'json');
function wall_attach_post(App $a) {
$r_json = (!empty($_GET['response']) && $_GET['response']=='json');
if (DI::args()->getArgc() > 1) {
$nick = DI::args()->getArgv()[1];
$nick = DI::args()->getArgv()[1];
$owner = User::getOwnerDataByNick($nick);
if (!DBA::isResult($owner)) {
Logger::warning('owner is not a valid record:', ['owner' => $owner, 'nick' => $nick]);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
} else {
Logger::warning('Argument count is zero or one (invalid)');
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
$can_post = false;
$can_post = false;
$page_owner_uid = $owner['uid'];
$page_owner_cid = $owner['id'];
$community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid);
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
}
if (!$can_post) {
Logger::warning('User does not have required permissions', ['contact_id' => $contact_id, 'page_owner_uid' => $page_owner_uid]);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
}
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
notice(DI::l10n()->t('Permission denied.') . EOL );
System::exit();
}
if (empty($_FILES['userfile'])) {
Logger::warning('No file uploaded (empty userfile)');
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
System::exit();
}
$tempFileName = $_FILES['userfile']['tmp_name'];
$fileName = basename($_FILES['userfile']['name']);
$fileSize = intval($_FILES['userfile']['size']);
$maxFileSize = DI::config()->get('system', 'maxfilesize');
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
/*
* Found html code written in text field of form, when trying to upload a
* file with filesize greater than upload_max_filesize. Cause is unknown.
$maxfilesize = DI::config()->get('system','maxfilesize');
/* Found html code written in text field of form,
* when trying to upload a file with filesize
* greater than upload_max_filesize. Cause is unknown.
* Then Filesize gets <= 0.
*/
if ($fileSize <= 0) {
$msg = DI::l10n()->t('Sorry, maybe your upload is bigger than the PHP configuration allows') . '<br />' . DI::l10n()->t('Or - did you try to upload an empty file?');
Logger::warning($msg, ['fileSize' => $fileSize]);
@unlink($tempFileName);
if ($isJson) {
if ($filesize <= 0) {
$msg = DI::l10n()->t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(DI::l10n()->t('Or - did you try to upload an empty file?'));
@unlink($src);
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
DI::sysmsg()->addNotice($msg);
notice($msg);
}
System::exit();
}
if ($maxFileSize && $fileSize > $maxFileSize) {
$msg = DI::l10n()->t('File exceeds size limit of %s', Strings::formatBytes($maxFileSize));
Logger::warning($msg, ['fileSize' => $fileSize]);
@unlink($tempFileName);
if ($isJson) {
if ($maxfilesize && $filesize > $maxfilesize) {
$msg = DI::l10n()->t('File exceeds size limit of %s', Strings::formatBytes($maxfilesize));
@unlink($src);
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . '<br />';
echo $msg . EOL;
}
System::exit();
}
$newid = Attach::storeFile($tempFileName, $page_owner_uid, $fileName, '<' . $page_owner_cid . '>');
$newid = Attach::storeFile($src, $page_owner_uid, $filename, '<' . $page_owner_cid . '>');
@unlink($tempFileName);
@unlink($src);
if ($newid === false) {
$msg = DI::l10n()->t('File upload failed.');
Logger::warning($msg);
if ($isJson) {
$msg = DI::l10n()->t('File upload failed.');
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . '<br />';
echo $msg . EOL;
}
System::exit();
}
if ($isJson) {
if ($r_json) {
System::jsonExit(['ok' => true, 'id' => $newid]);
}

View File

@ -27,6 +27,7 @@
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -39,18 +40,17 @@ use Friendica\Util\Strings;
function wall_upload_post(App $a, $desktopmode = true)
{
Logger::info('wall upload: starting new upload');
Logger::info("wall upload: starting new upload");
$isJson = (!empty($_GET['response']) && $_GET['response'] == 'json');
$album = trim($_GET['album'] ?? '');
$r_json = (!empty($_GET['response']) && $_GET['response'] == 'json');
$album = trim($_GET['album'] ?? '');
if (DI::args()->getArgc() > 1) {
if (empty($_FILES['media'])) {
$nick = DI::args()->getArgv()[1];
$nick = DI::args()->getArgv()[1];
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) {
Logger::warning('wall upload: user instance is not valid', ['user' => $user, 'nickname' => $nick]);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
@ -59,8 +59,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['uid' => BaseApi::getCurrentUserID(), 'blocked' => false]);
}
} else {
Logger:warning('Argument count is zero or one (invalid)');
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
@ -69,50 +68,47 @@ function wall_upload_post(App $a, $desktopmode = true)
/*
* Setup permissions structures
*/
$can_post = false;
$visitor = 0;
$can_post = false;
$visitor = 0;
$page_owner_uid = $user['uid'];
$default_cid = $user['id'];
$page_owner_nick = $user['nickname'];
$community_page = ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY);
$page_owner_uid = $user['uid'];
$default_cid = $user['id'];
$page_owner_nick = $user['nickname'];
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if ((DI::userSession()->getLocalUserId()) && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
if ((local_user()) && (local_user() == $page_owner_uid)) {
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
$visitor = $contact_id;
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid);
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
$visitor = $contact_id;
}
if (!$can_post) {
Logger::warning('No permission to upload files', ['contact_id' => $contact_id, 'page_owner_uid' => $page_owner_uid]);
$msg = DI::l10n()->t('Permission denied.');
if ($isJson) {
System::jsonExit(['error' => $msg]);
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
}
DI::sysmsg()->addNotice($msg);
notice(DI::l10n()->t('Permission denied.'));
System::exit();
}
if (empty($_FILES['userfile']) && empty($_FILES['media'])) {
Logger::warning('Empty "userfile" and "media" field');
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
System::exit();
}
$src = '';
$src = '';
$filename = '';
$filesize = 0;
$filetype = '';
if (!empty($_FILES['userfile'])) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
} elseif (!empty($_FILES['media'])) {
if (!empty($_FILES['media']['tmp_name'])) {
if (is_array($_FILES['media']['tmp_name'])) {
@ -147,36 +143,29 @@ function wall_upload_post(App $a, $desktopmode = true)
}
}
if ($src == '') {
Logger::warning('File source (temporary file) cannot be determined');
$msg = DI::l10n()->t('Invalid request.');
if ($isJson) {
System::jsonExit(['error' => $msg]);
if ($src == "") {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
DI::sysmsg()->addNotice($msg);
notice(DI::l10n()->t('Invalid request.'));
System::exit();
}
$filetype = Images::getMimeTypeBySource($src, $filename, $filetype);
Logger::info('File upload:', [
'src' => $src,
'filename' => $filename,
'filesize' => $filesize,
'filetype' => $filetype,
]);
Logger::info("File upload src: " . $src . " - filename: " . $filename .
" - size: " . $filesize . " - type: " . $filetype);
$imagedata = @file_get_contents($src);
$image = new Image($imagedata, $filetype);
$image = new Image($imagedata, $filetype);
if (!$image->isValid()) {
$msg = DI::l10n()->t('Unable to process image.');
Logger::warning($msg, ['imagedata[]' => gettype($imagedata), 'filetype' => $filetype]);
@unlink($src);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . '<br />';
echo $msg. EOL;
}
System::exit();
}
@ -188,10 +177,10 @@ function wall_upload_post(App $a, $desktopmode = true)
if ($max_length > 0) {
$image->scaleDown($max_length);
$filesize = strlen($image->asString());
Logger::info('File upload: Scaling picture to new size', ['max_length' => $max_length]);
Logger::info("File upload: Scaling picture to new size " . $max_length);
}
$width = $image->getWidth();
$width = $image->getWidth();
$height = $image->getHeight();
$maximagesize = DI::config()->get('system', 'maximagesize');
@ -203,18 +192,18 @@ function wall_upload_post(App $a, $desktopmode = true)
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
$image->scaleDown($pixels);
$filesize = strlen($image->asString());
$width = $image->getWidth();
$height = $image->getHeight();
$width = $image->getWidth();
$height = $image->getHeight();
}
}
if ($filesize > $maximagesize) {
Logger::notice('Image size is too big', ['size' => $filesize, 'max' => $maximagesize]);
$msg = DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize));
@unlink($src);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . '<br />';
echo $msg. EOL;
}
System::exit();
}
@ -235,11 +224,10 @@ function wall_upload_post(App $a, $desktopmode = true)
if (!$r) {
$msg = DI::l10n()->t('Image upload failed.');
Logger::warning('Photo::store() failed', ['r' => $r]);
if ($isJson) {
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . '<br />';
echo $msg. EOL;
}
System::exit();
}
@ -263,34 +251,32 @@ function wall_upload_post(App $a, $desktopmode = true)
if (!$desktopmode) {
$photo = Photo::selectFirst(['id', 'datasize', 'width', 'height', 'type'], ['resource-id' => $resource_id], ['order' => ['width']]);
if (!$photo) {
Logger::warning('Cannot find photo in database', ['resource-id' => $resource_id]);
if ($isJson) {
System::jsonExit(['error' => 'Cannot find photo']);
if ($r_json) {
System::jsonExit(['error' => '']);
}
return false;
}
$picture = [];
$picture = [
'id' => $photo['id'],
'size' => $photo['datasize'],
'width' => $photo['width'],
'height' => $photo['height'],
'type' => $photo['type'],
'albumpage' => DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id,
'picture' => DI::baseUrl() . "/photo/{$resource_id}-0." . $image->getExt(),
'preview' => DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt(),
];
$picture["id"] = $photo["id"];
$picture["size"] = $photo["datasize"];
$picture["width"] = $photo["width"];
$picture["height"] = $photo["height"];
$picture["type"] = $photo["type"];
$picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
$picture["picture"] = DI::baseUrl() . "/photo/{$resource_id}-0." . $image->getExt();
$picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt();
if ($isJson) {
if ($r_json) {
System::jsonExit(['picture' => $picture]);
}
Logger::info('upload done');
Logger::info("upload done");
return $picture;
}
Logger::info('upload done');
Logger::info("upload done");
if ($isJson) {
if ($r_json) {
System::jsonExit(['ok' => true]);
}

146
mod/wallmessage.php Normal file
View File

@ -0,0 +1,146 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @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\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Mail;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
function wallmessage_post(App $a) {
$replyto = Profile::getMyURL();
if (!$replyto) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
$subject = trim($_REQUEST['subject'] ?? '');
$body = Strings::escapeHtml(trim($_REQUEST['body'] ?? ''));
$recipient = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
if ((! $recipient) || (! $body)) {
return;
}
$user = User::getByNickname($recipient);
if (empty($r)) {
Logger::notice('wallmessage: no recipient');
return;
}
if (!$user['unkmail']) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
$total = DBA::count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
if ($total > $user['cntunkmail']) {
notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
return;
}
$ret = Mail::sendWall($user, $body, $subject, $replyto);
switch ($ret) {
case -1:
notice(DI::l10n()->t('No recipient selected.'));
break;
case -2:
notice(DI::l10n()->t('Unable to check your home location.'));
break;
case -3:
notice(DI::l10n()->t('Message could not be sent.'));
break;
case -4:
notice(DI::l10n()->t('Message collection failure.'));
break;
}
DI::baseUrl()->redirect('profile/'.$user['nickname']);
}
function wallmessage_content(App $a) {
if (!Profile::getMyURL()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
$recipient = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
if (!$recipient) {
notice(DI::l10n()->t('No recipient.'));
return;
}
$user = User::getByNickname($recipient);
if (empty($user)) {
notice(DI::l10n()->t('No recipient.'));
Logger::notice('wallmessage: no recipient');
return;
}
if (!$user['unkmail']) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
$total = DBA::count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
if ($total > $user['cntunkmail']) {
notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
return;
}
$tpl = Renderer::getMarkupTemplate('wallmsg-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => DI::baseUrl()->get(true),
'$nickname' => $user['nickname'],
'$linkurl' => DI::l10n()->t('Please enter a link URL:')
]);
$tpl = Renderer::getMarkupTemplate('wallmessage.tpl');
$o = Renderer::replaceMacros($tpl, [
'$header' => DI::l10n()->t('Send Private Message'),
'$subheader' => DI::l10n()->t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.', $user['username']),
'$to' => DI::l10n()->t('To:'),
'$subject' => DI::l10n()->t('Subject:'),
'$recipname' => $user['username'],
'$nickname' => $user['nickname'],
'$subjtxt' => $_REQUEST['subject'] ?? '',
'$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> DI::l10n()->t('Your message:'),
'$parent' => '',
'$upload' => DI::l10n()->t('Upload photo'),
'$insert' => DI::l10n()->t('Insert web link'),
'$wait' => DI::l10n()->t('Please wait')
]);
return $o;
}

View File

@ -29,7 +29,7 @@ return [
// ****************************************************************
'config' => [
'hostname' => '192.168.56.10',
'hostname' => 'friendica.local',
'admin_email' => 'admin@friendica.local',
'sitename' => 'Friendica Social Network',
'register_policy' => \Friendica\Module\Register::OPEN,

View File

@ -19,6 +19,7 @@ static/
vendor/
view/
.htaccess-dist
boot.php
CHANGELOG
CREDITS.txt
database.sql

View File

@ -1,6 +1,6 @@
Contact: mailto:info@friendi.ca
Expires: Sun, 30 Jun 2023 23:59 +0000
Expires: Sun, 31 Dec 2022 23:59 +0000
Preferred-Languages: en

View File

@ -26,7 +26,6 @@ use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Config\Factory\Config;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Module\Maintenance;
use Friendica\Security\Authentication;
use Friendica\Core\Config\ValueObject\Cache;
@ -59,10 +58,6 @@ use Psr\Log\LoggerInterface;
*/
class App
{
const PLATFORM = 'Friendica';
const CODENAME = 'Giant Rhubarb';
const VERSION = '2022.12-dev';
// Allow themes to control internal parameters
// by changing App values in theme.php
private $theme_info = [
@ -128,11 +123,6 @@ class App
*/
private $pConfig;
/**
* @var IHandleUserSessions
*/
private $session;
/**
* Set the user ID
*
@ -157,7 +147,7 @@ class App
public function isLoggedIn(): bool
{
return $this->session->getLocalUserId() && $this->user_id && ($this->user_id == $this->session->getLocalUserId());
return local_user() && $this->user_id && ($this->user_id == local_user());
}
/**
@ -171,7 +161,7 @@ class App
$adminlist = explode(',', str_replace(' ', '', $admin_email));
return $this->session->getLocalUserId() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
return local_user() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
}
/**
@ -334,9 +324,8 @@ class App
* @param L10n $l10n The translator instance
* @param App\Arguments $args The Friendica Arguments of the call
* @param IManagePersonalConfigValues $pConfig Personal configuration
* @param IHandleUserSessions $session The (User)Session handler
*/
public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleUserSessions $session)
public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig)
{
$this->database = $database;
$this->config = $config;
@ -347,7 +336,6 @@ class App
$this->l10n = $l10n;
$this->args = $args;
$this->pConfig = $pConfig;
$this->session = $session;
$this->load();
}
@ -359,11 +347,6 @@ class App
{
set_time_limit(0);
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined('SIGTERM')) {
define('SIGTERM', 15);
}
// Ensure that all "strtotime" operations do run timezone independent
date_default_timezone_set('UTC');
@ -423,7 +406,7 @@ class App
}
// Specific mobile theme override
if (($this->mode->isMobile() || $this->mode->isTablet()) && $this->session->get('show-mobile', true)) {
if (($this->mode->isMobile() || $this->mode->isTablet()) && Core\Session::get('show-mobile', true)) {
$user_mobile_theme = $this->getCurrentMobileTheme();
// --- means same mobile theme as desktop
@ -495,16 +478,16 @@ class App
$page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
if (!empty($this->profile_owner) && ($this->profile_owner != $this->session->getLocalUserId())) {
if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
if ($this->database->isResult($user) && !$this->session->getLocalUserId()) {
if ($this->database->isResult($user) && !local_user()) {
$page_theme = $user['theme'];
}
}
$theme_name = $page_theme ?: $this->session->get('theme', $system_theme);
$theme_name = $page_theme ?: Core\Session::get('theme', $system_theme);
$theme_name = Strings::sanitizeFilePathItem($theme_name);
if ($theme_name
@ -528,15 +511,15 @@ class App
$page_mobile_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
if (!empty($this->profile_owner) && ($this->profile_owner != $this->session->getLocalUserId())) {
if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
if (!$this->session->getLocalUserId()) {
if (!local_user()) {
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
}
}
$mobile_theme_name = $page_mobile_theme ?: $this->session->get('mobile-theme', $system_mobile_theme);
$mobile_theme_name = $page_mobile_theme ?: Core\Session::get('mobile-theme', $system_mobile_theme);
$mobile_theme_name = Strings::sanitizeFilePathItem($mobile_theme_name);
if ($mobile_theme_name == '---'
@ -603,7 +586,7 @@ class App
$this->profiler->set(microtime(true), 'classinit');
$moduleName = $this->args->getModuleName();
$page->setLogging($this->args->getMethod(), $this->args->getModuleName(), $this->args->getCommand());
$page->setLogging($this->args->getCommand(), $this->args->getMethod());
try {
// Missing DB connection: ERROR
@ -628,14 +611,14 @@ class App
}
// ZRL
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) {
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !local_user()) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
strstr(parse_url($_GET['zrl'], PHP_URL_PATH), '/profile/')) {
if ($this->session->get('visitor_home') != $_GET['zrl']) {
$this->session->set('my_url', $_GET['zrl']);
$this->session->set('authenticated', 0);
if (Core\Session::get('visitor_home') != $_GET['zrl']) {
Core\Session::set('my_url', $_GET['zrl']);
Core\Session::set('authenticated', 0);
$remote_contact = Contact::getByURL($_GET['zrl'], false, ['subscribe']);
if (!empty($remote_contact['subscribe'])) {
@ -736,7 +719,7 @@ class App
$response = $module->run($input);
$this->profiler->set(microtime(true) - $timestamp, 'content');
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $this->session->getLocalUserId());
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
} else {
$page->exit($response);
}

View File

@ -80,9 +80,8 @@ class Page implements ArrayAccess
private $basePath;
private $timestamp = 0;
private $method = '';
private $module = '';
private $command = '';
private $method = '';
/**
* @param string $basepath The Page basepath
@ -93,25 +92,21 @@ class Page implements ArrayAccess
$this->basePath = $basepath;
}
public function setLogging(string $method, string $module, string $command)
public function setLogging(string $command, string $method)
{
$this->method = $method;
$this->module = $module;
$this->command = $command;
$this->method = $method;
}
public function logRuntime(IManageConfigValues $config, string $origin = '')
{
$ignore = $config->get('system', 'runtime_ignore');
if (in_array($this->module, $ignore) || in_array($this->command, $ignore)) {
if (in_array($this->command, $config->get('system', 'runtime_ignore'))) {
return;
}
$signature = !empty($_SERVER['HTTP_SIGNATURE']);
$load = number_format(System::currentLoad(), 2);
$runtime = number_format(microtime(true) - $this->timestamp, 3);
$runtime = number_format(microtime(true) - $this->timestamp, 3);
if ($runtime > $config->get('system', 'runtime_loglimit')) {
Logger::debug('Runtime', ['method' => $this->method, 'module' => $this->module, 'runtime' => $runtime, 'load' => $load, 'origin' => $origin, 'signature' => $signature, 'request' => $_SERVER['REQUEST_URI'] ?? '']);
Logger::debug('Runtime', ['method' => $this->method, 'command' => $this->command, 'runtime' => $runtime, 'origin' => $origin]);
}
}
@ -202,7 +197,7 @@ class Page implements ArrayAccess
*/
public function registerStylesheet(string $path, string $media = 'screen')
{
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
if (mb_strpos($path, $this->basePath . DIRECTORY_SEPARATOR) === 0) {
$path = mb_substr($path, mb_strlen($this->basePath . DIRECTORY_SEPARATOR));
@ -221,18 +216,17 @@ class Page implements ArrayAccess
* - Infinite scroll data
* - head.tpl template
*
* @param App $app The Friendica App instance
* @param Arguments $args The Friendica App Arguments
* @param L10n $l10n The l10n language instance
* @param IManageConfigValues $config The Friendica configuration
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
* @param int $localUID The local user id
* @param App $app The Friendica App instance
* @param Arguments $args The Friendica App Arguments
* @param L10n $l10n The l10n language instance
* @param IManageConfigValues $config The Friendica configuration
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
*
* @throws HTTPException\InternalServerErrorException
*/
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, int $localUID)
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
{
$interval = ($localUID ? $pConfig->get($localUID, 'system', 'update_interval') : 40000);
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
// If the update is 'deactivated' set it to the highest integer number (~24 days)
if ($interval < 0) {
@ -277,8 +271,8 @@ class Page implements ArrayAccess
* being first
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
'$local_user' => $localUID,
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
'$update_interval' => $interval,
@ -396,7 +390,7 @@ class Page implements ArrayAccess
*/
public function registerFooterScript($path)
{
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$url = str_replace($this->basePath . DIRECTORY_SEPARATOR, '', $path);
@ -444,11 +438,10 @@ class Page implements ArrayAccess
* @param L10n $l10n The l10n language class
* @param IManageConfigValues $config The Configuration of this node
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
* @param int $localUID The UID of the local user
*
* @throws HTTPException\InternalServerErrorException|HTTPException\ServiceUnavailableException
*/
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig, int $localUID)
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig)
{
$moduleName = $args->getModuleName();
@ -482,7 +475,7 @@ class Page implements ArrayAccess
* all the module functions have executed so that all
* theme choices made by the modules can take effect.
*/
$this->initHead($app, $args, $l10n, $config, $pconfig, $localUID);
$this->initHead($app, $args, $l10n, $config, $pconfig);
/* Build the page ending -- this is stuff that goes right before
* the closing </body> tag
@ -545,7 +538,7 @@ class Page implements ArrayAccess
$page = $this->page;
header("X-Friendica-Version: " . App::VERSION);
header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8");
if ($config->get('system', 'hsts') && ($baseURL->getSSLPolicy() == BaseURL::SSL_POLICY_FULL)) {

View File

@ -34,7 +34,6 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\LegacyModule;
use Friendica\Module\HTTPException\MethodNotAllowed;
use Friendica\Module\HTTPException\PageNotFound;
@ -99,9 +98,6 @@ class Router
/** @var LoggerInterface */
private $logger;
/** @var bool */
private $isLocalUser;
/** @var float */
private $dice_profiler_threshold;
@ -124,10 +120,9 @@ class Router
* @param Arguments $args
* @param LoggerInterface $logger
* @param Dice $dice
* @param IHandleUserSessions $userSession
* @param RouteCollector|null $routeCollector
*/
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, Dice $dice, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, Dice $dice, RouteCollector $routeCollector = null)
{
$this->baseRoutesFilepath = $baseRoutesFilepath;
$this->l10n = $l10n;
@ -138,7 +133,6 @@ class Router
$this->dice = $dice;
$this->server = $server;
$this->logger = $logger;
$this->isLocalUser = !empty($userSession->getLocalUserId());
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
@ -314,7 +308,7 @@ class Router
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
//Check if module is an app and if public access to apps is allowed or not
$privateapps = $this->config->get('config', 'private_addons', false);
if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) {
if ((!local_user()) && Hook::isAddonApp($moduleName) && $privateapps) {
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
} else {
include_once "addon/{$moduleName}/{$moduleName}.php";
@ -345,7 +339,7 @@ class Router
if ($this->dice_profiler_threshold > 0) {
$dur = floatval(microtime(true) - $stamp);
if ($dur >= $this->dice_profiler_threshold) {
$this->logger->notice('Dice module creation lasts too long.', ['duration' => round($dur, 3), 'module' => $module_class, 'parameters' => $module_parameters]);
$this->logger->warning('Dice module creation lasts too long.', ['duration' => round($dur, 3), 'module' => $module_class, 'parameters' => $module_parameters]);
}
}
}

View File

@ -389,7 +389,7 @@ abstract class BaseModule implements ICanHandleRequests
public static function getFormSecurityStandardErrorMessage(): string
{
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.");
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
}
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
@ -397,7 +397,7 @@ abstract class BaseModule implements ICanHandleRequests
if (!self::checkFormSecurityToken($typename, $formname)) {
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]);
DI::sysmsg()->addNotice(self::getFormSecurityStandardErrorMessage());
notice(self::getFormSecurityStandardErrorMessage());
DI::baseUrl()->redirect($err_redirect);
}
}

View File

@ -75,8 +75,9 @@ HELP;
$arr = [];
$files = array_merge(
['index.php'],
['index.php', 'boot.php'],
glob('mod/*'),
glob('include/*'),
glob('addon/*/*'),
$this->globRecursive('src')
);

View File

@ -23,7 +23,6 @@ namespace Friendica\Console;
use Friendica\Core\L10n;
use Friendica\Database\Database;
use Friendica\Model\Contact;
/**
* tool to find and merge duplicated contact entries.
@ -138,7 +137,7 @@ HELP;
$this->updateTable('post-thread-user', 'contact-id', $from, $to, false);
$this->updateTable('user-contact', 'cid', $from, $to, true);
if (!Contact::deleteById($from)) {
if (!$this->dba->delete('contact', ['id' => $from])) {
$this->err($this->l10n->t('Deletion of id %d failed', $from));
} else {
$this->out($this->l10n->t('Deletion of id %d was successful', $from));

View File

@ -46,7 +46,7 @@ class MoveToAvatarCache extends \Asika\SimpleConsole\Console
/**
* @var $baseurl Friendica\App\BaseURL
*/
private $baseUrl;
private $baseurl;
/**
* @var L10n
@ -75,12 +75,12 @@ HELP;
return $help;
}
public function __construct(\Friendica\Database\Database $dba, BaseURL $baseUrl, L10n $l10n, IManageConfigValues $config, array $argv = null)
public function __construct(\Friendica\Database\Database $dba, BaseURL $baseurl, L10n $l10n, IManageConfigValues $config, array $argv = null)
{
parent::__construct($argv);
$this->dba = $dba;
$this->baseUrl = $baseUrl;
$this->baseurl = $baseurl;
$this->l10n = $l10n;
$this->config = $config;
}
@ -94,7 +94,7 @@ HELP;
$fields = ['id', 'avatar', 'photo', 'thumb', 'micro', 'uri-id', 'url', 'avatar', 'network'];
$condition = ["NOT `self` AND `avatar` != ? AND `photo` LIKE ? AND `uid` = ? AND `uri-id` != ? AND NOT `uri-id` IS NULL AND NOT `network` IN (?, ?)",
'', $this->baseUrl->get() . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED];
'', $this->baseurl->get() . '/photo/%', 0, 0, Protocol::MAIL, Protocol::FEED];
$count = 0;
$total = $this->dba->count('contact', $condition);

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