1
1
Fork 0

Merge remote-tracking branch 'origin/2022.12-rc' into fixes

This commit is contained in:
Michael 2022-12-11 19:00:59 +00:00
commit 2f3f41ed9c
714 changed files with 34811 additions and 27839 deletions

258
.ddev/config.yaml Normal file
View file

@ -0,0 +1,258 @@
name: my-friendica
type: php
docroot: ""
php_version: "7.3"
webserver_type: apache-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.4"
nfs_mount_enabled: false
mutagen_enabled: false
use_dns_when_possible: true
composer_version: "1"
web_environment: []
nodejs_version: "16"
webimage_extra_packages: [php7.3-gmp]
# Key features of ddev's config.yaml:
# name: <projectname> # Name of the project, automatically provides
# http://projectname.ddev.site and https://projectname.ddev.site
# type: <projecttype> # drupal6/7/8, backdrop, typo3, wordpress, php
# docroot: <relative_path> # Relative path to the directory containing index.php.
# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"
# You can explicitly specify the webimage but this
# is not recommended, as the images are often closely tied to ddev's' behavior,
# so this can break upgrades.
# webimage: <docker_image> # nginx/php docker image.
# database:
# type: <dbtype> # mysql, mariadb
# version: <version> # database version, like "10.3" or "8.0"
# Note that mariadb_version or mysql_version from v1.18 and earlier
# will automatically be converted to this notation with just a "ddev config --auto"
# router_http_port: <port> # Port to be used for http (defaults to port 80)
# router_https_port: <port> # Port for https (defaults to 443)
# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart"
# Note that for most people the commands
# "ddev xdebug" to enable xdebug and "ddev xdebug off" to disable it work better,
# as leaving xdebug enabled all the time is a big performance hit.
# xhprof_enabled: false # Set to true to enable xhprof and "ddev start" or "ddev restart"
# Note that for most people the commands
# "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better,
# as leaving xhprof enabled all the time is a big performance hit.
# webserver_type: nginx-fpm # or apache-fpm
# timezone: Europe/Berlin
# This is the timezone used in the containers and by PHP;
# it can be set to any valid timezone,
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# For example Europe/Dublin or MST7MDT
# composer_root: <relative_path>
# Relative path to the composer root directory from the project root. This is
# the directory which contains the composer.json and where all Composer related
# commands are executed.
# composer_version: "2"
# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
# to use the latest major version available at the time your container is built.
# It is also possible to use each other Composer version channel. This includes:
# - 2.2 (latest Composer LTS version)
# - stable
# - preview
# - snapshot
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
# To reinstall Composer after the image was built, run "ddev debug refresh".
# nodejs_version: "16"
# change from the default system Node.js version to another supported version, like 12, 14, 17, 18.
# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any
# Node.js version, including v6, etc.
# additional_hostnames:
# - somename
# - someothername
# would provide http and https URLs for "somename.ddev.site"
# and "someothername.ddev.site".
# additional_fqdns:
# - example.com
# - sub1.example.com
# would provide http and https URLs for "example.com" and "sub1.example.com"
# Please take care with this because it can cause great confusion.
# upload_dir: custom/upload/dir
# would set the destination path for ddev import-files to <docroot>/custom/upload/dir
# When mutagen is enabled this path is bind-mounted so that all the files
# in the upload_dir don't have to be synced into mutagen
# working_dir:
# web: /var/www/html
# db: /home
# would set the default working directory for the web and db services.
# These values specify the destination directory for ddev ssh and the
# directory in which commands passed into ddev exec are run.
# omit_containers: [db, dba, ddev-ssh-agent]
# Currently only these containers are supported. Some containers can also be
# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
# the "db" container, several standard features of ddev that access the
# database container will be unusable. In the global configuration it is also
# possible to omit ddev-router, but not here.
# nfs_mount_enabled: false
# Great performance improvement but requires host configuration first.
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs
# mutagen_enabled: false
# Performance improvement using mutagen asynchronous updates.
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen
# fail_on_hook_fail: False
# Decide whether 'ddev start' should be interrupted by a failing hook
# host_https_port: "59002"
# The host port binding for https can be explicitly specified. It is
# dynamic unless otherwise specified.
# This is not used by most people, most people use the *router* instead
# of the localhost port.
# host_webserver_port: "59001"
# The host port binding for the ddev-webserver can be explicitly specified. It is
# dynamic unless otherwise specified.
# This is not used by most people, most people use the *router* instead
# of the localhost port.
# host_db_port: "59002"
# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
# unless explicitly specified.
# phpmyadmin_port: "8036"
# phpmyadmin_https_port: "8037"
# The PHPMyAdmin ports can be changed from the default 8036 and 8037
# host_phpmyadmin_port: "8036"
# The phpmyadmin (dba) port is not normally bound on the host at all, instead being routed
# through ddev-router, but it can be specified and bound.
# mailhog_port: "8025"
# mailhog_https_port: "8026"
# The MailHog ports can be changed from the default 8025 and 8026
# host_mailhog_port: "8025"
# The mailhog port is not normally bound on the host at all, instead being routed
# through ddev-router, but it can be bound directly to localhost if specified here.
# webimage_extra_packages: [php7.4-tidy, php-bcmath]
# Extra Debian packages that are needed in the webimage can be added here
# dbimage_extra_packages: [telnet,netcat]
# Extra Debian packages that are needed in the dbimage can be added here
# use_dns_when_possible: true
# If the host has internet access and the domain configured can
# successfully be looked up, DNS will be used for hostname resolution
# instead of editing /etc/hosts
# Defaults to true
# project_tld: ddev.site
# The top-level domain used for project URLs
# The default "ddev.site" allows DNS lookup via a wildcard
# If you prefer you can change this to "ddev.local" to preserve
# pre-v1.9 behavior.
# ngrok_args: --basic-auth username:pass1234
# Provide extra flags to the "ngrok http" command, see
# https://ngrok.com/docs#http or run "ngrok http -h"
# disable_settings_management: false
# If true, ddev will not create CMS-specific settings files like
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php
# In this case the user must provide all such settings.
# You can inject environment variables into the web container with:
# web_environment:
# - SOMEENV=somevalue
# - SOMEOTHERENV=someothervalue
# no_project_mount: false
# (Experimental) If true, ddev will not mount the project into the web container;
# the user is responsible for mounting it manually or via a script.
# This is to enable experimentation with alternate file mounting strategies.
# For advanced users only!
# bind_all_interfaces: false
# If true, host ports will be bound on all network interfaces,
# not just the localhost interface. This means that ports
# will be available on the local network if the host firewall
# allows it.
# default_container_timeout: 120
# The default time that ddev waits for all containers to become ready can be increased from
# the default 120. This helps in importing huge databases, for example.
#web_extra_exposed_ports:
#- name: nodejs
# container_port: 3000
# http_port: 2999
# https_port: 3000
#- name: something
# container_port: 4000
# https_port: 4000
# http_port: 3999
# Allows a set of extra ports to be exposed via ddev-router
# The port behavior on the ddev-webserver must be arranged separately, for example
# using web_extra_daemons.
# For example, with a web app on port 3000 inside the container, this config would
# expose that web app on https://<project>.ddev.site:9999 and http://<project>.ddev.site:9998
# web_extra_exposed_ports:
# - container_port: 3000
# http_port: 9998
# https_port: 9999
#web_extra_daemons:
#- name: "http-1"
# command: "/var/www/html/node_modules/.bin/http-server -p 3000"
# directory: /var/www/html
#- name: "http-2"
# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
# directory: /var/www/html
# override_config: false
# By default, config.*.yaml files are *merged* into the configuration
# But this means that some things can't be overridden
# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge
# and you can't erase existing hooks or all environment variables.
# However, with "override_config: true" in a particular config.*.yaml file,
# 'nfs_mount_enabled: false' can override the existing values, and
# hooks:
# post-start: []
# or
# web_environment: []
# or
# additional_hostnames: []
# can have their intended affect. 'override_config' affects only behavior of the
# config.*.yaml file it exists in.
# Many ddev commands can be extended to run tasks before or after the
# ddev command is executed, for example "post-start", "post-import-db",
# "pre-composer", "post-composer"
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
# information on the commands that can be extended and the tasks you can define
# for them. Example:
#hooks:

7
.gitignore vendored
View file

@ -10,10 +10,9 @@ home.html
robots.txt robots.txt
#ignore local config #ignore local config
/config/local.config.php !/config/local-sample.config.php
/config/addon.config.php /config/*.config.php
/config/local.ini.php /config/*.ini.php
/config/addon.ini.php
#ignore documentation, it should be newly built #ignore documentation, it should be newly built
/doc/api /doc/api

View file

@ -51,6 +51,6 @@ AddType audio/ogg .oga
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pagename=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] RewriteRule ^(.*)$ index.php?pagename=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA,B]
</IfModule> </IfModule>

View file

@ -39,7 +39,7 @@ pipeline:
branch: [ develop, '*-rc' ] branch: [ develop, '*-rc' ]
event: push event: push
composer_install: composer_install:
image: friendicaci/php7.4:php7.4.18 image: friendicaci/php7.4:php7.4.33
commands: commands:
- export COMPOSER_HOME=.composer - export COMPOSER_HOME=.composer
- composer validate - composer validate

View file

@ -1,7 +1,7 @@
matrix: matrix:
include: include:
- PHP_MAJOR_VERSION: 7.4 - PHP_MAJOR_VERSION: 7.4
PHP_VERSION: 7.4.18 PHP_VERSION: 7.4.33
branches: branches:
exclude: [ stable ] exclude: [ stable ]

View file

@ -1,11 +1,17 @@
matrix: matrix:
include: include:
- PHP_MAJOR_VERSION: 7.3 - PHP_MAJOR_VERSION: 7.3
PHP_VERSION: 7.3.28 PHP_VERSION: 7.3.33
- PHP_MAJOR_VERSION: 7.4 - PHP_MAJOR_VERSION: 7.4
PHP_VERSION: 7.4.18 PHP_VERSION: 7.4.33
- PHP_MAJOR_VERSION: 8.0 - PHP_MAJOR_VERSION: 8.0
PHP_VERSION: 8.0.5 PHP_VERSION: 8.0.25
- PHP_MAJOR_VERSION: 8.1
PHP_VERSION: 8.1.12
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
labels:
location: opensocial
pipeline: pipeline:
php-lint: php-lint:

View file

@ -37,7 +37,7 @@ pipeline:
branch: stable branch: stable
event: tag event: tag
composer_install: composer_install:
image: friendicaci/php7.4:php7.4.18 image: friendicaci/php7.4:php7.4.33
commands: commands:
- export COMPOSER_HOME=.composer - export COMPOSER_HOME=.composer
- composer validate - composer validate

View file

@ -1,10 +1,59 @@
Version 2022.09 (unreleased) Version 2022.12 (unreleased)
Friendica Core Friendica Core
The rewrite rule in .htaccess-dist has been changed. The change has to be applied manually to the existing .htaccess
Friendica Addons 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 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) Version 2022.06 (2022-06-11)
Friendica Core Friendica Core

View file

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

View file

@ -9,7 +9,7 @@ Our mission is to free friends, family and colleagues from data-harvesting corpo
Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on [Friendica]( https://friendi.ca), [Mastodon](https://joinmastodon.org/), [Diaspora](https://diasporafoundation.org/), [GnuSocial](https://gnu.io/social/), [Pleroma](https://pleroma.social/), or [Hubzilla](https://hubzilla.org/), regardless where each user profile is hosted. Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on [Friendica]( https://friendi.ca), [Mastodon](https://joinmastodon.org/), [Diaspora](https://diasporafoundation.org/), [GnuSocial](https://gnu.io/social/), [Pleroma](https://pleroma.social/), or [Hubzilla](https://hubzilla.org/), regardless where each user profile is hosted.
With Friendica, you can also fully interact with anyone on Twitter, post on Facebook and receive any content on Tumblr, Wordpress or RSS. Friendica allows you to integrate most things on the web via a range of addons such as ITTT, Buffer; you will be able to easily control your own data as you decide. With Friendica, you can also fully interact with anyone on Twitter and receive any content from Tumblr, Wordpress or RSS. Friendica allows you to integrate most things on the web via a range of addons such as ITTT, Buffer; you will be able to easily control your own data as you decide.
Join today and [get your Friendica profile!](https://dir.friendica.social/servers 'Join Friendica today!') Join today and [get your Friendica profile!](https://dir.friendica.social/servers 'Join Friendica today!')

View file

@ -1 +1 @@
2022.09-rc 2022.12-rc

2
Vagrantfile vendored
View file

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

View file

@ -26,6 +26,7 @@ if (php_sapi_name() !== 'cli') {
} }
use Dice\Dice; use Dice\Dice;
use Friendica\DI;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
@ -33,6 +34,8 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['console']]); $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)); \Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
(new Friendica\Core\Console($dice, $argv))->execute(); (new Friendica\Core\Console($dice, $argv))->execute();

View file

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

View file

@ -45,13 +45,13 @@ apt-get install -qq apache2
a2enmod rewrite actions ssl a2enmod rewrite actions ssl
cp /vagrant/bin/dev/vagrant_vhost.sh /usr/local/bin/vhost cp /vagrant/bin/dev/vagrant_vhost.sh /usr/local/bin/vhost
chmod guo+x /usr/local/bin/vhost chmod guo+x /usr/local/bin/vhost
vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.local vhost -s 192.168.56.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.local
a2dissite 000-default a2dissite 000-default
service apache2 restart service apache2 restart
#Install php #Install php
echo ">>> Installing PHP7" 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 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
systemctl restart apache2 systemctl restart apache2
echo ">>> Installing PHP8" 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 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 - wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
apt update 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 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
systemctl restart apache2 systemctl restart apache2
#Install mysql #Install mysql

View file

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

194
boot.php
View file

@ -1,194 +0,0 @@
<?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-rc');
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,15 +41,15 @@
"michelf/php-markdown": "^1.7", "michelf/php-markdown": "^1.7",
"minishlink/web-push": "^6.0", "minishlink/web-push": "^6.0",
"mobiledetect/mobiledetectlib": "^2.8", "mobiledetect/mobiledetectlib": "^2.8",
"monolog/monolog": "^1.25",
"nikic/fast-route": "^1.3", "nikic/fast-route": "^1.3",
"paragonie/hidden-string": "^1.0", "paragonie/hidden-string": "^1.0",
"patrickschur/language-detection": "^5.0.0", "patrickschur/language-detection": "^5.0.0",
"pear/console_table": "^1.3", "pear/console_table": "^1.3",
"phpseclib/phpseclib": "^2.0", "phpseclib/phpseclib": "^3.0",
"pragmarx/google2fa": "^5.0", "pragmarx/google2fa": "^5.0",
"pragmarx/recovery": "^0.2", "pragmarx/recovery": "^0.2",
"psr/container": "^1.0", "psr/container": "^1.0",
"psr/log": "^1.1",
"seld/cli-prompt": "^1.0", "seld/cli-prompt": "^1.0",
"smarty/smarty": "^4", "smarty/smarty": "^4",
"ua-parser/uap-php": "^3.9", "ua-parser/uap-php": "^3.9",
@ -59,7 +59,6 @@
"bower-asset/chart-js": "^2.8", "bower-asset/chart-js": "^2.8",
"bower-asset/dompurify": "^1.0", "bower-asset/dompurify": "^1.0",
"bower-asset/fork-awesome": "^1.1", "bower-asset/fork-awesome": "^1.1",
"bower-asset/vue": "^2.6",
"npm-asset/cropperjs": "1.2.2", "npm-asset/cropperjs": "1.2.2",
"npm-asset/es-jquery-sortable": "^0.9.13", "npm-asset/es-jquery-sortable": "^0.9.13",
"npm-asset/fullcalendar": "^3.10", "npm-asset/fullcalendar": "^3.10",
@ -71,7 +70,8 @@
"npm-asset/moment": "^2.24", "npm-asset/moment": "^2.24",
"npm-asset/perfect-scrollbar": "0.6.16", "npm-asset/perfect-scrollbar": "0.6.16",
"npm-asset/textcomplete": "^0.18.2", "npm-asset/textcomplete": "^0.18.2",
"npm-asset/typeahead.js": "^0.11.1" "npm-asset/typeahead.js": "^0.11.1",
"kornrunner/blurhash": "^1.2"
}, },
"repositories": [ "repositories": [
{ {
@ -83,10 +83,7 @@
"psr-4": { "psr-4": {
"Friendica\\": "src/", "Friendica\\": "src/",
"Friendica\\Addon\\": "addon/" "Friendica\\Addon\\": "addon/"
}, }
"files": [
"boot.php"
]
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {

168
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f5922f03b367e68a5930df6ed80c5c2f", "content-hash": "f8e7baec685d20e6aee56978c275d64c",
"packages": [ "packages": [
{ {
"name": "asika/simple-console", "name": "asika/simple-console",
@ -241,22 +241,6 @@
], ],
"time": "2021-08-26T18:46:39+00:00" "time": "2021-08-26T18:46:39+00:00"
}, },
{
"name": "bower-asset/vue",
"version": "v2.7.10",
"source": {
"type": "git",
"url": "https://github.com/vuejs/vue.git",
"reference": "ee57d9fd1d51abe245c6c37e6f8f2d45977b929e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vuejs/vue/zipball/ee57d9fd1d51abe245c6c37e6f8f2d45977b929e",
"reference": "ee57d9fd1d51abe245c6c37e6f8f2d45977b929e",
"shasum": ""
},
"type": "bower-asset-library"
},
{ {
"name": "brick/math", "name": "brick/math",
"version": "0.9.3", "version": "0.9.3",
@ -1132,6 +1116,50 @@
], ],
"time": "2022-06-20T21:43:03+00:00" "time": "2022-06-20T21:43:03+00:00"
}, },
{
"name": "kornrunner/blurhash",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/kornrunner/php-blurhash.git",
"reference": "bc8a4596cb0a49874f0158696a382ab3933fefe4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kornrunner/php-blurhash/zipball/bc8a4596cb0a49874f0158696a382ab3933fefe4",
"reference": "bc8a4596cb0a49874f0158696a382ab3933fefe4",
"shasum": ""
},
"require": {
"php": "^7.3|^8.0"
},
"require-dev": {
"ext-gd": "*",
"ocramius/package-versions": "^1.4|^2.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^9",
"vimeo/psalm": "^4.3"
},
"type": "library",
"autoload": {
"psr-4": {
"kornrunner\\Blurhash\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Boris Momčilović",
"email": "boris.momcilovic@gmail.com"
}
],
"description": "Pure PHP implementation of Blurhash",
"homepage": "https://github.com/kornrunner/php-blurhash",
"time": "2022-07-13T19:38:39+00:00"
},
{ {
"name": "league/html-to-markdown", "name": "league/html-to-markdown",
"version": "4.10.0", "version": "4.10.0",
@ -1543,88 +1571,6 @@
], ],
"time": "2022-02-17T19:24:25+00:00" "time": "2022-02-17T19:24:25+00:00"
}, },
{
"name": "monolog/monolog",
"version": "1.27.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/904713c5929655dc9b97288b69cfeedad610c9a1",
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "~4.5",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2022-06-09T08:53:42+00:00"
},
{ {
"name": "nikic/fast-route", "name": "nikic/fast-route",
"version": "v1.3.0", "version": "v1.3.0",
@ -3050,32 +2996,32 @@
}, },
{ {
"name": "phpseclib/phpseclib", "name": "phpseclib/phpseclib",
"version": "2.0.38", "version": "3.0.17",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpseclib/phpseclib.git", "url": "https://github.com/phpseclib/phpseclib.git",
"reference": "b03536539f43a4f9aa33c4f0b2f3a1c752088fcd" "reference": "dbc2307d5c69aeb22db136c52e91130d7f2ca761"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/b03536539f43a4f9aa33c4f0b2f3a1c752088fcd", "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/dbc2307d5c69aeb22db136c52e91130d7f2ca761",
"reference": "b03536539f43a4f9aa33c4f0b2f3a1c752088fcd", "reference": "dbc2307d5c69aeb22db136c52e91130d7f2ca761",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "paragonie/constant_time_encoding": "^1|^2",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
}, },
"require-dev": { "require-dev": {
"phing/phing": "~2.7", "phpunit/phpunit": "*"
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0"
}, },
"suggest": { "suggest": {
"ext-dom": "Install the DOM extension to load XML formatted public keys.",
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.", "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
"ext-xml": "Install the XML extension to load XML formatted public keys."
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -3083,7 +3029,7 @@
"phpseclib/bootstrap.php" "phpseclib/bootstrap.php"
], ],
"psr-4": { "psr-4": {
"phpseclib\\": "phpseclib/" "phpseclib3\\": "phpseclib/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -3152,7 +3098,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-09-02T17:04:26+00:00" "time": "2022-10-24T10:51:50+00:00"
}, },
{ {
"name": "pragmarx/google2fa", "name": "pragmarx/google2fa",

View file

@ -1,12 +0,0 @@
<?php
// Addon configuration
// Copy this configuration file to addon.config.php and edit it if you want to configure addons, see below example for the twitter addon
return [
'twitter' => [
'consumerkey' => '1234567890',
'consumersecret' => 'ABCDEFGHIJKLMONPQRSTUVWXYZ',
],
];

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2022.09-rc (Giant Rhubarb) -- Friendica 2022.12-rc (Giant Rhubarb)
-- DB_UPDATE_VERSION 1484 -- DB_UPDATE_VERSION 1500
-- ------------------------------------------ -- ------------------------------------------
@ -59,6 +59,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language', `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
`register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration', `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
`login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login', `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
`last-activity` date COMMENT 'Day of the last activity',
`default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location', `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
`allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location', `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
`theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference', `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
@ -80,7 +81,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`pwdreset` varchar(255) COMMENT 'Password reset request token', `pwdreset` varchar(255) COMMENT 'Password reset request token',
`pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request', `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
`maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '', `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
`expire` int unsigned NOT NULL DEFAULT 0 COMMENT '', `expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
`account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed', `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
`account_expired` boolean NOT NULL DEFAULT '0' COMMENT '', `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
`account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted', `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
@ -309,6 +310,20 @@ CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
--
-- TABLE account-suggestion
--
CREATE TABLE IF NOT EXISTS `account-suggestion` (
`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',
`level` smallint unsigned COMMENT 'level of closeness',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
PRIMARY KEY(`uid`,`uri-id`),
INDEX `uri-id_uid` (`uri-id`,`uid`),
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='Account suggestion';
-- --
-- TABLE account-user -- TABLE account-user
-- --
@ -563,6 +578,40 @@ CREATE TABLE IF NOT EXISTS `delayed-post` (
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
--
-- TABLE diaspora-contact
--
CREATE TABLE IF NOT EXISTS `diaspora-contact` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
`addr` varchar(255) COMMENT '',
`alias` varchar(255) COMMENT '',
`nick` varchar(255) COMMENT '',
`name` varchar(255) COMMENT '',
`given-name` varchar(255) COMMENT '',
`family-name` varchar(255) COMMENT '',
`photo` varchar(255) COMMENT '',
`photo-medium` varchar(255) COMMENT '',
`photo-small` varchar(255) COMMENT '',
`batch` varchar(255) COMMENT '',
`notify` varchar(255) COMMENT '',
`poll` varchar(255) COMMENT '',
`subscribe` varchar(255) COMMENT '',
`searchable` boolean COMMENT '',
`pubkey` text COMMENT '',
`gsid` int unsigned COMMENT 'Global Server ID',
`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',
`post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
PRIMARY KEY(`uri-id`),
UNIQUE INDEX `addr` (`addr`),
INDEX `alias` (`alias`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
-- --
-- TABLE diaspora-interaction -- TABLE diaspora-interaction
-- --
@ -618,39 +667,6 @@ CREATE TABLE IF NOT EXISTS `event` (
FOREIGN KEY (`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='Events'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
--
-- TABLE fcontact
--
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 '',
`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 '',
`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 '',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
`alias` varbinary(383) 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',
`post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
PRIMARY KEY(`id`),
INDEX `addr` (`addr`(32)),
UNIQUE INDEX `url` (`url`(190)),
UNIQUE INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
-- --
-- TABLE fetch-entry -- TABLE fetch-entry
-- --
@ -1073,6 +1089,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
`height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '', `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
`width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '', `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
`datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '', `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`blurhash` varbinary(255) COMMENT 'BlurHash representation of the photo',
`data` mediumblob NOT NULL COMMENT '', `data` mediumblob NOT NULL COMMENT '',
`scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`profile` boolean NOT NULL DEFAULT '0' COMMENT '', `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
@ -1186,6 +1203,7 @@ CREATE TABLE IF NOT EXISTS `post-content` (
`content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '', `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`body` mediumtext COMMENT 'item body content', `body` mediumtext COMMENT 'item body content',
`raw-body` mediumtext COMMENT 'Body without embedded media links', `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', `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', `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
`language` text COMMENT 'Language information about this post', `language` text COMMENT 'Language information about this post',
@ -1202,7 +1220,9 @@ CREATE TABLE IF NOT EXISTS `post-content` (
INDEX `plink` (`plink`(191)), INDEX `plink` (`plink`(191)),
INDEX `resource-id` (`resource-id`), INDEX `resource-id` (`resource-id`),
FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`), FULLTEXT INDEX `title-content-warning-body` (`title`,`content-warning`,`body`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE 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
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
-- --
@ -1289,11 +1309,13 @@ CREATE TABLE IF NOT EXISTS `post-media` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', `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', `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', `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', `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
`mimetype` varchar(60) COMMENT '', `mimetype` varchar(60) COMMENT '',
`height` smallint unsigned COMMENT 'Height of the media', `height` smallint unsigned COMMENT 'Height of the media',
`width` smallint unsigned COMMENT 'Width of the media', `width` smallint unsigned COMMENT 'Width of the media',
`size` bigint unsigned COMMENT 'Media size', `size` bigint unsigned COMMENT 'Media size',
`blurhash` varbinary(255) COMMENT 'BlurHash representation of the image',
`preview` varbinary(512) COMMENT 'Preview URL', `preview` varbinary(512) COMMENT 'Preview URL',
`preview-height` smallint unsigned COMMENT 'Height of the preview picture', `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
`preview-width` smallint unsigned COMMENT 'Width of the preview picture', `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
@ -1308,7 +1330,9 @@ CREATE TABLE IF NOT EXISTS `post-media` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)), UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)),
INDEX `uri-id-id` (`uri-id`,`id`), INDEX `uri-id-id` (`uri-id`,`id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE 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
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';
-- --
@ -1571,6 +1595,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`education` text COMMENT 'Deprecated', `education` text COMMENT 'Deprecated',
`contact` text COMMENT 'Deprecated', `contact` text COMMENT 'Deprecated',
`homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '', `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`homepage_verified` boolean NOT NULL DEFAULT '0' COMMENT 'was the homepage verified by a rel-me link back to the profile',
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address', `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
`matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address', `matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
`photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '', `photo` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
@ -1639,6 +1664,37 @@ CREATE TABLE IF NOT EXISTS `register` (
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
--
-- TABLE report
--
CREATE TABLE IF NOT EXISTS `report` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned COMMENT 'Reporting user',
`cid` int unsigned NOT NULL COMMENT 'Reported contact',
`comment` text COMMENT 'Report',
`forward` boolean COMMENT 'Forward the report to the remote server',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`status` tinyint unsigned COMMENT 'Status of the report',
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
INDEX `cid` (`cid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
--
-- TABLE report-post
--
CREATE TABLE IF NOT EXISTS `report-post` (
`rid` int unsigned NOT NULL COMMENT 'Report id',
`uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post',
`status` tinyint unsigned COMMENT 'Status of the reported post',
PRIMARY KEY(`rid`,`uri-id`),
INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`rid`) REFERENCES `report` (`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='';
-- --
-- TABLE search -- TABLE search
-- --
@ -1807,6 +1863,8 @@ CREATE VIEW `post-user-view` AS SELECT
`post-user`.`thr-parent-id` AS `thr-parent-id`, `post-user`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`, `conversation-item-uri`.`uri` AS `conversation`,
`post-thread-user`.`conversation-id` AS `conversation-id`, `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`, `item-uri`.`guid` AS `guid`,
`post-user`.`wall` AS `wall`, `post-user`.`wall` AS `wall`,
`post-user`.`gravity` AS `gravity`, `post-user`.`gravity` AS `gravity`,
@ -1944,9 +2002,7 @@ CREATE VIEW `post-user-view` AS SELECT
`parent-post-author`.`url` AS `parent-author-link`, `parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`, `parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`nick` AS `parent-author-nick`, `parent-post-author`.`nick` AS `parent-author-nick`,
`parent-post-author`.`network` AS `parent-author-network`, `parent-post-author`.`network` AS `parent-author-network`
`parent-post-author`.`blocked` AS `parent-author-blocked`,
`parent-post-author`.`hidden` AS `parent-author-hidden`
FROM `post-user` FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid` STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id` STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
@ -1962,6 +2018,7 @@ CREATE VIEW `post-user-view` AS SELECT
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id` 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 `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 `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-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 `post-question` ON `post-question`.`uri-id` = `post-user`.`uri-id`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid` LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
@ -1985,6 +2042,8 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`post-user`.`thr-parent-id` AS `thr-parent-id`, `post-user`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`, `conversation-item-uri`.`uri` AS `conversation`,
`post-thread-user`.`conversation-id` AS `conversation-id`, `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`, `item-uri`.`guid` AS `guid`,
`post-thread-user`.`wall` AS `wall`, `post-thread-user`.`wall` AS `wall`,
`post-user`.`gravity` AS `gravity`, `post-user`.`gravity` AS `gravity`,
@ -2120,9 +2179,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`parent-post`.`author-id` AS `parent-author-id`, `parent-post`.`author-id` AS `parent-author-id`,
`parent-post-author`.`url` AS `parent-author-link`, `parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`, `parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`network` AS `parent-author-network`, `parent-post-author`.`network` AS `parent-author-network`
`parent-post-author`.`blocked` AS `parent-author-blocked`,
`parent-post-author`.`hidden` AS `parent-author-hidden`
FROM `post-thread-user` FROM `post-thread-user`
INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id` INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id` STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
@ -2138,6 +2195,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id` 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 `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 `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-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 `post-question` ON `post-question`.`uri-id` = `post-thread-user`.`uri-id`
LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid` LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
@ -2157,6 +2215,8 @@ CREATE VIEW `post-view` AS SELECT
`post`.`thr-parent-id` AS `thr-parent-id`, `post`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`, `conversation-item-uri`.`uri` AS `conversation`,
`post-thread`.`conversation-id` AS `conversation-id`, `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`, `item-uri`.`guid` AS `guid`,
`post`.`gravity` AS `gravity`, `post`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`, `external-item-uri`.`uri` AS `extid`,
@ -2263,9 +2323,7 @@ CREATE VIEW `post-view` AS SELECT
`parent-post`.`author-id` AS `parent-author-id`, `parent-post`.`author-id` AS `parent-author-id`,
`parent-post-author`.`url` AS `parent-author-link`, `parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`, `parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`network` AS `parent-author-network`, `parent-post-author`.`network` AS `parent-author-network`
`parent-post-author`.`blocked` AS `parent-author-blocked`,
`parent-post-author`.`hidden` AS `parent-author-hidden`
FROM `post` FROM `post`
STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id` STRAIGHT_JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id` STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post`.`author-id`
@ -2279,6 +2337,7 @@ CREATE VIEW `post-view` AS SELECT
LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid` LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post`.`uri-id` 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 `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-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 `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`; LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@ -2296,6 +2355,8 @@ CREATE VIEW `post-thread-view` AS SELECT
`post`.`thr-parent-id` AS `thr-parent-id`, `post`.`thr-parent-id` AS `thr-parent-id`,
`conversation-item-uri`.`uri` AS `conversation`, `conversation-item-uri`.`uri` AS `conversation`,
`post-thread`.`conversation-id` AS `conversation-id`, `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`, `item-uri`.`guid` AS `guid`,
`post`.`gravity` AS `gravity`, `post`.`gravity` AS `gravity`,
`external-item-uri`.`uri` AS `extid`, `external-item-uri`.`uri` AS `extid`,
@ -2396,15 +2457,15 @@ CREATE VIEW `post-thread-view` AS SELECT
`post-question`.`end-time` AS `question-end-time`, `post-question`.`end-time` AS `question-end-time`,
0 AS `has-categories`, 0 AS `has-categories`,
EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`, EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
(SELECT COUNT(*) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-comments`,
(SELECT COUNT(DISTINCT(`author-id`)) FROM `post` WHERE `parent-uri-id` = `post-thread`.`uri-id` AND `gravity` = 6) AS `total-actors`,
`diaspora-interaction`.`interaction` AS `signed_text`, `diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item-uri`.`guid` AS `parent-guid`, `parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`, `parent-post`.`network` AS `parent-network`,
`parent-post`.`author-id` AS `parent-author-id`, `parent-post`.`author-id` AS `parent-author-id`,
`parent-post-author`.`url` AS `parent-author-link`, `parent-post-author`.`url` AS `parent-author-link`,
`parent-post-author`.`name` AS `parent-author-name`, `parent-post-author`.`name` AS `parent-author-name`,
`parent-post-author`.`network` AS `parent-author-network`, `parent-post-author`.`network` AS `parent-author-network`
`parent-post-author`.`blocked` AS `parent-author-blocked`,
`parent-post-author`.`hidden` AS `parent-author-hidden`
FROM `post-thread` FROM `post-thread`
INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id` INNER JOIN `post` ON `post`.`uri-id` = `post-thread`.`uri-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id` STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-thread`.`author-id`
@ -2418,6 +2479,7 @@ CREATE VIEW `post-thread-view` AS SELECT
LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid` LEFT JOIN `verb` ON `verb`.`id` = `post`.`vid`
LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread`.`uri-id` 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 `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-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 `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`; LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`;
@ -2457,6 +2519,24 @@ CREATE VIEW `collection-view` AS SELECT
INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id` INNER JOIN `post` ON `post-collection`.`uri-id` = `post`.`uri-id`
INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`; INNER JOIN `post-thread` ON `post-thread`.`uri-id` = `post`.`parent-uri-id`;
--
-- VIEW media-view
--
DROP VIEW IF EXISTS `media-view`;
CREATE VIEW `media-view` AS SELECT
`post-media`.`uri-id` AS `uri-id`,
`post-media`.`type` AS `type`,
`post`.`received` AS `received`,
`post`.`created` AS `created`,
`post`.`private` AS `private`,
`post`.`visible` AS `visible`,
`post`.`deleted` AS `deleted`,
`post`.`thr-parent-id` AS `thr-parent-id`,
`post`.`author-id` AS `author-id`,
`post`.`gravity` AS `gravity`
FROM `post-media`
INNER JOIN `post` ON `post-media`.`uri-id` = `post`.`uri-id`;
-- --
-- VIEW tag-view -- VIEW tag-view
-- --
@ -2616,6 +2696,7 @@ CREATE VIEW `owner-view` AS SELECT
`user`.`language` AS `language`, `user`.`language` AS `language`,
`user`.`register_date` AS `register_date`, `user`.`register_date` AS `register_date`,
`user`.`login_date` AS `login_date`, `user`.`login_date` AS `login_date`,
`user`.`last-activity` AS `last-activity`,
`user`.`default-location` AS `default-location`, `user`.`default-location` AS `default-location`,
`user`.`allow_location` AS `allow_location`, `user`.`allow_location` AS `allow_location`,
`user`.`theme` AS `theme`, `user`.`theme` AS `theme`,
@ -2656,6 +2737,7 @@ CREATE VIEW `owner-view` AS SELECT
`profile`.`postal-code` AS `postal-code`, `profile`.`postal-code` AS `postal-code`,
`profile`.`country-name` AS `country-name`, `profile`.`country-name` AS `country-name`,
`profile`.`homepage` AS `homepage`, `profile`.`homepage` AS `homepage`,
`profile`.`homepage_verified` AS `homepage_verified`,
`profile`.`dob` AS `dob` `profile`.`dob` AS `dob`
FROM `user` FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self` INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
@ -2721,11 +2803,11 @@ CREATE VIEW `account-view` AS SELECT
`contact`.`blocked` AS `blocked`, `contact`.`blocked` AS `blocked`,
`contact`.`notify` AS `dfrn-notify`, `contact`.`notify` AS `dfrn-notify`,
`contact`.`poll` AS `dfrn-poll`, `contact`.`poll` AS `dfrn-poll`,
`fcontact`.`guid` AS `diaspora-guid`, `item-uri`.`guid` AS `diaspora-guid`,
`fcontact`.`batch` AS `diaspora-batch`, `diaspora-contact`.`batch` AS `diaspora-batch`,
`fcontact`.`notify` AS `diaspora-notify`, `diaspora-contact`.`notify` AS `diaspora-notify`,
`fcontact`.`poll` AS `diaspora-poll`, `diaspora-contact`.`poll` AS `diaspora-poll`,
`fcontact`.`alias` AS `diaspora-alias`, `diaspora-contact`.`alias` AS `diaspora-alias`,
`apcontact`.`uuid` AS `ap-uuid`, `apcontact`.`uuid` AS `ap-uuid`,
`apcontact`.`type` AS `ap-type`, `apcontact`.`type` AS `ap-type`,
`apcontact`.`following` AS `ap-following`, `apcontact`.`following` AS `ap-following`,
@ -2743,7 +2825,7 @@ CREATE VIEW `account-view` AS SELECT
FROM `contact` FROM `contact`
LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id` LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id`
LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id` LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = contact.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid` LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
WHERE `contact`.`uid` = 0; WHERE `contact`.`uid` = 0;
@ -2822,14 +2904,14 @@ CREATE VIEW `account-user-view` AS SELECT
`ucontact`.`reason` AS `reason`, `ucontact`.`reason` AS `reason`,
`contact`.`notify` AS `dfrn-notify`, `contact`.`notify` AS `dfrn-notify`,
`contact`.`poll` AS `dfrn-poll`, `contact`.`poll` AS `dfrn-poll`,
`fcontact`.`guid` AS `diaspora-guid`, `item-uri`.`guid` AS `diaspora-guid`,
`fcontact`.`batch` AS `diaspora-batch`, `diaspora-contact`.`batch` AS `diaspora-batch`,
`fcontact`.`notify` AS `diaspora-notify`, `diaspora-contact`.`notify` AS `diaspora-notify`,
`fcontact`.`poll` AS `diaspora-poll`, `diaspora-contact`.`poll` AS `diaspora-poll`,
`fcontact`.`alias` AS `diaspora-alias`, `diaspora-contact`.`alias` AS `diaspora-alias`,
`fcontact`.`interacting_count` AS `diaspora-interacting_count`, `diaspora-contact`.`interacting_count` AS `diaspora-interacting_count`,
`fcontact`.`interacted_count` AS `diaspora-interacted_count`, `diaspora-contact`.`interacted_count` AS `diaspora-interacted_count`,
`fcontact`.`post_count` AS `diaspora-post_count`, `diaspora-contact`.`post_count` AS `diaspora-post_count`,
`apcontact`.`uuid` AS `ap-uuid`, `apcontact`.`uuid` AS `ap-uuid`,
`apcontact`.`type` AS `ap-type`, `apcontact`.`type` AS `ap-type`,
`apcontact`.`following` AS `ap-following`, `apcontact`.`following` AS `ap-following`,
@ -2848,7 +2930,7 @@ CREATE VIEW `account-user-view` AS SELECT
INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0 INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0
LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id` LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id`
LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `ucontact`.`uri-id`
LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = `ucontact`.`uri-id` AND `fcontact`.`network` = 'dspr' LEFT JOIN `diaspora-contact` ON `diaspora-contact`.`uri-id` = `ucontact`.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`; LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`;
-- --
@ -2925,3 +3007,37 @@ CREATE VIEW `profile_field-view` AS SELECT
`profile_field`.`edited` AS `edited` `profile_field`.`edited` AS `edited`
FROM `profile_field` FROM `profile_field`
INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`; INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
--
-- VIEW diaspora-contact-view
--
DROP VIEW IF EXISTS `diaspora-contact-view`;
CREATE VIEW `diaspora-contact-view` AS SELECT
`diaspora-contact`.`uri-id` AS `uri-id`,
`item-uri`.`uri` AS `url`,
`item-uri`.`guid` AS `guid`,
`diaspora-contact`.`addr` AS `addr`,
`diaspora-contact`.`alias` AS `alias`,
`diaspora-contact`.`nick` AS `nick`,
`diaspora-contact`.`name` AS `name`,
`diaspora-contact`.`given-name` AS `given-name`,
`diaspora-contact`.`family-name` AS `family-name`,
`diaspora-contact`.`photo` AS `photo`,
`diaspora-contact`.`photo-medium` AS `photo-medium`,
`diaspora-contact`.`photo-small` AS `photo-small`,
`diaspora-contact`.`batch` AS `batch`,
`diaspora-contact`.`notify` AS `notify`,
`diaspora-contact`.`poll` AS `poll`,
`diaspora-contact`.`subscribe` AS `subscribe`,
`diaspora-contact`.`searchable` AS `searchable`,
`diaspora-contact`.`pubkey` AS `pubkey`,
`gserver`.`url` AS `baseurl`,
`diaspora-contact`.`gsid` AS `gsid`,
`diaspora-contact`.`created` AS `created`,
`diaspora-contact`.`updated` AS `updated`,
`diaspora-contact`.`interacting_count` AS `interacting_count`,
`diaspora-contact`.`interacted_count` AS `interacted_count`,
`diaspora-contact`.`post_count` AS `post_count`
FROM `diaspora-contact`
INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;

View file

@ -47,6 +47,7 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
- [`POST /api/v1/accounts/:id/unmute`](https://docs.joinmastodon.org/methods/accounts/) - [`POST /api/v1/accounts/:id/unmute`](https://docs.joinmastodon.org/methods/accounts/)
- [`GET /api/v1/accounts/relationships`](https://docs.joinmastodon.org/methods/accounts/) - [`GET /api/v1/accounts/relationships`](https://docs.joinmastodon.org/methods/accounts/)
- [`GET /api/v1/accounts/search`](https://docs.joinmastodon.org/methods/accounts) - [`GET /api/v1/accounts/search`](https://docs.joinmastodon.org/methods/accounts)
- [`PATCH /api/v1/accounts/update_credentials`](https://docs.joinmastodon.org/methods/accounts/#update_credentials)
- [`GET /api/v1/accounts/verify_credentials`](https://docs.joinmastodon.org/methods/accounts) - [`GET /api/v1/accounts/verify_credentials`](https://docs.joinmastodon.org/methods/accounts)
- [`POST /api/v1/apps`](https://docs.joinmastodon.org/methods/apps/) - [`POST /api/v1/apps`](https://docs.joinmastodon.org/methods/apps/)
- [`GET /api/v1/apps/verify_credentials`](https://docs.joinmastodon.org/methods/apps/) - [`GET /api/v1/apps/verify_credentials`](https://docs.joinmastodon.org/methods/apps/)
@ -72,7 +73,7 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
- `:id` is a follow request ID, not a regular account id - `:id` is a follow request ID, not a regular account id
- Returns a [Relationship](https://docs.joinmastodon.org/entities/relationship) object. - Returns a [Relationship](https://docs.joinmastodon.org/entities/relationship) object.
- [`GET /api/v1/followed_tags'](https://docs.joinmastodon.org/methods/followed_tags/)
- [`GET /api/v1/instance`](https://docs.joinmastodon.org/methods/instance#fetch-instance) - [`GET /api/v1/instance`](https://docs.joinmastodon.org/methods/instance#fetch-instance)
- `GET /api/v1/instance/rules` Undocumented, returns Terms of Service - `GET /api/v1/instance/rules` Undocumented, returns Terms of Service
- [`GET /api/v1/instance/peers`](https://docs.joinmastodon.org/methods/instance#list-of-connected-domains) - [`GET /api/v1/instance/peers`](https://docs.joinmastodon.org/methods/instance#list-of-connected-domains)
@ -100,35 +101,44 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
- [`GET /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/) - [`GET /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/)
- [`PUSH /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/) - [`PUSH /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/)
- [`PUT /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/) - [`PUT /api/v1/push/subscription`](https://docs.joinmastodon.org/methods/notifications/push/)
- [`POST /api/v1/reports`](https://docs.joinmastodon.org/methods/accounts/reports/)
- [`GET /api/v1/scheduled_statuses`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/) - [`GET /api/v1/scheduled_statuses`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/)
- [`DELETE /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/) - [`DELETE /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/)
- [`GET /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/) - [`GET /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/)
- [`GET /api/v1/search`](https://docs.joinmastodon.org/methods/search/) - [`GET /api/v1/search`](https://docs.joinmastodon.org/methods/search/)
- [`POST /api/v1/statuses`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses`](https://docs.joinmastodon.org/methods/statuses/#create)
- Additionally to the static values `public`, `unlisted` and `private`, the `visibility` parameter can contain a numeric value with a group id. - Additionally to the static values `public`, `unlisted` and `private`, the `visibility` parameter can contain a numeric value with a group id.
- [`GET /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/) - [`GET /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/#get)
- [`DELETE /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/) - [`DELETE /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/#delete)
- [`GET /api/v1/statuses/:id/card`](https://docs.joinmastodon.org/methods/statuses/) - [`GET /api/v1/statuses/:id/context`](https://docs.joinmastodon.org/methods/statuses/#context)
- [`GET /api/v1/statuses/:id/context`](https://docs.joinmastodon.org/methods/statuses/) - [`GET /api/v1/statuses/:id/reblogged_by`](https://docs.joinmastodon.org/methods/statuses/#reblogged_by)
- [`GET /api/v1/statuses/:id/reblogged_by`](https://docs.joinmastodon.org/methods/statuses/) - [`GET /api/v1/statuses/:id/favourited_by`](https://docs.joinmastodon.org/methods/statuses/#favourited_by)
- [`GET /api/v1/statuses/:id/favourited_by`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/favourite`](https://docs.joinmastodon.org/methods/statuses/#favourite)
- [`POST /api/v1/statuses/:id/favourite`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/unfavourite`](https://docs.joinmastodon.org/methods/statuses/#unfavourite)
- [`POST /api/v1/statuses/:id/unfavourite`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/reblog`](https://docs.joinmastodon.org/methods/statuses/#boost)
- [`POST /api/v1/statuses/:id/reblog`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/unreblog`](https://docs.joinmastodon.org/methods/statuses/#unreblog)
- [`POST /api/v1/statuses/:id/unreblog`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/bookmark`](https://docs.joinmastodon.org/methods/statuses/#bookmark)
- [`POST /api/v1/statuses/:id/bookmark`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/unbookmark`](https://docs.joinmastodon.org/methods/statuses/#unbookmark)
- [`POST /api/v1/statuses/:id/unbookmark`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/mute`](https://docs.joinmastodon.org/methods/statuses/#mute)
- [`POST /api/v1/statuses/:id/mute`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/unmute`](https://docs.joinmastodon.org/methods/statuses/#unmute)
- [`POST /api/v1/statuses/:id/unmute`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/pin`](https://docs.joinmastodon.org/methods/statuses/#pin)
- [`POST /api/v1/statuses/:id/pin`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id/unpin`](https://docs.joinmastodon.org/methods/statuses/#unpin)
- [`POST /api/v1/statuses/:id/unpin`](https://docs.joinmastodon.org/methods/statuses/) - [`POST /api/v1/statuses/:id`](https://docs.joinmastodon.org/methods/statuses/#edit)
- [`GET /api/v1/statuses/:id/source`](https://docs.joinmastodon.org/methods/statuses/#source)
- [`GET /api/v1/statuses/:id/card`](https://docs.joinmastodon.org/methods/statuses/#card)
- [`GET /api/v1/suggestions`](https://docs.joinmastodon.org/methods/accounts/suggestions/) - [`GET /api/v1/suggestions`](https://docs.joinmastodon.org/methods/accounts/suggestions/)
- [`GET /api/v1/tags/:id`](https://docs.joinmastodon.org/methods/tags/#get)
- [`GET /api/v1/tags/:id/follow`](https://docs.joinmastodon.org/methods/tags/#follow)
- [`GET /api/v1/tags/:id/unfollow`](https://docs.joinmastodon.org/methods/tags/#unfollow)
- [`GET /api/v1/timelines/direct`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/direct`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/home`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/home`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/list/:id`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/list/:id`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/public`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/public`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/timelines/tag/:hashtag`](https://docs.joinmastodon.org/methods/timelines/) - [`GET /api/v1/timelines/tag/:hashtag`](https://docs.joinmastodon.org/methods/timelines/)
- [`GET /api/v1/trends`](https://docs.joinmastodon.org/methods/instance/trends/) - [`GET /api/v1/trends`](https://docs.joinmastodon.org/methods/instance/trends/)
- [`GET /api/v1/trends/links`](https://github.com/mastodon/mastodon/pull/16917)
- [`GET /api/v1/trends/statuses`](https://docs.joinmastodon.org/methods/trends/#statuses)
- [`GET /api/v1/trends/tags`](https://docs.joinmastodon.org/methods/trends/#tags)
- [`GET /api/v2/search`](https://docs.joinmastodon.org/methods/search/) - [`GET /api/v2/search`](https://docs.joinmastodon.org/methods/search/)
@ -136,15 +146,10 @@ These endpoints use the [Mastodon API entities](https://docs.joinmastodon.org/en
These emdpoints are planned to be implemented somewhere in the future. These emdpoints are planned to be implemented somewhere in the future.
- [`PATCH /api/v1/accounts/update_credentials`](https://docs.joinmastodon.org/methods/accounts/)
- [`POST /api/v1/accounts/:id/remove_from_followers`](https://github.com/mastodon/mastodon/pull/16864) - [`POST /api/v1/accounts/:id/remove_from_followers`](https://github.com/mastodon/mastodon/pull/16864)
- [`GET /api/v1/accounts/familiar_followers`](https://github.com/mastodon/mastodon/pull/17700) - [`GET /api/v1/accounts/familiar_followers`](https://github.com/mastodon/mastodon/pull/17700)
- [`GET /api/v1/accounts/lookup`](https://github.com/mastodon/mastodon/pull/15740) - [`GET /api/v1/accounts/lookup`](https://github.com/mastodon/mastodon/pull/15740)
- [`GET /api/v1/trends/links`](https://github.com/mastodon/mastodon/pull/16917)
- [`GET /api/v1/trends/statuses`](https://github.com/mastodon/mastodon/pull/17431)
- [`GET /api/v1/trends/tags`](https://github.com/mastodon/mastodon/pull/16917)
- [`POST /api/v1/polls/:id/votes`](https://docs.joinmastodon.org/methods/statuses/polls/) - [`POST /api/v1/polls/:id/votes`](https://docs.joinmastodon.org/methods/statuses/polls/)
- [`GET /api/v1/statuses/{id:\d+}/source`](https://github.com/mastodon/mastodon/pull/16697)
- [`GET /api/v1/featured_tags`](https://docs.joinmastodon.org/methods/accounts/featured_tags/) - [`GET /api/v1/featured_tags`](https://docs.joinmastodon.org/methods/accounts/featured_tags/)
- [`POST /api/v1/featured_tags`](https://docs.joinmastodon.org/methods/accounts/featured_tags/) - [`POST /api/v1/featured_tags`](https://docs.joinmastodon.org/methods/accounts/featured_tags/)
- [`DELETE /api/v1/featured_tags/:id`](https://docs.joinmastodon.org/methods/accounts/featured_tags/) - [`DELETE /api/v1/featured_tags/:id`](https://docs.joinmastodon.org/methods/accounts/featured_tags/)
@ -189,7 +194,6 @@ They refer to features or data that don't exist in Friendica yet.
- [`DELETE /api/v1/filters/:id`](https://docs.joinmastodon.org/methods/accounts/filters/) - [`DELETE /api/v1/filters/:id`](https://docs.joinmastodon.org/methods/accounts/filters/)
- [`GET /api/v1/instance/activity`](https://docs.joinmastodon.org/methods/instance#weekly-activity) - [`GET /api/v1/instance/activity`](https://docs.joinmastodon.org/methods/instance#weekly-activity)
- [`POST /api/v1/markers`](https://docs.joinmastodon.org/methods/timelines/markers/) - [`POST /api/v1/markers`](https://docs.joinmastodon.org/methods/timelines/markers/)
- [`POST /api/v1/reports`](https://docs.joinmastodon.org/methods/accounts/reports/)
- [`PUT /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/) - [`PUT /api/v1/scheduled_statuses/:id`](https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/)
- [`GET /api/v1/statuses/{id:\d+}/history`](https://github.com/mastodon/mastodon/pull/16697) - [`GET /api/v1/statuses/{id:\d+}/history`](https://github.com/mastodon/mastodon/pull/16697)
- [`GET /api/v1/streaming`](https://docs.joinmastodon.org/methods/timelines/streaming/) - [`GET /api/v1/streaming`](https://docs.joinmastodon.org/methods/timelines/streaming/)

View file

@ -19,6 +19,7 @@ General
* c - Community * c - Community
* s - Search * s - Search
* a - Admin * a - Admin
* m - Moderation
* f - Notifications * f - Notifications
* u - User menu * u - User menu

View file

@ -281,7 +281,7 @@ $data = [
'submit' => [ 'submit' => [
'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'), 'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'),
'catavatar-morecat' => DI::l10n()->t('Another random Cat!'), 'catavatar-morecat' => DI::l10n()->t('Another random Cat!'),
'catavatar-emailcat' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null, 'catavatar-emailcat' => DI::pConfig()->get(Session::getLocalUser(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
], ],
]; ];
``` ```
@ -790,10 +790,6 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('post_local', $datarray); Hook::callAll('post_local', $datarray);
Hook::callAll('post_local_end', $datarray); Hook::callAll('post_local_end', $datarray);
### mod/editpost.php
Hook::callAll('jot_tool', $jotplugins);
### src/Render/FriendicaSmartyEngine.php ### src/Render/FriendicaSmartyEngine.php
Hook::callAll("template_vars", $arr); Hook::callAll("template_vars", $arr);
@ -855,6 +851,10 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('lockview_content', $item); Hook::callAll('lockview_content', $item);
### src/Module/Post/Edit.php
Hook::callAll('jot_tool', $jotplugins);
### src/Module/Settings/Delegation.php ### src/Module/Settings/Delegation.php
Hook::callAll('authenticate', $addon_auth); Hook::callAll('authenticate', $addon_auth);
@ -919,6 +919,10 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('block', $hook_data); Hook::callAll('block', $hook_data);
Hook::callAll('unblock', $hook_data); Hook::callAll('unblock', $hook_data);
### src/Core/Logger/Factory.php
Hook::callAll('logger_instance', $data);
### src/Core/StorageManager ### src/Core/StorageManager
Hook::callAll('storage_instance', $data); 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. 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 through `boot.php`. 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.
* [Class autoloading](help/autoloader) * [Class autoloading](help/autoloader)

View file

@ -37,8 +37,8 @@ The `config` directory holds key configuration files and can have different conf
All of them have to end with `.config.php` and must not include `-sample` in their name. All of them have to end with `.config.php` and must not include `-sample` in their name.
Some examples of common known configuration files: Some examples of common known configuration files:
- `local.config.php` holds the current node custom configuration. - `local.config.php` holds the base node custom configuration.
- `addon.config.php` is optional and holds the custom configuration for specific addons. - Any other file in this folder is meant for additional configuration (e.g. for addons).
Addons can define their own default configuration values in `addon/[addon]/config/[addon].config.php` which is loaded when the addon is activated. Addons can define their own default configuration values in `addon/[addon]/config/[addon].config.php` which is loaded when the addon is activated.
@ -59,7 +59,7 @@ Currently, the following configurations are included:
The legacy `.htconfig.php` configuration file is still supported, but is deprecated and will be removed in a subsequent Friendica release. The legacy `.htconfig.php` configuration file is still supported, but is deprecated and will be removed in a subsequent Friendica release.
The migration is pretty straightforward: The migration is pretty straightforward:
If you had any addon-specific configuration in your `.htconfig.php`, just copy `config/addon-sample.config.php` to `config/addon.config.php` and move your configuration values. If you had any addon-specific configuration in your `.htconfig.php`, copy `config/local-sample.config.php` to `config/addon.config.php` and move your configuration values.
Afterwards, copy `config/local-sample.config.php` to `config/local.config.php`, move the remaining configuration values to it according to the following conversion chart, then rename your `.htconfig.php` to check your node is working as expected before deleting it. Afterwards, copy `config/local-sample.config.php` to `config/local.config.php`, move the remaining configuration values to it according to the following conversion chart, then rename your `.htconfig.php` to check your node is working as expected before deleting it.
<style> <style>
@ -206,7 +206,7 @@ $lang = "value";
The legacy `config/local.ini.php` configuration file is still supported, but is deprecated and will be removed in a subsequent Friendica release. The legacy `config/local.ini.php` configuration file is still supported, but is deprecated and will be removed in a subsequent Friendica release.
The migration is pretty straightforward: The migration is pretty straightforward:
If you had any addon-specific configuration in your `config/addon.ini.php`, just copy `config/addon-sample.config.php` to `config/addon.config.php` and move your configuration values. If you had any addon-specific configuration in your `config/addon.ini.php`, copy `config/local-sample.config.php` to `config/addon.config.php` and move your configuration values.
Afterwards, copy `config/local-sample.config.php` to `config/local.config.php`, move the remaining configuration values to it according to the following conversion chart, then rename your `config/local.ini.php` file to check your node is working as expected before deleting it. Afterwards, copy `config/local-sample.config.php` to `config/local.config.php`, move the remaining configuration values to it according to the following conversion chart, then rename your `config/local.ini.php` file to check your node is working as expected before deleting it.
<table class="config"> <table class="config">
@ -278,16 +278,16 @@ key[] = value3
### Database Settings ### Database Settings
The configuration variables database.hostname, database.username, database.password, database.database and database.charset are holding your credentials for the database connection. The configuration variables `database.hostname` (or `database.socket`), `database.username`, `database.password`, `database.database` and optionally `database.charset` are holding your credentials for the database connection.
If you need to specify a port to access the database, you can do so by appending ":portnumber" to the database.hostname variable. If you need to specify a port to access the database, you can do so by appending ":portnumber" to the `database.hostname` variable.
'database' => [ 'database' => [
'hostname' => 'your.mysqlhost.com:123456', 'hostname' => 'your.mysqlhost.com:123456',
] ]
If all of the following environment variables are set, Friendica will use them instead of the previously configured variables for the db: If all the following environment variables are set, Friendica will use them instead of the previously configured variables for the db:
MYSQL_HOST MYSQL_HOST or MYSQL_SOCKET
MYSQL_PORT MYSQL_PORT
MYSQL_USERNAME MYSQL_USERNAME
MYSQL_PASSWORD MYSQL_PASSWORD
@ -316,7 +316,7 @@ Enabling the admin panel for an account, and thus making the account holder admi
Where you have to match the email address used for the account with the one you enter to the `config/local.config.php` file. Where you have to match the email address used for the account with the one you enter to the `config/local.config.php` file.
If more then one account should be able to access the admin panel, separate the email addresses with a comma. If more than one account should be able to access the admin panel, separate the email addresses with a comma.
'config' => [ 'config' => [
'admin_email' => 'someone@example.com,someoneelse@example.com', 'admin_email' => 'someone@example.com,someoneelse@example.com',

View file

@ -9,8 +9,8 @@ There is also a connector for accessing your email INBOX.
If the following network connectors are installed on your system, select the following links to visit the appropriate settings page and configure them for your account: If the following network connectors are installed on your system, select the following links to visit the appropriate settings page and configure them for your account:
* [Twitter](/settings/addon) * [Twitter](/settings/addons)
* [GNU Social](/settings/addon) * [GNU Social](/settings/addons)
* [Email](/settings) * [Email](/settings)
Instructions For Connecting To People On Specific Services Instructions For Connecting To People On Specific Services

View file

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

@ -50,7 +50,7 @@ We recommend to talk to the admin(s) of the affected friendica server. (Admins,
### How can I upload images, files, links, videos and sound files to posts? ### How can I upload images, files, links, videos and sound files to posts?
You can upload images from your computer using the [editor](help/Text_editor). You can upload images from your computer using the [editor](help/Text_editor).
An overview of all uploaded images is listed at *yourpage.com/photos/profilename*. An overview of all uploaded images is listed at *yourpage.com/profile/profilename/photos*.
On that page, you can also upload images directly and choose if your contacts will receive a message about this upload. On that page, you can also upload images directly and choose if your contacts will receive a message about this upload.
Generally, you can attach any kind of file to a post. Generally, you can attach any kind of file to a post.
@ -178,47 +178,40 @@ The available features are client specific and may differ.
#### Android #### Android
* [AndStatus](http://andstatus.org) ([F-Droid](https://f-droid.org/repository/browse/?fdid=org.andstatus.app), [Google Play](https://play.google.com/store/apps/details?id=org.andstatus.app)) * [AndStatus](http://andstatus.org) ([F-Droid](https://f-droid.org/repository/browse/?fdid=org.andstatus.app), [Google Play](https://play.google.com/store/apps/details?id=org.andstatus.app))
* [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma) * [Fedi](https://github.com/Big-Fig/Fediverse.app) ([Google Play](https://play.google.com/store/apps/details?id=com.fediverse.app))
* [Fedi](https://play.google.com/store/apps/details?id=com.fediverse.app)
* [Fedilab](https://fedilab.app) ([F-Droid](https://f-droid.org/app/fr.gouv.etalab.mastodon), [Google Play](https://play.google.com/store/apps/details?id=app.fedilab.android)) * [Fedilab](https://fedilab.app) ([F-Droid](https://f-droid.org/app/fr.gouv.etalab.mastodon), [Google Play](https://play.google.com/store/apps/details?id=app.fedilab.android))
* [Friendiqa](https://git.friendi.ca/lubuwest/Friendiqa) ([F-Droid](https://git.friendi.ca/lubuwest/Friendiqa#install), [Google Play](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa)) * [Friendiqa](https://git.friendi.ca/lubuwest/Friendiqa) ([F-Droid](https://git.friendi.ca/lubuwest/Friendiqa#install), [Google Play](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa))
* [Husky](https://git.sr.ht/~captainepoch/husky) ([F-Droid](https://f-droid.org/repository/browse/?fdid=su.xash.husky), [Google Play](https://play.google.com/store/apps/details?id=su.xash.husky)) * [Husky](https://git.sr.ht/~captainepoch/husky) ([F-Droid](https://f-droid.org/repository/browse/?fdid=su.xash.husky), [Google Play](https://play.google.com/store/apps/details?id=su.xash.husky))
* [Mastodon for Android](https://github.com/mastodon/mastodon-android) (F-Droid: Pending, [Google-Play](https://play.google.com/store/apps/details?id=org.joinmastodon.android)) * [Mastodon](https://github.com/mastodon/mastodon-android) ([F-Droid](https://f-droid.org/en/packages/org.joinmastodon.android/), [Google Play](https://play.google.com/store/apps/details?id=org.joinmastodon.android))
* [Subway Tooter](https://github.com/tateisu/SubwayTooter) * [Subway Tooter](https://github.com/tateisu/SubwayTooter) ([F-Droid](https://android.izzysoft.de/repo/apk/jp.juggler.subwaytooter))
* [Tooot](https://tooot.app/) * [Tooot](https://tooot.app/) ([Google Play](https://play.google.com/store/apps/details?id=com.xmflsct.app.tooot))
* [Tusky](https://tusky.app) ([F-Droid](https://f-droid.org/repository/browse/?fdid=com.keylesspalace.tusky), [Google Play](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky)) * [Tusky](https://tusky.app) ([F-Droid](https://f-droid.org/repository/browse/?fdid=com.keylesspalace.tusky), [Google Play](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky))
* [Twidere](https://github.com/TwidereProject/Twidere-Android) ([F-Droid](https://f-droid.org/repository/browse/?fdid=org.mariotaku.twidere), [Google Play](https://play.google.com/store/apps/details?id=com.twidere.twiderex))
* [TwidereX](https://github.com/TwidereProject/TwidereX-Android) ([F-Droid](https://f-droid.org/en/packages/com.twidere.twiderex/), [Google Play](https://play.google.com/store/apps/details?id=com.twidere.twiderex)) * [TwidereX](https://github.com/TwidereProject/TwidereX-Android) ([F-Droid](https://f-droid.org/en/packages/com.twidere.twiderex/), [Google Play](https://play.google.com/store/apps/details?id=com.twidere.twiderex))
* [Yuito](https://github.com/accelforce/Yuito) ([Google Play](https://play.google.com/store/apps/details?id=net.accelf.yuito)) * [Yuito](https://github.com/accelforce/Yuito) ([Google Play](https://play.google.com/store/apps/details?id=net.accelf.yuito))
#### SailfishOS
* [Friendly](https://openrepos.net/content/fabrixxm/friendly), last update: 2018
#### iOS #### iOS
* [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma) ([AppStore](https://apps.apple.com/app/b4x-pleroma/id1538396871)) * [Fedi](https://github.com/Big-Fig/Fediverse.app) ([AppStore](https://apps.apple.com/de/app/fedi-for-pleroma-and-mastodon/id1478806281))
* [Fedi](https://fediapp.com) ([AppStore](https://apps.apple.com/de/app/fedi-for-pleroma-and-mastodon/id1478806281)) * [Mastodon](https://joinmastodon.org/apps) ([AppStore](https://apps.apple.com/us/app/mastodon-for-iphone/id1571998974))
* [Mastodon for iPhone and iPad](https://joinmastodon.org/apps) ([AppStore](https://apps.apple.com/us/app/mastodon-for-iphone/id1571998974))
* [Stella*](https://www.stella-app.net/) ([AppStore](https://apps.apple.com/us/app/stella-for-mastodon-twitter/id921372048)) * [Stella*](https://www.stella-app.net/) ([AppStore](https://apps.apple.com/us/app/stella-for-mastodon-twitter/id921372048))
* [Tooot](https://github.com/tooot-app) ([AppStore](https://apps.apple.com/app/id1549772269), Data collection (not linked to identity) * [Tooot](https://github.com/tooot-app) ([AppStore](https://apps.apple.com/app/id1549772269)
* [Tootle](https://mastodon.cloud/@tootleapp) ([AppStore](https://apps.apple.com/de/app/tootle-for-mastodon/id1236013466)), last update: 2020 * [TwidereX](https://github.com/TwidereProject/TwidereX-iOS) ([AppStore](https://apps.apple.com/app/twidere-x/id1530314034))
#### Linux #### Linux
* [Choqok](https://choqok.kde.org) * [Choqok](https://choqok.kde.org)
* [Whalebird](https://whalebird.social) * [Whalebird](https://whalebird.social/en/desktop/contents) ([GitHub](https://github.com/h3poteto/whalebird-desktop))
* [TheDesk](https://ja.mstdn.wiki/TheDesk) * [TheDesk](https://thedesk.top/en/) ([GitHub](https://github.com/cutls/TheDesk))
* [Toot](https://toot.readthedocs.io/en/latest/) * [Toot](https://toot.readthedocs.io/en/latest/)
* [Tootle](https://github.com/bleakgrey/tootle)
#### macOS #### macOS
* [Mastonaut](https://mastonaut.app/) ([AppStore](https://apps.apple.com/us/app/mastonaut/id1450757574)), closed source * [TheDesk](https://thedesk.top/en/) ([GitHub](https://github.com/cutls/TheDesk))
* [Whalebird](https://whalebird.social/en/desktop/contents) ([AppStore](https://apps.apple.com/de/app/whalebird/id1378283354), [GitHub](https://github.com/h3poteto/whalebird-desktop)) * [Whalebird](https://whalebird.social/en/desktop/contents) ([AppStore](https://apps.apple.com/de/app/whalebird/id1378283354), [GitHub](https://github.com/h3poteto/whalebird-desktop))
#### Windows #### Windows
* [TheDesk](https://thedesk.top/en/) ([GitHub](https://github.com/cutls/TheDesk))
* [Whalebird](https://whalebird.social/en/desktop/contents) ([Website Download](https://whalebird.social/en/desktop/contents/downloads#windows), [GitHub](https://github.com/h3poteto/whalebird-desktop)) * [Whalebird](https://whalebird.social/en/desktop/contents) ([Website Download](https://whalebird.social/en/desktop/contents/downloads#windows), [GitHub](https://github.com/h3poteto/whalebird-desktop))
#### Web Frontend #### Web Frontend

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) * 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. * 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. 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 5.6+ or an equivalent alternative for MySQL (MariaDB, Percona Server etc.) * 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)
* ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows) * 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. * 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

@ -9,8 +9,8 @@ How to move your account between servers
* Go to "Settings" -> "[Export personal data](uexport)" * Go to "Settings" -> "[Export personal data](uexport)"
* Click on "Export account" to save your account data. * Click on "Export account" to save your account data.
* **Save the file in a secure place!** It contains your details, your contacts, groups, and personal settings. It also contains your secret keys to authenticate yourself to your contacts. * **Save the file in a secure place!** It contains your details, your contacts, groups, and personal settings. It also contains your secret keys to authenticate yourself to your contacts.
* Go to your new server, and open *http://newserver.com/uimport* (there is not a direct link to this page at the moment). Please consider that this is only possible on servers with open registration. On other systems only the administrator can add accounts with an uploaded file. * Go to your new server, and open *http://newserver.com/user/import* (there is not a direct link to this page at the moment). Please consider that this is only possible on servers with open registration. On other systems only the administrator can add accounts with an uploaded file.
* Do NOT create a new account prior to importing your old settings - uimport should be used *instead* of register. * Do NOT create a new account prior to importing your old settings - user import should be used *instead* of register.
* Load your saved account file and click "Import". * Load your saved account file and click "Import".
* After the move, the account on the old server will not work reliably anymore, and should be not used. * After the move, the account on the old server will not work reliably anymore, and should be not used.

View file

@ -5,7 +5,7 @@ Remove Account
We don't like to see people leave Friendica, but if you need to remove your account, you should visit the URL We don't like to see people leave Friendica, but if you need to remove your account, you should visit the URL
http://sitename/removeme http://sitename/settings/removeme
with your web browser. with your web browser.
You will need to be logged in at the time. You will need to be logged in at the time.

View file

@ -30,13 +30,3 @@ Here you can find an overview of the different ways to comment and sort existing
<P style="clear: both;"></p> <P style="clear: both;"></p>
<img src="doc/img/post_choose.png" width="27" height="32" alt="post_choose.png" align="left"> This symbol is used to choose more than one post to delete in a single step. After selecting all posts, go to the end of the page and click "Delete Selected Items".<P style="clear: both;"></p> <img src="doc/img/post_choose.png" width="27" height="32" alt="post_choose.png" align="left"> This symbol is used to choose more than one post to delete in a single step. After selecting all posts, go to the end of the page and click "Delete Selected Items".<P style="clear: both;"></p>
**Symbols of other themes**
Darkbubble <img src="doc/img/darkbubble.png" alt="darkbubble.png" style="padding-left: 20px; vertical-align:middle;">
Darkzero <img src="doc/img/darkzero.png" alt="darkzero.png" style="padding-left: 35px; vertical-align:middle;">
<span style="padding-left: 10px; font-style:italic;">(incl. more "zero"-themes, slackr, comix, easterbunny, facepark)</span>
Dispy <img src="doc/img/dispy.png" alt="dispy.png" style="padding-left: 57px; vertical-align:middle;"> <i>(incl. smoothly, testbubble)</i>

View file

@ -24,10 +24,6 @@ Below are examples of the post editor in 3 of Friendica's common themes:
<figcaption>Post editor, with the <b>Vier</b> theme.</figcaption> <figcaption>Post editor, with the <b>Vier</b> theme.</figcaption>
</figure> </figure>
<p style="clear:both;"></p> <p style="clear:both;"></p>
<figure>
<img src="doc/img/editor_dpzero.png" alt="duepuntozero editor">
<figcaption>Post editor, with the <b>Duepuntozero</b> theme.</figcaption>
</figure>
Post title is optional, you can set it by clicking on "Set title". Post title is optional, you can set it by clicking on "Set title".
@ -73,11 +69,6 @@ These icons can change depending on the theme. Some examples:
<td><img src="doc/img/vier_icons.png" alt="vier.png" style="vertical-align:middle;"></td> <td><img src="doc/img/vier_icons.png" alt="vier.png" style="vertical-align:middle;"></td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr>
<td>Smoothly: </td>
<td><img src="doc/img/editor_darkbubble.png" alt="darkbubble.png" style="vertical-align:middle;"></td>
<td>&nbsp;</td>
</tr>
</table> </table>
<i><b>*</b> how to [upload](help/FAQ#upload) files</i> <i><b>*</b> how to [upload](help/FAQ#upload) files</i>
<p style="clear:both;">&nbsp;</p> <p style="clear:both;">&nbsp;</p>

View file

@ -10,7 +10,7 @@ Getting started
No need to setup up a webserver, database etc. before actually starting. 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. 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 7.4 and MariaDB 10.5.11. It brings an Debian Bullseye with PHP 8.0 and MariaDB 10.5.11.
What you need to do: 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. 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. 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. 5. Open you test installation in a browser.
Go to friendica.local (or 192.168.22.10). Go to friendica.local (or 192.168.56.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. 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". 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). 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). 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. 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 through `boot.php`. 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.
* [Using Composer](help/Composer) * [Using Composer](help/Composer)
@ -39,7 +39,6 @@ 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`. 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 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: The code will be something like:

View file

@ -8,6 +8,7 @@ Database Tables
| [2fa_app_specific_password](help/database/db_2fa_app_specific_password) | Two-factor app-specific _password | | [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_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 | | [2fa_trusted_browser](help/database/db_2fa_trusted_browser) | Two-factor authentication trusted browsers |
| [account-suggestion](help/database/db_account-suggestion) | Account suggestion |
| [account-user](help/database/db_account-user) | Remote and local accounts | | [account-user](help/database/db_account-user) | Remote and local accounts |
| [addon](help/database/db_addon) | registered addons | | [addon](help/database/db_addon) | registered addons |
| [apcontact](help/database/db_apcontact) | ActivityPub compatible contacts - used in the ActivityPub implementation | | [apcontact](help/database/db_apcontact) | ActivityPub compatible contacts - used in the ActivityPub implementation |
@ -22,10 +23,10 @@ Database Tables
| [contact-relation](help/database/db_contact-relation) | Contact relations | | [contact-relation](help/database/db_contact-relation) | Contact relations |
| [conv](help/database/db_conv) | private messages | | [conv](help/database/db_conv) | private messages |
| [delayed-post](help/database/db_delayed-post) | Posts that are about to be distributed at a later time | | [delayed-post](help/database/db_delayed-post) | Posts that are about to be distributed at a later time |
| [diaspora-contact](help/database/db_diaspora-contact) | Diaspora compatible contacts - used in the Diaspora implementation |
| [diaspora-interaction](help/database/db_diaspora-interaction) | Signed Diaspora Interaction | | [diaspora-interaction](help/database/db_diaspora-interaction) | Signed Diaspora Interaction |
| [endpoint](help/database/db_endpoint) | ActivityPub endpoints - used in the ActivityPub implementation | | [endpoint](help/database/db_endpoint) | ActivityPub endpoints - used in the ActivityPub implementation |
| [event](help/database/db_event) | Events | | [event](help/database/db_event) | Events |
| [fcontact](help/database/db_fcontact) | Diaspora compatible contacts - used in the Diaspora implementation |
| [fetch-entry](help/database/db_fetch-entry) | | | [fetch-entry](help/database/db_fetch-entry) | |
| [fetched-activity](help/database/db_fetched-activity) | Id of fetched activities | | [fetched-activity](help/database/db_fetched-activity) | Id of fetched activities |
| [fsuggest](help/database/db_fsuggest) | friend suggestion stuff | | [fsuggest](help/database/db_fsuggest) | friend suggestion stuff |
@ -74,6 +75,8 @@ Database Tables
| [profile_field](help/database/db_profile_field) | Custom profile fields | | [profile_field](help/database/db_profile_field) | Custom profile fields |
| [push_subscriber](help/database/db_push_subscriber) | Used for OStatus: Contains feed subscribers | | [push_subscriber](help/database/db_push_subscriber) | Used for OStatus: Contains feed subscribers |
| [register](help/database/db_register) | registrations requiring admin approval | | [register](help/database/db_register) | registrations requiring admin approval |
| [report](help/database/db_report) | |
| [report-post](help/database/db_report-post) | |
| [search](help/database/db_search) | | | [search](help/database/db_search) | |
| [session](help/database/db_session) | web session storage | | [session](help/database/db_session) | web session storage |
| [storage](help/database/db_storage) | Data stored by Database storage backend | | [storage](help/database/db_storage) | Data stored by Database storage backend |

View file

@ -0,0 +1,32 @@
Table account-suggestion
===========
Account suggestion
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------ | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the account url | int unsigned | NO | PRI | NULL | |
| uid | User ID | mediumint unsigned | NO | PRI | NULL | |
| level | level of closeness | smallint unsigned | YES | | NULL | |
| ignore | If set, this account will not be suggested again | boolean | NO | | 0 | |
Indexes
------------
| Name | Fields |
| ---------- | ----------- |
| PRIMARY | uid, uri-id |
| uri-id_uid | uri-id, uid |
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

@ -0,0 +1,52 @@
Table diaspora-contact
===========
Diaspora compatible contacts - used in the Diaspora implementation
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ----------------- | ------------------------------------------------------------ | ------------ | ---- | --- | ------------------- | ----- |
| uri-id | Id of the item-uri table entry that contains the contact URL | int unsigned | NO | PRI | NULL | |
| addr | | varchar(255) | YES | | NULL | |
| alias | | varchar(255) | YES | | NULL | |
| nick | | varchar(255) | YES | | NULL | |
| name | | varchar(255) | YES | | NULL | |
| given-name | | varchar(255) | YES | | NULL | |
| family-name | | varchar(255) | YES | | NULL | |
| photo | | varchar(255) | YES | | NULL | |
| photo-medium | | varchar(255) | YES | | NULL | |
| photo-small | | varchar(255) | YES | | NULL | |
| batch | | varchar(255) | YES | | NULL | |
| notify | | varchar(255) | YES | | NULL | |
| poll | | varchar(255) | YES | | NULL | |
| subscribe | | varchar(255) | YES | | NULL | |
| searchable | | boolean | YES | | NULL | |
| pubkey | | text | YES | | NULL | |
| gsid | Global Server ID | int unsigned | 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 | |
| post_count | Number of posts and comments | int unsigned | YES | | 0 | |
Indexes
------------
| Name | Fields |
| ------- | ------------ |
| PRIMARY | uri-id |
| addr | UNIQUE, addr |
| alias | alias |
| gsid | gsid |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| gsid | [gserver](help/database/db_gserver) | id |
Return to [database documentation](help/database)

View file

@ -1,51 +0,0 @@
Table fcontact
===========
Diaspora compatible contacts - used in the Diaspora implementation
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 | | | |
| 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 | | | |
| nick | | varchar(255) | NO | | | |
| addr | | varchar(255) | NO | | | |
| batch | | varbinary(383) | NO | | | |
| notify | | varbinary(383) | NO | | | |
| poll | | varbinary(383) | NO | | | |
| confirm | | varbinary(383) | NO | | | |
| priority | | tinyint unsigned | NO | | 0 | |
| network | | char(4) | NO | | | |
| alias | | varbinary(383) | 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 | |
| post_count | Number of posts and comments | int unsigned | YES | | 0 | |
Indexes
------------
| Name | Fields |
| ------- | ---------------- |
| PRIMARY | id |
| addr | addr(32) |
| url | UNIQUE, url(190) |
| uri-id | UNIQUE, uri-id |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
Return to [database documentation](help/database)

View file

@ -25,6 +25,7 @@ Fields
| height | | smallint unsigned | NO | | 0 | | | height | | smallint unsigned | NO | | 0 | |
| width | | smallint unsigned | NO | | 0 | | | width | | smallint unsigned | NO | | 0 | |
| datasize | | int unsigned | NO | | 0 | | | datasize | | int unsigned | NO | | 0 | |
| blurhash | BlurHash representation of the photo | varbinary(255) | YES | | NULL | |
| data | | mediumblob | NO | | NULL | | | data | | mediumblob | NO | | NULL | |
| scale | | tinyint unsigned | NO | | 0 | | | scale | | tinyint unsigned | NO | | 0 | |
| profile | | boolean | NO | | 0 | | | profile | | boolean | NO | | 0 | |

View file

@ -13,6 +13,7 @@ Fields
| content-warning | | varchar(255) | NO | | | | | content-warning | | varchar(255) | NO | | | |
| body | item body content | mediumtext | YES | | NULL | | | body | item body content | mediumtext | YES | | NULL | |
| raw-body | Body without embedded media links | 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 | | | | | location | text location where this item originated | varchar(255) | NO | | | |
| coord | longitude/latitude pair representing 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 | | | language | Language information about this post | text | YES | | NULL | |
@ -35,6 +36,7 @@ Indexes
| plink | plink(191) | | plink | plink(191) |
| resource-id | resource-id | | resource-id | resource-id |
| title-content-warning-body | FULLTEXT, title, content-warning, body | | title-content-warning-body | FULLTEXT, title, content-warning, body |
| quote-uri-id | quote-uri-id |
Foreign Keys Foreign Keys
------------ ------------
@ -42,5 +44,6 @@ Foreign Keys
| Field | Target Table | Target Field | | Field | Target Table | Target Field |
|-------|--------------|--------------| |-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id | | 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) Return to [database documentation](help/database)

View file

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

View file

@ -6,51 +6,52 @@ user profiles data
Fields Fields
------ ------
| Field | Description | Type | Null | Key | Default | Extra | | Field | Description | Type | Null | Key | Default | Extra |
| ------------ | --------------------------------------------- | ------------------ | ---- | --- | ---------- | -------------- | | ----------------- | -------------------------------------------------------------- | ------------------ | ---- | --- | ---------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uid | Owner User id | mediumint unsigned | NO | | 0 | | | uid | Owner User id | mediumint unsigned | NO | | 0 | |
| profile-name | Deprecated | varchar(255) | YES | | NULL | | | profile-name | Deprecated | varchar(255) | YES | | NULL | |
| is-default | Deprecated | boolean | YES | | NULL | | | is-default | Deprecated | boolean | YES | | NULL | |
| hide-friends | Hide friend list from viewers of this profile | boolean | NO | | 0 | | | hide-friends | Hide friend list from viewers of this profile | boolean | NO | | 0 | |
| name | | varchar(255) | NO | | | | | name | | varchar(255) | NO | | | |
| pdesc | Deprecated | varchar(255) | YES | | NULL | | | pdesc | Deprecated | varchar(255) | YES | | NULL | |
| dob | Day of birth | varchar(32) | NO | | 0000-00-00 | | | dob | Day of birth | varchar(32) | NO | | 0000-00-00 | |
| address | | varchar(255) | NO | | | | | address | | varchar(255) | NO | | | |
| locality | | varchar(255) | NO | | | | | locality | | varchar(255) | NO | | | |
| region | | varchar(255) | NO | | | | | region | | varchar(255) | NO | | | |
| postal-code | | varchar(32) | NO | | | | | postal-code | | varchar(32) | NO | | | |
| country-name | | varchar(255) | NO | | | | | country-name | | varchar(255) | NO | | | |
| hometown | Deprecated | varchar(255) | YES | | NULL | | | hometown | Deprecated | varchar(255) | YES | | NULL | |
| gender | Deprecated | varchar(32) | YES | | NULL | | | gender | Deprecated | varchar(32) | YES | | NULL | |
| marital | Deprecated | varchar(255) | YES | | NULL | | | marital | Deprecated | varchar(255) | YES | | NULL | |
| with | Deprecated | text | YES | | NULL | | | with | Deprecated | text | YES | | NULL | |
| howlong | Deprecated | datetime | YES | | NULL | | | howlong | Deprecated | datetime | YES | | NULL | |
| sexual | Deprecated | varchar(255) | YES | | NULL | | | sexual | Deprecated | varchar(255) | YES | | NULL | |
| politic | Deprecated | varchar(255) | YES | | NULL | | | politic | Deprecated | varchar(255) | YES | | NULL | |
| religion | Deprecated | varchar(255) | YES | | NULL | | | religion | Deprecated | varchar(255) | YES | | NULL | |
| pub_keywords | | text | YES | | NULL | | | pub_keywords | | text | YES | | NULL | |
| prv_keywords | | text | YES | | NULL | | | prv_keywords | | text | YES | | NULL | |
| likes | Deprecated | text | YES | | NULL | | | likes | Deprecated | text | YES | | NULL | |
| dislikes | Deprecated | text | YES | | NULL | | | dislikes | Deprecated | text | YES | | NULL | |
| about | Profile description | text | YES | | NULL | | | about | Profile description | text | YES | | NULL | |
| summary | Deprecated | varchar(255) | YES | | NULL | | | summary | Deprecated | varchar(255) | YES | | NULL | |
| music | Deprecated | text | YES | | NULL | | | music | Deprecated | text | YES | | NULL | |
| book | Deprecated | text | YES | | NULL | | | book | Deprecated | text | YES | | NULL | |
| tv | Deprecated | text | YES | | NULL | | | tv | Deprecated | text | YES | | NULL | |
| film | Deprecated | text | YES | | NULL | | | film | Deprecated | text | YES | | NULL | |
| interest | Deprecated | text | YES | | NULL | | | interest | Deprecated | text | YES | | NULL | |
| romance | Deprecated | text | YES | | NULL | | | romance | Deprecated | text | YES | | NULL | |
| work | Deprecated | text | YES | | NULL | | | work | Deprecated | text | YES | | NULL | |
| education | Deprecated | text | YES | | NULL | | | education | Deprecated | text | YES | | NULL | |
| contact | Deprecated | text | YES | | NULL | | | contact | Deprecated | text | YES | | NULL | |
| homepage | | varchar(255) | NO | | | | | homepage | | varchar(255) | NO | | | |
| xmpp | XMPP address | varchar(255) | NO | | | | | homepage_verified | was the homepage verified by a rel-me link back to the profile | boolean | NO | | 0 | |
| matrix | Matrix address | varchar(255) | NO | | | | | xmpp | XMPP address | varchar(255) | NO | | | |
| photo | | varbinary(383) | NO | | | | | matrix | Matrix address | varchar(255) | NO | | | |
| thumb | | varbinary(383) | NO | | | | | photo | | varbinary(383) | NO | | | |
| publish | publish default profile in local directory | boolean | NO | | 0 | | | thumb | | varbinary(383) | NO | | | |
| net-publish | publish profile in global directory | boolean | NO | | 0 | | | publish | publish default profile in local directory | boolean | NO | | 0 | |
| net-publish | publish profile in global directory | boolean | NO | | 0 | |
Indexes Indexes
------------ ------------

View file

@ -0,0 +1,31 @@
Table report-post
===========
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------ | --------------------------- | ---------------- | ---- | --- | ------- | ----- |
| rid | Report id | int unsigned | NO | PRI | NULL | |
| uri-id | Uri-id of the reported post | int unsigned | NO | PRI | NULL | |
| status | Status of the reported post | tinyint unsigned | YES | | NULL | |
Indexes
------------
| Name | Fields |
| ------- | ----------- |
| PRIMARY | rid, uri-id |
| uri-id | uri-id |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| rid | [report](help/database/db_report) | id |
| uri-id | [item-uri](help/database/db_item-uri) | id |
Return to [database documentation](help/database)

36
doc/database/db_report.md Normal file
View file

@ -0,0 +1,36 @@
Table report
===========
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------- | --------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uid | Reporting user | mediumint unsigned | YES | | NULL | |
| cid | Reported contact | int unsigned | NO | | NULL | |
| comment | Report | text | YES | | NULL | |
| forward | Forward the report to the remote server | boolean | YES | | NULL | |
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
| status | Status of the report | tinyint unsigned | YES | | NULL | |
Indexes
------------
| Name | Fields |
| ------- | ------ |
| PRIMARY | id |
| uid | uid |
| cid | cid |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uid | [user](help/database/db_user) | uid |
| cid | [contact](help/database/db_contact) | id |
Return to [database documentation](help/database)

View file

@ -6,53 +6,54 @@ The local users
Fields Fields
------ ------
| Field | Description | Type | Null | Key | Default | Extra | | Field | Description | Type | Null | Key | Default | Extra |
| ------------------------ | --------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | ------------------------ | --------------------------------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- |
| uid | sequential ID | mediumint unsigned | NO | PRI | NULL | auto_increment | | uid | sequential ID | mediumint unsigned | NO | PRI | NULL | auto_increment |
| parent-uid | The parent user that has full control about this user | mediumint unsigned | YES | | NULL | | | parent-uid | The parent user that has full control about this user | mediumint unsigned | YES | | NULL | |
| guid | A unique identifier for this user | varchar(64) | NO | | | | | guid | A unique identifier for this user | varchar(64) | NO | | | |
| username | Name that this user is known by | varchar(255) | NO | | | | | username | Name that this user is known by | varchar(255) | NO | | | |
| password | encrypted password | varchar(255) | NO | | | | | password | encrypted password | varchar(255) | NO | | | |
| legacy_password | Is the password hash double-hashed? | boolean | NO | | 0 | | | legacy_password | Is the password hash double-hashed? | boolean | NO | | 0 | |
| nickname | nick- and user name | varchar(255) | NO | | | | | nickname | nick- and user name | varchar(255) | NO | | | |
| email | the users email address | varchar(255) | NO | | | | | email | the users email address | varchar(255) | NO | | | |
| openid | | varchar(255) | NO | | | | | openid | | varchar(255) | NO | | | |
| timezone | PHP-legal timezone | varchar(128) | NO | | | | | timezone | PHP-legal timezone | varchar(128) | NO | | | |
| language | default language | varchar(32) | NO | | en | | | language | default language | varchar(32) | NO | | en | |
| register_date | timestamp of registration | datetime | NO | | 0001-01-01 00:00:00 | | | register_date | timestamp of registration | datetime | NO | | 0001-01-01 00:00:00 | |
| login_date | timestamp of last login | datetime | NO | | 0001-01-01 00:00:00 | | | login_date | timestamp of last login | datetime | NO | | 0001-01-01 00:00:00 | |
| default-location | Default for item.location | varchar(255) | NO | | | | | last-activity | Day of the last activity | date | YES | | NULL | |
| allow_location | 1 allows to display the location | boolean | NO | | 0 | | | default-location | Default for item.location | varchar(255) | NO | | | |
| theme | user theme preference | varchar(255) | NO | | | | | allow_location | 1 allows to display the location | boolean | NO | | 0 | |
| pubkey | RSA public key 4096 bit | text | YES | | NULL | | | theme | user theme preference | varchar(255) | NO | | | |
| prvkey | RSA private key 4096 bit | text | YES | | NULL | | | pubkey | RSA public key 4096 bit | text | YES | | NULL | |
| spubkey | | text | YES | | NULL | | | prvkey | RSA private key 4096 bit | text | YES | | NULL | |
| sprvkey | | text | YES | | NULL | | | spubkey | | text | YES | | NULL | |
| verified | user is verified through email | boolean | NO | | 0 | | | sprvkey | | text | YES | | NULL | |
| blocked | 1 for user is blocked | boolean | NO | | 0 | | | verified | user is verified through email | boolean | NO | | 0 | |
| blockwall | Prohibit contacts to post to the profile page of the user | boolean | NO | | 0 | | | blocked | 1 for user is blocked | boolean | NO | | 0 | |
| hidewall | Hide profile details from unkown viewers | boolean | NO | | 0 | | | blockwall | Prohibit contacts to post to the profile page of the user | boolean | NO | | 0 | |
| blocktags | Prohibit contacts to tag the post of this user | boolean | NO | | 0 | | | hidewall | Hide profile details from unkown viewers | boolean | NO | | 0 | |
| unkmail | Permit unknown people to send private mails to this user | boolean | NO | | 0 | | | blocktags | Prohibit contacts to tag the post of this user | boolean | NO | | 0 | |
| cntunkmail | | int unsigned | NO | | 10 | | | unkmail | Permit unknown people to send private mails to this user | boolean | NO | | 0 | |
| notify-flags | email notification options | smallint unsigned | NO | | 65535 | | | cntunkmail | | int unsigned | NO | | 10 | |
| page-flags | page/profile type | tinyint unsigned | NO | | 0 | | | notify-flags | email notification options | smallint unsigned | NO | | 65535 | |
| account-type | | tinyint unsigned | NO | | 0 | | | page-flags | page/profile type | tinyint unsigned | NO | | 0 | |
| prvnets | | boolean | NO | | 0 | | | account-type | | tinyint unsigned | NO | | 0 | |
| pwdreset | Password reset request token | varchar(255) | YES | | NULL | | | prvnets | | boolean | NO | | 0 | |
| pwdreset_time | Timestamp of the last password reset request | datetime | YES | | NULL | | | pwdreset | Password reset request token | varchar(255) | YES | | NULL | |
| maxreq | | int unsigned | NO | | 10 | | | pwdreset_time | Timestamp of the last password reset request | datetime | YES | | NULL | |
| expire | | int unsigned | NO | | 0 | | | maxreq | | int unsigned | NO | | 10 | |
| account_removed | if 1 the account is removed | boolean | NO | | 0 | | | expire | Delay in days before deleting user-related posts. Scope is controlled by pConfig. | int unsigned | NO | | 0 | |
| account_expired | | boolean | NO | | 0 | | | account_removed | if 1 the account is removed | boolean | NO | | 0 | |
| account_expires_on | timestamp when account expires and will be deleted | datetime | NO | | 0001-01-01 00:00:00 | | | account_expired | | boolean | NO | | 0 | |
| expire_notification_sent | timestamp of last warning of account expiration | datetime | NO | | 0001-01-01 00:00:00 | | | account_expires_on | timestamp when account expires and will be deleted | datetime | NO | | 0001-01-01 00:00:00 | |
| def_gid | | int unsigned | NO | | 0 | | | expire_notification_sent | timestamp of last warning of account expiration | datetime | NO | | 0001-01-01 00:00:00 | |
| allow_cid | default permission for this user | mediumtext | YES | | NULL | | | def_gid | | int unsigned | NO | | 0 | |
| allow_gid | default permission for this user | mediumtext | YES | | NULL | | | allow_cid | default permission for this user | mediumtext | YES | | NULL | |
| deny_cid | default permission for this user | mediumtext | YES | | NULL | | | allow_gid | default permission for this user | mediumtext | YES | | NULL | |
| deny_gid | default permission for this user | mediumtext | YES | | NULL | | | deny_cid | default permission for this user | mediumtext | YES | | NULL | |
| openidserver | | text | YES | | NULL | | | deny_gid | default permission for this user | mediumtext | YES | | NULL | |
| openidserver | | text | YES | | NULL | |
Indexes Indexes
------------ ------------

View file

@ -309,10 +309,6 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('post_local', $datarray); Hook::callAll('post_local', $datarray);
Hook::callAll('post_local_end', $datarray); Hook::callAll('post_local_end', $datarray);
### mod/editpost.php
Hook::callAll('jot_tool', $jotplugins);
### src/Network/FKOAuth1.php ### src/Network/FKOAuth1.php
Hook::callAll('logged_in', $a->user); Hook::callAll('logged_in', $a->user);
@ -405,6 +401,10 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('block', $hook_data); Hook::callAll('block', $hook_data);
Hook::callAll('unblock', $hook_data); Hook::callAll('unblock', $hook_data);
### src/Core/Logger/Factory.php
Hook::callAll('logger_instance', $data);
### src/Core/StorageManager ### src/Core/StorageManager
Hook::callAll('storage_instance', $data); Hook::callAll('storage_instance', $data);
@ -418,6 +418,10 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('lockview_content', $item); Hook::callAll('lockview_content', $item);
### src/Module/Post/Edit.php
Hook::callAll('jot_tool', $jotplugins);
### src/Worker/Directory.php ### src/Worker/Directory.php
Hook::callAll('globaldir_update', $arr); Hook::callAll('globaldir_update', $arr);

View file

@ -69,7 +69,7 @@ Andere erlauben nur kostenpflichtige Zertifikate als eigenes Angebot bzw. von an
### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen? ### Wie kann ich Bilder, Dateien, Links, Video und Audio in Beiträge einfügen?
Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden. Bilder können direkt im [Beitragseditor](help/Text_editor) vom Computer hochgeladen werden.
Eine Übersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/photos/profilname</i>. Eine Übersicht aller Bilder, die auf Deinem Server liegen, findest Du unter <i>deineSeite.de/profile/profilname/photos</i>.
Dort kannst Du auch direkt Bilder hochladen und festlegen, ob Deine Kontakte eine Nachricht über das neue Bild bekommen. Dort kannst Du auch direkt Bilder hochladen und festlegen, ob Deine Kontakte eine Nachricht über das neue Bild bekommen.
Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden. Alle Arten von Dateien können grundsätzlich als Anhang in Friendica hochgeladen werden.

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) * 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. * 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. 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 5.6+ (oder eine äquivalente Alternative: MariaDB, Percona Server etc.) * 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)
* 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] * 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. * 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

@ -15,14 +15,14 @@ Außerdem enthält sie deinen geheimen Schlüssel mit dem du dich deinen Kontakt
**Speichere diese Datei an einem sicheren Ort**! **Speichere diese Datei an einem sicheren Ort**!
Rufe nun dem neuen Server die Seite *http://newserver.com/uimport* auf (es gibt derzeit keinen direkten Link auf diese Seite). Rufe nun dem neuen Server die Seite *http://newserver.com/user/import* auf (es gibt derzeit keinen direkten Link auf diese Seite).
Bitte beachte, dass dies nur auf Servern möglich ist, an denen man sich offen anmelden kann. Bitte beachte, dass dies nur auf Servern möglich ist, an denen man sich offen anmelden kann.
Bei Servern, bei denen der Administrator Accounts freigeben muss, ist das Hochladen nicht möglich. Bei Servern, bei denen der Administrator Accounts freigeben muss, ist das Hochladen nicht möglich.
Hier kann dies nur der Administrator selber durchführen. Hier kann dies nur der Administrator selber durchführen.
Lege auf dem neuen Server auf keinen Fall einen gleichnamigen Account an! Lege auf dem neuen Server auf keinen Fall einen gleichnamigen Account an!
uimport muss anstelle des Registrierens verwendet werden. user import muss anstelle des Registrierens verwendet werden.
Wähle die gesicherte Account Datei aus und klicke "Importieren". Wähle die gesicherte Account Datei aus und klicke "Importieren".

View file

@ -5,7 +5,7 @@ Accounts löschen
Wir freuen uns nicht, wenn Leute Friendica verlassen, aber wenn du deinen Account löschen willst, dann besuche die folgende URL Wir freuen uns nicht, wenn Leute Friendica verlassen, aber wenn du deinen Account löschen willst, dann besuche die folgende URL
[Lösche mich (http://NamederSeite/removeme)](../removeme) [Lösche mich (http://NamederSeite/settings/removeme)](../settings/removeme)
in deinem Webbrowser. Du musst dabei eingeloggt sein. in deinem Webbrowser. Du musst dabei eingeloggt sein.

View file

@ -47,13 +47,3 @@ Wähle eine vorhandene Gruppe oder gib einen neuen Namen ein. Die erstellten Gru
<img src="doc/img/post_choose.png" width="27" height="32" alt="post_choose.png" align="left"> Mit diesem Symbol kannst du mehrere Beiträge auswählen und gesammelt löschen. <img src="doc/img/post_choose.png" width="27" height="32" alt="post_choose.png" align="left"> Mit diesem Symbol kannst du mehrere Beiträge auswählen und gesammelt löschen.
Hierfür gehst du nach dem Markieren aller gewünschten Beiträge auf "Lösche die markierten Beiträge" am Ende der Seite mit allen Beiträgen. Hierfür gehst du nach dem Markieren aller gewünschten Beiträge auf "Lösche die markierten Beiträge" am Ende der Seite mit allen Beiträgen.
<P style="clear: both;"></p> <P style="clear: both;"></p>
**Im Folgenden findest du Symbole weiterer Themen**
Darkbubble <img src="doc/img/darkbubble.png" alt="darkbubble.png" style="padding-left: 20px; vertical-align:middle;">
Darkzero <img src="doc/img/darkzero.png" alt="darkzero.png" style="padding-left: 35px; vertical-align:middle;">
<span style="padding-left: 10px; font-style:italic;">(inkl. weiterer "zero"-Themen, slackr, comix, easterbunny, facepark)</span>
Dispy <img src="doc/img/dispy.png" alt="dispy.png" style="padding-left: 57px; vertical-align:middle;"> <i>(inkl. smoothly, testbubble)</i>

View file

@ -9,35 +9,35 @@ Achtung: für dieses Beispiel wurde das Thema <b>"Diabook"</b> genutzt.
Wenn du ein anderes Design benutzt, wirst du manche dieser Symbole gar nicht oder in anderer Form vorfinden. Wenn du ein anderes Design benutzt, wirst du manche dieser Symbole gar nicht oder in anderer Form vorfinden.
</span> </span>
<img src="doc/img/friendica_editor.png" width="538" height="218" alt="editor"> <img src="doc/img/friendica_rich_editor.png" width="538" height="218" alt="editor">
<i>Die einzelnen Symbole</i> <i>Die einzelnen Symbole</i>
<img src="doc/img/camera.png" width="44" height="33" alt="editor" align="left" style="padding-bottom: 20px;"> Wenn du auf dieses Symbol klickst, dann kannst du ein Bild von deinem Computer hinzufügen. <img src="doc/img/camera.png" alt="editor" align="left" style="margin: 0 10px 10px 0;"> Wenn du auf dieses Symbol klickst, dann kannst du ein Bild von deinem Computer hinzufügen.
Wenn du eine Internetadresse (URL) eingeben willst, dann kannst du das "Baum"-Symbol im oberen Teil des Editors nutzen. Wenn du eine Internetadresse (URL) eingeben willst, dann kannst du das "Baum"-Symbol im oberen Teil des Editors nutzen.
Wenn du ein Bild ausgewählt hast, dann erscheint eine Miniaturdarstellung des Bildes im Editor.* Wenn du ein Bild ausgewählt hast, dann erscheint eine Miniaturdarstellung des Bildes im Editor.*
<p style="clear:both;"></p> <p style="clear:both;"></p>
<img src="doc/img/paper_clip.png" width="44" height="33" alt="paper_clip" align="left"> Wenn du dieses Symbol anklickst, dann kannst du weitere Dateien von deinem Computer einfügen. Eine Vorschau des Dateiinhalts erfolgt nicht.* <img src="doc/img/paper_clip.png" alt="paper_clip" align="left" style="margin: 0 10px 10px 0;"> Wenn du dieses Symbol anklickst, dann kannst du weitere Dateien von deinem Computer einfügen. Eine Vorschau des Dateiinhalts erfolgt nicht.*
<p style="clear:both;"></p> <p style="clear:both;"></p>
<img src="doc/img/chain.png" width="44" height="33" alt="chain" align="left"> Wenn du die Kette anklickst, dann kannst du eine Internetadresse (URL) einfügen. <img src="doc/img/chain.png" alt="chain" align="left" style="margin: 0 10px 10px 0;"> Wenn du die Kette anklickst, dann kannst du eine Internetadresse (URL) einfügen.
Im Editor erscheint automatisch eine kurze Information zum eingefügten Link.* Im Editor erscheint automatisch eine kurze Information zum eingefügten Link.*
<p style="clear:both;"></p> <p style="clear:both;"></p>
<img src="doc/img/video.png" width="44" height="33" alt="video" align="left" style="padding-bottom: 40px;"> Mit dieser Funktion kannst du die Internetadresse (URL) einer Videodatei einfügen. <img src="doc/img/video.png" alt="video" align="left" style="margin: 0 10px 10px 0;"> Mit dieser Funktion kannst du die Internetadresse (URL) einer Videodatei einfügen.
Das Video erscheint dann mit einem Player in deinem Beitrag. Das Video erscheint dann mit einem Player in deinem Beitrag.
Da Friendica zur Einbindung [HTML5](http://en.wikipedia.org/wiki/HTML5_video) verwendet, werden je nach Browser verschiedene Videoformate unterstützt (z.B. WebM oder MP4). Da Friendica zur Einbindung [HTML5](http://en.wikipedia.org/wiki/HTML5_video) verwendet, werden je nach Browser verschiedene Videoformate unterstützt (z.B. WebM oder MP4).
Außerdem kannst du hier die URLs von Videos auf Youtube, Vimeo und manchen anderen Videohostern eingeben. Außerdem kannst du hier die URLs von Videos auf Youtube, Vimeo und manchen anderen Videohostern eingeben.
Die Videos werden dann mit Vorschaubild angezeigt, nach einem Klick öffnet sich ein eingebetteter Player.* Die Videos werden dann mit Vorschaubild angezeigt, nach einem Klick öffnet sich ein eingebetteter Player.*
<p style="clear:both;"></p> <p style="clear:both;"></p>
<img src="doc/img/mic.png" width="44" height="33" alt="mic" align="left" style="padding-bottom: 40px;"> Mit dieser Funktion kannst du die Internetadresse (URL) einer Sound-Datei einfügen. <img src="doc/img/mic.png" alt="mic" align="left" style="margin: 0 10px 10px 0;"> Mit dieser Funktion kannst du die Internetadresse (URL) einer Sound-Datei einfügen.
Da Friendica zur Einbindung [HTML5](http://en.wikipedia.org/wiki/HTML5_video) verwendet, werden je nach Browser und Betriebssystem MP3, Ogg oder AAC unterstützt. Da Friendica zur Einbindung [HTML5](http://en.wikipedia.org/wiki/HTML5_video) verwendet, werden je nach Browser und Betriebssystem MP3, Ogg oder AAC unterstützt.
Außerdem kannst du hier auch URLs von manchen Audiohostern wie Soundcloud eingeben, um eine dort gespeicherte Audiodatei mit Player in deinem Beitrag anzuzeigen.* Außerdem kannst du hier auch URLs von manchen Audiohostern wie Soundcloud eingeben, um eine dort gespeicherte Audiodatei mit Player in deinem Beitrag anzuzeigen.*
<p style="clear:both;"></p> <p style="clear:both;"></p>
<img src="doc/img/globe.png" width="44" height="33" alt="globe" align="left"> Wenn du dieses Symbol wählst, dann kannst du deinen Standort festlegen. <img src="doc/img/globe.png" alt="globe" align="left" style="margin: 0 10px 10px 0;"> Wenn du dieses Symbol wählst, dann kannst du deinen Standort festlegen.
Hier reicht schon eine Angabe wie "Berlin" oder "10775". Hier reicht schon eine Angabe wie "Berlin" oder "10775".
Dieser Eintrag führt anschließend zu einer Suchanfrage bei Google Maps. Dieser Eintrag führt anschließend zu einer Suchanfrage bei Google Maps.
<p style="clear:both;"></p> <p style="clear:both;"></p>
@ -46,12 +46,6 @@ Dieser Eintrag führt anschließend zu einer Suchanfrage bei Google Maps.
**Im Folgenden findest du Symbole weiterer Themen** **Im Folgenden findest du Symbole weiterer Themen**
Cleanzero <img src="doc/img/editor_zero.png" alt="cleanzero.png" style="padding-left: 20px; vertical-align:middle;">
<span style="padding-left: 10px; font-style:italic;">(inkl. weiterer "zero"-Themen, comix, easterbunny, facepark, slackr </span>
Darkbubble <img src="doc/img/editor_darkbubble.png" alt="darkbubble.png" style="padding-left: 14px; vertical-align:middle;"> <i>(inkl. smoothly, testbubble)</i>
Frio <img src="doc/img/editor_frio.png" alt="frio.png" style="padding-left: 44px; vertical-align:middle;"> Frio <img src="doc/img/editor_frio.png" alt="frio.png" style="padding-left: 44px; vertical-align:middle;">
Vier <img src="doc/img/editor_vier.png" alt="vier.png" style="padding-left: 44px; vertical-align:middle;"> <i>(inkl. dispy)</i> Vier <img src="doc/img/editor_vier.png" alt="vier.png" style="padding-left: 44px; vertical-align:middle;">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -17,7 +17,7 @@ The below for a more detailed description of theme heritage.
Some themes also allow users to select *variants* of the theme. Some themes also allow users to select *variants* of the theme.
Those theme variants most often contain an additional [CSS](https://en.wikipedia.org/wiki/CSS) file to override some styling of the default theme values. Those theme variants most often contain an additional [CSS](https://en.wikipedia.org/wiki/CSS) file to override some styling of the default theme values.
From the themes in the main repository *duepunto zero* and *vier* are using this methods for variations. From the themes in the main repository *vier* and *vier* are using this methods for variations.
Quattro is using a slightly different approach. Quattro is using a slightly different approach.
Third you can start your theme from scratch. Third you can start your theme from scratch.
@ -60,145 +60,6 @@ they will be overwritten by files in
/view/theme/**your-theme-name**/js. /view/theme/**your-theme-name**/js.
## Expand an existing Theme
### Theme Variations
Many themes are more *theme families* than only one theme.
*duepunto zero* and *vier* allow easily to add new theme variation.
We will go through the process of creating a new variation for *duepunto zero*.
The same (well almost, some names change) procedure applies to the *vier* theme.
And similar steps are needed for *quattro* but this theme is using [lesscss](http://lesscss.org/#docs) to maintain the CSS files..
In
/view/theme/duepuntozero/deriv
you find a couple of CSS files that define color derivations from the duepunto theme.
These resemble some of the now as unsupported marked themes, that were inherited by the duepunto theme.
Darkzero and Easter Bunny for example.
The selection of the colorset is done in a combination of a template for a new form in the settings and aome functions in the theme.php file.
The template (theme_settings.tpl)
{{include file="field_select.tpl" field=$colorset}}
<div class="settings-submit-wrapper">
<input type="submit" value="{{$submit}}" class="settings-submit" name="duepuntozero-settings-submit" />
</div>
defines a formular consisting of a [select](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select) pull-down which contains all aviable variants and s submit button.
See the documentation about [SMARTY3 templates](/help/snarty3-templates.md) for a summary of friendica specific blocks other than the select element.
But we don't really need to change anything at the template itself.
The template alone wont work though.
You make friendica aware of its existance and tell it how to use the template file, by defining a config.php file.
It needs to define at least the following functions
* theme_content
* theme_post
and may also define functions for the admin interface
* theme_admin
* theme_admin_post.
theme_content and theme_admin are used to make the form available in the settings, repectively the admin panel.
The _post functions handle the processing of the send form, in this case they save to selected variand in friendicas database.
To make your own variation appear in the menu, all you need to do is to create a new CSS file in the deriv directoy and include it in the array in the config.php:
$colorset = array(
'default'=>DI::l10n()->t('default'),
'greenzero'=>DI::l10n()->t('greenzero'),
'purplezero'=>DI::l10n()->t('purplezero'),
'easterbunny'=>DI::l10n()->t('easterbunny'),
'darkzero'=>DI::l10n()->t('darkzero'),
'comix'=>DI::l10n()->t('comix'),
'slackr'=>DI::l10n()->t('slackr'),
);
the 1st part of the line is the name of the CSS file (without the .css) the 2nd part is the common name of the variant.
Calling the DI::l10n()->t() function with the common name makes the string translateable.
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 (! 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(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
Now that this information is set in the database, what should friendica do with it?
For this, have a look at the theme.php file of the *duepunto zero*.
There you'll find somethink alike
$colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset');
if ($colorset) {
if ($colorset == 'greenzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n";
/* some more variants */
}
which tells friendica to get the personal config of a user.
Check if it is set and if not look for the global config.
And finally if a config for the colorset was found, apply it by adding a link to the CSS file into the HTML header of the page.
So you'll just need to add a if selection, fitting your variant keyword and link to the CSS file of it.
Done.
Now you can use the variant on your system.
But remember once the theme.php or the config.php you have to readd your variant to them.
If you think your color variation could be benifical for other friendica users as well, feel free to generate a pull request at github so we can include your work into the repository.
### Inheritation
Say, you like the duepuntozero but you want to have the content of the outer columns left and right exchanged.
That would be not a color variation as shown above.
Instead we will create a new theme, duepuntozero_lr, inherit the properties of duepuntozero and make small changes to the underlying php files.
So create a directory called duepunto_lr and create a file called theme.php with your favorite text editor.
The content of this file should be something like
<?php
/* meta informations for the theme, see below */
use Friendica\App;
function duepuntozero_lr_init(App $a) {
$a->setThemeInfoValue('extends', 'duepuntozero');
$a->set_template_engine('smarty3');
/* and more stuff e.g. the JavaScript function for the header */
}
Next take the default.php file found in the /view direcotry and exchange the aside and right_aside elements.
So the central part of the file now looks like this:
<body>
<?php if(!empty($page['nav'])) echo $page['nav']; ?>
<aside><?php if(!empty($page['right_aside'])) echo $page['right_aside']; ?></aside>
<section><?php if(!empty($page['content'])) echo $page['content']; ?>
<div id="page-footer"></div>
</section>
<right_aside><?php if(!empty($page['aside'])) echo $page['aside']; ?></right_aside>
<footer><?php if(!empty($page['footer'])) echo $page['footer']; ?></footer>
</body>
Finally we need a style.css file, inheriting the definitions from the parent theme and containing out changes for the new theme.
***Note***:You need to create the style.css and at lest import the base CSS file from the parent theme.
@import url('../duepuntozero/style.css');
Done.
But I agree it is not really useful at this state.
Nevertheless, to use it, you just need to activate in the admin panel.
That done, you can select it in the settings like any other activated theme.
## Creating a Theme from Scratch ## Creating a Theme from Scratch
Keep patient. Keep patient.
@ -231,15 +92,19 @@ Supported formats are PNG and JPEG.
This is the main definition file of the theme. This is the main definition file of the theme.
In the header of that file, some meta information is stored. In the header of that file, some meta information is stored.
For example, have a look at the theme.php of the *quattro* theme: For example, have a look at the theme.php of the *vier* theme:
<?php <?php
/** /**
* Name: Quattro * [Licence]
* Version: 0.6 *
* Name: Vier
* Version: 1.2
* Author: Fabio <http://kirgroup.com/profile/fabrixxm> * Author: Fabio <http://kirgroup.com/profile/fabrixxm>
* Maintainer: Fabio <http://kirgroup.com/profile/fabrixxm> * Author: Ike <http://pirati.ca/profile/heluecht>
* Maintainer: Tobias <https://f.diekershoff.de/profile/tobias> * Author: Beanow <https://fc.oscp.info/profile/beanow>
* Maintainer: Ike <http://pirati.ca/profile/heluecht>
* Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
*/ */
You see the definition of the theme's name, it's version and the initial author of the theme. You see the definition of the theme's name, it's version and the initial author of the theme.
@ -255,11 +120,11 @@ This will make our job a little easier, as we don't have to specify the full nam
The next crucial part of the theme.php file is a definition of an init function. The next crucial part of the theme.php file is a definition of an init function.
The name of the function is <theme-name>_init. The name of the function is <theme-name>_init.
So in the case of quattro it is So in the case of vier it is
function quattro_init(App $a) { function vier_init(App $a) {
$a->theme_info = array(); $a->theme_info = array();
$a->set_template_engine('smarty3'); $a->set_template_engine('smarty3');
} }
Here we have set the basic theme information, in this case they are empty. Here we have set the basic theme information, in this case they are empty.
@ -269,12 +134,6 @@ At the moment you should use the *smarty3* engine.
There once was a friendica specific templating engine as well but that is not used anymore. There once was a friendica specific templating engine as well but that is not used anymore.
If you like to use another templating engine, please implement it. If you like to use another templating engine, please implement it.
When you want to inherit stuff from another theme you have to *announce* this in the theme_info:
$a->setThemeInfoValue('extends', 'duepuntozero');
which declares *duepuntozero* as parent of the theme.
If you want to add something to the HTML header of the theme, one way to do so is by adding it to the theme.php file. If you want to add something to the HTML header of the theme, one way to do so is by adding it to the theme.php file.
To do so, add something alike To do so, add something alike
@ -282,7 +141,6 @@ To do so, add something alike
/* stuff you want to add to the header */ /* stuff you want to add to the header */
EOT; EOT;
The $a variable holds the friendica application.
So you can access the properties of this friendica session from the theme.php file as well. So you can access the properties of this friendica session from the theme.php file as well.
### default.php ### default.php

View file

@ -1,298 +0,0 @@
<?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/>.
*
* The calendar module
*
* This calendar is for profile visitors and contains only the events
* of the profile owner
*/
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;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\BaseProfile;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
function cal_init(App $a)
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
if (DI::args()->getArgc() < 2) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
Nav::setSelected('events');
// if it's a json request abort here becaus we don't
// need the widget data
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
return;
}
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}
DI::page()['aside'] .= Widget\VCard::getHTML($owner);
DI::page()['aside'] .= Widget\CalendarExport::getHTML($owner['uid']);
return;
}
function cal_content(App $a)
{
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
Nav::setSelected('events');
// get the translation strings for the callendar
$i18n = Event::getStrings();
DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
$htpl = Renderer::getMarkupTemplate('event_head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
'$module_url' => '/cal/' . $owner['nickname'],
'$modparams' => 2,
'$i18n' => $i18n,
]);
$mode = 'view';
$y = 0;
$m = 0;
$ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0);
$format = 'ical';
if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') {
$mode = 'export';
$format = DI::args()->getArgv()[3];
}
// Setup permissions structures
$owner_uid = intval($owner['uid']);
$nick = $owner['nickname'];
$contact_id = Session::getRemoteContactID($owner['uid']);
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
$is_owner = local_user() == $owner['uid'];
if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
notice(DI::l10n()->t('Access to this profile has been restricted.'));
return;
}
// get the permissions
$sql_perms = Item::getPermissionsSQLByUserId($owner_uid);
// we only want to have the events of the profile owner
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
// get the tab navigation bar
$tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner['nickname'], $owner['hide-friends']);
// The view mode part is similiar to /mod/events.php
if ($mode == 'view') {
$thisyear = DateTimeFormat::localNow('Y');
$thismonth = DateTimeFormat::localNow('m');
if (!$y) {
$y = intval($thisyear);
}
if (!$m) {
$m = intval($thismonth);
}
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
if ($y < 1901) {
$y = 1900;
}
if ($y > 2099) {
$y = 2100;
}
$nextyear = $y;
$nextmonth = $m + 1;
if ($nextmonth > 12) {
$nextmonth = 1;
$nextyear ++;
}
$prevyear = $y;
if ($m > 1) {
$prevmonth = $m - 1;
} else {
$prevmonth = 12;
$prevyear --;
}
$dim = Temporal::getDaysInMonth($y, $m);
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
if (!empty($_GET['start'])) {
$start = $_GET['start'];
}
if (!empty($_GET['end'])) {
$finish = $_GET['end'];
}
}
$start = DateTimeFormat::utc($start);
$finish = DateTimeFormat::utc($finish);
// put the event parametes in an array so we can better transmit them
$event_params = [
'event_id' => intval($_GET['id'] ?? 0),
'start' => $start,
'finish' => $finish,
'ignore' => $ignored,
];
// get events by id or by date
if ($event_params['event_id']) {
$r = Event::getListById($owner_uid, $event_params['event_id'], $sql_extra);
} else {
$r = Event::getListByDate($owner_uid, $event_params, $sql_extra);
}
$links = [];
if (DBA::isResult($r)) {
$r = Event::sortByDate($r);
foreach ($r as $rr) {
$j = DateTimeFormat::local($rr['start'], 'j');
if (empty($links[$j])) {
$links[$j] = DI::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
}
}
}
// transform the event in a usable array
$events = Event::prepareListForTemplate($r);
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
System::jsonExit($events);
}
// links: array('href', 'text', 'extra css classes', 'title')
if (!empty($_GET['id'])) {
$tpl = Renderer::getMarkupTemplate("event.tpl");
} else {
$tpl = Renderer::getMarkupTemplate("events_js.tpl");
}
// Get rid of dashes in key names, Smarty3 can't handle them
foreach ($events as $key => $event) {
$event_item = [];
foreach ($event['item'] as $k => $v) {
$k = str_replace('-', '_', $k);
$event_item[$k] = $v;
}
$events[$key]['item'] = $event_item;
}
$o = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
'$title' => DI::l10n()->t('Events'),
'$view' => DI::l10n()->t('View'),
'$previous' => [DI::baseUrl() . "/events/$prevyear/$prevmonth", DI::l10n()->t('Previous'), '', ''],
'$next' => [DI::baseUrl() . "/events/$nextyear/$nextmonth", DI::l10n()->t('Next'), '', ''],
'$calendar' => Temporal::getCalendarTable($y, $m, $links, ' eventcal'),
'$events' => $events,
"today" => DI::l10n()->t("today"),
"month" => DI::l10n()->t("month"),
"week" => DI::l10n()->t("week"),
"day" => DI::l10n()->t("day"),
"list" => DI::l10n()->t("list"),
]);
if (!empty($_GET['id'])) {
System::httpExit($o);
}
return $o;
}
if ($mode == 'export') {
if (!$owner_uid) {
notice(DI::l10n()->t('User not found'));
return;
}
// Get the export data by uid
$evexport = Event::exportListByUserId($owner_uid, $format);
if (!$evexport["success"]) {
if ($evexport["content"]) {
notice(DI::l10n()->t('This calendar format is not supported'));
} else {
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 (local_user() === $owner_uid) {
$return_path = "events";
} else {
$return_path = "cal/" . $nick;
}
DI::baseUrl()->redirect($return_path);
}
// If nothing went wrong we can echo the export content
if ($evexport["success"]) {
header('content-disposition: attachment; filename="' . DI::l10n()->t('calendar') . '-' . $nick . '.' . $evexport["extension"] . '"');
System::httpExit($evexport["content"], Response::TYPE_BLANK, 'text/calendar');
}
return;
}
}

View file

@ -1,371 +0,0 @@
<?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\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;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\ActivityPub\Objects;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
function display_init(App $a)
{
if (ActivityPub::isRequest()) {
(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') && !Session::isAuthenticated()) {
return;
}
$nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
$item = null;
$item_user = local_user();
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
// If there is only one parameter, then check if this parameter could be a guid
if (DI::args()->getArgc() == 2) {
$nick = '';
// Does the local user have this item?
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) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item)) {
if (!Contact::isFollower(remote_user(), $item['uid'])) {
$item = null;
} else {
$item_user = $item['uid'];
}
}
}
// Is it an item with uid=0?
if (!DBA::isResult($item)) {
$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(local_user(), $fields, ['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
}
if (!DBA::isResult($item)) {
return;
}
if (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
displayShowFeed($item['uri-id'], $item['uid'], DI::args()->getArgc() > 3 && DI::args()->getArgv()[3] == 'conversation.atom');
}
if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
Logger::debug('Directly serving XML', ['uri-id' => $item['uri-id']]);
displayShowFeed($item['uri-id'], $item['uid'], false);
}
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;
}
$author = display_fetchauthor($item);
if (\Friendica\Util\Network::isLocalLink($author['url'])) {
\Friendica\Model\Profile::load(DI::app(), $author['nick'], false);
} else {
DI::page()['aside'] = Widget\VCard::getHTML($author);
}
$a->setProfileOwner($item['uid']);
}
function display_fetchauthor($item)
{
if (Diaspora::isReshare($item['body'], true)) {
$shared = Item::getShareArray($item);
if (!empty($shared['profile'])) {
$contact = Contact::getByURLForUser($shared['profile'], local_user());
}
}
if (empty($contact)) {
$contact = Contact::getById($item['author-id']);
}
return $contact;
}
function display_content(App $a, $update = false, $update_uid = 0)
{
if (DI::config()->get('system','block_public') && !Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
$o = '';
$item = null;
$force = (bool)($_REQUEST['force'] ?? false);
if ($update) {
$uri_id = $_REQUEST['uri_id'];
$item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => [0, $update_uid]], ['order' => ['uid' => true]]);
if (!empty($item)) {
if ($item['uid'] != 0) {
$a->setProfileOwner($item['uid']);
} else {
$a->setProfileOwner($update_uid);
}
$parent_uri_id = $item['parent-uri-id'];
}
if (empty($_REQUEST['force'])) {
$browser_update = intval(DI::pConfig()->get($update_uid, 'system', 'update_interval'));
if (!empty($browser_update)) {
$update_date = date(DateTimeFormat::MYSQL, time() - ($browser_update / 500));
if (!Post::exists(["`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?", $parent_uri_id, 0, $update_uid, $update_date])) {
Logger::debug('No updated content', ['uri-id' => $uri_id, 'uid' => $update_uid, 'updated' => $update_date]);
return '';
} else {
Logger::debug('Updated content found', ['uri-id' => $uri_id, 'uid' => $update_uid, 'updated' => $update_date]);
}
}
} else {
Logger::debug('Forced content update', ['uri-id' => $uri_id, 'uid' => $update_uid]);
}
} else {
$uri_id = ((DI::args()->getArgc() > 2) ? DI::args()->getArgv()[2] : 0);
$parent_uri_id = $uri_id;
if (DI::args()->getArgc() == 2) {
$fields = ['uri-id', 'parent-uri-id', 'uid'];
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) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
}
}
if ($parent_uri_id == 0) {
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => DI::args()->getArgv()[1], 'uid' => 0];
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
}
}
}
}
if (empty($item)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
}
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
$is_public = Post::exists(['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED]]);
if ($is_public) {
// For the atom feed the nickname doesn't matter at all, we only need the item id.
$alternate = DI::baseUrl().'/display/feed-item/'.$uri_id.'.atom';
$conversation = DI::baseUrl().'/display/feed-item/' . $parent_uri_id . '/conversation.atom';
} else {
$alternate = '';
$conversation = '';
}
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('display-head.tpl'),
['$alternate' => $alternate,
'$conversation' => $conversation]);
$is_remote_contact = false;
$item_uid = local_user();
$page_uid = 0;
$parent = null;
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 = Session::getRemoteContactID($page_uid);
if ($is_remote_contact) {
$item_uid = $parent['uid'];
}
} else {
$page_uid = $item['uid'];
}
if (!empty($page_uid) && ($page_uid != local_user())) {
$page_user = User::getById($page_uid);
}
$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.'));
}
// We need the editor here to be able to reshare an item.
if ($is_owner && !$update) {
$o .= DI::conversation()->statusEditor([], 0, true);
}
$sql_extra = Item::getPermissionsSQLByUserId($page_uid);
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;
}
if ($update && !$unseen && !$force) {
return '';
}
$condition = ["`uri-id` = ? AND `uid` IN (0, ?) " . $sql_extra, $uri_id, $item_uid];
$fields = ['parent-uri-id', 'body', 'title', 'author-name', 'author-avatar', 'plink', 'author-id', 'owner-id', 'contact-id'];
$item = Post::selectFirstForUser($page_uid, $fields, $condition);
if (!DBA::isResult($item)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
}
$item['uri-id'] = $item['parent-uri-id'];
if ($unseen) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true];
Item::update(['unseen' => false], $condition);
}
if (!$update && local_user()) {
$o .= "<script> var netargs = '?uri_id=" . $item['uri-id'] . "'; </script>";
}
$o .= DI::conversation()->create([$item], 'display', $update_uid, false, 'commented', $item_uid);
// Preparing the meta header
$description = trim(BBCode::toPlaintext($item['body']));
$title = trim(BBCode::toPlaintext($item['title'] ?? ''));
$author_name = $item['author-name'];
$image = DI::baseUrl()->remove($item['author-avatar']);
if ($title == '') {
$title = $author_name;
}
// Limit the description to 160 characters
if (strlen($description) > 160) {
$description = substr($description, 0, 157) . '...';
}
$description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$page = DI::page();
if (DBA::exists('contact', ['unsearchable' => true, 'id' => [$item['contact-id'], $item['author-id'], $item['owner-id']]])) {
$page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
DI::page()['htmlhead'] .= '<meta name="author" content="'.$author_name.'" />'."\n";
$page['htmlhead'] .= '<meta name="title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="fulltitle" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="description" content="'.$description.'" />'."\n";
// Schema.org microdata
$page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="image" content="'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n";
// Twitter cards
$page['htmlhead'] .= '<meta name="twitter:card" content="summary" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:image" content="'.DI::baseUrl().'/'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:url" content="'.$item["plink"].'" />'."\n";
// Dublin Core
$page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n";
// Open Graph
$page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta property="og:image" content="'.DI::baseUrl().'/'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta property="og:url" content="'.$item["plink"].'" />'."\n";
$page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
// article:tag
return $o;
}
function displayShowFeed(int $uri_id, int $uid, bool $conversation)
{
$xml = DFRN::itemFeed($uri_id, $uid, $conversation);
if ($xml == '') {
throw new HTTPException\InternalServerErrorException(DI::l10n()->t('The feed for this item is unavailable.'));
}
System::httpExit($xml, Response::TYPE_ATOM);
}

View file

@ -1,166 +0,0 @@
<?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\Content\Feature;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Util\Crypto;
function editpost_content(App $a)
{
$o = '';
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) {
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(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
notice(DI::l10n()->t('Item not found'));
return;
}
$user = User::getById(local_user());
$geotag = '';
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
'$title' => DI::l10n()->t('Edit post')
]);
$tpl = Renderer::getMarkupTemplate('jot-header.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$ispublic' => '&nbsp;', // DI::l10n()->t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $a->getLoggedInUserNickname(),
'$is_mobile' => DI::mode()->isMobile(),
]);
if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
$lockstate = 'lock';
} else {
$lockstate = 'unlock';
}
$jotplugins = '';
$jotnets = '';
Hook::callAll('jot_tool', $jotplugins);
$tpl = Renderer::getMarkupTemplate('jot.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$is_edit' => true,
'$return_path' => '/display/' . $item['guid'],
'$action' => 'item',
'$share' => DI::l10n()->t('Save'),
'$loading' => DI::l10n()->t('Loading...'),
'$upload' => DI::l10n()->t('Upload photo'),
'$shortupload' => DI::l10n()->t('upload photo'),
'$attach' => DI::l10n()->t('Attach file'),
'$shortattach' => DI::l10n()->t('attach file'),
'$weblink' => DI::l10n()->t('Insert web link'),
'$shortweblink' => DI::l10n()->t('web link'),
'$video' => DI::l10n()->t('Insert video link'),
'$shortvideo' => DI::l10n()->t('video link'),
'$audio' => DI::l10n()->t('Insert audio link'),
'$shortaudio' => DI::l10n()->t('audio link'),
'$setloc' => DI::l10n()->t('Set your location'),
'$shortsetloc' => DI::l10n()->t('set location'),
'$noloc' => DI::l10n()->t('Clear browser location'),
'$shortnoloc' => DI::l10n()->t('clear location'),
'$wait' => DI::l10n()->t('Please wait'),
'$permset' => DI::l10n()->t('Permission settings'),
'$wall' => $item['wall'],
'$posttype' => $item['post-type'],
'$content' => undo_post_tagging($item['body']),
'$post_id' => $post_id,
'$defloc' => $user['default-location'],
'$visitor' => 'none',
'$pvisit' => 'none',
'$emailcc' => DI::l10n()->t('CC: email addresses'),
'$public' => DI::l10n()->t('Public post'),
'$jotnets' => $jotnets,
'$title' => $item['title'],
'$placeholdertitle' => DI::l10n()->t('Set title'),
'$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)),
'$bang' => ($lockstate === 'lock' ? '!' : ''),
'$profile_uid' => $_SESSION['uid'],
'$preview' => DI::l10n()->t('Preview'),
'$jotplugins' => $jotplugins,
'$cancel' => DI::l10n()->t('Cancel'),
'$rand_num' => Crypto::randomDigits(12),
// Formatting button labels
'$edbold' => DI::l10n()->t('Bold'),
'$editalic' => DI::l10n()->t('Italic'),
'$eduline' => DI::l10n()->t('Underline'),
'$edquote' => DI::l10n()->t('Quote'),
'$edcode' => DI::l10n()->t('Code'),
'$edurl' => DI::l10n()->t('Link'),
'$edattach' => DI::l10n()->t('Link or Media'),
//jot nav tab (used in some themes)
'$message' => DI::l10n()->t('Message'),
'$browser' => DI::l10n()->t('Browser'),
'$shortpermset' => DI::l10n()->t('Permissions'),
'$compose_link_title' => DI::l10n()->t('Open Compose page'),
]);
return $o;
}
function undo_post_tagging($s) {
$matches = null;
$cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
if (in_array($mtch[1], ['!', '@'])) {
$contact = Contact::getByURL($mtch[2], false, ['addr']);
$mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
}
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
}
}
return $s;
}

View file

@ -1,539 +0,0 @@
<?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/>.
*
* The events module
*/
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\BaseProfile;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Worker\Delivery;
function events_init(App $a)
{
if (!local_user()) {
return;
}
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}
$cal_widget = CalendarExport::getHTML(local_user());
DI::page()['aside'] .= $cal_widget;
return;
}
function events_post(App $a)
{
Logger::debug('post', ['request' => $_REQUEST]);
if (!local_user()) {
return;
}
$event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user();
$start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
$finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
$nofinish = intval($_POST['nofinish'] ?? 0);
$share = intval($_POST['share'] ?? 0);
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
$start = DBA::NULL_DATETIME;
$finish = DBA::NULL_DATETIME;
if ($start_text) {
$start = $start_text;
}
if ($finish_text) {
$finish = $finish_text;
}
$start = DateTimeFormat::convert($start, 'UTC', $a->getTimeZone());
if (!$nofinish) {
$finish = DateTimeFormat::convert($finish, 'UTC', $a->getTimeZone());
}
// Don't allow the event to finish before it begins.
// It won't hurt anything, but somebody will file a bug report
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
$summary = trim($_POST['summary'] ?? '');
$desc = trim($_POST['desc'] ?? '');
$location = trim($_POST['location'] ?? '');
$type = 'event';
$params = [
'summary' => $summary,
'description' => $desc,
'location' => $location,
'start' => $start_text,
'finish' => $finish_text,
'nofinish' => $nofinish,
];
$action = ($event_id == '') ? 'new' : 'event/' . $event_id;
$onerror_path = 'events/' . $action . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986);
if (strcmp($finish, $start) < 0 && !$nofinish) {
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.'));
}
DI::baseUrl()->redirect($onerror_path);
}
if (!$summary || ($start === DBA::NULL_DATETIME)) {
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.'));
}
DI::baseUrl()->redirect($onerror_path);
}
$self = \Friendica\Model\Contact::getPublicIdByUserId($uid);
$aclFormatter = DI::aclFormatter();
if ($share) {
$user = User::getById($uid, ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);
if (!DBA::isResult($user)) {
return;
}
$str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $user['allow_cid'] ?? '';
$str_group_allow = isset($_REQUEST['group_allow']) ? $aclFormatter->toString($_REQUEST['group_allow']) : $user['allow_gid'] ?? '';
$str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $user['deny_cid'] ?? '';
$str_group_deny = isset($_REQUEST['group_deny']) ? $aclFormatter->toString($_REQUEST['group_deny']) : $user['deny_gid'] ?? '';
$visibility = $_REQUEST['visibility'] ?? '';
if ($visibility === 'public') {
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
$str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
} else if ($visibility === 'custom') {
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
// case that would make it public. So we always append the author's contact id to the allowed contacts.
// See https://github.com/friendica/friendica/issues/9672
$str_contact_allow .= $aclFormatter->toString($self);
}
} else {
$str_contact_allow = $aclFormatter->toString($self);
$str_group_allow = $str_contact_deny = $str_group_deny = '';
}
// Make sure to set the `private` field as true. This is necessary to
// have the posts show up correctly in Diaspora if an event is created
// as visible only to self at first, but then edited to display to others.
if (strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) {
$private_event = true;
}
$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));
}
$event_id = Event::store($datarray);
$item = ['network' => Protocol::DFRN, 'protocol' => Conversation::PARCEL_DIRECT, 'direction' => Conversation::PUSH];
$item = Event::getItemArrayForId($event_id, $item);
if (Item::insert($item)) {
$uri_id = $item['uri-id'];
} else {
$uri_id = 0;
}
if (!$cid && $uri_id) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
}
DI::baseUrl()->redirect('events');
}
function events_content(App $a)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
if (DI::args()->getArgc() == 1) {
$_SESSION['return_path'] = DI::args()->getCommand();
}
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' => 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' => local_user()]);
}
if ($a->getThemeInfoValue('events_in_profile')) {
Nav::setSelected('home');
} else {
Nav::setSelected('events');
}
// get the translation strings for the callendar
$i18n = Event::getStrings();
DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
$htpl = Renderer::getMarkupTemplate('event_head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
'$module_url' => '/events',
'$modparams' => 1,
'$i18n' => $i18n,
]);
$o = '';
$tabs = '';
// tabs
if ($a->getThemeInfoValue('events_in_profile')) {
$tabs = BaseProfile::getTabsHTML($a, 'events', true, $a->getLoggedInUserNickname(), false);
}
$mode = 'view';
$y = 0;
$m = 0;
$ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0;
if (DI::args()->getArgc() > 1) {
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'event') {
$mode = 'edit';
$event_id = intval(DI::args()->getArgv()[2]);
}
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'drop') {
$mode = 'drop';
$event_id = intval(DI::args()->getArgv()[2]);
}
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'copy') {
$mode = 'copy';
$event_id = intval(DI::args()->getArgv()[2]);
}
if (DI::args()->getArgv()[1] === 'new') {
$mode = 'new';
$event_id = 0;
}
if (DI::args()->getArgc() > 2 && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
$mode = 'view';
$y = intval(DI::args()->getArgv()[1]);
$m = intval(DI::args()->getArgv()[2]);
}
}
// The view mode part is similiar to /mod/cal.php
if ($mode == 'view') {
$thisyear = DateTimeFormat::localNow('Y');
$thismonth = DateTimeFormat::localNow('m');
if (!$y) {
$y = intval($thisyear);
}
if (!$m) {
$m = intval($thismonth);
}
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
if ($y < 1901) {
$y = 1900;
}
if ($y > 2099) {
$y = 2100;
}
$dim = Temporal::getDaysInMonth($y, $m);
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
// put the event parametes in an array so we can better transmit them
$event_params = [
'event_id' => intval($_GET['id'] ?? 0),
'start' => $start,
'finish' => $finish,
'ignore' => $ignored,
];
// get events by id or by date
if ($event_params['event_id']) {
$r = Event::getListById(local_user(), $event_params['event_id']);
} else {
$r = Event::getListByDate(local_user(), $event_params);
}
$links = [];
if (DBA::isResult($r)) {
$r = Event::sortByDate($r);
foreach ($r as $rr) {
$j = DateTimeFormat::local($rr['start'], 'j');
if (empty($links[$j])) {
$links[$j] = DI::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
}
}
}
$events = [];
// transform the event in a usable array
if (DBA::isResult($r)) {
$r = Event::sortByDate($r);
$events = Event::prepareListForTemplate($r);
}
if (!empty($_GET['id'])) {
$tpl = Renderer::getMarkupTemplate("event.tpl");
} else {
$tpl = Renderer::getMarkupTemplate("events_js.tpl");
}
// Get rid of dashes in key names, Smarty3 can't handle them
foreach ($events as $key => $event) {
$event_item = [];
foreach ($event['item'] as $k => $v) {
$k = str_replace('-', '_', $k);
$event_item[$k] = $v;
}
$events[$key]['item'] = $event_item;
}
// ACL blocks are loaded in modals in frio
DI::page()->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
$o = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
'$title' => DI::l10n()->t('Events'),
'$view' => DI::l10n()->t('View'),
'$new_event' => [DI::baseUrl() . '/events/new', DI::l10n()->t('Create New Event'), '', ''],
'$previous' => [DI::baseUrl() . '/events/$prevyear/$prevmonth', DI::l10n()->t('Previous'), '', ''],
'$next' => [DI::baseUrl() . '/events/$nextyear/$nextmonth', DI::l10n()->t('Next'), '', ''],
'$calendar' => Temporal::getCalendarTable($y, $m, $links, ' eventcal'),
'$events' => $events,
'$today' => DI::l10n()->t('today'),
'$month' => DI::l10n()->t('month'),
'$week' => DI::l10n()->t('week'),
'$day' => DI::l10n()->t('day'),
'$list' => DI::l10n()->t('list'),
]);
if (!empty($_GET['id'])) {
System::httpExit($o);
}
return $o;
}
if (($mode === 'edit' || $mode === 'copy') && $event_id) {
$orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => local_user()]);
}
// Passed parameters overrides anything found in the DB
if (in_array($mode, ['edit', 'new', 'copy'])) {
$share_checked = '';
$share_disabled = '';
if (empty($orig_event)) {
$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']) {
$share_checked = ' checked="checked" ';
}
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
if (!empty($_REQUEST['nofinish'])) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
if (!empty($_REQUEST['summary'])) {$orig_event['summary'] = $_REQUEST['summary'];}
if (!empty($_REQUEST['desc'])) {$orig_event['desc'] = $_REQUEST['desc'];}
if (!empty($_REQUEST['location'])) {$orig_event['location'] = $_REQUEST['location'];}
if (!empty($_REQUEST['start'])) {$orig_event['start'] = $_REQUEST['start'];}
if (!empty($_REQUEST['finish'])) {$orig_event['finish'] = $_REQUEST['finish'];}
$n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : '');
$t_orig = $orig_event['summary'] ?? '';
$d_orig = $orig_event['desc'] ?? '';
$l_orig = $orig_event['location'] ?? '';
$eid = $orig_event['id'] ?? 0;
$cid = $orig_event['cid'] ?? 0;
$uri = $orig_event['uri'] ?? '';
if ($cid || $mode === 'edit') {
$share_disabled = 'disabled="disabled"';
}
$sdt = $orig_event['start'] ?? 'now';
$fdt = $orig_event['finish'] ?? 'now';
$syear = DateTimeFormat::local($sdt, 'Y');
$smonth = DateTimeFormat::local($sdt, 'm');
$sday = DateTimeFormat::local($sdt, 'd');
$shour = !empty($orig_event) ? DateTimeFormat::local($sdt, 'H') : '00';
$sminute = !empty($orig_event) ? DateTimeFormat::local($sdt, 'i') : '00';
$fyear = DateTimeFormat::local($fdt, 'Y');
$fmonth = DateTimeFormat::local($fdt, 'm');
$fday = DateTimeFormat::local($fdt, 'd');
$fhour = !empty($orig_event) ? DateTimeFormat::local($fdt, 'H') : '00';
$fminute = !empty($orig_event) ? DateTimeFormat::local($fdt, 'i') : '00';
if (!$cid && in_array($mode, ['new', 'copy'])) {
$acl = ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), false, ACL::getDefaultUserPermissions($orig_event));
} else {
$acl = '';
}
// If we copy an old event, we need to remove the ID and URI
// from the original event.
if ($mode === 'copy') {
$eid = 0;
$uri = '';
}
$tpl = Renderer::getMarkupTemplate('event_form.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$post' => DI::baseUrl() . '/events',
'$eid' => $eid,
'$cid' => $cid,
'$uri' => $uri,
'$title' => DI::l10n()->t('Event details'),
'$desc' => DI::l10n()->t('Starting date and Title are required.'),
'$s_text' => DI::l10n()->t('Event Starts:') . ' <span class="required" title="' . DI::l10n()->t('Required') . '">*</span>',
'$s_dsel' => Temporal::getDateTimeField(
new DateTime(),
DateTime::createFromFormat('Y', intval($syear) + 5),
DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
DI::l10n()->t('Event Starts:'),
'start_text',
true,
true,
'',
'',
true
),
'$n_text' => DI::l10n()->t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked,
'$f_text' => DI::l10n()->t('Event Finishes:'),
'$f_dsel' => Temporal::getDateTimeField(
new DateTime(),
DateTime::createFromFormat('Y', intval($fyear) + 5),
DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
DI::l10n()->t('Event Finishes:'),
'finish_text',
true,
true,
'start_text'
),
'$d_text' => DI::l10n()->t('Description:'),
'$d_orig' => $d_orig,
'$l_text' => DI::l10n()->t('Location:'),
'$l_orig' => $l_orig,
'$t_text' => DI::l10n()->t('Title:') . ' <span class="required" title="' . DI::l10n()->t('Required') . '">*</span>',
'$t_orig' => $t_orig,
'$summary' => ['summary', DI::l10n()->t('Title:'), $t_orig, '', '*'],
'$sh_text' => DI::l10n()->t('Share this event'),
'$share' => ['share', DI::l10n()->t('Share this event'), $share_checked, '', $share_disabled],
'$sh_checked' => $share_checked,
'$nofinish' => ['nofinish', DI::l10n()->t('Finish date/time is not known or not relevant'), $n_checked],
'$preview' => DI::l10n()->t('Preview'),
'$acl' => $acl,
'$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'),
'$permissions' => DI::l10n()->t('Permissions'),
]);
return $o;
}
// Remove an event from the calendar and its related items
if ($mode === 'drop' && $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']], local_user());
}
if (Post::exists(['id' => $ev[0]['itemid']])) {
notice(DI::l10n()->t('Failed to remove event'));
}
DI::baseUrl()->redirect('events');
}
}

View file

@ -1,160 +0,0 @@
<?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/>.
*
* @package Friendica\modules
* @subpackage FileBrowser
* @author Fabio Comuni <fabrixxm@kirgroup.com>
*/
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Util\Images;
use Friendica\Util\Strings;
/**
* @param App $a
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
function fbrowser_content(App $a)
{
if (!local_user()) {
System::exit();
}
if (DI::args()->getArgc() == 1) {
System::exit();
}
// Needed to match the correct template in a module that uses a different theme than the user/site/default
$theme = Strings::sanitizeFilePathItem($_GET['theme'] ?? '');
if ($theme && is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme);
}
$template_file = "filebrowser.tpl";
$o = '';
switch (DI::args()->getArgv()[1]) {
case "image":
$path = ['' => DI::l10n()->t('Photos')];
$albums = false;
$sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
if (DI::args()->getArgc() == 2) {
$photos = DBA::toArray(DBA::p("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)",
local_user(),
Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER
));
$albums = array_column($photos, 'album');
}
if (DI::args()->getArgc() == 3) {
$album = DI::args()->getArgv()[2];
$sql_extra = sprintf("AND `album` = '%s' ", DBA::escape($album));
$sql_extra2 = "";
$path[$album] = $album;
}
$r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
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",
local_user(),
Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER
));
function _map_files1($rr)
{
$a = DI::app();
$types = Images::supportedTypes();
$ext = $types[$rr['type']];
$filename_e = $rr['filename'];
// Take the largest picture that is smaller or equal 640 pixels
$photo = Photo::selectFirst(['scale'], ["`resource-id` = ? AND `height` <= ? AND `width` <= ?", $rr['resource-id'], 640, 640], ['order' => ['scale']]);
$scale = $photo['scale'] ?? $rr['loq'];
return [
DI::baseUrl() . '/photos/' . $a->getLoggedInUserNickname() . '/image/' . $rr['resource-id'],
$filename_e,
DI::baseUrl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext,
$rr['desc']
];
}
$files = array_map("_map_files1", $r);
$tpl = Renderer::getMarkupTemplate($template_file);
$o = Renderer::replaceMacros($tpl, [
'$type' => 'image',
'$path' => $path,
'$folders' => $albums,
'$files' => $files,
'$cancel' => DI::l10n()->t('Cancel'),
'$nickname' => $a->getLoggedInUserNickname(),
'$upload' => DI::l10n()->t('Upload')
]);
break;
case "file":
if (DI::args()->getArgc()==2) {
$files = DBA::selectToArray('attach', ['id', 'filename', 'filetype'], ['uid' => local_user()]);
function _map_files2($rr)
{
list($m1, $m2) = explode("/", $rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
$filename_e = $rr['filename'];
return [DI::baseUrl() . '/attach/' . $rr['id'], $filename_e, DI::baseUrl() . '/images/icons/16/' . $filetype . '.png'];
}
$files = array_map("_map_files2", $files);
$tpl = Renderer::getMarkupTemplate($template_file);
$o = Renderer::replaceMacros($tpl, [
'$type' => 'file',
'$path' => ['' => DI::l10n()->t('Files')],
'$folders' => false,
'$files' => $files,
'$cancel' => DI::l10n()->t('Cancel'),
'$nickname' => $a->getLoggedInUserNickname(),
'$upload' => DI::l10n()->t('Upload')
]);
}
break;
}
if (!empty($_GET['mode'])) {
return $o;
} else {
System::httpExit($o);
}
}

View file

@ -1,210 +0,0 @@
<?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\Content\Widget;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Database\DBA;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Util\Strings;
function follow_post(App $a)
{
if (!local_user()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
if (isset($_REQUEST['cancel'])) {
DI::baseUrl()->redirect('contact');
}
$url = Probe::cleanURI($_REQUEST['url']);
follow_process($a, $url);
}
function follow_content(App $a)
{
$return_path = 'contact';
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
$uid = local_user();
$url = Probe::cleanURI(trim($_REQUEST['url'] ?? ''));
// Issue 6874: Allow remote following from Peertube
if (strpos($url, 'acct:') === 0) {
$url = str_replace('acct:', '', $url);
}
if (!$url) {
DI::baseUrl()->redirect($return_path);
}
$submit = DI::l10n()->t('Submit Request');
// Don't try to add a pending contact
$user_contact = DBA::selectFirst('contact', ['pending'], ["`uid` = ? AND ((`rel` != ?) OR (`network` = ?)) AND
(`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
$uid, Contact::FOLLOWER, Protocol::DFRN, Strings::normaliseLink($url),
Strings::normaliseLink($url), $url, Protocol::STATUSNET]);
if (DBA::isResult($user_contact)) {
if ($user_contact['pending']) {
notice(DI::l10n()->t('You already added this contact.'));
$submit = '';
}
}
$contact = Contact::getByURL($url, true);
// Possibly it is a mail contact
if (empty($contact)) {
$contact = Probe::uri($url, Protocol::MAIL, $uid);
}
if (empty($contact) || ($contact['network'] == Protocol::PHANTOM)) {
// Possibly it is a remote item and not an account
follow_remote_item($url);
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' => ''];
}
$protocol = Contact::getProtocol($contact['url'], $contact['network']);
if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) {
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')) {
notice(DI::l10n()->t("OStatus support is disabled. Contact can't be added."));
$submit = '';
}
if ($protocol == Protocol::MAIL) {
$contact['url'] = $contact['addr'];
}
if (!empty($_REQUEST['auto'])) {
follow_process($a, $contact['url']);
}
$request = DI::baseUrl() . '/follow';
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
$owner = User::getOwnerDataById($uid);
if (empty($owner)) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
$myaddr = $owner['url'];
$o = Renderer::replaceMacros($tpl, [
'$header' => DI::l10n()->t('Connect/Follow'),
'$pls_answer' => DI::l10n()->t('Please answer the following:'),
'$your_address' => DI::l10n()->t('Your Identity Address:'),
'$url_label' => DI::l10n()->t('Profile URL'),
'$keywords_label'=> DI::l10n()->t('Tags:'),
'$submit' => $submit,
'$cancel' => DI::l10n()->t('Cancel'),
'$request' => $request,
'$name' => $contact['name'],
'$url' => $contact['url'],
'$zrl' => Profile::zrl($contact['url']),
'$myaddr' => $myaddr,
'$keywords' => $contact['keywords'],
'$does_know_you' => ['knowyou', DI::l10n()->t('%s knows you', $contact['name'])],
'$addnote_field' => ['dfrn-request-message', DI::l10n()->t('Add a personal note:')],
]);
DI::page()['aside'] = '';
if (!in_array($protocol, [Protocol::PHANTOM, Protocol::MAIL])) {
DI::page()['aside'] = Widget\VCard::getHTML($contact);
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'),
['$title' => DI::l10n()->t('Status Messages and Posts')]
);
// Show last public posts
$o .= Contact::getPostsFromUrl($contact['url']);
}
return $o;
}
function follow_process(App $a, string $url)
{
$return_path = 'follow?url=' . urlencode($url);
$result = Contact::createFromProbeForUser($a->getLoggedInUserId(), $url);
if ($result['success'] == false) {
// Possibly it is a remote item and not an account
follow_remote_item($url);
if ($result['message']) {
notice($result['message']);
}
DI::baseUrl()->redirect($return_path);
} elseif ($result['cid']) {
DI::baseUrl()->redirect('contact/' . $result['cid']);
}
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, local_user());
if (!$item_id) {
// If the user-specific search failed, we search and probe a public post
$item_id = Item::fetchByLink($url);
}
if (!empty($item_id)) {
$item = Post::selectFirst(['guid'], ['id' => $item_id]);
if (DBA::isResult($item)) {
DI::baseUrl()->redirect('display/' . $item['guid']);
}
}
}

View file

@ -34,8 +34,8 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
@ -57,11 +57,11 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
function item_post(App $a) { function item_post(App $a) {
if (!Session::isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
} }
$uid = local_user(); $uid = DI::userSession()->getLocalUserId();
if (!empty($_REQUEST['dropitems'])) { if (!empty($_REQUEST['dropitems'])) {
$arr_drop = explode(',', $_REQUEST['dropitems']); $arr_drop = explode(',', $_REQUEST['dropitems']);
@ -77,8 +77,6 @@ function item_post(App $a) {
Logger::debug('postvars', ['_REQUEST' => $_REQUEST]); Logger::debug('postvars', ['_REQUEST' => $_REQUEST]);
$api_source = $_REQUEST['api_source'] ?? false;
$return_path = $_REQUEST['return'] ?? ''; $return_path = $_REQUEST['return'] ?? '';
$preview = intval($_REQUEST['preview'] ?? 0); $preview = intval($_REQUEST['preview'] ?? 0);
@ -90,7 +88,7 @@ function item_post(App $a) {
if (!$preview && !empty($_REQUEST['post_id_random'])) { if (!$preview && !empty($_REQUEST['post_id_random'])) {
if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
Logger::warning('duplicate post'); Logger::warning('duplicate post');
item_post_return(DI::baseUrl(), $api_source, $return_path); item_post_return(DI::baseUrl(), $return_path);
} else { } else {
$_SESSION['post-random'] = $_REQUEST['post_id_random']; $_SESSION['post-random'] = $_REQUEST['post_id_random'];
} }
@ -106,7 +104,7 @@ function item_post(App $a) {
$toplevel_user_id = null; $toplevel_user_id = null;
$objecttype = null; $objecttype = null;
$profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user(); $profile_uid = DI::userSession()->getLocalUserId();
$posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE; $posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
if ($parent_item_id || $thr_parent_uri) { if ($parent_item_id || $thr_parent_uri) {
@ -122,13 +120,13 @@ function item_post(App $a) {
$thr_parent_uri = $parent_item['uri']; $thr_parent_uri = $parent_item['uri'];
$toplevel_item = $parent_item; $toplevel_item = $parent_item;
if ($parent_item['gravity'] != GRAVITY_PARENT) { if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]); $toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
} }
} }
if (!DBA::isResult($toplevel_item)) { if (!DBA::isResult($toplevel_item)) {
notice(DI::l10n()->t('Unable to locate original post.')); DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -138,7 +136,7 @@ function item_post(App $a) {
// When commenting on a public post then store the post for the current user // When commenting on a public post then store the post for the current user
// This enables interaction like starring and saving into folders // This enables interaction like starring and saving into folders
if ($toplevel_item['uid'] == 0) { if ($toplevel_item['uid'] == 0) {
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], local_user(), ['post-reason' => Item::PR_ACTIVITY]); $stored = Item::storeForUserByUriId($toplevel_item['uri-id'], DI::userSession()->getLocalUserId(), ['post-reason' => Item::PR_ACTIVITY]);
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]); Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
if ($stored) { if ($stored) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]); $toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]);
@ -168,17 +166,17 @@ function item_post(App $a) {
} }
// Ensure that the user id in a thread always stay the same // Ensure that the user id in a thread always stay the same
if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [local_user(), 0])) { if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [DI::userSession()->getLocalUserId(), 0])) {
$profile_uid = $toplevel_user_id; $profile_uid = $toplevel_user_id;
} }
// Allow commenting if it is an answer to a public post // Allow commenting if it is an answer to a public post
$allow_comment = local_user() && $toplevel_item_id && in_array($toplevel_item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($toplevel_item['network'], Protocol::FEDERATED); $allow_comment = DI::userSession()->getLocalUserId() && $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 // Now check that valid personal details have been provided
if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) { if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
Logger::warning('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]); Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
notice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -241,6 +239,8 @@ function item_post(App $a) {
$att_bbcode = "\n" . PageInfo::getFooterFromData($attachment); $att_bbcode = "\n" . PageInfo::getFooterFromData($attachment);
$body .= $att_bbcode; $body .= $att_bbcode;
} elseif (preg_match("/\[attachment\](.*?)\[\/attachment\]/ism", $body, $matches)) {
$body = preg_replace("/\[attachment].*?\[\/attachment\]/ism", PageInfo::getFooterFromUrl($matches[1]), $body);
} }
// Convert links with empty descriptions to links without an explicit description // Convert links with empty descriptions to links without an explicit description
@ -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 // for non native networks use the network of the original post as network of the item
if (($toplevel_item['network'] != Protocol::DIASPORA) if (($toplevel_item['network'] != Protocol::DIASPORA)
&& ($toplevel_item['network'] != Protocol::OSTATUS) && ($toplevel_item['network'] != Protocol::OSTATUS)
&& ($network == "")) { && ($network == '')) {
$network = $toplevel_item['network']; $network = $toplevel_item['network'];
} }
@ -322,19 +322,12 @@ function item_post(App $a) {
$pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private; $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 == local_user() && !$private) {
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
$pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']);
}
}
if (!strlen($body)) { if (!strlen($body)) {
if ($preview) { if ($preview) {
System::jsonExit(['preview' => '']); System::jsonExit(['preview' => '']);
} }
notice(DI::l10n()->t('Empty post discarded.')); DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -362,11 +355,11 @@ function item_post(App $a) {
$self = false; $self = false;
$contact_id = 0; $contact_id = 0;
if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) { if (DI::userSession()->getLocalUserId() && ((DI::userSession()->getLocalUserId() == $profile_uid) || $allow_comment)) {
$self = true; $self = true;
$author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]); $author = DBA::selectFirst('contact', [], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
} elseif (!empty(Session::getRemoteContactID($profile_uid))) { } elseif (!empty(DI::userSession()->getRemoteContactID($profile_uid))) {
$author = DBA::selectFirst('contact', [], ['id' => Session::getRemoteContactID($profile_uid)]); $author = DBA::selectFirst('contact', [], ['id' => DI::userSession()->getRemoteContactID($profile_uid)]);
} }
if (DBA::isResult($author)) { if (DBA::isResult($author)) {
@ -374,7 +367,7 @@ function item_post(App $a) {
} }
// get contact info for owner // get contact info for owner
if ($profile_uid == local_user() || $allow_comment) { if ($profile_uid == DI::userSession()->getLocalUserId() || $allow_comment) {
$contact_record = $author ?: []; $contact_record = $author ?: [];
} else { } else {
$contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: []; $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: [];
@ -384,8 +377,8 @@ function item_post(App $a) {
if ($posttype != Item::PT_PERSONAL_NOTE) { if ($posttype != Item::PT_PERSONAL_NOTE) {
// Look for any tags and linkify them // Look for any tags and linkify them
$item = [ $item = [
'uid' => local_user() ? local_user() : $profile_uid, 'uid' => DI::userSession()->getLocalUserId() ? DI::userSession()->getLocalUserId() : $profile_uid,
'gravity' => $toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT, 'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
'network' => $network, 'network' => $network,
'body' => $body, 'body' => $body,
'postopts' => $postopts, 'postopts' => $postopts,
@ -462,7 +455,7 @@ function item_post(App $a) {
$data = BBCode::getAttachmentData($body); $data = BBCode::getAttachmentData($body);
$match = []; $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_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE; $posttype = Item::PT_PAGE;
$objecttype = Activity\ObjectType::BOOKMARK; $objecttype = Activity\ObjectType::BOOKMARK;
@ -477,11 +470,11 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::NOTE; // Default value $objecttype = Activity\ObjectType::NOTE; // Default value
$objectdata = BBCode::getAttachedData($body); $objectdata = BBCode::getAttachedData($body);
if ($objectdata["type"] == "link") { if ($objectdata['type'] == 'link') {
$objecttype = Activity\ObjectType::BOOKMARK; $objecttype = Activity\ObjectType::BOOKMARK;
} elseif ($objectdata["type"] == "video") { } elseif ($objectdata['type'] == 'video') {
$objecttype = Activity\ObjectType::VIDEO; $objecttype = Activity\ObjectType::VIDEO;
} elseif ($objectdata["type"] == "photo") { } elseif ($objectdata['type'] == 'photo') {
$objecttype = Activity\ObjectType::IMAGE; $objecttype = Activity\ObjectType::IMAGE;
} }
@ -509,11 +502,11 @@ function item_post(App $a) {
$verb = Activity::POST; $verb = Activity::POST;
} }
if ($network == "") { if ($network == '') {
$network = Protocol::DFRN; $network = Protocol::DFRN;
} }
$gravity = ($toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT); $gravity = ($toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
// even if the post arrived via API we are considering that it // even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability. // originated on this site by default for determining relayability.
@ -532,68 +525,65 @@ function item_post(App $a) {
$thr_parent_uri = $uri; $thr_parent_uri = $uri;
} }
$datarray = []; $datarray = [
$datarray['uid'] = $profile_uid; 'uid' => $profile_uid,
$datarray['wall'] = $wall; 'wall' => $wall,
$datarray['gravity'] = $gravity; 'gravity' => $gravity,
$datarray['network'] = $network; 'network' => $network,
$datarray['contact-id'] = $contact_id; 'contact-id' => $contact_id,
$datarray['owner-name'] = $contact_record['name'] ?? ''; 'owner-name' => $contact_record['name'] ?? '',
$datarray['owner-link'] = $contact_record['url'] ?? ''; 'owner-link' => $contact_record['url'] ?? '',
$datarray['owner-avatar'] = $contact_record['thumb'] ?? ''; 'owner-avatar' => $contact_record['thumb'] ?? '',
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']); 'author-name' => $author['name'],
$datarray['author-name'] = $author['name']; 'author-link' => $author['url'],
$datarray['author-link'] = $author['url']; 'author-avatar' => $author['thumb'],
$datarray['author-avatar'] = $author['thumb']; 'created' => empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'],
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']); 'received' => DateTimeFormat::utcNow(),
$datarray['created'] = empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at']; 'extid' => $extid,
$datarray['edited'] = $datarray['created']; 'guid' => $guid,
$datarray['commented'] = $datarray['created']; 'uri' => $uri,
$datarray['changed'] = $datarray['created']; 'title' => $title,
$datarray['received'] = DateTimeFormat::utcNow(); 'body' => $body,
$datarray['extid'] = $extid; 'app' => $app,
$datarray['guid'] = $guid; 'location' => $location,
$datarray['uri'] = $uri; 'coord' => $coord,
$datarray['title'] = $title; 'file' => $categories,
$datarray['body'] = $body; 'inform' => $inform,
$datarray['app'] = $app; 'verb' => $verb,
$datarray['location'] = $location; 'post-type' => $posttype,
$datarray['coord'] = $coord; 'object-type' => $objecttype,
$datarray['file'] = $categories; 'allow_cid' => $str_contact_allow,
$datarray['inform'] = $inform; 'allow_gid' => $str_group_allow,
$datarray['verb'] = $verb; 'deny_cid' => $str_contact_deny,
$datarray['post-type'] = $posttype; 'deny_gid' => $str_group_deny,
$datarray['object-type'] = $objecttype; 'private' => $private,
$datarray['allow_cid'] = $str_contact_allow; 'pubmail' => $pubmail_enabled,
$datarray['allow_gid'] = $str_group_allow; 'attach' => $attachments,
$datarray['deny_cid'] = $str_contact_deny; 'thr-parent' => $thr_parent_uri,
$datarray['deny_gid'] = $str_group_deny; 'postopts' => $postopts,
$datarray['private'] = $private; 'origin' => $origin,
$datarray['pubmail'] = $pubmail_enabled; 'object' => $object,
$datarray['attach'] = $attachments; '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' => false,
// This field is for storing the raw conversation data
'protocol' => Conversation::PARCEL_DIRECT,
'direction' => Conversation::PUSH,
];
$datarray['thr-parent'] = $thr_parent_uri; // These cannot be part of above initialization ...
$datarray['edited'] = $datarray['created'];
$datarray['postopts'] = $postopts; $datarray['commented'] = $datarray['created'];
$datarray['origin'] = $origin; $datarray['changed'] = $datarray['created'];
$datarray['object'] = $object; $datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$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;
$datarray['edit'] = $orig_post; $datarray['edit'] = $orig_post;
@ -606,15 +596,16 @@ function item_post(App $a) {
if ($preview) { if ($preview) {
// We set the datarray ID to -1 because in preview mode the dataray // We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID. // doesn't have an ID.
$datarray["id"] = -1; $datarray['id'] = -1;
$datarray["uri-id"] = -1; $datarray['uri-id'] = -1;
$datarray["author-network"] = Protocol::DFRN; $datarray['author-network'] = Protocol::DFRN;
$datarray["author-updated"] = ''; $datarray['author-updated'] = '';
$datarray["author-gsid"] = 0; $datarray['author-gsid'] = 0;
$datarray["author-uri-id"] = ItemURI::getIdByURI($datarray["author-link"]); $datarray['author-uri-id'] = ItemURI::getIdByURI($datarray['author-link']);
$datarray["owner-updated"] = ''; $datarray['owner-updated'] = '';
$datarray["has-media"] = false; $datarray['has-media'] = false;
$datarray['body'] = Item::improveSharedDataInBody($datarray); $datarray['quote-uri-id'] = Item::getQuoteUriId($datarray['body'], $datarray['uid']);
$datarray['body'] = BBCode::removeSharedData($datarray['body']);
$o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true); $o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
@ -635,8 +626,8 @@ function item_post(App $a) {
unset($datarray['self']); unset($datarray['self']);
unset($datarray['api_source']); unset($datarray['api_source']);
Post\Delayed::add($datarray['uri'], $datarray, PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at); Post\Delayed::add($datarray['uri'], $datarray, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
item_post_return(DI::baseUrl(), $api_source, $return_path); item_post_return(DI::baseUrl(), $return_path);
} }
} }
@ -655,15 +646,20 @@ function item_post(App $a) {
} }
$datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']); $datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
$datarray['body'] = Item::improveSharedDataInBody($datarray);
if ($orig_post) { $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) {
$fields = [ $fields = [
'title' => $datarray['title'], 'title' => $datarray['title'],
'body' => $datarray['body'], 'body' => $datarray['body'],
'attach' => $datarray['attach'], 'attach' => $datarray['attach'],
'file' => $datarray['file'], 'file' => $datarray['file'],
'edited' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utcNow(),
'changed' => DateTimeFormat::utcNow() 'changed' => DateTimeFormat::utcNow()
]; ];
@ -684,7 +680,7 @@ function item_post(App $a) {
$post_id = Item::insert($datarray); $post_id = Item::insert($datarray);
if (!$post_id) { if (!$post_id) {
notice(DI::l10n()->t('Item wasn\'t stored.')); DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -705,7 +701,7 @@ function item_post(App $a) {
Tag::storeFromBody($datarray['uri-id'], $datarray['body']); Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == GRAVITY_COMMENT)) { if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == Item::GRAVITY_COMMENT)) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']); Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
} }
@ -736,7 +732,7 @@ function item_post(App $a) {
Hook::callAll('post_local_end', $datarray); Hook::callAll('post_local_end', $datarray);
if (strlen($emailcc) && $profile_uid == local_user()) { if (strlen($emailcc) && $profile_uid == DI::userSession()->getLocalUserId()) {
$recipients = explode(',', $emailcc); $recipients = explode(',', $emailcc);
if (count($recipients)) { if (count($recipients)) {
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
@ -752,20 +748,12 @@ function item_post(App $a) {
Logger::debug('post_complete'); Logger::debug('post_complete');
if ($api_source) { item_post_return(DI::baseUrl(), $return_path);
return $post_id;
}
item_post_return(DI::baseUrl(), $api_source, $return_path);
// NOTREACHED // NOTREACHED
} }
function item_post_return($baseurl, $api_source, $return_path) function item_post_return($baseurl, $return_path)
{ {
if ($api_source) {
return;
}
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
} }
@ -782,7 +770,7 @@ function item_post_return($baseurl, $api_source, $return_path)
function item_content(App $a) function item_content(App $a)
{ {
if (!Session::isAuthenticated()) { if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\UnauthorizedException(); throw new HTTPException\UnauthorizedException();
} }
@ -796,9 +784,9 @@ function item_content(App $a)
switch ($args->get(1)) { switch ($args->get(1)) {
case 'drop': case 'drop':
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
Item::deleteForUser(['id' => $args->get(2)], local_user()); Item::deleteForUser(['id' => $args->get(2)], DI::userSession()->getLocalUserId());
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), local_user()]); System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
} else { } else {
if (!empty($args->get(3))) { if (!empty($args->get(3))) {
$o = drop_item($args->get(2), $args->get(3)); $o = drop_item($args->get(2), $args->get(3));
@ -807,17 +795,18 @@ function item_content(App $a)
} }
} }
break; break;
case 'block': case 'block':
$item = Post::selectFirstForUser(local_user(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]); $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
if (empty($item['author-id'])) { if (empty($item['author-id'])) {
throw new HTTPException\NotFoundException('Item not found'); throw new HTTPException\NotFoundException('Item not found');
} }
Contact\User::setBlocked($item['author-id'], local_user(), true); Contact\User::setBlocked($item['author-id'], DI::userSession()->getLocalUserId(), true);
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), local_user()]); System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
} else { } else {
item_redirect_after_action($item, $args->get(3)); item_redirect_after_action($item, $args->get(3));
} }
@ -833,15 +822,15 @@ function item_content(App $a)
* @return string * @return string
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
function drop_item(int $id, string $return = '') function drop_item(int $id, string $return = ''): string
{ {
// locate item to be deleted // Locate item to be deleted
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent']; $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
notice(DI::l10n()->t('Item not found.')); DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network'); DI::baseUrl()->redirect('network');
//NOTREACHED
} }
if ($item['deleted']) { if ($item['deleted']) {
@ -851,18 +840,19 @@ function drop_item(int $id, string $return = '')
$contact_id = 0; $contact_id = 0;
// check if logged in user is either the author or owner of this item // check if logged in user is either the author or owner of this item
if (Session::getRemoteContactID($item['uid']) == $item['contact-id']) { if (DI::userSession()->getRemoteContactID($item['uid']) == $item['contact-id']) {
$contact_id = $item['contact-id']; $contact_id = $item['contact-id'];
} }
if ((local_user() == $item['uid']) || $contact_id) { if ((DI::userSession()->getLocalUserId() == $item['uid']) || $contact_id) {
// delete the item // delete the item
Item::deleteForUser(['id' => $item['id']], local_user()); Item::deleteForUser(['id' => $item['id']], DI::userSession()->getLocalUserId());
item_redirect_after_action($item, $return); item_redirect_after_action($item, $return);
//NOTREACHED
} else { } else {
Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]); Logger::warning('Permission denied.', ['local' => DI::userSession()->getLocalUserId(), 'uid' => $item['uid'], 'cid' => $contact_id]);
notice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('display/' . $item['guid']); DI::baseUrl()->redirect('display/' . $item['guid']);
//NOTREACHED //NOTREACHED
} }
@ -870,17 +860,17 @@ function drop_item(int $id, string $return = '')
return ''; return '';
} }
function item_redirect_after_action($item, $returnUrlHex) function item_redirect_after_action(array $item, string $returnUrlHex)
{ {
$return_url = hex2bin($returnUrlHex); $return_url = hex2bin($returnUrlHex);
// removes update_* from return_url to ignore Ajax refresh // 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 // Check if delete a comment
if ($item['gravity'] == GRAVITY_COMMENT) { if ($item['gravity'] == Item::GRAVITY_COMMENT) {
if (!empty($item['parent'])) { if (!empty($item['parent'])) {
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]); $parentitem = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid'], ['id' => $item['parent']]);
} }
// Return to parent guid // Return to parent guid

View file

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

View file

@ -1,132 +0,0 @@
<?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\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\Contact as ModuleContact;
/**
* Controller for /match.
*
* It takes keywords from your profile and queries the directory server for
* matching keywords from other profiles.
*
* @param App $a App
*
* @return string
* @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws Exception
*/
function match_content(App $a)
{
if (!local_user()) {
return '';
}
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
$_SESSION['return_path'] = DI::args()->getCommand();
$profile = Profile::getByUID(local_user());
if (!DBA::isResult($profile)) {
return '';
}
if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) {
notice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.'));
return '';
}
$params = [];
$tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']);
if (DI::mode()->isMobile()) {
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
$params['s'] = $tags;
$params['n'] = 100;
$entries = [];
foreach ([Search::getGlobalDirectory(), DI::baseUrl()] as $server) {
if (empty($server)) {
continue;
}
$msearch = json_decode(DI::httpClient()->post($server . '/msearch', $params)->getBody());
if (!empty($msearch)) {
$entries = match_get_contacts($msearch, $entries, $limit);
}
}
if (empty($entries)) {
info(DI::l10n()->t('No matches'));
}
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
$o = Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Profile Match'),
'$contacts' => array_slice($entries, 0, $limit),
]);
return $o;
}
function match_get_contacts($msearch, $entries, $limit)
{
if (empty($msearch->results)) {
return $entries;
}
foreach ($msearch->results as $profile) {
if (!$profile) {
continue;
}
// Already known contact
$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, local_user());
if (!empty($contact)) {
$entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact);
}
if (count($entries) == $limit) {
break;
}
}
return $entries;
}

View file

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

View file

@ -1,64 +0,0 @@
<?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\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\Proxy;
function msearch_post(App $a)
{
$search = $_POST['s'] ?? '';
$perpage = intval(($_POST['n'] ?? 0) ?: 80);
$page = intval(($_POST['p'] ?? 0) ?: 1);
$startrec = ($page - 1) * $perpage;
$total = 0;
$results = [];
if (!strlen($search)) {
$output = ['total' => 0, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
System::jsonExit($output);
}
$total = 0;
$condition = ["`net-publish` AND MATCH(`pub_keywords`) AGAINST (?)", $search];
$total = DBA::count('owner-view', $condition);
$search_stmt = DBA::select('owner-view', ['pub_keywords', 'name', 'nickname', 'uid'], $condition, ['limit' => [$startrec, $perpage]]);
while ($search_result = DBA::fetch($search_stmt)) {
$results[] = [
'name' => $search_result['name'],
'url' => DI::baseUrl() . '/profile/' . $search_result['nickname'],
'photo' => User::getAvatarUrl($search_result, Proxy::SIZE_THUMB),
'tags' => str_replace([',', ' '], [' ', ' '], $search_result['pub_keywords'])
];
}
DBA::close($search_stmt);
$output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results];
System::jsonExit($output);
}

View file

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

View file

@ -20,6 +20,8 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Response; use Friendica\Module\Response;
@ -93,9 +95,9 @@ function oexchange_init(App $a)
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml'); System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
} }
function oexchange_content(App $a) { function oexchange_content(App $a)
{
if (!local_user()) { if (!DI::userSession()->getLocalUserId()) {
$o = Login::form(); $o = Login::form();
return $o; return $o;
} }
@ -109,7 +111,7 @@ function oexchange_content(App $a) {
$description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : ''; $description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : '';
$tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : ''; $tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : '';
$s = \Friendica\Content\Text\BBCode::embedURL($url, true, $title, $description, $tags); $s = BBCode::embedURL($url, true, $title, $description, $tags);
if (!strlen($s)) { if (!strlen($s)) {
return; return;
@ -117,11 +119,10 @@ function oexchange_content(App $a) {
$post = []; $post = [];
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done'; $post['return'] = '/oexchange/done';
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s); $post['body'] = HTML::toBBCode($s);
$_REQUEST = $post; $_REQUEST = $post;
require_once('mod/item.php'); require_once 'mod/item.php';
item_post($a); item_post($a);
} }

View file

@ -1,132 +0,0 @@
<?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\Protocol;
use Friendica\DI;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\ActivityPub;
function ostatus_subscribe_content(App $a)
{
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 = 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.');
}
$contact = Contact::getByURL($_REQUEST['url']);
if (!$contact) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch information for contact.');
}
if ($contact['network'] == Protocol::OSTATUS) {
$api = $contact['baseurl'] . '/api/';
// Fetching friends
$curlResult = DI::httpClient()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick'], HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch friends for contact.');
}
$friends = $curlResult->getBody();
if (empty($friends)) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch following contacts.');
}
DI::pConfig()->set($uid, 'ostatus', 'legacy_friends', $friends);
} elseif ($apcontact = APContact::getByURL($contact['url'])) {
if (empty($apcontact['following'])) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch remote profile.');
}
$followings = ActivityPub::fetchItems($apcontact['following']);
if (empty($followings)) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch following contacts.');
}
DI::pConfig()->set($uid, 'ostatus', 'legacy_friends', json_encode($followings));
} else {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Unsupported network');
}
}
$friends = json_decode(DI::pConfig()->get($uid, 'ostatus', 'legacy_friends'));
if (empty($friends)) {
$friends = [];
}
$total = sizeof($friends);
if ($counter >= $total) {
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . DI::baseUrl() . '/settings/connectors">';
DI::pConfig()->delete($uid, 'ostatus', 'legacy_friends');
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
$o .= DI::l10n()->t('Done');
return $o;
}
$friend = $friends[$counter++];
$url = $friend->statusnet_profile_url ?? $friend;
$o .= '<p>' . $counter . '/' . $total . ': ' . $url;
$probed = Contact::getByURL($url);
if (in_array($probed['network'], Protocol::FEDERATED)) {
$result = Contact::createFromProbeForUser($a->getLoggedInUserId(), $probed['url']);
if ($result['success']) {
$o .= ' - ' . DI::l10n()->t('success');
} else {
$o .= ' - ' . DI::l10n()->t('failed');
}
} else {
$o .= ' - ' . DI::l10n()->t('ignored');
}
$o .= '</p>';
$o .= '<p>' . DI::l10n()->t('Keep this window open until done.') . '</p>';
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . DI::baseUrl() . '/ostatus_subscribe?counter=' . $counter . '">';
return $o;
}

View file

@ -20,7 +20,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
@ -30,7 +29,6 @@ use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -42,22 +40,21 @@ use Friendica\Model\Profile;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\BaseProfile; use Friendica\Module\BaseProfile;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Security\Security;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Security\Security;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Network\HTTPException;
function photos_init(App $a) { function photos_init(App $a)
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
return; return;
} }
@ -69,11 +66,11 @@ function photos_init(App $a) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$is_owner = (local_user() && (local_user() == $owner['uid'])); $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner['uid']));
$albums = Photo::getAlbums($owner['uid']); $albums = Photo::getAlbums($owner['uid']);
$albums_visible = ((intval($owner['hidewall']) && !Session::isAuthenticated()) ? false : true); $albums_visible = ((intval($owner['hidewall']) && !DI::userSession()->isAuthenticated()) ? false : true);
// add various encodings to the array so we can just loop through and pick them out in a template // add various encodings to the array so we can just loop through and pick them out in a template
$ret = ['success' => false]; $ret = ['success' => false];
@ -96,7 +93,7 @@ function photos_init(App $a) {
} }
} }
if (local_user() && $owner['uid'] == local_user()) { if (DI::userSession()->getLocalUserId() && $owner['uid'] == DI::userSession()->getLocalUserId()) {
$can_post = true; $can_post = true;
} else { } else {
$can_post = false; $can_post = false;
@ -148,23 +145,23 @@ function photos_post(App $a)
$page_owner_uid = intval($user['uid']); $page_owner_uid = intval($user['uid']);
$community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY; $community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) { if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) { } elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid); $contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
$can_post = true; $can_post = true;
$visitor = $contact_id; $visitor = $contact_id;
} }
if (!$can_post) { if (!$can_post) {
notice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
System::exit(); System::exit();
} }
$owner_record = User::getOwnerDataById($page_owner_uid); $owner_record = User::getOwnerDataById($page_owner_uid);
if (!$owner_record) { if (!$owner_record) {
notice(DI::l10n()->t('Contact information unavailable')); DI::sysmsg()->addNotice(DI::l10n()->t('Contact information unavailable'));
DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
System::exit(); System::exit();
} }
@ -193,7 +190,7 @@ function photos_post(App $a)
$album = hex2bin(DI::args()->getArgv()[3]); $album = hex2bin(DI::args()->getArgv()[3]);
if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid, 'photo-type' => Photo::DEFAULT])) { if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid, 'photo-type' => Photo::DEFAULT])) {
notice(DI::l10n()->t('Album not found.')); DI::sysmsg()->addNotice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album'); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
return; // NOTREACHED return; // NOTREACHED
} }
@ -229,7 +226,7 @@ function photos_post(App $a)
)); ));
} else { } else {
$r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?", $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
local_user(), DI::userSession()->getLocalUserId(),
$album $album
)); ));
} }
@ -247,9 +244,9 @@ function photos_post(App $a)
// Update the photo albums cache // Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid); Photo::clearAlbumCache($page_owner_uid);
notice(DI::l10n()->t('Album successfully deleted')); DI::sysmsg()->addNotice(DI::l10n()->t('Album successfully deleted'));
} else { } else {
notice(DI::l10n()->t('Album was empty.')); DI::sysmsg()->addNotice(DI::l10n()->t('Album was empty.'));
} }
} }
@ -268,7 +265,7 @@ function photos_post(App $a)
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]]; $condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
} else { } else {
$condition = ['uid' => local_user(), 'resource-id' => DI::args()->getArgv()[3]]; $condition = ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => DI::args()->getArgv()[3]];
} }
$photo = DBA::selectFirst('photo', ['resource-id'], $condition); $photo = DBA::selectFirst('photo', ['resource-id'], $condition);
@ -281,12 +278,11 @@ function photos_post(App $a)
// Update the photo albums cache // Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid); Photo::clearAlbumCache($page_owner_uid);
} else { } else {
notice(DI::l10n()->t('Failed to delete the photo.')); DI::sysmsg()->addNotice(DI::l10n()->t('Failed to delete the photo.'));
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]); DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
} }
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1]); DI::baseUrl()->redirect('profile/' . DI::args()->getArgv()[1] . '/photos');
return; // NOTREACHED
} }
} }
@ -526,44 +522,40 @@ function photos_post(App $a)
foreach ($taginfo as $tagged) { foreach ($taginfo as $tagged) {
$uri = Item::newURI(); $uri = Item::newURI();
$arr = []; $arr = [
$arr['guid'] = System::createUUID(); 'guid' => System::createUUID(),
$arr['uid'] = $page_owner_uid; 'uid' => $page_owner_uid,
$arr['uri'] = $uri; 'uri' => $uri,
$arr['wall'] = 1; 'wall' => 1,
$arr['contact-id'] = $owner_record['id']; 'contact-id' => $owner_record['id'],
$arr['owner-name'] = $owner_record['name']; 'owner-name' => $owner_record['name'],
$arr['owner-link'] = $owner_record['url']; 'owner-link' => $owner_record['url'],
$arr['owner-avatar'] = $owner_record['thumb']; 'owner-avatar' => $owner_record['thumb'],
$arr['author-name'] = $owner_record['name']; 'author-name' => $owner_record['name'],
$arr['author-link'] = $owner_record['url']; 'author-link' => $owner_record['url'],
$arr['author-avatar'] = $owner_record['thumb']; 'author-avatar' => $owner_record['thumb'],
$arr['title'] = ''; 'title' => '',
$arr['allow_cid'] = $photo['allow_cid']; 'allow_cid' => $photo['allow_cid'],
$arr['allow_gid'] = $photo['allow_gid']; 'allow_gid' => $photo['allow_gid'],
$arr['deny_cid'] = $photo['deny_cid']; 'deny_cid' => $photo['deny_cid'],
$arr['deny_gid'] = $photo['deny_gid']; 'deny_gid' => $photo['deny_gid'],
$arr['visible'] = 0; 'visible' => 0,
$arr['verb'] = Activity::TAG; 'verb' => Activity::TAG,
$arr['gravity'] = GRAVITY_PARENT; 'gravity' => Item::GRAVITY_PARENT,
$arr['object-type'] = Activity\ObjectType::PERSON; 'object-type' => Activity\ObjectType::PERSON,
$arr['target-type'] = Activity\ObjectType::IMAGE; 'target-type' => Activity\ObjectType::IMAGE,
$arr['inform'] = $tagged[2]; 'inform' => $tagged[2],
$arr['origin'] = 1; '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]') ; '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",
$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" ; '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['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]) { if ($tagged[3]) {
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n"); $arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
} }
$arr['object'] .= '</link></object>' . "\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); Item::insert($arr);
} }
} }
@ -571,219 +563,11 @@ function photos_post(App $a)
DI::baseUrl()->redirect($_SESSION['photo_return']); DI::baseUrl()->redirect($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
} }
// default post action - upload a photo
Hook::callAll('photo_post_init', $_POST);
// Determine the album to use
$album = trim($_REQUEST['album'] ?? '');
$newalbum = trim($_REQUEST['newalbum'] ?? '');
Logger::debug('album= ' . $album . ' newalbum= ' . $newalbum);
if (!strlen($album)) {
if (strlen($newalbum)) {
$album = $newalbum;
} else {
$album = DateTimeFormat::localNow('Y');
}
}
/*
* We create a wall item for every photo, but we don't want to
* overwhelm the data stream with a hundred newly uploaded photos.
* So we will make the first photo uploaded to this album in the last several hours
* visible by default, the rest will become visible over time when and if
* they acquire comments, likes, dislikes, and/or tags
*/
$r = Photo::selectToArray([], ['`album` = ? AND `uid` = ? AND `created` > ?', $album, $page_owner_uid, DateTimeFormat::utc('now - 3 hours')]);
if (!DBA::isResult($r) || ($album == DI::l10n()->t(Photo::PROFILE_PHOTOS))) {
$visible = 1;
} else {
$visible = 0;
}
if (!empty($_REQUEST['not_visible']) && $_REQUEST['not_visible'] !== 'false') {
$visible = 0;
}
$ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
Hook::callAll('photo_post_file', $ret);
if (!empty($ret['src']) && !empty($ret['filesize'])) {
$src = $ret['src'];
$filename = $ret['filename'];
$filesize = $ret['filesize'];
$type = $ret['type'];
$error = UPLOAD_ERR_OK;
} elseif (!empty($_FILES['userfile'])) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$type = $_FILES['userfile']['type'];
$error = $_FILES['userfile']['error'];
} else {
$error = UPLOAD_ERR_NO_FILE;
}
if ($error !== UPLOAD_ERR_OK) {
switch ($error) {
case UPLOAD_ERR_INI_SIZE:
notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
break;
case UPLOAD_ERR_FORM_SIZE:
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
break;
case UPLOAD_ERR_PARTIAL:
notice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
break;
case UPLOAD_ERR_NO_FILE:
notice(DI::l10n()->t('Image file is missing'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
case UPLOAD_ERR_EXTENSION:
notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
break;
}
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
return;
}
$type = Images::getMimeTypeBySource($src, $filename, $type);
Logger::info('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes');
$maximagesize = DI::config()->get('system', 'maximagesize');
if ($maximagesize && ($filesize > $maximagesize)) {
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
return;
}
if (!$filesize) {
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]);
$imagedata = @file_get_contents($src);
$image = new Image($imagedata, $type);
if (!$image->isValid()) {
Logger::notice('unable to process image');
notice(DI::l10n()->t('Unable to process image.'));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end',$foo);
return;
}
$exif = $image->orient($src);
@unlink($src);
$max_length = DI::config()->get('system', 'max_image_length');
if ($max_length > 0) {
$image->scaleDown($max_length);
}
$width = $image->getWidth();
$height = $image->getHeight();
$smallest = 0;
$resource_id = Photo::newResource();
$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');
notice(DI::l10n()->t('Image upload failed.'));
return;
}
if ($width > 640 || $height > 640) {
$image->scaleDown(640);
Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 1;
}
if ($width > 320 || $height > 320) {
$image->scaleDown(320);
Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 2;
}
$uri = Item::newURI();
// Create item container
$lat = $lon = null;
if (!empty($exif['GPS']) && Feature::isEnabled($page_owner_uid, 'photo_location')) {
$lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
}
$arr = [];
if ($lat && $lon) {
$arr['coord'] = $lat . ' ' . $lon;
}
$arr['guid'] = System::createUUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['post-type'] = Item::PT_IMAGE;
$arr['wall'] = 1;
$arr['resource-id'] = $resource_id;
$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'] = $str_contact_allow;
$arr['allow_gid'] = $str_group_allow;
$arr['deny_cid'] = $str_contact_deny;
$arr['deny_gid'] = $str_group_deny;
$arr['visible'] = $visible;
$arr['origin'] = 1;
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $resource_id . ']'
. '[img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$image->getExt() . '[/img]'
. '[/url]';
$item_id = Item::insert($arr);
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
Hook::callAll('photo_post_end', $item_id);
// addon uploaders should call "exit()" within the photo_post_end hook
// if they do not wish to be redirected
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
} }
function photos_content(App $a) function photos_content(App $a)
{ {
// URLs: // URLs:
// photos/name
// photos/name/upload // photos/name/upload
// photos/name/upload/xxxxx (xxxxx is album name) // photos/name/upload/xxxxx (xxxxx is album name)
// photos/name/album/xxxxx // photos/name/album/xxxxx
@ -793,18 +577,18 @@ function photos_content(App $a)
// photos/name/image/xxxxx/edit // photos/name/image/xxxxx/edit
// photos/name/image/xxxxx/drop // photos/name/image/xxxxx/drop
$user = User::getByNickname(DI::args()->getArgv()[1]); $user = User::getByNickname(DI::args()->getArgv()[1] ?? '');
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
notice(DI::l10n()->t('Public access denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.'));
return; return;
} }
if (empty($user)) { if (empty($user)) {
notice(DI::l10n()->t('No photos selected')); DI::sysmsg()->addNotice(DI::l10n()->t('No photos selected'));
return; return;
} }
@ -844,10 +628,10 @@ function photos_content(App $a)
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if (local_user() && (local_user() == $owner_uid)) { if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) { } elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
$contact_id = Session::getRemoteContactID($owner_uid); $contact_id = DI::userSession()->getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
@ -858,23 +642,22 @@ function photos_content(App $a)
} }
// perhaps they're visiting - but not a community page, so they wouldn't have write access // perhaps they're visiting - but not a community page, so they wouldn't have write access
if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) { if (!empty(DI::userSession()->getRemoteContactID($owner_uid)) && !$visitor) {
$contact_id = Session::getRemoteContactID($owner_uid); $contact_id = DI::userSession()->getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
$remote_contact = DBA::isResult($contact); $remote_contact = DBA::isResult($contact);
} }
if (!$remote_contact && local_user()) { if (!$remote_contact && DI::userSession()->getLocalUserId()) {
$contact_id = $_SESSION['cid']; $contact_id = $_SESSION['cid'];
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
} }
if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($user['hidewall'] && !DI::userSession()->isAuthenticated()) {
notice(DI::l10n()->t('Access to this item is restricted.')); DI::baseUrl()->redirect('profile/' . $user['nickname'] . '/restricted');
return;
} }
$sql_extra = Security::getPermissionsSQLByUserId($owner_uid); $sql_extra = Security::getPermissionsSQLByUserId($owner_uid);
@ -882,16 +665,19 @@ function photos_content(App $a)
$o = ""; $o = "";
// tabs // tabs
$is_owner = (local_user() && (local_user() == $owner_uid)); $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid));
$o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']); $o .= BaseProfile::getTabsHTML('photos', $is_owner, $user['nickname'], $profile['hide-friends']);
// Display upload form // Display upload form
if ($datatype === 'upload') { if ($datatype === 'upload') {
if (!$can_post) { if (!$can_post) {
notice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return; return;
} }
// This prevents the photo upload form to return to itself without a hint the picture has been correctly uploaded.
DI::session()->remove('photo_return');
$selname = (!is_null($datum) && Strings::isHex($datum)) ? hex2bin($datum) : ''; $selname = (!is_null($datum) && Strings::isHex($datum)) ? hex2bin($datum) : '';
$albumselect = ''; $albumselect = '';
@ -910,7 +696,7 @@ function photos_content(App $a)
$uploader = ''; $uploader = '';
$ret = ['post_url' => 'photos/' . $user['nickname'], $ret = ['post_url' => 'profile/' . $user['nickname'] . '/photos',
'addon_text' => $uploader, 'addon_text' => $uploader,
'default_upload' => true]; 'default_upload' => true];
@ -921,7 +707,20 @@ function photos_content(App $a)
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
]); ]);
$usage_message = ''; // Get the relevant size limits for uploads. Abbreviated var names: MaxImageSize -> mis; upload_max_filesize -> umf
$mis_bytes = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
$umf_bytes = Strings::getBytesFromShorthand(ini_get('upload_max_filesize'));
// Per Friendica definition a value of '0' means unlimited:
If ($mis_bytes == 0) {
$mis_bytes = INF;
}
// When PHP is configured with upload_max_filesize less than maximagesize provide this lower limit.
$maximagesize_bytes = (is_numeric($mis_bytes) && ($mis_bytes < $umf_bytes) ? $mis_bytes : $umf_bytes);
// @todo We may be want to use appropriate binary prefixed dynamicly
$usage_message = DI::l10n()->t('The maximum accepted image size is %s', Strings::formatBytes($maximagesize_bytes));
$tpl = Renderer::getMarkupTemplate('photos_upload.tpl'); $tpl = Renderer::getMarkupTemplate('photos_upload.tpl');
@ -1088,9 +887,9 @@ function photos_content(App $a)
if (!DBA::isResult($ph)) { if (!DBA::isResult($ph)) {
if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) { if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied. Access to this item may be restricted.'));
} else { } else {
notice(DI::l10n()->t('Photo not available')); DI::sysmsg()->addNotice(DI::l10n()->t('Photo not available'));
} }
return; return;
} }
@ -1201,7 +1000,7 @@ function photos_content(App $a)
} }
if ( if (
$ph[0]['uid'] == local_user() $ph[0]['uid'] == DI::userSession()->getLocalUserId()
&& (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) && (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'); $tools['lock'] = DI::l10n()->t('Private Photo');
@ -1233,7 +1032,7 @@ function photos_content(App $a)
$link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]); $link_item = Post::selectFirst([], ["`resource-id` = ?" . $sql_extra, $datum]);
if (!empty($link_item['parent']) && !empty($link_item['uid'])) { if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], GRAVITY_COMMENT]; $condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
$total = Post::count($condition); $total = Post::count($condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString()); $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
@ -1241,7 +1040,7 @@ function photos_content(App $a)
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; $params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params)); $items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
if (local_user() == $link_item['uid']) { if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]); Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
} }
} }
@ -1255,15 +1054,17 @@ function photos_content(App $a)
if (!empty($link_item['id'])) { if (!empty($link_item['id'])) {
// parse tags and add links // parse tags and add links
$tag_arr = []; $tag_arr = [];
foreach (Tag::getByURIId($link_item['uri-id']) as $tag) { foreach (explode(',', Tag::getCSVByURIId($link_item['uri-id'])) as $tag_name) {
$tag_arr[] = [ if ($tag_name) {
'name' => $tag['name'], $tag_arr[] = [
'removeurl' => '/tagrm/' . $link_item['id'] . '/' . bin2hex($tag['name']) 'name' => BBCode::toPlaintext($tag_name),
]; 'removeurl' => 'post/' . $link_item['id'] . '/tag/remove/' . bin2hex($tag_name) . '?return=' . urlencode(DI::args()->getCommand()),
];
}
} }
$tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr]; $tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr];
if ($cmd === 'edit') { if ($cmd === 'edit') {
$tags['removeanyurl'] = 'tagrm/' . $link_item['id']; $tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand());
$tags['removetitle'] = DI::l10n()->t('[Select tags to remove]'); $tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
} }
} }
@ -1319,7 +1120,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1350,7 +1151,7 @@ function photos_content(App $a)
'attendmaybe' => [] 'attendmaybe' => []
]; ];
if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']); unset($conv_responses['dislike']);
} }
@ -1375,7 +1176,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1404,42 +1205,42 @@ function photos_content(App $a)
if (($activity->match($item['verb'], Activity::LIKE) || if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) && $activity->match($item['verb'], Activity::DISLIKE)) &&
($item['gravity'] != GRAVITY_PARENT)) { ($item['gravity'] != Item::GRAVITY_PARENT)) {
continue; continue;
} }
$author = ['uid' => 0, 'id' => $item['author-id'], $author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']]; 'network' => $item['author-network'], 'url' => $item['author-link']];
$profile_url = Contact::magicLinkByContact($author); $profile_url = Contact::magicLinkByContact($author);
if (strpos($profile_url, 'redir/') === 0) { if (strpos($profile_url, 'contact/redir/') === 0) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} else { } else {
$sparkle = ''; $sparkle = '';
} }
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
$drop = [ $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
'pagedrop' => false, 'pagedrop' => false,
'select' => DI::l10n()->t('Select'), 'select' => DI::l10n()->t('Select'),
'delete' => DI::l10n()->t('Delete'), 'delete' => DI::l10n()->t('Delete'),
]; ];
$title_e = $item['title']; $title_e = $item['title'];
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']); $body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
$comments .= Renderer::replaceMacros($template,[ $comments .= Renderer::replaceMacros($template,[
'$id' => $item['id'], '$id' => $item['id'],
'$profile_url' => $profile_url, '$profile_url' => $profile_url,
'$name' => $item['author-name'], '$name' => $item['author-name'],
'$thumb' => $item['author-avatar'], '$thumb' => $item['author-avatar'],
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
'$title' => $title_e, '$title' => $title_e,
'$body' => $body_e, '$body' => $body_e,
'$ago' => Temporal::getRelativeDate($item['created']), '$ago' => Temporal::getRelativeDate($item['created']),
'$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''), '$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
'$drop' => $drop, '$drop' => $drop,
'$comment' => $comment '$comment' => $comment
]); ]);
if (($can_post || Security::canWriteToUserWall($owner_uid))) { if (($can_post || Security::canWriteToUserWall($owner_uid))) {
@ -1449,7 +1250,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1488,7 +1289,7 @@ function photos_content(App $a)
'$dislike' => DI::l10n()->t('Dislike'), '$dislike' => DI::l10n()->t('Dislike'),
'$wait' => DI::l10n()->t('Please wait'), '$wait' => DI::l10n()->t('Please wait'),
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'), '$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
'$hide_dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike'), '$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
'$responses' => $responses, '$responses' => $responses,
'$return_path' => DI::args()->getQueryString(), '$return_path' => DI::args()->getQueryString(),
]); ]);
@ -1525,68 +1326,4 @@ function photos_content(App $a)
return $o; return $o;
} }
// Default - show recent photos with upload link (if applicable)
//$o = '';
$total = 0;
$r = DBA::toArray(DBA::p("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `photo-type` = ?
$sql_extra GROUP BY `resource-id`",
$user['uid'],
Photo::DEFAULT,
));
if (DBA::isResult($r)) {
$total = count($r);
}
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20);
$r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,
ANY_VALUE(`created`) AS `created` FROM `photo`
WHERE `uid` = ? AND `photo-type` = ?
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT ? , ?",
$user['uid'],
Photo::DEFAULT,
$pager->getStart(),
$pager->getItemsPerPage()
));
$photos = [];
if (DBA::isResult($r)) {
// "Twist" is only used for the duepunto theme with style "slackr"
$twist = false;
foreach ($r as $rr) {
$twist = !$twist;
$ext = $phototypes[$rr['type']];
$alt_e = $rr['filename'];
$name_e = $rr['album'];
$photos[] = [
'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id'],
'title' => DI::l10n()->t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e,
'album' => [
'link' => 'photos/' . $user['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e,
'alt' => DI::l10n()->t('View Album'),
],
];
}
}
$tpl = Renderer::getMarkupTemplate('photos_recent.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Recent Photos'),
'$can_post' => $can_post,
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload'],
'$photos' => $photos,
'$paginate' => $pager->renderFull($total),
]);
return $o;
} }

View file

@ -1,234 +0,0 @@
<?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/>.
*
* @see https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\DateTimeFormat;
function poco_init(App $a) {
if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
if (DI::args()->getArgc() > 1) {
// Only the system mode is supported
throw new \Friendica\Network\HTTPException\NotFoundException();
}
$format = ($_GET['format'] ?? '') ?: 'json';
$totalResults = DBA::count('profile', ['net-publish' => true]);
if ($totalResults == 0) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
if (!empty($_GET['startIndex'])) {
$startIndex = intval($_GET['startIndex']);
} else {
$startIndex = 0;
}
$itemsPerPage = (!empty($_GET['count']) ? intval($_GET['count']) : $totalResults);
Logger::info("Start system mode query");
$contacts = DBA::selectToArray('owner-view', [], ['net-publish' => true], ['limit' => [$startIndex, $itemsPerPage]]);
Logger::info("Query done");
$ret = [];
if (!empty($_GET['sorted'])) {
$ret['sorted'] = false;
}
if (!empty($_GET['filtered'])) {
$ret['filtered'] = false;
}
if (!empty($_GET['updatedSince'])) {
$ret['updatedSince'] = false;
}
$ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults;
$ret['entry'] = [];
$fields_ret = [
'id' => false,
'displayName' => false,
'urls' => false,
'updated' => false,
'preferredUsername' => false,
'photos' => false,
'aboutMe' => false,
'currentLocation' => false,
'network' => false,
'tags' => false,
'address' => false,
'contactType' => false,
'generation' => false
];
if (empty($_GET['fields'])) {
foreach ($fields_ret as $k => $v) {
$fields_ret[$k] = true;
}
} else {
$fields_req = explode(',', $_GET['fields']);
foreach ($fields_req as $f) {
$fields_ret[trim($f)] = true;
}
}
if (!is_array($contacts)) {
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
if (DBA::isResult($contacts)) {
foreach ($contacts as $contact) {
if (!isset($contact['updated'])) {
$contact['updated'] = '';
}
if (! isset($contact['generation'])) {
$contact['generation'] = 1;
}
if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) {
$contact['keywords'] = $contact['pub_keywords'];
}
if (isset($contact['account-type'])) {
$contact['contact-type'] = $contact['account-type'];
}
$cacheKey = 'about:' . $contact['nick'] . ':' . DateTimeFormat::utc($contact['updated'], DateTimeFormat::ATOM);
$about = DI::cache()->get($cacheKey);
if (is_null($about)) {
$about = BBCode::convertForUriId($contact['uri-id'], $contact['about']);
DI::cache()->set($cacheKey, $about);
}
// Non connected persons can only see the keywords of a Diaspora account
if ($contact['network'] == Protocol::DIASPORA) {
$contact['location'] = "";
$about = "";
}
$entry = [];
if ($fields_ret['id']) {
$entry['id'] = (int)$contact['id'];
}
if ($fields_ret['displayName']) {
$entry['displayName'] = $contact['name'];
}
if ($fields_ret['aboutMe']) {
$entry['aboutMe'] = $about;
}
if ($fields_ret['currentLocation']) {
$entry['currentLocation'] = $contact['location'];
}
if ($fields_ret['generation']) {
$entry['generation'] = (int)$contact['generation'];
}
if ($fields_ret['urls']) {
$entry['urls'] = [['value' => $contact['url'], 'type' => 'profile']];
if ($contact['addr'] && ($contact['network'] !== Protocol::MAIL)) {
$entry['urls'][] = ['value' => 'acct:' . $contact['addr'], 'type' => 'webfinger'];
}
}
if ($fields_ret['preferredUsername']) {
$entry['preferredUsername'] = $contact['nick'];
}
if ($fields_ret['updated']) {
$entry['updated'] = $contact['success_update'];
if ($contact['name-date'] > $entry['updated']) {
$entry['updated'] = $contact['name-date'];
}
if ($contact['uri-date'] > $entry['updated']) {
$entry['updated'] = $contact['uri-date'];
}
if ($contact['avatar-date'] > $entry['updated']) {
$entry['updated'] = $contact['avatar-date'];
}
$entry['updated'] = date("c", strtotime($entry['updated']));
}
if ($fields_ret['photos']) {
$entry['photos'] = [['value' => $contact['photo'], 'type' => 'profile']];
}
if ($fields_ret['network']) {
$entry['network'] = $contact['network'];
if ($entry['network'] == Protocol::STATUSNET) {
$entry['network'] = Protocol::OSTATUS;
}
if (($entry['network'] == "") && ($contact['self'])) {
$entry['network'] = Protocol::DFRN;
}
}
if ($fields_ret['tags']) {
$tags = str_replace(",", " ", $contact['keywords']);
$tags = explode(" ", $tags);
$cleaned = [];
foreach ($tags as $tag) {
$tag = trim(strtolower($tag));
if ($tag != "") {
$cleaned[] = $tag;
}
}
$entry['tags'] = [$cleaned];
}
if ($fields_ret['address']) {
$entry['address'] = [];
if (isset($contact['locality'])) {
$entry['address']['locality'] = $contact['locality'];
}
if (isset($contact['region'])) {
$entry['address']['region'] = $contact['region'];
}
if (isset($contact['country'])) {
$entry['address']['country'] = $contact['country'];
}
}
if ($fields_ret['contactType']) {
$entry['contactType'] = intval($contact['contact-type']);
}
$ret['entry'][] = $entry;
}
} else {
$ret['entry'][] = [];
}
Logger::info("End of poco");
if ($format === 'json') {
System::jsonExit($ret);
} else {
throw new \Friendica\Network\HTTPException\UnsupportedMediaTypeException();
}
}

View file

@ -1,158 +0,0 @@
<?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\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
use Friendica\Util\Strings;
use Friendica\Util\Network;
use Friendica\Model\GServer;
use Friendica\Model\Post;
function hub_return($valid, $body)
{
if ($valid) {
echo $body;
} else {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
System::exit();
}
// when receiving an XML feed, always return OK
function hub_post_return()
{
throw new \Friendica\Network\HTTPException\OKException();
}
function pubsub_init(App $a)
{
$nick = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : '');
$contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
if (DI::args()->getMethod() === App\Router::GET) {
$hub_mode = trim($_GET['hub_mode'] ?? '');
$hub_topic = trim($_GET['hub_topic'] ?? '');
$hub_challenge = trim($_GET['hub_challenge'] ?? '');
$hub_verify = trim($_GET['hub_verify_token'] ?? '');
Logger::notice('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick);
Logger::debug('Data: ', ['get' => $_GET]);
$subscribe = (($hub_mode === 'subscribe') ? 1 : 0);
$owner = DBA::selectFirst('user', ['uid'], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($owner)) {
Logger::notice('Local account not found: ' . $nick);
hub_return(false, '');
}
$condition = ['uid' => $owner['uid'], 'id' => $contact_id, 'blocked' => false, 'pending' => false];
if (!empty($hub_verify)) {
$condition['hub-verify'] = $hub_verify;
}
$contact = DBA::selectFirst('contact', ['id', 'poll'], $condition);
if (!DBA::isResult($contact)) {
Logger::notice('Contact ' . $contact_id . ' not found.');
hub_return(false, '');
}
if (!empty($hub_topic) && !Strings::compareLink($hub_topic, $contact['poll'])) {
Logger::notice('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
hub_return(false, '');
}
// We must initiate an unsubscribe request with a verify_token.
// Don't allow outsiders to unsubscribe us.
if (($hub_mode === 'unsubscribe') && empty($hub_verify)) {
Logger::notice('Bogus unsubscribe');
hub_return(false, '');
}
if (!empty($hub_mode)) {
Contact::update(['subhub' => $subscribe], ['id' => $contact['id']]);
Logger::notice($hub_mode . ' success for contact ' . $contact_id . '.');
}
hub_return(true, $hub_challenge);
}
}
function pubsub_post(App $a)
{
$xml = Network::postdata();
Logger::info('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
Logger::debug('Data: ' . $xml);
$nick = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : '');
$contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($importer)) {
hub_post_return();
}
$condition = ['id' => $contact_id, 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false];
$contact = DBA::selectFirst('contact', [], $condition);
if (!DBA::isResult($contact)) {
$author = OStatus::salmonAuthor($xml, $importer);
if (!empty($author['contact-id'])) {
$condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false];
$contact = DBA::selectFirst('contact', [], $condition);
Logger::notice('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.');
}
if (!DBA::isResult($contact)) {
Logger::notice('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml);
hub_post_return();
}
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
}
if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) {
Logger::notice('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
hub_post_return();
}
// We only import feeds from OStatus here
if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS])) {
Logger::warning('Unexpected network', ['contact' => $contact]);
hub_post_return();
}
Logger::info('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')');
$feedhub = '';
OStatus::import($xml, $importer, $contact, $feedhub);
hub_post_return();
}

View file

@ -1,147 +0,0 @@
<?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\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\PushSubscriber;
use Friendica\Util\Strings;
function pubsubhubbub_init(App $a) {
// PuSH subscription must be considered "public" so just block it
// if public access isn't enabled.
if (DI::config()->get('system', 'block_public')) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
// Subscription request from subscriber
// https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#anchor4
// Example from GNU Social:
// [hub_mode] => subscribe
// [hub_callback] => http://status.local/main/push/callback/1
// [hub_verify] => sync
// [hub_verify_token] => af11...
// [hub_secret] => af11...
// [hub_topic] => http://friendica.local/dfrn_poll/sazius
if (DI::args()->getMethod() === App\Router::POST) {
$hub_mode = $_POST['hub_mode'] ?? '';
$hub_callback = $_POST['hub_callback'] ?? '';
$hub_verify_token = $_POST['hub_verify_token'] ?? '';
$hub_secret = $_POST['hub_secret'] ?? '';
$hub_topic = $_POST['hub_topic'] ?? '';
// check for valid hub_mode
if ($hub_mode === 'subscribe') {
$subscribe = 1;
} elseif ($hub_mode === 'unsubscribe') {
$subscribe = 0;
} else {
Logger::notice("Invalid hub_mode=$hub_mode, ignoring.");
throw new \Friendica\Network\HTTPException\NotFoundException();
}
Logger::info("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
if (DI::args()->getArgc() > 1) {
// Normally the url should now contain the nick name as last part of the url
$nick = DI::args()->getArgv()[1];
} else {
// Get the nick name from the topic as a fallback
$nick = $hub_topic;
}
// Extract nick name and strip any .atom extension
$nick = basename($nick, '.atom');
if (!$nick) {
Logger::notice('Bad hub_topic=$hub_topic, ignoring.');
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// fetch user from database given the nickname
$condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false];
$owner = DBA::selectFirst('user', ['uid', 'nickname'], $condition);
if (!DBA::isResult($owner)) {
Logger::notice('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// get corresponding row from contact table
$condition = ['uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'self' => true];
$contact = DBA::selectFirst('contact', ['poll'], $condition);
if (!DBA::isResult($contact)) {
Logger::notice('Self contact for user ' . $owner['uid'] . ' not found.');
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// sanity check that topic URLs are the same
$hub_topic2 = str_replace('/feed/', '/dfrn_poll/', $hub_topic);
$self = DI::baseUrl() . '/api/statuses/user_timeline/' . $owner['nickname'] . '.atom';
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
Logger::notice('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// do subscriber verification according to the PuSH protocol
$hub_challenge = Strings::getRandomHex(40);
$params = http_build_query([
'hub.mode' => $subscribe == 1 ? 'subscribe' : 'unsubscribe',
'hub.topic' => $hub_topic,
'hub.challenge' => $hub_challenge,
'hub.verify_token' => $hub_verify_token,
// lease time is hard coded to one week (in seconds)
// we don't actually enforce the lease time because GNU
// Social/StatusNet doesn't honour it (yet)
'hub.lease_seconds' => 604800,
]);
$hub_callback = rtrim($hub_callback, ' ?&#');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
$fetchResult = DI::httpClient()->fetchFull($hub_callback . $separator . $params);
$body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode();
// give up if the HTTP return code wasn't a success (2xx)
if ($ret < 200 || $ret > 299) {
Logger::notice("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring.");
throw new \Friendica\Network\HTTPException\NotFoundException();
}
// check that the correct hub_challenge code was echoed back
if (trim($body) !== $hub_challenge) {
Logger::notice("Subscriber did not echo back hub.challenge, ignoring.");
Logger::notice("\"$hub_challenge\" != \"".trim($body)."\"");
throw new \Friendica\Network\HTTPException\NotFoundException();
}
PushSubscriber::renew($owner['uid'], $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret);
throw new \Friendica\Network\HTTPException\AcceptedException();
}
System::exit();
}

View file

@ -1,178 +0,0 @@
<?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\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Util\Strings;
function redir_init(App $a) {
if (!Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
$url = $_GET['url'] ?? '';
if (DI::args()->getArgc() > 1 && intval(DI::args()->getArgv()[1])) {
$cid = intval(DI::args()->getArgv()[1]);
} else {
$cid = 0;
}
// Try magic auth before the legacy stuff
redir_magic($a, $cid, $url);
if (empty($cid)) {
throw new \Friendica\Network\HTTPException\BadRequestException(DI::l10n()->t('Bad Request.'));
}
$fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name'];
$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.'));
}
$contact_url = $contact['url'];
if (!empty($a->getContactId()) && $a->getContactId() == $cid) {
// Local user is already authenticated.
redir_check_url($contact_url, $url);
$a->redirect($url ?: $contact_url);
}
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' => local_user()]);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
}
if (!empty($a->getContactId()) && $a->getContactId() == $cid) {
// Local user is already authenticated.
redir_check_url($contact_url, $url);
$target_url = $url ?: $contact_url;
Logger::info($contact['name'] . " is already authenticated. Redirecting to " . $target_url);
$a->redirect($target_url);
}
}
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);
// On a local instance we have to check if the local user has already authenticated
// 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) && (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;
Logger::info($contact['name'] . " is already authenticated. Redirecting to " . $target_url);
$a->redirect($target_url);
}
}
if (empty($url)) {
throw new \Friendica\Network\HTTPException\BadRequestException(DI::l10n()->t('Bad Request.'));
}
// If we don't have a connected contact, redirect with
// the 'zrl' parameter.
$my_profile = Profile::getMyURL();
if (!empty($my_profile) && !Strings::compareLink($my_profile, $url)) {
$separator = strpos($url, '?') ? '&' : '?';
$url .= $separator . 'zrl=' . urlencode($my_profile);
}
Logger::info('redirecting to ' . $url);
$a->redirect($url);
}
function redir_magic($a, $cid, $url)
{
$visitor = Profile::getMyURL();
if (!empty($visitor)) {
Logger::info('Got my url', ['visitor' => $visitor]);
}
$contact = DBA::selectFirst('contact', ['url'], ['id' => $cid]);
if (!DBA::isResult($contact)) {
Logger::info('Contact not found', ['id' => $cid]);
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
} else {
$contact_url = $contact['url'];
redir_check_url($contact_url, $url);
$target_url = $url ?: $contact_url;
}
$basepath = Contact::getBasepath($contact_url);
// We don't use magic auth when there is no visitor, we are on the same system or we visit our own stuff
if (empty($visitor) || Strings::compareLink($basepath, DI::baseUrl()) || Strings::compareLink($contact_url, $visitor)) {
Logger::info('Redirecting without magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
DI::app()->redirect($target_url);
}
// Test for magic auth on the target system
$serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
if ($serverret->isSuccess()) {
$separator = strpos($target_url, '?') ? '&' : '?';
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
Logger::info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
System::externalRedirect($target_url);
} else {
Logger::info('No magic for contact', ['contact' => $contact_url]);
}
}
function redir_check_url(string $contact_url, string $url)
{
if (empty($contact_url) || empty($url)) {
return;
}
$url_host = parse_url($url, PHP_URL_HOST);
if (empty($url_host)) {
$url_host = parse_url(DI::baseUrl(), PHP_URL_HOST);
}
$contact_url_host = parse_url($contact_url, PHP_URL_HOST);
if ($url_host == $contact_url_host) {
return;
}
Logger::error('URL check host mismatch', ['contact' => $contact_url, 'url' => $url]);
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}

View file

@ -1,108 +0,0 @@
<?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\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\Strings;
function removeme_post(App $a)
{
if (!local_user()) {
return;
}
if (!empty($_SESSION['submanage'])) {
return;
}
if (empty($_POST['qxz_password'])) {
return;
}
if (empty($_POST['verify'])) {
return;
}
if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
return;
}
// send notification to admins so that they can clean um the backups
// send email to admins
$admin_mails = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email')));
foreach ($admin_mails as $mail) {
$admin = DBA::selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => $mail]);
if (!DBA::isResult($admin)) {
continue;
}
$l10n = DI::l10n()->withLang($admin['language']);
$email = DI::emailer()
->newSystemMail()
->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', local_user()))
->forUser($admin)
->withRecipient($admin['email'])
->build();
DI::emailer()->send($email);
}
if (User::getIdFromPasswordAuthentication($a->getLoggedInUserId(), trim($_POST['qxz_password']))) {
User::remove($a->getLoggedInUserId());
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
DI::baseUrl()->redirect();
// NOTREACHED
}
}
function removeme_content(App $a)
{
if (!local_user()) {
DI::baseUrl()->redirect();
}
$hash = Strings::getRandomHex();
require_once("mod/settings.php");
settings_init($a);
$_SESSION['remove_account_verify'] = $hash;
$tpl = Renderer::getMarkupTemplate('removeme.tpl');
$o = Renderer::replaceMacros($tpl, [
'$basedir' => DI::baseUrl()->get(),
'$hash' => $hash,
'$title' => DI::l10n()->t('Remove My Account'),
'$desc' => DI::l10n()->t('This will completely remove your account. Once this has been done it is not recoverable.'),
'$passwd' => DI::l10n()->t('Please enter your password for verification:'),
'$submit' => DI::l10n()->t('Remove My Account')
]);
return $o;
}

View file

@ -1,64 +0,0 @@
<?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\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
function repair_ostatus_content(App $a) {
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 = local_user();
$counter = intval($_REQUEST['counter'] ?? 0);
$condition = ['uid' => $uid, 'network' => Protocol::OSTATUS, 'rel' => [Contact::FRIEND, Contact::SHARING]];
$total = DBA::count('contact', $condition);
if (!$total) {
return ($o . DI::l10n()->t('Error'));
}
$contact = Contact::selectToArray(['url'], $condition, ['order' => ['url'], 'limit' => [$counter++, 1]]);
if (!DBA::isResult($contact)) {
$o .= DI::l10n()->t('Done');
return $o;
}
$o .= '<p>' . $counter . '/' . $total . ': ' . $contact[0]['url'] . '</p>';
$o .= '<p>' . DI::l10n()->t('Keep this window open until done.') . '</p>';
Contact::createFromProbeForUser($a->getLoggedInUserId(), $contact[0]['url']);
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . DI::baseUrl() . '/repair_ostatus?counter=' . $counter . '">';
return $o;
}

View file

@ -1,183 +0,0 @@
<?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\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\GServer;
use Friendica\Model\Post;
use Friendica\Protocol\ActivityNamespace;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\Strings;
function salmon_post(App $a, $xml = '') {
if (empty($xml)) {
$xml = Network::postdata();
}
Logger::debug('new salmon ' . $xml);
$nick = trim(DI::args()->getArgv()[1] ?? '');
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (! DBA::isResult($importer)) {
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
// parse the xml
$dom = simplexml_load_string($xml,'SimpleXMLElement',0, ActivityNamespace::SALMON_ME);
$base = null;
// figure out where in the DOM tree our data is hiding
if (!empty($dom->provenance->data))
$base = $dom->provenance;
elseif (!empty($dom->env->data))
$base = $dom->env;
elseif (!empty($dom->data))
$base = $dom;
if (empty($base)) {
Logger::notice('unable to locate salmon data in xml');
throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Stash the signature away for now. We have to find their key or it won't be good for anything.
$signature = Strings::base64UrlDecode($base->sig);
// unpack the data
// strip whitespace so our data element will return to one big base64 blob
$data = str_replace([" ","\t","\r","\n"],["","","",""],$base->data);
// stash away some other stuff for later
$type = $base->data[0]->attributes()->type[0];
$keyhash = $base->sig[0]->attributes()->keyhash[0] ?? '';
$encoding = $base->encoding;
$alg = $base->alg;
// Salmon magic signatures have evolved and there is no way of knowing ahead of time which
// flavour we have. We'll try and verify it regardless.
$stnet_signed_data = $data;
$signed_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
$compliant_format = str_replace('=', '', $signed_data);
// decode the data
$data = Strings::base64UrlDecode($data);
$author = OStatus::salmonAuthor($data, $importer);
$author_link = $author["author-link"];
if(! $author_link) {
Logger::notice('Could not retrieve author URI.');
throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Once we have the author URI, go to the web and try to find their public key
Logger::notice('Fetching key for ' . $author_link);
$key = Salmon::getKey($author_link, $keyhash);
if(! $key) {
Logger::notice('Could not retrieve author key.');
throw new \Friendica\Network\HTTPException\BadRequestException();
}
$key_info = explode('.',$key);
$m = Strings::base64UrlDecode($key_info[1]);
$e = Strings::base64UrlDecode($key_info[2]);
Logger::info('key details', ['info' => $key_info]);
$pubkey = Crypto::meToPem($m, $e);
// We should have everything we need now. Let's see if it verifies.
// Try GNU Social format
$verify = Crypto::rsaVerify($signed_data, $signature, $pubkey);
$mode = 1;
if (! $verify) {
Logger::notice('message did not verify using protocol. Trying compliant format.');
$verify = Crypto::rsaVerify($compliant_format, $signature, $pubkey);
$mode = 2;
}
if (! $verify) {
Logger::notice('message did not verify using padding. Trying old statusnet format.');
$verify = Crypto::rsaVerify($stnet_signed_data, $signature, $pubkey);
$mode = 3;
}
if (! $verify) {
Logger::notice('Message did not verify. Discarding.');
throw new \Friendica\Network\HTTPException\BadRequestException();
}
Logger::notice('Message verified with mode '.$mode);
/*
*
* If we reached this point, the message is good. Now let's figure out if the author is allowed to send us stuff.
*
*/
$contact = DBA::selectFirst('contact', [], ["`network` IN (?, ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `uid` = ?",
Protocol::OSTATUS, Protocol::DFRN, Strings::normaliseLink($author_link), $author_link, Strings::normaliseLink($author_link), $importer['uid']]);
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
}
// Have we ignored the person?
// If so we can not accept this post.
if (!empty($contact['blocked'])) {
Logger::notice('Ignoring this author.');
throw new \Friendica\Network\HTTPException\AcceptedException();
}
// Placeholder for hub discovery.
$hub = '';
$contact = $contact ?: [];
OStatus::import($data, $importer, $contact, $hub);
throw new \Friendica\Network\HTTPException\OKException();
}

View file

@ -1,358 +0,0 @@
<?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\BaseModule;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\BaseSettings;
use Friendica\Module\Security\Login;
use Friendica\Protocol\Email;
function settings_init(App $a)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
BaseSettings::createAside();
}
function settings_post(App $a)
{
if (!$a->isLoggedIn()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
if (!empty($_SESSION['submanage'])) {
return;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'addon')) {
BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_addon');
Hook::callAll('addon_settings_post', $_POST);
DI::baseUrl()->redirect(DI::args()->getQueryString());
return;
}
$user = User::getById($a->getLoggedInUserId());
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) {
BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors');
if (!empty($_POST['general-submit'])) {
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', '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'] ?? '';
$mail_ssl = strtolower(trim($_POST['mail_ssl'] ?? ''));
$mail_user = $_POST['mail_user'] ?? '';
$mail_pass = trim($_POST['mail_pass'] ?? '');
$mail_action = trim($_POST['mail_action'] ?? '');
$mail_movetofolder = trim($_POST['mail_movetofolder'] ?? '');
$mail_replyto = $_POST['mail_replyto'] ?? '';
$mail_pubmail = $_POST['mail_pubmail'] ?? '';
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
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' => local_user()]);
}
$r = DBA::update('mailacct', [
'server' => $mail_server,
'port' => $mail_port,
'ssltype' => $mail_ssl,
'user' => $mail_user,
'action' => $mail_action,
'movetofolder' => $mail_movetofolder,
'mailbox' => 'INBOX',
'reply_to' => $mail_replyto,
'pubmail' => $mail_pubmail
], ['uid' => local_user()]);
Logger::debug('updating mailaccount', ['response' => $r]);
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
if (DBA::isResult($mailacct)) {
$mb = Email::constructMailboxName($mailacct);
if (strlen($mailacct['server'])) {
$dcrpass = '';
openssl_private_decrypt(hex2bin($mailacct['pass']), $dcrpass, $user['prvkey']);
$mbox = Email::connect($mb, $mail_user, $dcrpass);
unset($dcrpass);
if (!$mbox) {
notice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
}
}
}
}
}
Hook::callAll('connector_settings_post', $_POST);
DI::baseUrl()->redirect(DI::args()->getQueryString());
return;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) {
DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
}
}
return;
}
}
function settings_content(App $a)
{
$o = '';
Nav::setSelected('settings');
if (!local_user()) {
//notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
if (!empty($_SESSION['submanage'])) {
notice(DI::l10n()->t('Permission denied.'));
return '';
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth')) {
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' => local_user()]);
DI::baseUrl()->redirect('settings/oauth/', true);
return '';
}
$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, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
'$baseurl' => DI::baseUrl()->get(true),
'$title' => DI::l10n()->t('Connected Apps'),
'$name' => DI::l10n()->t('Name'),
'$website' => DI::l10n()->t('Home Page'),
'$created_at' => DI::l10n()->t('Created'),
'$delete' => DI::l10n()->t('Remove authorization'),
'$apps' => $applications,
]);
return $o;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'addon')) {
$addon_settings_forms = [];
foreach (DI::dba()->selectToArray('hook', ['file', 'function'], ['hook' => 'addon_settings']) as $hook) {
$data = [];
Hook::callSingle(DI::app(), 'addon_settings', [$hook['file'], $hook['function']], $data);
if (!empty($data['href'])) {
$tpl = Renderer::getMarkupTemplate('settings/addon/link.tpl');
$addon_settings_forms[] = Renderer::replaceMacros($tpl, [
'$addon' => $data['addon'],
'$title' => $data['title'],
'$href' => $data['href'],
]);
} elseif(!empty($data['addon'])) {
$tpl = Renderer::getMarkupTemplate('settings/addon/panel.tpl');
$addon_settings_forms[$data['addon']] = Renderer::replaceMacros($tpl, [
'$addon' => $data['addon'],
'$title' => $data['title'],
'$open' => (DI::args()->getArgv()[2] ?? '') === $data['addon'],
'$html' => $data['html'] ?? '',
'$submit' => $data['submit'] ?? DI::l10n()->t('Save Settings'),
]);
}
}
$tpl = Renderer::getMarkupTemplate('settings/addons.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_addon"),
'$title' => DI::l10n()->t('Addon Settings'),
'$no_addons_settings_configured' => DI::l10n()->t('No Addon settings configured'),
'$addon_settings_forms' => $addon_settings_forms,
]);
return $o;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features')) {
$arr = [];
$features = Feature::get();
foreach ($features as $fname => $fdata) {
$arr[$fname] = [];
$arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(local_user(), $f[0]), $f[2]];
}
}
$tpl = Renderer::getMarkupTemplate('settings/features.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_features"),
'$title' => DI::l10n()->t('Additional Features'),
'$features' => $arr,
'$submit' => DI::l10n()->t('Save Settings'),
]);
return $o;
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) {
$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_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?
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . DI::baseUrl().'/ostatus_subscribe?url=' . urlencode($legacy_contact) . '">';
}
$connector_settings_forms = [];
foreach (DI::dba()->selectToArray('hook', ['file', 'function'], ['hook' => 'connector_settings']) as $hook) {
$data = [];
Hook::callSingle(DI::app(), 'connector_settings', [$hook['file'], $hook['function']], $data);
$tpl = Renderer::getMarkupTemplate('settings/addon/connector.tpl');
$connector_settings_forms[$data['connector']] = Renderer::replaceMacros($tpl, [
'$connector' => $data['connector'],
'$title' => $data['title'],
'$image' => $data['image'] ?? '',
'$enabled' => $data['enabled'] ?? true,
'$open' => (DI::args()->getArgv()[2] ?? '') === $data['connector'],
'$html' => $data['html'] ?? '',
'$submit' => $data['submit'] ?? DI::l10n()->t('Save Settings'),
]);
}
if ($a->isSiteAdmin()) {
$diasp_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('Diaspora (Socialhome, Hubzilla)'), ((DI::config()->get('system', 'diaspora_enabled')) ? DI::l10n()->t('enabled') : DI::l10n()->t('disabled')));
$ostat_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('OStatus (GNU Social)'), ((DI::config()->get('system', 'ostatus_disabled')) ? DI::l10n()->t('disabled') : DI::l10n()->t('enabled')));
} else {
$diasp_enabled = "";
$ostat_enabled = "";
}
$mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1);
if (!$mail_disabled) {
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
} else {
$mailacct = null;
}
$mail_server = $mailacct['server'] ?? '';
$mail_port = (!empty($mailacct['port']) && is_numeric($mailacct['port'])) ? (int)$mailacct['port'] : '';
$mail_ssl = $mailacct['ssltype'] ?? '';
$mail_user = $mailacct['user'] ?? '';
$mail_replyto = $mailacct['reply_to'] ?? '';
$mail_pubmail = $mailacct['pubmail'] ?? 0;
$mail_action = $mailacct['action'] ?? 0;
$mail_movetofolder = $mailacct['movetofolder'] ?? '';
$mail_chk = $mailacct['last_check'] ?? DBA::NULL_DATETIME;
$tpl = Renderer::getMarkupTemplate('settings/connectors.tpl');
$mail_disabled_message = ($mail_disabled ? DI::l10n()->t('Email access is disabled on this site.') : '');
$ssl_options = ['TLS' => 'TLS', 'SSL' => 'SSL'];
if (DI::config()->get('system', 'insecure_imap')) {
$ssl_options['notls'] = DI::l10n()->t('None');
}
$o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_connectors"),
'$title' => DI::l10n()->t('Social Networks'),
'$diasp_enabled' => $diasp_enabled,
'$ostat_enabled' => $ostat_enabled,
'$general_settings' => DI::l10n()->t('General Social Media Settings'),
'$accept_only_sharer' => [
'accept_only_sharer',
DI::l10n()->t('Followed content scope'),
$accept_only_sharer,
DI::l10n()->t('By default, conversations in which your follows participated but didn\'t start will be shown in your timeline. You can turn this behavior off, or expand it to the conversations in which your follows liked a post.'),
[
Item::COMPLETION_NONE => DI::l10n()->t('Only conversations my follows started'),
Item::COMPLETION_COMMENT => DI::l10n()->t('Conversations my follows started or commented on (default)'),
Item::COMPLETION_LIKE => DI::l10n()->t('Any conversation my follows interacted with, including likes'),
]
],
'$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_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.')],
'$legacy_contact' => ['legacy_contact', DI::l10n()->t('Your legacy ActivityPub/GNU Social account'), $legacy_contact, DI::l10n()->t("If you enter your old account name from an ActivityPub based system or your GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.")],
'$repair_ostatus_url' => DI::baseUrl() . '/repair_ostatus',
'$repair_ostatus_text' => DI::l10n()->t('Repair OStatus subscriptions'),
'$connector_settings_forms' => $connector_settings_forms,
'$h_mail' => DI::l10n()->t('Email/Mailbox Setup'),
'$mail_desc' => DI::l10n()->t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."),
'$mail_lastcheck' => ['mail_lastcheck', DI::l10n()->t('Last successful email check:'), $mail_chk, ''],
'$mail_disabled' => $mail_disabled_message,
'$mail_server' => ['mail_server', DI::l10n()->t('IMAP server name:'), $mail_server, ''],
'$mail_port' => ['mail_port', DI::l10n()->t('IMAP port:'), $mail_port, ''],
'$mail_ssl' => ['mail_ssl', DI::l10n()->t('Security:'), strtoupper($mail_ssl), '', $ssl_options],
'$mail_user' => ['mail_user', DI::l10n()->t('Email login name:'), $mail_user, ''],
'$mail_pass' => ['mail_pass', DI::l10n()->t('Email password:'), '', ''],
'$mail_replyto' => ['mail_replyto', DI::l10n()->t('Reply-to address:'), $mail_replyto, 'Optional'],
'$mail_pubmail' => ['mail_pubmail', DI::l10n()->t('Send public posts to all email contacts:'), $mail_pubmail, ''],
'$mail_action' => ['mail_action', DI::l10n()->t('Action after import:'), $mail_action, '', [0 => DI::l10n()->t('None'), 1 => DI::l10n()->t('Delete'), 2 => DI::l10n()->t('Mark as seen'), 3 => DI::l10n()->t('Move to folder')]],
'$mail_movetofolder' => ['mail_movetofolder', DI::l10n()->t('Move to folder:'), $mail_movetofolder, ''],
'$submit' => DI::l10n()->t('Save Settings'),
]);
Hook::callAll('display_settings', $o);
return $o;
}
}

View file

@ -1,58 +0,0 @@
<?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\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Module\Contact as ModuleContact;
use Friendica\Network\HTTPException;
function suggest_content(App $a)
{
if (!local_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$_SESSION['return_path'] = DI::args()->getCommand();
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
$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.');
}
$entries = [];
foreach ($contacts as $contact) {
$entries[] = ModuleContact::getContactTemplateVars($contact);
}
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
return Renderer::replaceMacros($tpl,[
'$title' => DI::l10n()->t('Friend Suggestions'),
'$contacts' => $entries,
]);
}

View file

@ -1,171 +0,0 @@
<?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\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Protocol\Activity;
use Friendica\Util\XML;
use Friendica\Worker\Delivery;
function tagger_content(App $a) {
if (!Session::isAuthenticated()) {
return;
}
$term = trim($_GET['term'] ?? '');
// no commas allowed
$term = str_replace([',',' ', '<', '>'],['','_', '', ''], $term);
if (!$term) {
return;
}
$item_id = ((DI::args()->getArgc() > 1) ? trim(DI::args()->getArgv()[1]) : 0);
Logger::info('tagger: tag', ['term' => $term, 'item' => $item_id]);
$item = Post::selectFirst([], ['id' => $item_id]);
if (!$item_id || !DBA::isResult($item)) {
Logger::notice('tagger: no item ' . $item_id);
return;
}
$owner_uid = $item['uid'];
if (local_user() != $owner_uid) {
return;
}
$contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]);
if (!DBA::isResult($contact)) {
Logger::warning('Self contact not found.', ['uid' => local_user()]);
return;
}
$uri = Item::newURI();
$xterm = XML::escape($term);
$post_type = (($item['resource-id']) ? DI::l10n()->t('photo') : DI::l10n()->t('status'));
$targettype = (($item['resource-id']) ? Activity\ObjectType::IMAGE : Activity\ObjectType::NOTE );
$href = DI::baseUrl() . '/display/' . $item['guid'];
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
$body = XML::escape($item['body']);
$target = <<< EOT
<target>
<type>$targettype</type>
<local>1</local>
<id>{$item['uri']}</id>
<link>$link</link>
<title></title>
<content>$body</content>
</target>
EOT;
$tagid = DI::baseUrl() . '/search?tag=' . $xterm;
$objtype = Activity\ObjectType::TAGTERM;
$obj = <<< EOT
<object>
<type>$objtype</type>
<local>1</local>
<id>$tagid</id>
<link>$tagid</link>
<title>$xterm</title>
<content>$xterm</content>
</object>
EOT;
$bodyverb = DI::l10n()->t('%1$s tagged %2$s\'s %3$s with %4$s');
if (!isset($bodyverb)) {
return;
}
$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['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);
if (!$item['visible']) {
Item::update(['visible' => true], ['id' => $item['id']]);
}
Tag::store($item['uri-id'], Tag::HASHTAG, $term);
$arr['id'] = $post_id;
Hook::callAll('post_local_end', $arr);
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
System::exit();
}

View file

@ -1,131 +0,0 @@
<?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\Content\Text\BBCode;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
use Friendica\Model\Tag;
function tagrm_post(App $a)
{
if (!local_user()) {
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
if (!empty($_POST['submit']) && ($_POST['submit'] === DI::l10n()->t('Cancel'))) {
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
$tags = [];
foreach ($_POST['tag'] ?? [] as $tag) {
$tags[] = hex2bin(trim($tag));
}
$item_id = $_POST['item'] ?? 0;
update_tags($item_id, $tags);
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
}
/**
* Updates tags from an item
*
* @param $item_id
* @param $tags array
* @throws Exception
*/
function update_tags($item_id, $tags)
{
if (empty($item_id) || empty($tags)) {
return;
}
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
return;
}
foreach ($tags as $new_tag) {
if (preg_match_all('/([#@!])\[url\=([^\[\]]*)\]([^\[\]]*)\[\/url\]/ism', $new_tag, $results, PREG_SET_ORDER)) {
foreach ($results as $tag) {
Tag::removeByHash($item['uri-id'], $tag[1], $tag[3], $tag[2]);
}
}
}
}
function tagrm_content(App $a)
{
$o = '';
$photo_return = $_SESSION['photo_return'] ?? '';
if (!local_user()) {
DI::baseUrl()->redirect($photo_return);
// NOTREACHED
}
if (DI::args()->getArgc()== 3) {
update_tags(DI::args()->getArgv()[1], [trim(hex2bin(DI::args()->getArgv()[2]))]);
DI::baseUrl()->redirect($photo_return);
}
$item_id = ((DI::args()->getArgc()> 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$item_id) {
DI::baseUrl()->redirect($photo_return);
// NOTREACHED
}
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
DI::baseUrl()->redirect($photo_return);
}
$tag_text = Tag::getCSVByURIId($item['uri-id']);
$arr = explode(',', $tag_text);
if (empty($arr)) {
DI::baseUrl()->redirect($photo_return);
}
$o .= '<h3>' . DI::l10n()->t('Remove Item Tag') . '</h3>';
$o .= '<p id="tag-remove-desc">' . DI::l10n()->t('Select a tag to remove: ') . '</p>';
$o .= '<form id="tagrm" action="tagrm" method="post" >';
$o .= '<input type="hidden" name="item" value="' . $item_id . '" />';
$o .= '<ul>';
foreach ($arr as $x) {
$o .= '<li><input type="checkbox" name="tag[]" value="' . bin2hex($x) . '" >' . BBCode::convert($x) . '</input></li>';
}
$o .= '</ul>';
$o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . DI::l10n()->t('Remove') .'" />';
$o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . DI::l10n()->t('Cancel') .'" />';
$o .= '</form>';
return $o;
}

View file

@ -1,71 +0,0 @@
<?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/>.
*
* View for user import
*/
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\UserImport;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
function uimport_post(App $a)
{
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
notice(DI::l10n()->t('Permission denied.'));
return;
}
if (!empty($_FILES['accountfile'])) {
UserImport::importAccount($_FILES['accountfile']);
return;
}
}
function uimport_content(App $a)
{
if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.'));
return;
}
$max_dailies = intval(DI::config()->get('system', 'max_daily_registrations'));
if ($max_dailies) {
$total = DBA::count('user', ["`register_date` > UTC_TIMESTAMP - INTERVAL 1 DAY"]);
if ($total >= $max_dailies) {
Logger::notice('max daily registrations exceeded.');
notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
return;
}
}
$tpl = Renderer::getMarkupTemplate("uimport.tpl");
return Renderer::replaceMacros($tpl, [
'$regbutt' => DI::l10n()->t('Import'),
'$import' => [
'title' => DI::l10n()->t("Move account"),
'intro' => DI::l10n()->t("You can import an account from another Friendica server."),
'instruct' => DI::l10n()->t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."),
'warn' => DI::l10n()->t("This feature is experimental. We can't import contacts from the OStatus network \x28GNU Social/Statusnet\x29 or from Diaspora"),
'field' => ['accountfile', DI::l10n()->t('Account file'), '<input id="id_accountfile" name="accountfile" type="file">', DI::l10n()->t('To export your account, go to "Settings->Export your personal data" and select "Export account"')],
],
]);
}

View file

@ -1,151 +0,0 @@
<?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\Content\Widget;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Util\Strings;
function unfollow_post(App $a)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login');
// NOTREACHED
}
$url = trim($_REQUEST['url'] ?? '');
unfollow_process($url);
}
function unfollow_content(App $a)
{
$base_return_path = 'contact';
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login');
// NOTREACHED
}
$uid = local_user();
$url = trim($_REQUEST['url']);
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
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)) {
notice(DI::l10n()->t("You aren't following this contact."));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
if (!Protocol::supportsFollow($contact['network'])) {
notice(DI::l10n()->t('Unfollowing is currently not supported by your network.'));
DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']);
// NOTREACHED
}
$request = DI::baseUrl() . '/unfollow';
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
if (!empty($_REQUEST['auto'])) {
unfollow_process($contact['url']);
}
$o = Renderer::replaceMacros($tpl, [
'$header' => DI::l10n()->t('Disconnect/Unfollow'),
'$page_desc' => '',
'$your_address' => DI::l10n()->t('Your Identity Address:'),
'$invite_desc' => '',
'$submit' => DI::l10n()->t('Submit Request'),
'$cancel' => DI::l10n()->t('Cancel'),
'$url' => $contact['url'],
'$zrl' => Contact::magicLinkByContact($contact),
'$url_label' => DI::l10n()->t('Profile URL'),
'$myaddr' => $self['url'],
'$request' => $request,
'$keywords' => '',
'$keywords_label'=> ''
]);
DI::page()['aside'] = Widget\VCard::getHTML(Contact::getByURL($contact['url'], false));
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => DI::l10n()->t('Status Messages and Posts')]);
// Show last public posts
$o .= Contact::getPostsFromUrl($contact['url']);
return $o;
}
function unfollow_process(string $url)
{
$base_return_path = 'contact';
$uid = local_user();
$owner = User::getOwnerDataById($uid);
if (!$owner) {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
Strings::normaliseLink($url), $url];
$contact = DBA::selectFirst('contact', [], $condition);
if (!DBA::isResult($contact)) {
notice(DI::l10n()->t("You aren't following this contact."));
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
$return_path = $base_return_path . '/' . $contact['id'];
try {
Contact::unfollow($contact);
$notice_message = DI::l10n()->t('Contact was successfully unfollowed');
} catch (Exception $e) {
DI::logger()->error($e->getMessage(), ['contact' => $contact]);
$notice_message = DI::l10n()->t('Unable to unfollow this contact, please contact your administrator');
}
notice($notice_message);
DI::baseUrl()->redirect($return_path);
}

View file

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

View file

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

View file

@ -1,137 +0,0 @@
<?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\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach;
use Friendica\Model\User;
use Friendica\Util\Strings;
function wall_attach_post(App $a) {
$r_json = (!empty($_GET['response']) && $_GET['response']=='json');
if (DI::args()->getArgc() > 1) {
$nick = DI::args()->getArgv()[1];
$owner = User::getOwnerDataByNick($nick);
if (!DBA::isResult($owner)) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
} else {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
$can_post = false;
$page_owner_uid = $owner['uid'];
$page_owner_cid = $owner['id'];
$community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
} 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) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
}
notice(DI::l10n()->t('Permission denied.') . EOL );
System::exit();
}
if (empty($_FILES['userfile'])) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
System::exit();
}
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$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') . EOL .(DI::l10n()->t('Or - did you try to upload an empty file?'));
@unlink($src);
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
notice($msg);
}
System::exit();
}
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 . EOL;
}
System::exit();
}
$newid = Attach::storeFile($src, $page_owner_uid, $filename, '<' . $page_owner_cid . '>');
@unlink($src);
if ($newid === false) {
$msg = DI::l10n()->t('File upload failed.');
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg . EOL;
}
System::exit();
}
if ($r_json) {
System::jsonExit(['ok' => true, 'id' => $newid]);
}
$lf = "\n";
echo $lf . $lf . '[attachment]' . $newid . '[/attachment]' . $lf;
System::exit();
// NOTREACHED
}

View file

@ -1,286 +0,0 @@
<?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/>.
*
* Module for uploading a picture to the profile wall
*
* By default the picture will be stored in the photo album with the name Wall Photos.
* You can specify a different album by adding an optional query string "album="
* to the url
*
*/
use Friendica\App;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Model\User;
use Friendica\Module\BaseApi;
use Friendica\Object\Image;
use Friendica\Util\Images;
use Friendica\Util\Strings;
function wall_upload_post(App $a, $desktopmode = true)
{
Logger::info("wall upload: starting new upload");
$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];
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
} else {
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['uid' => BaseApi::getCurrentUserID(), 'blocked' => false]);
}
} else {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
return;
}
/*
* Setup permissions structures
*/
$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) ? true : false);
if ((local_user()) && (local_user() == $page_owner_uid)) {
$can_post = true;
} 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) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
}
notice(DI::l10n()->t('Permission denied.'));
System::exit();
}
if (empty($_FILES['userfile']) && empty($_FILES['media'])) {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
System::exit();
}
$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'])) {
$src = $_FILES['media']['tmp_name'][0];
} else {
$src = $_FILES['media']['tmp_name'];
}
}
if (!empty($_FILES['media']['name'])) {
if (is_array($_FILES['media']['name'])) {
$filename = basename($_FILES['media']['name'][0]);
} else {
$filename = basename($_FILES['media']['name']);
}
}
if (!empty($_FILES['media']['size'])) {
if (is_array($_FILES['media']['size'])) {
$filesize = intval($_FILES['media']['size'][0]);
} else {
$filesize = intval($_FILES['media']['size']);
}
}
if (!empty($_FILES['media']['type'])) {
if (is_array($_FILES['media']['type'])) {
$filetype = $_FILES['media']['type'][0];
} else {
$filetype = $_FILES['media']['type'];
}
}
}
if ($src == "") {
if ($r_json) {
System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
}
notice(DI::l10n()->t('Invalid request.'));
System::exit();
}
$filetype = Images::getMimeTypeBySource($src, $filename, $filetype);
Logger::info("File upload src: " . $src . " - filename: " . $filename .
" - size: " . $filesize . " - type: " . $filetype);
$imagedata = @file_get_contents($src);
$image = new Image($imagedata, $filetype);
if (!$image->isValid()) {
$msg = DI::l10n()->t('Unable to process image.');
@unlink($src);
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg. EOL;
}
System::exit();
}
$image->orient($src);
@unlink($src);
$max_length = DI::config()->get('system', 'max_image_length');
if ($max_length > 0) {
$image->scaleDown($max_length);
$filesize = strlen($image->asString());
Logger::info("File upload: Scaling picture to new size " . $max_length);
}
$width = $image->getWidth();
$height = $image->getHeight();
$maximagesize = DI::config()->get('system', 'maximagesize');
if (!empty($maximagesize) && ($filesize > $maximagesize)) {
// Scale down to multiples of 640 until the maximum size isn't exceeded anymore
foreach ([5120, 2560, 1280, 640] as $pixels) {
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
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();
}
}
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 ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg. EOL;
}
System::exit();
}
}
$resource_id = Photo::newResource();
$smallest = 0;
// If we don't have an album name use the Wall Photos album
if (!strlen($album)) {
$album = DI::l10n()->t('Wall Photos');
}
$defperm = '<' . $default_cid . '>';
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
if (!$r) {
$msg = DI::l10n()->t('Image upload failed.');
if ($r_json) {
System::jsonExit(['error' => $msg]);
} else {
echo $msg. EOL;
}
System::exit();
}
if ($width > 640 || $height > 640) {
$image->scaleDown(640);
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
if ($r) {
$smallest = 1;
}
}
if ($width > 320 || $height > 320) {
$image->scaleDown(320);
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
if ($r && ($smallest == 0)) {
$smallest = 2;
}
}
if (!$desktopmode) {
$photo = Photo::selectFirst(['id', 'datasize', 'width', 'height', 'type'], ['resource-id' => $resource_id], ['order' => ['width']]);
if (!$photo) {
if ($r_json) {
System::jsonExit(['error' => '']);
}
return false;
}
$picture = [];
$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 ($r_json) {
System::jsonExit(['picture' => $picture]);
}
Logger::info("upload done");
return $picture;
}
Logger::info("upload done");
if ($r_json) {
System::jsonExit(['ok' => true]);
}
echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt() . "[/img][/url]\n\n";
System::exit();
// NOTREACHED
}

View file

@ -1,146 +0,0 @@
<?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' => [ 'config' => [
'hostname' => 'friendica.local', 'hostname' => '192.168.56.10',
'admin_email' => 'admin@friendica.local', 'admin_email' => 'admin@friendica.local',
'sitename' => 'Friendica Social Network', 'sitename' => 'Friendica Social Network',
'register_policy' => \Friendica\Module\Register::OPEN, 'register_policy' => \Friendica\Module\Register::OPEN,

View file

@ -7,7 +7,6 @@ bin/daemon.php
bin/testargs.php bin/testargs.php
bin/wait-for-connection bin/wait-for-connection
bin/worker.php bin/worker.php
config/addon-sample.config.php
config/local-sample.config.php config/local-sample.config.php
doc/ doc/
images/ images/
@ -19,7 +18,6 @@ static/
vendor/ vendor/
view/ view/
.htaccess-dist .htaccess-dist
boot.php
CHANGELOG CHANGELOG
CREDITS.txt CREDITS.txt
database.sql database.sql

View file

@ -0,0 +1,128 @@
##
# Friendica Nginx configuration template to be autoconfigured with certbot
# based on sample-nginx.config by Olaf Conradi
#
# On Debian based distributions you can add this file to
# /etc/nginx/sites-available
#
# Then customize it to your needs. At least replace the server_name in line 41.
#
# Enable the configuration by
# symlink it to /etc/nginx/sites-enabled
#
# and run
# certbot --nginx -d friendica.example.net
#
# Then reload Nginx using
# systemctl nginx reload
#
##
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
#
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
##
##
# This configuration assumes your domain is example.net
# You have a separate subdomain friendica.example.net
# You want all Friendica traffic to be https using letsencrypt with cerbot
# You have an SSL certificate and key for your subdomain
# You have PHP FastCGI Process Manager (php7.4-fpm) running on localhost
# You have Friendica installed in /var/www/friendica
##
server {
listen 80;
server_name friendica.example.net;
# Point here to the path where your friendica files are located
root /var/www/friendica;
# Logging
access_log /var/log/nginx/friendica_access.log;
# uncomment the following line if you would like to log errors in a separate file for friendica
#error_log /var/log/nginx/friendica_error.log;
index index.php;
charset utf-8;
# Uncomment the following line to include a standard configuration file Note
# that the most specific rule wins and your standard configuration will
# therefore *add* to this file, but not override it.
#include standard.conf
# allow uploads up to 20MB in size
client_max_body_size 20m;
client_body_buffer_size 128k;
# rewrite to front controller as default rule
location / {
try_files $uri /index.php?pagename=$uri&$args;
}
# make sure webfinger and other well known services aren't blocked
# by denying dot files and rewrite request to the front controller
location ^~ /.well-known/ {
allow all;
rewrite ^ /index.php?pagename=$uri;
}
include mime.types;
# statically serve these file types when possible otherwise fall back to
# front controller allow browser to cache them added .htm for advanced source
# code editor library
#location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
# expires 30d;
# try_files $uri /index.php?pagename=$uri&$args;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# or a unix socket
location ~* \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this
# server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on
# another machine. And then cross your fingers that you won't get hacked.
try_files $uri =404;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.4-fpm:
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
# block these file types
location ~* \.(tpl|md|tgz|log|out)$ {
deny all;
}
# deny access to all dot files
location ~ /\. {
deny all;
}
# deny access to the CLI scripts
location ^~ /bin {
deny all;
}
}

View file

@ -35,7 +35,7 @@ server {
index index.php; index index.php;
root /var/www/friendica; root /var/www/friendica;
rewrite ^ https://friendica.example.net$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
## ##
@ -51,8 +51,6 @@ server {
listen 443 ssl; listen 443 ssl;
server_name friendica.example.net; server_name friendica.example.net;
ssl on;
#Traditional SSL #Traditional SSL
ssl_certificate /etc/nginx/ssl/friendica.example.net.chain.pem; ssl_certificate /etc/nginx/ssl/friendica.example.net.chain.pem;
ssl_certificate_key /etc/nginx/ssl/example.net.key; ssl_certificate_key /etc/nginx/ssl/example.net.key;
@ -122,7 +120,7 @@ server {
# fastcgi_pass 127.0.0.1:9000; # fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm: # With php7.0-fpm:
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
include fastcgi_params; include fastcgi_params;
fastcgi_index index.php; fastcgi_index index.php;

View file

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

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