Merge pull request #5789 from friendica/master

Update develop from master-2019.09
This commit is contained in:
Hypolite Petovan 2018-09-23 18:55:20 -04:00 committed by GitHub
commit a6996601d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 17335 additions and 17104 deletions

131
CHANGELOG
View file

@ -1,3 +1,134 @@
Version 2018.09 (2018-09-23)
Friendica Core:
Update to the translation (CS, DE, EN-US, FI, IT, NL, PL, ZH-CN) [translation teams]
Update to the documentation [Aditoo17, annando, astifter, rebeka-catalina, fabrixxm, M-arcus, microgroove, nupplaphil, tobiasd]
Enhancements to the database structure, handling and documentation [abanink, Angristan, annando, miqrogroove, tobiasd]
Enhancements of unit testing [abanink, nupplaphil, rudloff]
Enhancements to labelling of UI elements [andyhee, tobiasd]
Enhancements to the background workers [annando, miqrogroove, rabuzarus]
Enhancements to the PHP7.2 compatibility [annando, miqrogroove, MrPetovan]
Enhancements to the content filter [MrPetovan]
Enhancements to the hooks provided for addons [abanink]
Enhancements to the interaction with public postings [annando]
Enhancements to the config storage [frabrixxm]
Enhancements to the themes (frio, quattro, smoothly, vier) [annando, astifter, hoergen, MrPetovan, rabuzarus, tobiasd]
Enhancements to the handling of locks [nupplaphil]
Enhancements to the redis integration [nupplaphil]
Enhancements to the admin panel [JeroenED, tobiasd]
Enhancements to the user import process [annando]
Enhancements to the display of invitation information [JeroenED]
Enhancements to the automatic installation process [nupplaphil]
Enhancements to the contact group UI [annando, astifter]
Enhancements to the call of JS [hypolite]
Enhancements to the storage of items in the database [annando]
Enhancements to the process of changing relationships [annando]
Enhancements to the OEmbed of data [MrPetovan]
Fixed various PHP notice occurrences [annando, MrPetovan]
Fixed a bug that could lead to the display of posts from deleted accounts on the community page for a short period [annando]
Fixed a bug that prevented email notification to be send out [annando]
Fixed a bug in database optimisation [annando]
Fixed a bug during removing contacts [annando]
Fixed a bug in the tag-cloud widget [annando]
Fixed a bug in the daemon mode of the background worker [annando]
Fixed a bug in the frio theme that contact filtering [rabuzarus]
Fixed a bug that mangled the display of some additional smileys [abanink]
Fixed a bug in generating registration mails [MrPetovan]
Fixed a bug that caused blank re-share bodies [MrPetovon]
Fixed a bug in the API handling of private mails [fabrixxm]
Fixed a bug when calling the mail() function [miqrogroove]
Fixed a bug that caused deleted accounts being displayed in the local directory [miqrogroove]
Fixed a bug when checking the domain of an email address [VVelox]
Fixed a bug that prevented re-shares from Twitter to be shown as this [annando]
Fixed a bug that caused broken profile links [miqrogroove]
Fixed a bug that caused content from unknown accounts appearing in the timeline [annando]
Fixed a bug with the ignoring and blocking of contacts [annando]
Fixed a bug with showing hidden contacts in some places [annando]
Fixed a bug that prevented the deletion of events by contacts [annando]
Fixed a bug that prevented email contacts from being added [annando]
Fixed a bug in the notification/seen API call [fabrixxm]
Fixed a bug that prevented a refresh after un-/ignoring a conversation [annando]
Fixed a bug in the handling of some language translations [anndno]
Fixed a bug in the hook handling [annando]
Fixed the handling of too long tags [annando]
Fixed a bug that prevented the unliking of dis-/likes [annando]
Fixed bugs with the handling of private nodes [annando]
Fixed a bug in the session initialisation [annando]
Fixed bugs in the execution of the background processes [annando, Quix0r]
Fixed a problem with the notification page [MrPetovan]
Fixed a bug with wrong dates in importing some Atom feeds [annando]
Fixed forum exclusive distribution of postings using the !notation [annando]
Fixed a bug that lead to empty notifications [MrPetovan]
Fixed a problem that could sometimes prevent the execution of the relocation [annando]
Fixed a bug with the handling of images in postings over the connectors [annando]
Added conversation cleanup configuration [miqrogroove]
Added support of the usage of internal diaspora links to accounts [annando]
Added the possibility for admins to block certain nicknames (e.g. role names) [tobiasd]
Added the generation of system guid [nupplaphil]
Added the possibility for admins to mark a node for explicit content [tobiasd]
Added filter by account type to the community page [annando]
Added private flag to API results [fabrixxm]
Added post update checks to the console utility [annando]
Added codecov analysis [nupplaphil]
Added access-keys to the frio theme [tobiasd]
Added the profile settings to the user settings [tobiasd]
General code refactoring and beautification work [annando, MrPetovan, Quix0r, tobiasd]
Fixation of the position on the network page when new posts arrive [rabuzarus]
Ported OpenWebAuth from Hubzilla [annando, rabuzarus]
Removed hard coded syntax highlighting from code blocks [MrPetovan]
Removed (temporarily) the possibility to add pictures to private messages [annando]
New INI style config file format in /config [MrPetovan, tobiasd]
The .htaccess file is not part of the git repository anymore [annando, Quix0r]
Friendica Addons:
Update to the translations (CS, DE, EN-US, NL, PL, ZH-CN) [translation teams]
General update to adopt changes in core [annando, MrPetovan, Quix0r, tobiasd]
advancedcontentfilter:
Enhancement to the error handling [MrPetovan]
Honour the CSP settings [MrPetovan]
Fixed translation problems [annando]
blockem:
Enhancement of the settings [AlfredSK]
buffer:
support for app.net removed [annando]
js_upload:
Enhancement of the album name handling [rabuzarus]
Enhancement to the wording of the labels [astifter]
langfilter:
Fixed a problem with default values of the filtered languages [tobiasd]
libravatar:
The service wont shutdown, so we can keep the addon [tobiasd]
pumpio:
Fixed a problem that prevented new connections [annando]
superblock:
Fixed a bug that prevented the addon to block accounts [annando]
Enhancements of the settings [AlfredSK]
twitter:
Use rich text for quote tweets [MrPetovan]
Prevent empty quotes from being created [annando]
Fixed a problem with re-shares from remote_self contacts [annando]
Changed URL display after link expansion [MrPetovan]
Fixed a problem with EXIF handling [MrPetovan]
added addons:
mastodoncustomemojis [MrPetovan]
deprecated addons:
notimeline, retriver, remote_permissions, widgets
Directory:
Enhancements of the health summary [andyhee]
Enhancements of the PHP7 compatibility [MrPetovan]
Closed Issues:
901, 1034, 1074, 1303, 1308, 1391, 1490, 1470, 1559, 2093, 2337,
2340, 2381, 2396, 2675, 3291, 3299, 3493, 3501, 3535, 3643, 3840,
4148, 4419, 4475, 4507, 4655, 4659, 4710, 4726, 4739, 4753, 4814,
4830, 4868, 4889, 4923, 4971, 4950, 4985, 5066, 5099, 5137, 5148,
5158, 5168, 5188, 5202, 5211, 5222, 5233, 5243, 5247, 5252, 5257,
5260, 5262, 5268, 5274, 5275, 5276, 5278, 5298, 5318, 5319, 5320,
5321, 5322, 5330, 5333, 5341, 5365, 5405, 5407, 5411, 5423, 5432,
5434, 5436, 5443, 5455, 5464, 5467, 5469, 5486, 5496, 5497, 5514,
5539, 5524, 5541, 5544, 5550, 5564, 5566, 5605, 5630, 5638, 5651,
5653, 5660, 5670, 5691, 5733, 5745, 5768
Version 2018.05 (2018-06-01)
Friendica Core:
Update to the translations (DE, EN-GB, EN-US, FI, IS, IT, NL, PL, RU, ZN CH) [translation teams]

View file

@ -1 +1 @@
2018.08-dev
2018.09

View file

@ -39,7 +39,7 @@ require_once 'include/text.php';
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
define('FRIENDICA_VERSION', '2018.08-dev');
define('FRIENDICA_VERSION', '2018.09');
define('DFRN_PROTOCOL_VERSION', '2.23');
define('DB_UPDATE_VERSION', 1283);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);

View file

@ -18,13 +18,12 @@
"asika/simple-console": "^1.0",
"divineomega/password_exposed": "^2.4",
"ezyang/htmlpurifier": "~4.7.0",
"league/html-to-markdown": "~4.4.1",
"league/html-to-markdown": "~4.8.0",
"lightopenid/lightopenid": "dev-master",
"michelf/php-markdown": "^1.7",
"mobiledetect/mobiledetectlib": "2.8.*",
"paragonie/random_compat": "^2.0",
"pear/Text_LanguageDetect": "1.*",
"pear/Text_Highlighter": "dev-master",
"seld/cli-prompt": "^1.0",
"smarty/smarty": "^3.1",
"fxp/composer-asset-plugin": "~1.3",

237
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "d62c3e3d6971ee63a862a22ff3cd3768",
"content-hash": "5f6a43237dc52758484cd21cd76e8ce6",
"packages": [
{
"name": "asika/simple-console",
@ -483,16 +483,16 @@
},
{
"name": "league/html-to-markdown",
"version": "4.4.1",
"version": "4.8.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186"
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/82ea375b5b2b1da1da222644c0565c695bf88186",
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/f9a879a068c68ff47b722de63f58bec79e448f9d",
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d",
"shasum": ""
},
"require": {
@ -511,7 +511,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.5-dev"
"dev-master": "4.9-dev"
}
},
"autoload": {
@ -524,17 +524,17 @@
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
},
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
@ -543,7 +543,7 @@
"html",
"markdown"
],
"time": "2017-03-16T00:45:59+00:00"
"time": "2018-09-18T12:18:08+00:00"
},
{
"name": "lightopenid/lightopenid",
@ -1669,204 +1669,6 @@
],
"time": "2018-02-15T05:50:20+00:00"
},
{
"name": "pear/console_getopt",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/pear/Console_Getopt.git",
"reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Console_Getopt/zipball/82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
"reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Console": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"./"
],
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Greg Beaver",
"email": "cellog@php.net",
"role": "Helper"
},
{
"name": "Andrei Zmievski",
"email": "andrei@php.net",
"role": "Lead"
},
{
"name": "Stig Bakken",
"email": "stig@php.net",
"role": "Developer"
}
],
"description": "More info available on: http://pear.php.net/package/Console_Getopt",
"time": "2015-07-20T20:28:12+00:00"
},
{
"name": "pear/pear-core-minimal",
"version": "v1.10.3",
"source": {
"type": "git",
"url": "https://github.com/pear/pear-core-minimal.git",
"reference": "070f0b600b2caca2501e2c9b7e553016e4b0d115"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/070f0b600b2caca2501e2c9b7e553016e4b0d115",
"reference": "070f0b600b2caca2501e2c9b7e553016e4b0d115",
"shasum": ""
},
"require": {
"pear/console_getopt": "~1.4",
"pear/pear_exception": "~1.0"
},
"replace": {
"rsky/pear-core-min": "self.version"
},
"type": "library",
"autoload": {
"psr-0": {
"": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"src/"
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Christian Weiske",
"email": "cweiske@php.net",
"role": "Lead"
}
],
"description": "Minimal set of PEAR core files to be used as composer dependency",
"time": "2017-02-28T16:46:11+00:00"
},
{
"name": "pear/pear_exception",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/pear/PEAR_Exception.git",
"reference": "8c18719fdae000b690e3912be401c76e406dd13b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b",
"reference": "8c18719fdae000b690e3912be401c76e406dd13b",
"shasum": ""
},
"require": {
"php": ">=4.4.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "class",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"PEAR": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"."
],
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Helgi Thormar",
"email": "dufuz@php.net"
},
{
"name": "Greg Beaver",
"email": "cellog@php.net"
}
],
"description": "The PEAR Exception base class.",
"homepage": "https://github.com/pear/PEAR_Exception",
"keywords": [
"exception"
],
"time": "2015-02-10T20:07:52+00:00"
},
{
"name": "pear/text_highlighter",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/pear/Text_Highlighter.git",
"reference": "2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Text_Highlighter/zipball/2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855",
"reference": "2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855",
"shasum": ""
},
"require": {
"pear/pear-core-minimal": "~1.10.0",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "@stable"
},
"type": "library",
"autoload": {
"psr-0": {
"Text": "./"
}
},
"include-path": [
"./"
],
"license": [
"PHP-3.01"
],
"authors": [
{
"email": "ssttoo@gmail.com",
"name": "Stoyan Stefanov",
"role": "Lead"
},
{
"email": "demenev@gmail.com",
"name": "Andrey Demenev",
"role": "Lead"
}
],
"description": "More info available on: http://pear.php.net/package/Text_Highlighter",
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Text_Highlighter",
"source": "https://github.com/pear/Text_Highlighter"
},
"time": "2018-01-27T08:24:15+00:00"
},
{
"name": "pear/text_languagedetect",
"version": "v1.0.0",
@ -3145,7 +2947,7 @@
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator",
"homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
@ -3247,7 +3049,7 @@
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "https://github.com/sebastianbergmann/environment",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
@ -3315,7 +3117,7 @@
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "https://github.com/sebastianbergmann/exporter",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
@ -3367,7 +3169,7 @@
}
],
"description": "Snapshotting of global state",
"homepage": "https://github.com/sebastianbergmann/global-state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
@ -3469,7 +3271,7 @@
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "https://github.com/sebastianbergmann/recursion-context",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-11-19T07:33:16+00:00"
},
{
@ -3669,8 +3471,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"lightopenid/lightopenid": 20,
"pear/text_highlighter": 20
"lightopenid/lightopenid": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View file

@ -33,7 +33,7 @@ If you don't want to translate the UI, or it is already done to your satisfactio
Are you good at designing things?
If you have seen Friendica you probably have ideas to improve it, haven't you?
* If you would like to work with us on enhancing the user interface, please join the [UX Watchdogs forum](https://fc.oscp.info/profile/ux-watchdogs)
* If you would like to work with us on enhancing the user interface, please join the [forum for Friendica development](https://forum.friendi.ca/profile/developers).
* Make plans for a better Friendica interface design and share them with us.
* Tell us if you are able to realize your ideas or what kind of help you need.
We can't promise we have the right skills in the group but we'll try.

View file

@ -15,6 +15,6 @@ Remember the link at the top of this page will bring you back here.
Once you've added some groups, <a href="help/Quick-Start-andfinally">move on to the next section</a>.
<iframe src="http://dir.friendica.com/directory/forum" width="950" height="600"></iframe>
<iframe src="http://dir.friendica.social/directory" width="950" height="600"></iframe>

View file

@ -180,7 +180,7 @@ Hier ist eine Liste von Clients bei denen dies möglich ist, bzw. die speziell f
<a name="help"></a>
### Wo finde ich Hilfe?
Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen.
Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) fragen oder Dir das [deutsche Wiki](https://friendica-wiki.de/) anschauen.
Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer öffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen.
Wenn du dir keinen weiteren Friendica Account einrichten willst, kannst du auch gerne über einen der folgenden alternativen Kanäle Hilfe suchen:

View file

@ -61,7 +61,7 @@ Friendica - Dokumentation und Ressourcen
**Externe Ressourcen**
* [Haupt-Webseite](https://friendi.ca)
* [Deutsches Friendica-Wiki](http://wiki.toktan.org/doku.php)
* [Deutsches Friendica-Wiki](https://friendica-wiki.de)
* Support Kanäle
* [Friendica Support Forum](https://forum.friendi.ca/~helpers)
* [Mailing Listen Archiv](http://mailman.friendi.ca/mailman/listinfo/support-friendi.ca) zum Abonnieren der Liste eine E-Mail an ``support-request(at)friendi.ca?subject=subscribe`` senden

View file

@ -581,7 +581,10 @@ function api_get_user(App $a, $contact_id = null)
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
if (!empty($a->argv[$argid])) {
list($user, $null) = explode(".", $a->argv[$argid]);
$data = explode(".", $a->argv[$argid]);
if (count($data) > 1) {
list($user, $null) = $data;
}
}
if (is_numeric($user)) {
$user = DBA::escape(api_unique_id_to_nurl(intval($user)));
@ -1056,10 +1059,10 @@ function api_statuses_mediap($type)
// now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]";
item_post($a);
$item_id = item_post($a);
// this should output the last post (the one we just posted).
return api_status_show($type);
// output the post that we just posted.
return api_status_show($type, $item_id);
}
/// @TODO move this to top of file or somewhere better!
@ -1075,7 +1078,6 @@ api_register_func('api/statuses/mediap', 'api_statuses_mediap', true, API_METHOD
*/
function api_statuses_update($type)
{
$a = get_app();
if (api_user() === false) {
@ -1129,8 +1131,8 @@ function api_statuses_update($type)
if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_day = DBA::count('item', $condition);
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_day = DBA::count('thread', $condition);
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1143,8 +1145,8 @@ function api_statuses_update($type)
if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_week = DBA::count('item', $condition);
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_week = DBA::count('thread', $condition);
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1157,8 +1159,8 @@ function api_statuses_update($type)
if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
$posts_month = DBA::count('item', $condition);
$condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_month = DBA::count('thread', $condition);
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1200,10 +1202,10 @@ function api_statuses_update($type)
}
// call out normal post function
item_post($a);
$item_id = item_post($a);
// this should output the last post (the one we just posted).
return api_status_show($type);
// output the post that we just posted.
return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better
@ -1260,7 +1262,7 @@ api_register_func('api/media/upload', 'api_media_upload', true, API_METHOD_POST)
*
* @return array|string
*/
function api_status_show($type)
function api_status_show($type, $item_id = 0)
{
$a = get_app();
@ -1274,9 +1276,14 @@ function api_status_show($type)
$privacy_sql = "";
}
// get last public wall message
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
if (!empty($item_id)) {
// Get the item with the given id
$condition = ['id' => $item_id];
} else {
// get last public wall message
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
}
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
if (DBA::isResult($lastwall)) {
@ -1993,14 +2000,14 @@ function api_statuses_repeat($type)
$_REQUEST["source"] = api_source();
}
item_post($a);
$item_id = item_post($a);
} else {
throw new ForbiddenException();
}
// this should output the last post (the one we just posted).
// output the post that we just posted.
$called_api = [];
return api_status_show($type);
return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better
@ -4396,7 +4403,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
if ($filetype == "") {
$filetype=Image::guessType($filename);
}
$imagedata = getimagesize($src);
$imagedata = @getimagesize($src);
if ($imagedata) {
$filetype = $imagedata['mime'];
}

View file

@ -229,12 +229,12 @@ function localize_item(&$item)
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = XML::parseString($xmlhead.$item['object']);
$links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title;
$Blink = "";
$Blink = $obj->id;
$Bphoto = "";
foreach ($links->link as $l) {
foreach ($obj->link as $l) {
$atts = $l->attributes();
switch ($atts['rel']) {
case "alternate": $Blink = $atts['href'];
@ -1454,7 +1454,7 @@ function get_responses(array $conv_responses, array $response_verbs, $ob, array
$ret = [];
foreach ($response_verbs as $v) {
$ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], 0);
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', []);
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
if (count($ret[$v]['list']) > MAX_LIKERS) {

View file

@ -72,7 +72,8 @@ function add_page_info_data(array $data, $no_photos = false)
$text .= " title='".$data["title"]."'";
}
if (!empty($data["images"])) {
// Only embedd a picture link when it seems to be a valid picture ("width" is set)
if (!empty($data["images"]) && !empty($data["images"][0]["width"])) {
$preview = str_replace(["[", "]"], ["&#91;", "&#93;"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
// if the preview picture is larger than 500 pixels then show it in a larger mode
// But only, if the picture isn't higher than large (To prevent huge posts)

View file

@ -1911,58 +1911,3 @@ function format_network_name($network, $url = 0) {
return $network_name;
}
}
/**
* @brief Syntax based code highlighting for popular languages.
* @param string $s Code block
* @param string $lang Programming language
* @return string Formated html
*/
function text_highlight($s, $lang) {
if ($lang === 'js') {
$lang = 'javascript';
}
if ($lang === 'bash') {
$lang = 'sh';
}
// @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
// Autoload the library to make constants available
class_exists('Text_Highlighter_Renderer_Html');
$options = [
'numbers' => HL_NUMBERS_LI,
'tabsize' => 4,
];
$tag_added = false;
$s = trim(html_entity_decode($s, ENT_COMPAT));
$s = str_replace(' ', "\t", $s);
/*
* The highlighter library insists on an opening php tag for php code blocks. If
* it isn't present, nothing is highlighted. So we're going to see if it's present.
* If not, we'll add it, and then quietly remove it after we get the processed output back.
*/
if ($lang === 'php' && strpos($s, '<?php') !== 0) {
$s = '<?php' . "\n" . $s;
$tag_added = true;
}
$renderer = new Text_Highlighter_Renderer_Html($options);
$factory = new Text_Highlighter();
$hl = $factory->factory($lang);
$hl->setRenderer($renderer);
$o = $hl->highlight($s);
$o = str_replace("\n", '', $o);
if ($tag_added) {
$b = substr($o, 0, strpos($o, '<li>'));
$e = substr($o, strpos($o, '</li>'));
$o = $b . $e;
}
return '<code>' . $o . '</code>';
}

View file

@ -6,9 +6,11 @@
use Friendica\Content\Text;
use Friendica\Core\L10n;
function visible_lf($s)
function visible_whitespace($s)
{
return str_replace("\n", '<br />', $s);
$s = str_replace(' ', '&nbsp;', $s);
return str_replace(["\r\n", "\n", "\r"], '<br />', $s);
}
function babel_content()
@ -20,19 +22,19 @@ function babel_content()
$bbcode = trim($_REQUEST['text']);
$results[] = [
'title' => L10n::t('Source input'),
'content' => visible_lf($bbcode)
'content' => visible_whitespace($bbcode)
];
$plain = Text\BBCode::toPlaintext($bbcode, false);
$results[] = [
'title' => L10n::t('BBCode::toPlaintext'),
'content' => visible_lf($plain)
'content' => visible_whitespace($plain)
];
$html = Text\BBCode::convert($bbcode);
$results[] = [
'title' => L10n::t("BBCode::convert \x28raw HTML\x29"),
'content' => htmlspecialchars($html)
'title' => L10n::t('BBCode::convert (raw HTML)'),
'content' => visible_whitespace(htmlspecialchars($html))
];
$results[] = [
@ -43,13 +45,13 @@ function babel_content()
$bbcode2 = Text\HTML::toBBCode($html);
$results[] = [
'title' => L10n::t('BBCode::convert => HTML::toBBCode'),
'content' => visible_lf($bbcode2)
'content' => visible_whitespace($bbcode2)
];
$markdown = Text\BBCode::toMarkdown($bbcode);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown'),
'content' => visible_lf($markdown)
'content' => visible_whitespace($markdown)
];
$html2 = Text\Markdown::convert($markdown);
@ -61,22 +63,33 @@ function babel_content()
$bbcode3 = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
'content' => visible_lf($bbcode3)
'content' => visible_whitespace($bbcode3)
];
$bbcode4 = Text\HTML::toBBCode($html2);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
'content' => visible_lf($bbcode4)
'content' => visible_whitespace($bbcode4)
];
break;
case 'markdown':
$markdown = trim($_REQUEST['text']);
$results[] = [
'title' => L10n::t('Source input \x28Diaspora format\x29'),
'title' => L10n::t('Source input (Diaspora format)'),
'content' => '<pre>' . $markdown . '</pre>'
];
$html = Text\Markdown::convert($markdown);
$results[] = [
'title' => L10n::t('Markdown::convert (raw HTML)'),
'content' => htmlspecialchars($html)
];
$results[] = [
'title' => L10n::t('Markdown::convert'),
'content' => $html
];
$bbcode = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => L10n::t('Markdown::toBBCode'),
@ -86,7 +99,7 @@ function babel_content()
case 'html' :
$html = trim($_REQUEST['text']);
$results[] = [
'title' => L10n::t("Raw HTML input"),
'title' => L10n::t('Raw HTML input'),
'content' => htmlspecialchars($html)
];
@ -98,7 +111,13 @@ function babel_content()
$bbcode = Text\HTML::toBBCode($html);
$results[] = [
'title' => L10n::t('HTML::toBBCode'),
'content' => visible_lf($bbcode)
'content' => visible_whitespace($bbcode)
];
$markdown = Text\HTML::toMarkdown($html);
$results[] = [
'title' => L10n::t('HTML::toMarkdown'),
'content' => visible_whitespace($markdown)
];
$text = Text\HTML::toPlaintext($html);
@ -111,7 +130,7 @@ function babel_content()
$tpl = get_markup_template('babel.tpl');
$o = replace_macros($tpl, [
'$text' => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
'$text' => ['text', L10n::t('Source text'), htmlentities(defaults($_REQUEST, 'text', '')), ''],
'$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],

View file

@ -30,6 +30,10 @@ function bookmarklet_content(App $a)
$page = normalise_link(System::baseUrl() . "/bookmarklet");
if (!strstr($referer, $page)) {
if (empty($_REQUEST["url"])) {
System::httpExit(400, ["title" => L10n::t('Bad Request')]);
}
$content = add_page_info($_REQUEST["url"]);
$x = [

View file

@ -47,6 +47,11 @@ function contacts_init(App $a)
if (!DBA::isResult($contact)) {
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]);
}
// Don't display contacts that are about to be deleted
if ($contact['network'] == Protocol::PHANTOM) {
$contact = false;
}
}
if (DBA::isResult($contact)) {
@ -122,11 +127,12 @@ function contacts_init(App $a)
function contacts_batch_actions(App $a)
{
$contacts_id = $_POST['contact_batch'];
if (!is_array($contacts_id)) {
if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
return;
}
$contacts_id = $_POST['contact_batch'];
$orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
implode(",", $contacts_id),
intval(local_user())
@ -367,7 +373,7 @@ function _contact_drop($orig_record)
return;
}
Contact::terminateFriendship($r[0], $orig_record);
Contact::terminateFriendship($r[0], $orig_record, true);
Contact::remove($orig_record['id']);
}
@ -595,17 +601,12 @@ function contacts_content(App $a, $update = 0)
/// @todo Only show the following link with DFRN when the remote version supports it
$follow = '';
$follow_text = '';
if (in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
$follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Disconnect/Unfollow");
} else {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Connect/Follow");
}
}
if ($contact['uid'] == 0) {
} else {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Connect/Follow");
}
@ -723,6 +724,8 @@ function contacts_content(App $a, $update = 0)
$sql_extra = " AND `blocked` = 0 ";
}
$sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
$nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : '';

View file

@ -79,13 +79,13 @@ function dfrn_notify_post(App $a) {
$condition = [];
switch ($direction) {
case (-1):
$condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id];
$condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
break;
case 0:
$condition = ['issued-id' => $dfrn_id, 'duplex' => true];
$condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break;
case 1:
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true];
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break;
default:
System::xmlExit(3, 'Invalid direction');
@ -182,7 +182,7 @@ function dfrn_notify_post(App $a) {
function dfrn_dispatch_public($postdata)
{
$msg = Diaspora::decodeRaw([], $postdata);
$msg = Diaspora::decodeRaw([], $postdata, true);
if (!$msg) {
// We have to fail silently to be able to hand it over to the salmon parser
return false;
@ -287,15 +287,15 @@ function dfrn_notify_content(App $a) {
$condition = [];
switch ($direction) {
case (-1):
$condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id];
$condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
$my_id = $dfrn_id;
break;
case 0:
$condition = ['issued-id' => $dfrn_id, 'duplex' => true];
$condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '1:' . $dfrn_id;
break;
case 1:
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true];
$condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '0:' . $dfrn_id;
break;
default:
@ -322,8 +322,8 @@ function dfrn_notify_content(App $a) {
$encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999);
$prv_key = trim($importer['prvkey']);
$pub_key = trim($importer['pubkey']);
$prv_key = trim($importer['cprvkey']);
$pub_key = trim($importer['cpubkey']);
$dplx = intval($importer['duplex']);
if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) {

View file

@ -44,7 +44,7 @@ function dirfind_content(App $a, $prefix = "") {
$local = Config::get('system','poco_local_search');
$search = $prefix.notags(trim($_REQUEST['search']));
$search = $prefix.notags(trim(defaults($_REQUEST, 'search', '')));
$header = '';

View file

@ -20,7 +20,8 @@ use Friendica\Util\Temporal;
require_once 'include/items.php';
function events_init(App $a) {
function events_init(App $a)
{
if (!local_user()) {
return;
}
@ -42,7 +43,8 @@ function events_init(App $a) {
return;
}
function events_post(App $a) {
function events_post(App $a)
{
logger('post: ' . print_r($_REQUEST, true), LOGGER_DATA);
@ -50,15 +52,15 @@ function events_post(App $a) {
return;
}
$event_id = (x($_POST, 'event_id') ? intval($_POST['event_id']) : 0);
$cid = (x($_POST, 'cid') ? intval($_POST['cid']) : 0);
$event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user();
$start_text = escape_tags($_REQUEST['start_text']);
$finish_text = escape_tags($_REQUEST['finish_text']);
$start_text = escape_tags(defaults($_REQUEST, 'start_text', ''));
$finish_text = escape_tags(defaults($_REQUEST, 'finish_text', ''));
$adjust = intval($_POST['adjust']);
$nofinish = intval($_POST['nofinish']);
$adjust = intval(defaults($_POST, 'adjust', 0));
$nofinish = intval(defaults($_POST, 'nofinish', 0));
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
@ -91,9 +93,9 @@ function events_post(App $a) {
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
$summary = escape_tags(trim(defaults($_POST, 'summary', '')));
$desc = escape_tags(trim(defaults($_POST, 'desc', '')));
$location = escape_tags(trim(defaults($_POST, 'location', '')));
$type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
@ -117,7 +119,7 @@ function events_post(App $a) {
goaway($onerror_url);
}
$share = (intval($_POST['share']) ? intval($_POST['share']) : 0);
$share = intval(defaults($_POST, 'share', 0));
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
@ -137,7 +139,7 @@ function events_post(App $a) {
$str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : '';
// Undo the pseudo-contact of self, since there are real contacts now
if (strpos($str_contact_allow, '<' . $self . '>') !== false ) {
if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
$str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
}
// Make sure to set the `private` field as true. This is necessary to
@ -187,8 +189,8 @@ function events_post(App $a) {
goaway($_SESSION['return_url']);
}
function events_content(App $a) {
function events_content(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
@ -244,7 +246,7 @@ function events_content(App $a) {
$mode = 'view';
$y = 0;
$m = 0;
$ignored = (x($_REQUEST, 'ignored') ? intval($_REQUEST['ignored']) : 0);
$ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0;
if ($a->argc > 1) {
if ($a->argc > 2 && $a->argv[1] == 'event') {
@ -272,7 +274,6 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php
if ($mode == 'view') {
$thisyear = DateTimeFormat::localNow('Y');
$thismonth = DateTimeFormat::localNow('m');
if (!$y) {
@ -312,10 +313,10 @@ function events_content(App $a) {
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
if ($a->argc > 1 && $a->argv[1] === 'json') {
if (x($_GET, 'start')) {
$start = $_GET['start'];
if (!empty($_GET['start'])) {
$start = $_GET['start'];
}
if (x($_GET, 'end')) {
if (!empty($_GET['end'])) {
$finish = $_GET['end'];
}
}
@ -349,7 +350,7 @@ function events_content(App $a) {
$r = Event::sortByDate($r);
foreach ($r as $rr) {
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
if (!x($links,$j)) {
if (empty($links[$j])) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
}
@ -363,12 +364,12 @@ function events_content(App $a) {
$events = Event::prepareListForTemplate($r);
}
if ($a->argc > 1 && $a->argv[1] === 'json'){
if ($a->argc > 1 && $a->argv[1] === 'json') {
echo json_encode($events);
killme();
}
if (x($_GET, 'id')) {
if (!empty($_GET['id'])) {
$tpl = get_markup_template("event.tpl");
} else {
$tpl = get_markup_template("events_js.tpl");
@ -378,7 +379,7 @@ function events_content(App $a) {
foreach ($events as $key => $event) {
$event_item = [];
foreach ($event['item'] as $k => $v) {
$k = str_replace('-' ,'_', $k);
$k = str_replace('-', '_', $k);
$event_item[$k] = $v;
}
$events[$key]['item'] = $event_item;
@ -403,7 +404,7 @@ function events_content(App $a) {
'$list' => L10n::t('list'),
]);
if (x($_GET, 'id')) {
if (!empty($_GET['id'])) {
echo $o;
killme();
}
@ -428,41 +429,45 @@ function events_content(App $a) {
}
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];}
if (x($_REQUEST, 'summary')) {$orig_event['summary'] = $_REQUEST['summary'];}
if (x($_REQUEST, 'description')) {$orig_event['description'] = $_REQUEST['description'];}
if (x($_REQUEST, 'location')) {$orig_event['location'] = $_REQUEST['location'];}
if (x($_REQUEST, 'start')) {$orig_event['start'] = $_REQUEST['start'];}
if (x($_REQUEST, 'finish')) {$orig_event['finish'] = $_REQUEST['finish'];}
if (x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
if (!empty($_REQUEST['nofinish'])) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
if (!empty($_REQUEST['adjust'])) {$orig_event['adjust'] = $_REQUEST['adjust'];}
if (!empty($_REQUEST['summary'])) {$orig_event['summary'] = $_REQUEST['summary'];}
if (!empty($_REQUEST['description'])) {$orig_event['description'] = $_REQUEST['description'];}
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 = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
$a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
$n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : '');
$a_checked = (!empty($orig_event['adjust']) ? ' checked="checked" ' : '');
$t_orig = (x($orig_event) ? $orig_event['summary'] : '');
$d_orig = (x($orig_event) ? $orig_event['desc'] : '');
$l_orig = (x($orig_event) ? $orig_event['location'] : '');
$eid = (x($orig_event) ? $orig_event['id'] : 0);
$cid = (x($orig_event) ? $orig_event['cid'] : 0);
$uri = (x($orig_event) ? $orig_event['uri'] : '');
$t_orig = !empty($orig_event) ? $orig_event['summary'] : '';
$d_orig = !empty($orig_event) ? $orig_event['desc'] : '';
$l_orig = !empty($orig_event) ? $orig_event['location'] : '';
$eid = !empty($orig_event) ? $orig_event['id'] : 0;
$cid = !empty($orig_event) ? $orig_event['cid'] : 0;
$uri = !empty($orig_event) ? $orig_event['uri'] : '';
$sh_disabled = '';
$sh_checked = '';
$sh_checked = '';
if (x($orig_event)) {
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid']) ? '' : ' checked="checked" ');
if (!empty($orig_event)
&& ($orig_event['allow_cid'] !== '<' . local_user() . '>'
|| $orig_event['allow_gid']
|| $orig_event['deny_cid']
|| $orig_event['deny_gid']))
{
$sh_checked = ' checked="checked" ';
}
if ($cid || $mode === 'edit') {
$sh_disabled = 'disabled="disabled"';
}
$sdt = (x($orig_event) ? $orig_event['start'] : 'now');
$fdt = (x($orig_event) ? $orig_event['finish'] : 'now');
$sdt = !empty($orig_event) ? $orig_event['start'] : 'now';
$fdt = !empty($orig_event) ? $orig_event['finish'] : 'now';
$tz = date_default_timezone_get();
if (x($orig_event)) {
if (!empty($orig_event)) {
$tz = ($orig_event['adjust'] ? date_default_timezone_get() : 'UTC');
}
@ -470,20 +475,22 @@ function events_content(App $a) {
$smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm');
$sday = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd');
$shour = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00');
$sminute = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00');
$shour = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00';
$sminute = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00';
$fyear = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y');
$fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm');
$fday = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd');
$fhour = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00');
$fminute = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00');
$fhour = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00';
$fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00';
$perms = ACL::getDefaultUserPermissions($orig_event);
if ($mode === 'new' || $mode === 'copy') {
$acl = ($cid ? '' : ACL::getFullSelectorHTML($a->user, false, $orig_event));
if (!$cid && in_array($mode, ['new', 'copy'])) {
$acl = ACL::getFullSelectorHTML($a->user, false, $orig_event);
} else {
$acl = '';
}
// If we copy an old event, we need to remove the ID and URI
@ -495,7 +502,7 @@ function events_content(App $a) {
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,[
$o .= replace_macros($tpl, [
'$post' => System::baseUrl() . '/events',
'$eid' => $eid,
'$cid' => $cid,
@ -509,11 +516,31 @@ function events_content(App $a) {
'$title' => L10n::t('Event details'),
'$desc' => L10n::t('Starting date and Title are required.'),
'$s_text' => L10n::t('Event Starts:') . ' <span class="required" title="' . L10n::t('Required') . '">*</span>',
'$s_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $syear+5), DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), L10n::t('Event Starts:'), 'start_text', true, true, '', '', true),
'$s_dsel' => Temporal::getDateTimeField(
new DateTime(),
DateTime::createFromFormat('Y', $syear+5),
DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
L10n::t('Event Starts:'),
'start_text',
true,
true,
'',
'',
true
),
'$n_text' => L10n::t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked,
'$f_text' => L10n::t('Event Finishes:'),
'$f_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $fyear+5), DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), L10n::t('Event Finishes:'), 'finish_text', true, true, 'start_text'),
'$f_dsel' => Temporal::getDateTimeField(
new DateTime(),
DateTime::createFromFormat('Y', $fyear+5),
DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
L10n::t('Event Finishes:'),
'finish_text',
true,
true,
'start_text'
),
'$a_text' => L10n::t('Adjust for viewer timezone'),
'$a_checked' => $a_checked,
'$d_text' => L10n::t('Description:'),
@ -534,7 +561,6 @@ function events_content(App $a) {
'$basic' => L10n::t('Basic'),
'$advanced' => L10n::t('Advanced'),
'$permissions' => L10n::t('Permissions'),
]);
return $o;

View file

@ -25,7 +25,7 @@ function fetch_init(App $a)
// Fetch the item
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network',
'event-id', 'resource-id', 'author-link', 'owner-link', 'attach'];
'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'attach'];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {

View file

@ -39,7 +39,7 @@ require_once 'include/items.php';
function item_post(App $a) {
if (!local_user() && !remote_user()) {
return;
return 0;
}
require_once 'include/security.php';
@ -154,7 +154,7 @@ function item_post(App $a) {
if (($message_id != '') && ($profile_uid != 0)) {
if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) {
logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
return;
return 0;
}
}
@ -183,7 +183,7 @@ function item_post(App $a) {
$user = DBA::selectFirst('user', [], ['uid' => $profile_uid]);
if (!DBA::isResult($user) && !$parent) {
return;
return 0;
}
$categories = '';
@ -843,6 +843,10 @@ function item_post(App $a) {
logger('post_complete');
if ($api_source) {
return $post_id;
}
item_post_return(System::baseUrl(), $api_source, $return_path);
// NOTREACHED
}

View file

@ -8,27 +8,31 @@ use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Model\Item;
function lockview_content(App $a) {
function lockview_content(App $a)
{
$type = (($a->argc > 1) ? $a->argv[1] : 0);
if (is_numeric($type)) {
$item_id = intval($type);
$type='item';
$type = 'item';
} else {
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
}
if (!$item_id)
if (!$item_id) {
killme();
}
if (!in_array($type, ['item','photo','event']))
if (!in_array($type, ['item','photo','event'])) {
killme();
}
$fields = ['uid', 'private', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$condition = ['id' => $item_id];
if ($type != 'item') {
$item = DBA::selectFirst($type, $fields, $condition);
} else {
$fields[] = 'private';
$item = Item::selectFirst($fields, $condition);
}
@ -43,18 +47,21 @@ function lockview_content(App $a) {
killme();
}
if (($item['private'] == 1) && empty($item['allow_cid']) && empty($item['allow_gid'])
&& empty($item['deny_cid']) && empty($item['deny_gid'])) {
if (isset($item['private'])
&& $item['private'] == 1
&& empty($item['allow_cid'])
&& empty($item['allow_gid'])
&& empty($item['deny_cid'])
&& empty($item['deny_gid']))
{
echo L10n::t('Remote privacy information not available.') . '<br />';
killme();
}
$allowed_users = expand_acl($item['allow_cid']);
$allowed_users = expand_acl($item['allow_cid']);
$allowed_groups = expand_acl($item['allow_gid']);
$deny_users = expand_acl($item['deny_cid']);
$deny_groups = expand_acl($item['deny_gid']);
$deny_users = expand_acl($item['deny_cid']);
$deny_groups = expand_acl($item['deny_gid']);
$o = L10n::t('Visible to:') . '<br />';
$l = [];
@ -63,36 +70,44 @@ function lockview_content(App $a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $allowed_groups))
);
if (DBA::isResult($r))
foreach($r as $rr)
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<b>' . $rr['name'] . '</b>';
}
}
}
if (count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
DBA::escape(implode(', ',$allowed_users))
DBA::escape(implode(', ', $allowed_users))
);
if (DBA::isResult($r))
foreach($r as $rr)
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = $rr['name'];
}
}
}
if (count($deny_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $deny_groups))
);
if (DBA::isResult($r))
foreach($r as $rr)
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
}
}
}
if (count($deny_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
DBA::escape(implode(', ',$deny_users))
DBA::escape(implode(', ', $deny_users))
);
if (DBA::isResult($r))
foreach($r as $rr)
if (DBA::isResult($r)) {
foreach ($r as $rr) {
$l[] = '<strike>' . $rr['name'] . '</strike>';
}
}
}
echo $o . implode(', ', $l);

View file

@ -488,7 +488,7 @@ function render_messages(array $msg, $t)
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
'$from_addr' => $contact['addr'],
'$from_addr' => defaults($contact, 'addr', ''),
'$sparkle' => ' sparkle',
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'$subject' => $subject_e,

View file

@ -70,8 +70,11 @@ function notes_content(App $a, $update = false)
$count = 0;
if (DBA::isResult($r)) {
$count = count($r);
$o .= conversation($a, DBA::toArray($r), 'notes', $update);
$notes = DBA::toArray($r);
$count = count($notes);
$o .= conversation($a, $notes, 'notes', $update);
}
$o .= alt_pager($a, $count);

View file

@ -21,7 +21,7 @@ function notifications_post(App $a)
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
if ($request_id === "all") {
if ($request_id === 'all') {
return;
}
@ -68,8 +68,8 @@ function notifications_content(App $a)
return;
}
$page = (x($_REQUEST,'page') ? $_REQUEST['page'] : 1);
$show = (x($_REQUEST,'show') ? $_REQUEST['show'] : 0);
$page = defaults($_REQUEST, 'page', 1);
$show = defaults($_REQUEST, 'show', 0);
Nav::setSelected('notifications');
@ -87,10 +87,11 @@ function notifications_content(App $a)
$perpage = 20;
$startrec = ($page * $perpage) - $perpage;
$notif_header = L10n::t('Notifications');
// Get introductions
if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
Nav::setSelected('introductions');
$notif_header = L10n::t('Notifications');
$all = (($a->argc > 2) && ($a->argv[2] == 'all'));
@ -115,10 +116,8 @@ function notifications_content(App $a)
} elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
$notif_header = L10n::t('Home Notifications');
$notifs = $nm->homeNotifs($show, $startrec, $perpage);
}
// Set the pager
$a->set_pager_itemspage($perpage);
@ -133,14 +132,15 @@ function notifications_content(App $a)
$notif_tpl = get_markup_template('notifications.tpl');
if (!isset($notifs['ident'])) {
logger('Missing data in notifs: ' . System::callstack(20), LOGGER_DEBUG);
}
$notif_show_lnk = [
'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ),
'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')),
];
// Process the data for template creation
if ($notifs['ident'] === 'introductions') {
if (defaults($notifs, 'ident', '') === 'introductions') {
$sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl");
$tpl = get_markup_template('intros.tpl');
// The link to switch between ignored and normal connection requests
$notif_show_lnk = [
@ -150,127 +150,121 @@ function notifications_content(App $a)
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
foreach ($notifs['notifications'] as $it) {
foreach ($notifs['notifications'] as $notif) {
// There are two kind of introduction. Contacts suggested by other contacts and normal connection requests.
// We have to distinguish between these two because they use different data.
switch ($it['label']) {
switch ($notif['label']) {
case 'friend_suggestion':
$notif_content[] = replace_macros($sugg, [
'$type' => $it['label'],
'$type' => $notif['label'],
'$str_notifytype' => L10n::t('Notification type:'),
'$notify_type' => $it['notify_type'],
'$intro_id' => $it['intro_id'],
'$notify_type'=> $notif['notify_type'],
'$intro_id' => $notif['intro_id'],
'$lbl_madeby' => L10n::t('Suggested by:'),
'$madeby' => $it['madeby'],
'$madeby_url' => $it['madeby_url'],
'$madeby_zrl' => $it['madeby_zrl'],
'$madeby_addr' => $it['madeby_addr'],
'$contact_id' => $it['contact_id'],
'$photo' => $it['photo'],
'$fullname' => $it['name'],
'$url' => $it['url'],
'$zrl' => $it['zrl'],
'$lbl_url' => L10n::t('Profile URL'),
'$addr' => $it['addr'],
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$knowyou' => $it['knowyou'],
'$approve' => L10n::t('Approve'),
'$note' => $it['note'],
'$request' => $it['request'],
'$ignore' => L10n::t('Ignore'),
'$discard' => L10n::t('Discard'),
'$madeby' => $notif['madeby'],
'$madeby_url' => $notif['madeby_url'],
'$madeby_zrl' => $notif['madeby_zrl'],
'$madeby_addr'=> $notif['madeby_addr'],
'$contact_id' => $notif['contact_id'],
'$photo' => $notif['photo'],
'$fullname' => $notif['name'],
'$url' => $notif['url'],
'$zrl' => $notif['zrl'],
'$lbl_url' => L10n::t('Profile URL'),
'$addr' => $notif['addr'],
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$knowyou' => $notif['knowyou'],
'$approve' => L10n::t('Approve'),
'$note' => $notif['note'],
'$request' => $notif['request'],
'$ignore' => L10n::t('Ignore'),
'$discard' => L10n::t('Discard'),
]);
break;
// Normal connection requests
default:
$friend_selected = (($it['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($it['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$dfrn_tpl = get_markup_template('netfriend.tpl');
$friend_selected = (($notif['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($notif['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$knowyou = '';
$lbl_knowyou = '';
$dfrn_text = '';
$helptext = '';
$helptext2 = '';
$helptext3 = '';
$knowyou = '';
$helptext = '';
$helptext2 = '';
$helptext3 = '';
if ($it['network'] === Protocol::DFRN || $it['network'] === Protocol::DIASPORA) {
if ($it['network'] === Protocol::DFRN) {
$lbl_knowyou = L10n::t('Claims to be known to you: ');
$knowyou = (($it['knowyou']) ? L10n::t('yes') : L10n::t('no'));
$helptext = L10n::t('Shall your connection be bidirectional or not?');
$helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']);
$helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']);
} else {
$knowyou = '';
$helptext = L10n::t('Shall your connection be bidirectional or not?');
$helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']);
$helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']);
}
if ($notif['network'] === Protocol::DFRN) {
$lbl_knowyou = L10n::t('Claims to be known to you: ');
$knowyou = (($notif['knowyou']) ? L10n::t('yes') : L10n::t('no'));
$helptext = L10n::t('Shall your connection be bidirectional or not?');
$helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
$helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
} elseif ($notif['network'] === Protocol::DIASPORA) {
$helptext = L10n::t('Shall your connection be bidirectional or not?');
$helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
$helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
}
$dfrn_text = replace_macros($dfrn_tpl,[
'$intro_id' => $it['intro_id'],
$dfrn_tpl = get_markup_template('netfriend.tpl');
$dfrn_text = replace_macros($dfrn_tpl, [
'$intro_id' => $notif['intro_id'],
'$friend_selected' => $friend_selected,
'$fan_selected' => $fan_selected,
'$fan_selected'=> $fan_selected,
'$approve_as1' => $helptext,
'$approve_as2' => $helptext2,
'$approve_as3' => $helptext3,
'$as_friend' => L10n::t('Friend'),
'$as_fan' => (($it['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
'$as_friend' => L10n::t('Friend'),
'$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
]);
$header = $it["name"];
$header = $notif['name'];
if ($it["addr"] != "") {
$header .= " <".$it["addr"].">";
if ($notif['addr'] != '') {
$header .= ' <' . $notif['addr'] . '>';
}
$header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
$header .= ' (' . ContactSelector::networkToName($notif['network'], $notif['url']) . ')';
if ($it['network'] != Protocol::DIASPORA) {
if ($notif['network'] != Protocol::DIASPORA) {
$discard = L10n::t('Discard');
} else {
$discard = '';
}
$notif_content[] = replace_macros($tpl, [
'$type' => $it['label'],
'$header' => htmlentities($header),
'$type' => $notif['label'],
'$header' => htmlentities($header),
'$str_notifytype' => L10n::t('Notification type:'),
'$notify_type' => $it['notify_type'],
'$dfrn_text' => $dfrn_text,
'$dfrn_id' => $it['dfrn_id'],
'$uid' => $it['uid'],
'$intro_id' => $it['intro_id'],
'$contact_id' => $it['contact_id'],
'$photo' => $it['photo'],
'$fullname' => $it['name'],
'$location' => $it['location'],
'$lbl_location' => L10n::t('Location:'),
'$about' => $it['about'],
'$lbl_about' => L10n::t('About:'),
'$keywords' => $it['keywords'],
'$lbl_keywords' => L10n::t('Tags:'),
'$gender' => $it['gender'],
'$lbl_gender' => L10n::t('Gender:'),
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$url' => $it['url'],
'$zrl' => $it['zrl'],
'$lbl_url' => L10n::t('Profile URL'),
'$addr' => $it['addr'],
'$notify_type' => $notif['notify_type'],
'$dfrn_text' => $dfrn_text,
'$dfrn_id' => $notif['dfrn_id'],
'$uid' => $notif['uid'],
'$intro_id' => $notif['intro_id'],
'$contact_id' => $notif['contact_id'],
'$photo' => $notif['photo'],
'$fullname' => $notif['name'],
'$location' => $notif['location'],
'$lbl_location'=> L10n::t('Location:'),
'$about' => $notif['about'],
'$lbl_about' => L10n::t('About:'),
'$keywords' => $notif['keywords'],
'$lbl_keywords'=> L10n::t('Tags:'),
'$gender' => $notif['gender'],
'$lbl_gender' => L10n::t('Gender:'),
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$url' => $notif['url'],
'$zrl' => $notif['zrl'],
'$lbl_url' => L10n::t('Profile URL'),
'$addr' => $notif['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => L10n::t('Network:'),
'$network' => ContactSelector::networkToName($it['network'], $it['url']),
'$knowyou' => $knowyou,
'$approve' => L10n::t('Approve'),
'$note' => $it['note'],
'$ignore' => L10n::t('Ignore'),
'$discard' => $discard,
'$network' => ContactSelector::networkToName($notif['network'], $notif['url']),
'$knowyou' => $knowyou,
'$approve' => L10n::t('Approve'),
'$note' => $notif['note'],
'$ignore' => L10n::t('Ignore'),
'$discard' => $discard,
]);
break;
}
@ -280,57 +274,47 @@ function notifications_content(App $a)
info(L10n::t('No introductions.') . EOL);
}
// Normal notifications (no introductions)
} else {
// The template files we need in different cases for formatting the content
$tpl_item_like = 'notifications_likes_item.tpl';
$tpl_item_dislike = 'notifications_dislikes_item.tpl';
$tpl_item_attend = 'notifications_attend_item.tpl';
$tpl_item_attendno = 'notifications_attend_item.tpl';
$tpl_item_attendmaybe = 'notifications_attend_item.tpl';
$tpl_item_friend = 'notifications_friends_item.tpl';
$tpl_item_comment = 'notifications_comments_item.tpl';
$tpl_item_post = 'notifications_posts_item.tpl';
$tpl_item_notify = 'notify.tpl';
// Normal notifications (no introductions)
} elseif (!empty($notifs['notifications'])) {
// Loop trough ever notification This creates an array with the output html for each
// notification and apply the correct template according to the notificationtype (label).
foreach ($notifs['notifications'] as $it) {
foreach ($notifs['notifications'] as $notif) {
$notification_templates = [
'like' => 'notifications_likes_item.tpl',
'dislike' => 'notifications_dislikes_item.tpl',
'attend' => 'notifications_attend_item.tpl',
'attendno' => 'notifications_attend_item.tpl',
'attendmaybe' => 'notifications_attend_item.tpl',
'friend' => 'notifications_friends_item.tpl',
'comment' => 'notifications_comments_item.tpl',
'post' => 'notifications_posts_item.tpl',
'notify' => 'notify.tpl',
];
// We use the notification label to get the correct template file
$tpl_var_name = 'tpl_item_'.$it['label'];
$tpl_notif = get_markup_template($$tpl_var_name);
$tpl_notif = get_markup_template($notification_templates[$notif['label']]);
$notif_content[] = replace_macros($tpl_notif,[
'$item_label' => $it['label'],
'$item_link' => $it['link'],
'$item_image' => $it['image'],
'$item_url' => $it['url'],
'$item_text' => $it['text'],
'$item_when' => $it['when'],
'$item_ago' => $it['ago'],
'$item_seen' => $it['seen'],
$notif_content[] = replace_macros($tpl_notif, [
'$item_label' => $notif['label'],
'$item_link' => $notif['link'],
'$item_image' => $notif['image'],
'$item_url' => $notif['url'],
'$item_text' => $notif['text'],
'$item_when' => $notif['when'],
'$item_ago' => $notif['ago'],
'$item_seen' => $notif['seen'],
]);
}
$notif_show_lnk = [
'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')),
];
// Output if there aren't any notifications available
if (count($notifs['notifications']) == 0) {
$notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']);
}
} else {
$notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']);
}
$o .= replace_macros($notif_tpl, [
'$notif_header' => $notif_header,
'$tabs' => $tabs,
'$notif_content' => $notif_content,
'$notif_header' => $notif_header,
'$tabs' => $tabs,
'$notif_content' => $notif_content,
'$notif_nocontent' => $notif_nocontent,
'$notif_show_lnk' => $notif_show_lnk,
'$notif_paginate' => alt_pager($a, count($notif_content))
'$notif_show_lnk' => $notif_show_lnk,
'$notif_paginate' => alt_pager($a, count($notif_content))
]);
return $o;

View file

@ -8,128 +8,127 @@
* information and does format this information to BBCode
*
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
*/
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
require_once("include/items.php");
function parse_url_content(App $a) {
require_once 'include/items.php';
function parse_url_content(App $a)
{
$text = null;
$str_tags = "";
$str_tags = '';
$br = "\n";
if (!empty($_GET["binurl"])) {
$url = trim(hex2bin($_GET["binurl"]));
if (!empty($_GET['binurl'])) {
$url = trim(hex2bin($_GET['binurl']));
} else {
$url = trim($_GET["url"]);
$url = trim($_GET['url']);
}
if (!empty($_GET["title"])) {
$title = strip_tags(trim($_GET["title"]));
if (!empty($_GET['title'])) {
$title = strip_tags(trim($_GET['title']));
}
if (!empty($_GET["description"])) {
$text = strip_tags(trim($_GET["description"]));
if (!empty($_GET['description'])) {
$text = strip_tags(trim($_GET['description']));
}
if (!empty($_GET["tags"])) {
$arr_tags = ParseUrl::convertTagsToArray($_GET["tags"]);
if (!empty($_GET['tags'])) {
$arr_tags = ParseUrl::convertTagsToArray($_GET['tags']);
if (count($arr_tags)) {
$str_tags = $br . implode(" ", $arr_tags) . $br;
$str_tags = $br . implode(' ', $arr_tags) . $br;
}
}
// Add url scheme if it is missing
$arrurl = parse_url($url);
if (!x($arrurl, "scheme")) {
if (x($arrurl, "host")) {
$url = "http:".$url;
if (!x($arrurl, 'scheme')) {
if (x($arrurl, 'host')) {
$url = 'http:' . $url;
} else {
$url = "http://".$url;
$url = 'http://' . $url;
}
}
logger("prse_url: " . $url);
logger($url);
// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
$redirects = 0;
// Fetch the header of the URL
$result = Network::curl($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
if($result["success"]) {
$result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
if ($result['success']) {
// Convert the header fields into an array
$hdrs = [];
$h = explode("\n", $result["header"]);
$h = explode("\n", $result['header']);
foreach ($h as $l) {
$header = array_map("trim", explode(":", trim($l), 2));
$header = array_map('trim', explode(':', trim($l), 2));
if (count($header) == 2) {
list($k,$v) = $header;
list($k, $v) = $header;
$hdrs[$k] = $v;
}
}
if (array_key_exists("Content-Type", $hdrs)) {
$type = $hdrs["Content-Type"];
if (array_key_exists('Content-Type', $hdrs)) {
$type = $hdrs['Content-Type'];
}
if ($type) {
if(stripos($type, "image/") !== false) {
echo $br . "[img]" . $url . "[/img]" . $br;
killme();
if (stripos($type, 'image/') !== false) {
echo $br . '[img]' . $url . '[/img]' . $br;
exit();
}
if (stripos($type, "video/") !== false) {
echo $br . "[video]" . $url . "[/video]" . $br;
killme();
if (stripos($type, 'video/') !== false) {
echo $br . '[video]' . $url . '[/video]' . $br;
exit();
}
if (stripos($type, "audio/") !== false) {
echo $br . "[audio]" . $url . "[/audio]" . $br;
killme();
if (stripos($type, 'audio/') !== false) {
echo $br . '[audio]' . $url . '[/audio]' . $br;
exit();
}
}
}
$template = "[bookmark=%s]%s[/bookmark]%s";
$template = '[bookmark=%s]%s[/bookmark]%s';
$arr = ["url" => $url, "text" => ""];
$arr = ['url' => $url, 'text' => ''];
Addon::callHooks("parse_link", $arr);
Addon::callHooks('parse_link', $arr);
if (strlen($arr["text"])) {
echo $arr["text"];
killme();
if (strlen($arr['text'])) {
echo $arr['text'];
exit();
}
// If there is already some content information submitted we don't
// need to parse the url for content.
if (!empty($url) && !empty($title) && !empty($text)) {
$title = str_replace(["\r", "\n"], ['', ''], $title);
$title = str_replace(["\r","\n"],["",""],$title);
$text = "[quote]" . trim($text) . "[/quote]" . $br;
$text = '[quote]' . trim($text) . '[/quote]' . $br;
$result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags;
logger("parse_url (unparsed): returns: " . $result);
logger('(unparsed): returns: ' . $result);
echo $result;
killme();
exit();
}
// Fetch the information directly from the webpage
$siteinfo = ParseUrl::getSiteinfo($url);
unset($siteinfo["keywords"]);
unset($siteinfo['keywords']);
// Format it as BBCode attachment
$info = add_page_info_data($siteinfo);
echo $info;
killme();
exit();
}
/**
@ -151,7 +150,8 @@ function parse_url_content(App $a) {
* @todo Remove this function after all Addons has been changed to use
* ParseUrl::getSiteinfoCached
*/
function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) {
function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true)
{
$siteinfo = ParseUrl::getSiteinfoCached($url, $no_guessing, $do_oembed);
return $siteinfo;
}

View file

@ -212,7 +212,7 @@ function photos_post(App $a)
}
// Check if the user has responded to a delete confirmation query
if ($_REQUEST['canceled']) {
if (!empty($_REQUEST['canceled'])) {
goaway($_SESSION['photo_return']);
}
@ -762,12 +762,14 @@ function photos_post(App $a)
$filesize = $ret['filesize'];
$type = $ret['type'];
$error = UPLOAD_ERR_OK;
} else {
} 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) {
@ -1633,7 +1635,7 @@ function photos_content(App $a)
'$paginate' => $paginate,
]);
$a->page['htmlhead'] .= "\n" . '<meta name="twitter:card" content="photo" />' . "\n";
$a->page['htmlhead'] .= "\n" . '<meta name="twitter:card" content="summary_large_image" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:title" content="' . $photo["album"] . '" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="' . $photo["href"] . '" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:image:width" content="' . $photo["width"] . '" />' . "\n";

View file

@ -510,16 +510,17 @@ function ping_get_notifications($uid)
* @brief Backward-compatible XML formatting for ping.php output
* @deprecated
*
* @param array $data The initial ping data array
* @param int $sysnotify Number of unseen system notifications
* @param array $notifs Complete list of notification
* @param array $sysmsgs List of system notice messages
* @param array $sysmsgs_info List of system info messages
* @param int $groups_unseen Number of unseen group items
* @param int $forums_unseen Number of unseen forum items
* @param array $data The initial ping data array
* @param int $sysnotify_count Number of unseen system notifications
* @param array $notifs Complete list of notification
* @param array $sysmsgs List of system notice messages
* @param array $sysmsgs_info List of system info messages
* @param int $groups_unseen Number of unseen group items
* @param int $forums_unseen Number of unseen forum items
*
* @return array XML-transform ready data array
*/
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
function ping_format_xml_data($data, $sysnotify_count, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{
$notifications = [];
foreach ($notifs as $key => $notif) {

View file

@ -24,19 +24,20 @@ use Friendica\Model\Item;
require_once 'include/security.php';
require_once 'include/items.php';
function poke_init(App $a) {
function poke_init(App $a)
{
if (!local_user()) {
return;
}
$uid = local_user();
$verb = notags(trim($_GET['verb']));
if (!$verb) {
if (empty($_GET['verb'])) {
return;
}
$verb = notags(trim($_GET['verb']));
$verbs = get_poke_verbs();
if (!array_key_exists($verb, $verbs)) {
@ -99,7 +100,7 @@ function poke_init(App $a) {
$arr['guid'] = System::createGUID(32);
$arr['uid'] = $uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = ($parent_uri ? $parent_uri : $uri);
$arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri);
$arr['wall'] = 1;
$arr['contact-id'] = $poster['id'];
$arr['owner-name'] = $poster['name'];
@ -121,7 +122,7 @@ function poke_init(App $a) {
$arr['origin'] = 1;
$arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . System::baseUrl() . '/contact/' . $target['id'] . '</id>';
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $target['url'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
@ -137,10 +138,8 @@ function poke_init(App $a) {
return;
}
function poke_content(App $a) {
function poke_content(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
@ -149,17 +148,17 @@ function poke_content(App $a) {
$name = '';
$id = '';
if (intval($_GET['c'])) {
$r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_GET['c']),
intval(local_user())
);
if (DBA::isResult($r)) {
$name = $item['name'];
$id = $item['id'];
}
if (empty($_GET['c'])) {
return;
}
$contact = DBA::selectFirst('contact', ['id', 'name'], ['id' => $_GET['c'], 'uid' => local_user()]);
if (!DBA::isResult($contact)) {
return;
}
$name = $contact['name'];
$id = $contact['id'];
$base = System::baseUrl();

View file

@ -333,7 +333,7 @@ function profile_content(App $a, $update = 0)
}
}
$o .= conversation($a, $items, 'profile', $update, false, 'commented', local_user());
$o .= conversation($a, $items, 'profile', $update, false, 'created', local_user());
if (!$update) {
$o .= alt_pager($a, count($items));

View file

@ -41,14 +41,14 @@ function salmon_post(App $a, $xml = '') {
$base = null;
// figure out where in the DOM tree our data is hiding
if($dom->provenance->data)
if (!empty($dom->provenance->data))
$base = $dom->provenance;
elseif($dom->env->data)
elseif (!empty($dom->env->data))
$base = $dom->env;
elseif($dom->data)
elseif (!empty($dom->data))
$base = $dom;
if(! $base) {
if (empty($base)) {
logger('unable to locate salmon data in xml ');
System::httpExit(400);
}

View file

@ -10,53 +10,67 @@ use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
function unfollow_post(App $a)
function unfollow_post()
{
$return_url = $_SESSION['return_url'];
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
notice(L10n::t('Permission denied.'));
goaway($return_url);
// NOTREACHED
}
if ($_REQUEST['cancel']) {
goaway($_SESSION['return_url']);
if (!empty($_REQUEST['cancel'])) {
goaway($return_url);
}
$uid = local_user();
$url = notags(trim($_REQUEST['url']));
$return_url = $_SESSION['return_url'];
$url = notags(trim(defaults($_REQUEST, 'url', '')));
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
$uid, Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, Protocol::STATUSNET];
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::SHARING, Contact::FRIEND, normalise_link($url),
normalise_link($url), $url];
$contact = DBA::selectFirst('contact', [], $condition);
if (!DBA::isResult($contact)) {
notice(L10n::t("Contact wasn't found or can't be unfollowed."));
} else {
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) {
$r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
intval($uid)
);
if (DBA::isResult($r)) {
Contact::terminateFriendship($r[0], $contact);
}
}
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
info(L10n::t('Contact unfollowed').EOL);
goaway(System::baseUrl().'/contacts/'.$contact['id']);
notice(L10n::t("You aren't following this contact."));
goaway($return_url);
// NOTREACHED
}
goaway($return_url);
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
goaway($return_url);
// NOTREACHED
}
$dissolve = ($contact['rel'] == Contact::SHARING);
$owner = User::getOwnerDataById($uid);
if ($owner) {
Contact::terminateFriendship($owner, $contact, $dissolve);
}
// Sharing-only contacts get deleted as there no relationship any more
if ($dissolve) {
Contact::remove($contact['id']);
$return_path = 'contacts';
} else {
DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
$return_path = 'contacts/' . $contact['id'];
}
info(L10n::t('Contact unfollowed'));
goaway($return_path);
// NOTREACHED
}
function unfollow_content(App $a)
{
if (! local_user()) {
notice(L10n::t('Permission denied.') . EOL);
if (!local_user()) {
notice(L10n::t('Permission denied.'));
goaway($_SESSION['return_url']);
// NOTREACHED
}
@ -64,78 +78,74 @@ function unfollow_content(App $a)
$uid = local_user();
$url = notags(trim($_REQUEST['url']));
$submit = L10n::t('Submit Request');
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
local_user(), Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, Protocol::STATUSNET];
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url),
normalise_link($url), $url];
$contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't a friend of this contact.").EOL);
$submit = "";
notice(L10n::t("You aren't following this contact."));
goaway('contacts');
// NOTREACHED
}
if (!in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
notice(L10n::t("Unfollowing is currently not supported by your network.").EOL);
$submit = "";
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
goaway('contacts/' . $contact['id']);
// NOTREACHED
}
$request = System::baseUrl()."/unfollow";
$request = System::baseUrl() . '/unfollow';
$tpl = get_markup_template('auto_request.tpl');
$r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
if (!$r) {
notice(L10n::t('Permission denied.') . EOL);
if (!DBA::isResult($self)) {
notice(L10n::t('Permission denied.'));
goaway($_SESSION['return_url']);
// NOTREACHED
}
$myaddr = $r[0]["url"];
// Makes the connection request for friendica contacts easier
$_SESSION["fastlane"] = $contact["url"];
$_SESSION['fastlane'] = $contact['url'];
$header = L10n::t("Disconnect/Unfollow");
$header = L10n::t('Disconnect/Unfollow');
$o = replace_macros($tpl, [
'$header' => htmlentities($header),
'$desc' => "",
'$pls_answer' => "",
'$does_know_you' => "",
'$add_note' => "",
'$page_desc' => "",
'$friendica' => "",
'$statusnet' => "",
'$diaspora' => "",
'$diasnote' => "",
'$your_address' => L10n::t('Your Identity Address:'),
'$invite_desc' => "",
'$emailnet' => "",
'$submit' => $submit,
'$cancel' => L10n::t('Cancel'),
'$nickname' => "",
'$name' => $contact["name"],
'$url' => $contact["url"],
'$zrl' => Contact::magicLink($contact["url"]),
'$url_label' => L10n::t("Profile URL"),
'$myaddr' => $myaddr,
'$request' => $request,
'$keywords' => "",
'$keywords_label' => ""
$o = replace_macros($tpl, [
'$header' => htmlentities($header),
'$desc' => '',
'$pls_answer' => '',
'$does_know_you' => '',
'$add_note' => '',
'$page_desc' => '',
'$friendica' => '',
'$statusnet' => '',
'$diaspora' => '',
'$diasnote' => '',
'$your_address' => L10n::t('Your Identity Address:'),
'$invite_desc' => '',
'$emailnet' => '',
'$submit' => L10n::t('Submit Request'),
'$cancel' => L10n::t('Cancel'),
'$nickname' => '',
'$name' => $contact['name'],
'$url' => $contact['url'],
'$zrl' => Contact::magicLink($contact['url']),
'$url_label' => L10n::t('Profile URL'),
'$myaddr' => $self['url'],
'$request' => $request,
'$keywords' => '',
'$keywords_label'=> ''
]);
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
$a->page['aside'] = '';
Profile::load($a, '', 0, Contact::getDetailsByURL($contact['url']));
$o .= replace_macros(get_markup_template('section_title.tpl'), ['$title' => L10n::t('Status Messages and Posts')]);
// Show last public posts
$o .= Contact::getPostsFromUrl($contact["url"]);
$o .= Contact::getPostsFromUrl($contact['url']);
return $o;
}

39
mod/update_contacts.php Normal file
View file

@ -0,0 +1,39 @@
<?php
// See update_profile.php for documentation
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
require_once 'mod/contacts.php';
function update_contacts_content(App $a)
{
header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>";
if ($_GET["force"] == 1) {
$text = contacts_content($a, true);
} else {
$text = '';
}
if (PConfig::get(local_user(), "system", "bandwidth_saver")) {
$replace = "<br />".L10n::t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
$text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t", " ", $text);
echo "</section>";
echo "</body></html>\r\n";
killme();
}

View file

@ -367,11 +367,12 @@ function videos_content(App $a)
foreach ($r as $rr) {
$alt_e = $rr['filename'];
/// @todo The album isn't part of the above query. This seems to be some unfinished code that needs to be reworked completely.
$rr['album'] = '';
$name_e = $rr['album'];
$videos[] = [
'id' => $rr['id'],
'link' => System::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
'link' => System::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['hash'],
'title' => L10n::t('View Video'),
'src' => System::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0',
'alt' => $alt_e,

View file

@ -23,7 +23,7 @@ function webfinger_content(App $a)
$o = '<h3>Webfinger Diagnostic</h3>';
$o .= '<form action="webfinger" method="get">';
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . defaults($_GET, 'addr', '') .'" />';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';

View file

@ -372,13 +372,13 @@ class App
}
if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) {
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php');
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php', true);
}
}
/**
* Tries to load the specified configuration file into the App->config array.
* Overwrites previously set values.
* Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
*
* The config format is INI and the template for configuration files is the following:
*
@ -391,9 +391,10 @@ class App
* // Keep this line
*
* @param type $filepath
* @param bool $overwrite Force value overwrite if the config key already exists
* @throws Exception
*/
public function loadConfigFile($filepath)
public function loadConfigFile($filepath, $overwrite = false)
{
if (!file_exists($filepath)) {
throw new Exception('Error parsing non-existent config file ' . $filepath);
@ -409,7 +410,11 @@ class App
foreach ($config as $category => $values) {
foreach ($values as $key => $value) {
$this->setConfigValue($category, $key, $value);
if ($overwrite) {
$this->setConfigValue($category, $key, $value);
} else {
$this->setDefaultConfigValue($category, $key, $value);
}
}
}
}
@ -427,7 +432,7 @@ class App
// Load the local addon config file to overwritten default addon config values
if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php')) {
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php');
$this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php', true);
}
}
@ -1074,7 +1079,11 @@ class App
$meminfo = [];
foreach ($memdata as $line) {
list($key, $val) = explode(':', $line);
$data = explode(':', $line);
if (count($data) != 2) {
continue;
}
list($key, $val) = $data;
$meminfo[$key] = (int) trim(str_replace('kB', '', $val));
$meminfo[$key] = (int) ($meminfo[$key] / 1024);
}
@ -1240,6 +1249,20 @@ class App
return $return;
}
/**
* Sets a default value in the config cache. Ignores already existing keys.
*
* @param string $cat Config category
* @param string $k Config key
* @param mixed $v Default value to set
*/
private function setDefaultConfigValue($cat, $k, $v)
{
if (!isset($this->config[$cat][$k])) {
$this->setConfigValue($cat, $k, $v);
}
}
/**
* Sets a value in the config cache. Accepts raw output from the config table
*

View file

@ -9,7 +9,7 @@ namespace Friendica;
* The filename of the module in src/Module needs to match the class name
* exactly to make the module available.
*
* @author Hypolite Petovan mrpetovan@gmail.com
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
abstract class BaseModule extends BaseObject
{

View file

@ -31,7 +31,7 @@ require_once 'include/dba.php';
*
* @see https://oembed.com
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class OEmbed
{

View file

@ -25,7 +25,6 @@ use Friendica\Util\Map;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy as ProxyUtils;
use League\HTMLToMarkdown\HtmlConverter;
class BBCode extends BaseObject
{
@ -348,7 +347,7 @@ class BBCode extends BaseObject
*/
public static function toPlaintext($text, $keep_urls = true)
{
$naked_text = preg_replace('/\[(.+?)\]/','', $text);
$naked_text = preg_replace('/\[(.+?)\]\s*/','', $text);
if (!$keep_urls) {
$naked_text = preg_replace('#https?\://[^\s<]+[^\s\.\)]#i', '', $naked_text);
}
@ -572,16 +571,17 @@ class BBCode extends BaseObject
$return = sprintf('<div class="type-%s">', $data["type"]);
}
if (!empty($data["image"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
} elseif (!empty($data["preview"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
}
if (($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
} else {
$return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
if (!empty($data['title']) && !empty($data['url'])) {
if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
} else {
if (!empty($data["image"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
} elseif (!empty($data["preview"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
}
$return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
}
}
if (!empty($data["description"]) && $data["description"] != $data["title"]) {
@ -589,7 +589,8 @@ class BBCode extends BaseObject
$bbcode = HTML::toBBCode($data["description"]);
$return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode)));
}
if ($data["type"] == "link") {
if (!empty($data['url'])) {
$return .= sprintf('<sup><a href="%s">%s</a></sup>', $data['url'], parse_url($data['url'], PHP_URL_HOST));
}
@ -1162,21 +1163,6 @@ class BBCode extends BaseObject
return $return;
}
private static function textHighlightCallback($match)
{
// Fallback in case the language doesn't exist
$return = '[code]' . $match[2] . '[/code]';
if (in_array(strtolower($match[1]),
['php', 'css', 'mysql', 'sql', 'abap', 'diff', 'html', 'perl', 'ruby',
'vbscript', 'avrc', 'dtd', 'java', 'xml', 'cpp', 'python', 'javascript', 'js', 'sh', 'bash'])
) {
$return = text_highlight($match[2], strtolower($match[1]));
}
return $return;
}
/**
* @brief Converts a BBCode message to HTML message
*
@ -1225,6 +1211,22 @@ class BBCode extends BaseObject
return $return;
};
// Extracting multi-line code blocks before the whitespace processing
$codeblocks = [];
$text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#is",
function ($matches) use (&$codeblocks) {
$return = $matches[0];
if (strpos($matches[2], "\n") !== false) {
$return = '#codeblock-' . count($codeblocks) . '#';
$codeblocks[] = '<pre><code class="language-' . trim($matches[1]) . '">' . trim($matches[2], "\n\r") . '</code></pre>';
}
return $return;
},
$text
);
// Hide all [noparse] contained bbtags by spacefying them
// POSSIBLE BUG --> Will the 'preg' functions crash if there's an embedded image?
@ -1271,11 +1273,6 @@ class BBCode extends BaseObject
$text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "\n[share$1$2]$3[/share]", $text);
}
// Check for [code] text here, before the linefeeds are messed with.
// The highlighter will unescape and re-escape the content.
if (strpos($text, '[code=') !== false) {
$text = preg_replace_callback("/\[code=(.*?)\](.*?)\[\/code\]/ism", 'self::textHighlightCallback', $text);
}
// Convert new line chars to html <br /> tags
// nlbr seems to be hopelessly messed up
@ -1769,6 +1766,18 @@ class BBCode extends BaseObject
$text = self::interpolateSavedImagesIntoItemBody($text, $saved_image);
}
// Restore code blocks
$text = preg_replace_callback('/#codeblock-([0-9]+)#/iU',
function ($matches) use ($codeblocks) {
$return = $matches[0];
if (isset($codeblocks[intval($matches[1])])) {
$return = $codeblocks[$matches[1]];
}
return $return;
},
$text
);
// Clean up the HTML by loading and saving the HTML with the DOM.
// Bad structured html can break a whole page.
// For performance reasons do it only with ativated item cache or at export.
@ -1903,23 +1912,6 @@ class BBCode extends BaseObject
// Converting images with size parameters to simple images. Markdown doesn't know it.
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $text);
// Extracting multi-line code blocks before the whitespace processing/code highlighter in self::convert()
$codeblocks = [];
$text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#is",
function ($matches) use (&$codeblocks) {
$return = $matches[0];
if (strpos($matches[2], "\n") !== false) {
$return = '#codeblock-' . count($codeblocks) . '#';
$prefix = '````' . $matches[1] . PHP_EOL;
$codeblocks[] = $prefix . trim($matches[2]) . PHP_EOL . '````';
}
return $return;
},
$text
);
// Convert it to HTML - don't try oembed
if ($for_diaspora) {
$text = self::convert($text, false, 3);
@ -1949,8 +1941,7 @@ class BBCode extends BaseObject
$stamp1 = microtime(true);
// Now convert HTML to Markdown
$converter = new HtmlConverter();
$text = $converter->convert($text);
$text = HTML::toMarkdown($text);
// unmask the special chars back to HTML
$text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['&lt;', '&gt;', '&amp;'], $text);
@ -1973,18 +1964,6 @@ class BBCode extends BaseObject
);
}
// Restore code blocks
$text = preg_replace_callback('/#codeblock-([0-9]+)#/iU',
function ($matches) use ($codeblocks) {
$return = '';
if (isset($codeblocks[intval($matches[1])])) {
$return = $codeblocks[$matches[1]];
}
return $return;
},
$text
);
Addon::callHooks('bb2diaspora', $text);
return $text;

View file

@ -11,6 +11,7 @@ use DOMXPath;
use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\XML;
use League\HTMLToMarkdown\HtmlConverter;
class HTML
{
@ -122,7 +123,7 @@ class HTML
// Removing code blocks before the whitespace removal processing below
$codeblocks = [];
$message = preg_replace_callback(
'#<pre><code(?: class="([^"]*)")?>(.*)</code></pre>#iUs',
'#<pre><code(?: class="language-([^"]*)")?>(.*)</code></pre>#iUs',
function ($matches) use (&$codeblocks) {
$return = '[codeblock-' . count($codeblocks) . ']';
@ -131,7 +132,7 @@ class HTML
$prefix = '[code=' . $matches[1] . ']';
}
$codeblocks[] = $prefix . trim($matches[2]) . '[/code]';
$codeblocks[] = $prefix . PHP_EOL . trim($matches[2]) . PHP_EOL . '[/code]';
return $return;
},
$message
@ -672,4 +673,19 @@ class HTML
return trim($message);
}
/**
* Converts provided HTML code to Markdown. The hardwrap parameter maximizes
* compatibility with Diaspora in spite of the Markdown standards.
*
* @param string $html
* @return string
*/
public static function toMarkdown($html)
{
$converter = new HtmlConverter(['hard_break' => true]);
$markdown = $converter->convert($html);
return $markdown;
}
}

View file

@ -14,7 +14,7 @@ use Friendica\Content\Text\HTML;
/**
* Friendica-specific usage of Markdown
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Markdown extends BaseObject
{
@ -32,6 +32,7 @@ class Markdown extends BaseObject
$MarkdownParser = new MarkdownExtra();
$MarkdownParser->hard_wrap = $hardwrap;
$MarkdownParser->code_class_prefix = 'language-';
$html = $MarkdownParser->transform($text);
self::getApp()->save_timestamp($stamp1, "parser");

View file

@ -17,7 +17,7 @@ use Friendica\Util\Network;
/**
* Handle ACL management and display
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class ACL extends BaseObject
{

View file

@ -9,7 +9,7 @@ use Friendica\Util\DateTimeFormat;
/**
* Database Cache Driver
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
{

View file

@ -7,7 +7,7 @@ use Friendica\Core\Cache;
/**
* Cache Driver Interface
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
interface ICacheDriver
{

View file

@ -10,7 +10,7 @@ use Memcache;
/**
* Memcache Cache Driver
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
{

View file

@ -10,7 +10,7 @@ use Memcached;
/**
* Memcached Cache Driver
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver
{

View file

@ -10,7 +10,7 @@ use Redis;
/**
* Redis Cache Driver. This driver is based on Memcache driver
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
* @author Roland Haeder <roland@mxchange.org>
*/
class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver

View file

@ -4,7 +4,7 @@ namespace Friendica\Core\Config;
/**
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
interface IConfigAdapter
{

View file

@ -11,7 +11,7 @@ require_once 'include/dba.php';
*
* Default Config Adapter. Provides the best performance for pages loading few configuration variables.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class JITConfigAdapter extends BaseObject implements IConfigAdapter
{

View file

@ -11,7 +11,7 @@ require_once 'include/dba.php';
*
* Default PConfig Adapter. Provides the best performance for pages loading few configuration variables.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class JITPConfigAdapter extends BaseObject implements IPConfigAdapter
{

View file

@ -13,7 +13,7 @@ require_once 'include/dba.php';
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
{

View file

@ -13,7 +13,7 @@ require_once 'include/dba.php';
*
* Minimizes the number of database queries to retrieve configuration values at the cost of memory.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
{

View file

@ -5,7 +5,7 @@ namespace Friendica\Core;
/**
* Description of Console
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Console extends \Asika\SimpleConsole\Console
{

View file

@ -37,8 +37,8 @@ require_once 'include/text.php';
* set to the value of the last parameter. (e.g. "system loglevel 0" will
* disable logging)
*
* @author Tobias Diekershoff
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Config extends \Asika\SimpleConsole\Console
{

View file

@ -5,7 +5,7 @@ namespace Friendica\Core\Console;
/**
* Description of CreateDoxygen
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class CreateDoxygen extends \Asika\SimpleConsole\Console
{

View file

@ -11,9 +11,9 @@ require_once 'boot.php';
require_once 'include/dba.php';
/**
* @brief Does database updates from the command line
* @brief Performs database updates from the command line
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class DatabaseStructure extends \Asika\SimpleConsole\Console
{
@ -22,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
protected function getHelp()
{
$help = <<<HELP
console dbstructure - Does database updates
console dbstructure - Performs database updates
Usage
bin/console dbstructure <command> [-h|--help|-?] [-v]

View file

@ -22,7 +22,7 @@ namespace Friendica\Core\Console;
* This is done for all files, so, in the end removing one file leads to a working doc build.
*
* @author Alexander Kampmann
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class DocBloxErrorChecker extends \Asika\SimpleConsole\Console
{

View file

@ -8,7 +8,7 @@ namespace Friendica\Core\Console;
*
* Outputs a PHP file with language strings used by Friendica
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Extract extends \Asika\SimpleConsole\Console
{

View file

@ -13,8 +13,8 @@ use Friendica\Model\Contact;
*
* License: AGPLv3 or later, same as Friendica
*
* @author Tobias Diekershoff <mrpetovan@gmail.com>
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
{

View file

@ -19,8 +19,8 @@ require_once 'include/text.php';
*
* License: AGPLv3 or later, same as Friendica
*
* @author Tobias Diekershoff
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
{

View file

@ -10,7 +10,7 @@ require_once 'include/dba.php';
/**
* @brief Sets maintenance mode for this node
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Maintenance extends \Asika\SimpleConsole\Console
{

View file

@ -5,7 +5,7 @@ namespace Friendica\Core\Console;
/**
* Read a strings.php file and create messages.po in the same directory
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PhpToPo extends \Asika\SimpleConsole\Console
{

View file

@ -5,7 +5,7 @@ namespace Friendica\Core\Console;
/**
* Read a messages.po file and create strings.php in the same directory
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PoToPhp extends \Asika\SimpleConsole\Console
{

View file

@ -3,26 +3,51 @@
namespace Friendica\Core\Console;
use Friendica\Core\L10n;
use Friendica\Core\Config;
/**
* @brief tool to block an account from the node
*
* With this tool, you can block an account in such a way, that no postings
* or comments this account writes are accepted to the node.
* Performs database post updates
*
* License: AGPLv3 or later, same as Friendica
*
* @author Tobias Diekershoff <mrpetovan@gmail.com>
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PostUpdate extends \Asika\SimpleConsole\Console
{
protected $helpOptions = ['h', 'help', '?'];
protected function getHelp()
{
$help = <<<HELP
console postupdate - Performs database post updates
Usage
bin/console postupdate [-h|--help|-?] [--reset <version>]
Options
-h|--help|-? Show help information
--reset <version> Reset the post update version
HELP;
return $help;
}
protected function doExecute()
{
$a = get_app();
if (count($this->args) > 0) {
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp());
return 0;
}
$reset_version = $this->getOption('reset');
if (is_bool($reset_version)) {
$this->out($this->getHelp());
return 0;
} elseif ($reset_version) {
Config::set('system', 'post_update_version', $reset_version);
echo L10n::t('Post update version number has been set to %s.', $reset_version) . "\n";
return 0;
}
if ($a->isInstallMode()) {

View file

@ -6,7 +6,7 @@ namespace Friendica\Core\Console;
* Tired of chasing typos and finding them after a commit.
* Run this and quickly see if we've got any parse errors in our application files.
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Typo extends \Asika\SimpleConsole\Console
{

View file

@ -183,6 +183,10 @@ class L10n extends BaseObject
{
$a = self::getApp();
if (!is_numeric($count)) {
logger('Non numeric count called by ' . System::callstack(20));
}
$lang = Config::get('system', 'language');
if (!empty($a->strings[$singular])) {

View file

@ -9,31 +9,37 @@ use Friendica\Util\Network;
/**
* Manage compatibility with federated networks
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Protocol
{
const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
const DIASPORA = 'dspr'; // Diaspora
const DIASPORA2 = 'dspc'; // Diaspora connector
const STATUSNET = 'stac'; // Statusnet connector
const OSTATUS = 'stat'; // GNU-social, Pleroma, Mastodon, other OStatus implementations
const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol
const MAIL = 'mail'; // IMAP/POP
const XMPP = 'xmpp'; // XMPP - Currently unsupported
// Native support
const ACTIVITYPUB = 'apub'; // ActivityPub
const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
const DIASPORA = 'dspr'; // Diaspora
const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol
const MAIL = 'mail'; // IMAP/POP
const OSTATUS = 'stat'; // GNU-social, Pleroma, Mastodon, other OStatus implementations
const FACEBOOK = 'face'; // Facebook API
const LINKEDIN = 'lnkd'; // LinkedIn
const MYSPACE = 'mysp'; // MySpace - Currently unsupported
const GPLUS = 'goog'; // Google+
const PUMPIO = 'pump'; // pump.io
const TWITTER = 'twit'; // Twitter
const NATIVE_SUPPORT = [self::DFRN, self::DIASPORA, self::OSTATUS, self::FEED, self::MAIL, self::ACTIVITYPUB];
// Supported through a connector
const APPNET = 'apdn'; // app.net - Dead protocol
const DIASPORA2 = 'dspc'; // Diaspora connector
const FACEBOOK = 'face'; // Facebook API
const GPLUS = 'goog'; // Google+
const LINKEDIN = 'lnkd'; // LinkedIn
const PUMPIO = 'pump'; // pump.io
const STATUSNET = 'stac'; // Statusnet connector
const TWITTER = 'twit'; // Twitter
const NEWS = 'nntp'; // Network News Transfer Protocol - Currently unsupported
const ICALENDAR = 'ical'; // iCalendar - Currently unsupported
const PNUT = 'pnut'; // pnut.io - Currently unsupported
const ZOT = 'zot!'; // Zot! - Currently unsupported
// Currently unsupported
const ICALENDAR = 'ical'; // iCalendar
const MYSPACE = 'mysp'; // MySpace
const NEWS = 'nntp'; // Network News Transfer Protocol
const PNUT = 'pnut'; // pnut.io
const XMPP = 'xmpp'; // XMPP
const ZOT = 'zot!'; // Zot!
const PHANTOM = 'unkn'; // Place holder

View file

@ -11,7 +11,7 @@ use Friendica\Core\Session\DatabaseSessionHandler;
/**
* High-level Session service class
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Session
{

View file

@ -13,7 +13,7 @@ require_once 'include/text.php';
/**
* SessionHandler using Friendica Cache
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class CacheSessionHandler extends BaseObject implements SessionHandlerInterface
{

View file

@ -14,7 +14,7 @@ require_once 'include/text.php';
/**
* SessionHandler using database
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterface
{

View file

@ -27,9 +27,6 @@ class PostUpdate
if (!self::update1194()) {
return false;
}
if (!self::update1198()) {
return false;
}
if (!self::update1206()) {
return false;
}
@ -111,88 +108,6 @@ class PostUpdate
logger("Done", LOGGER_DEBUG);
}
/**
* @brief set the author-id and owner-id in all item entries
*
* This job has to be started multiple times until all entries are set.
* It isn't started in the update function since it would consume too much time and can be done in the background.
*
* @return bool "true" when the job is done
*/
private static function update1198()
{
// Was the script completed?
if (Config::get("system", "post_update_version") >= 1198) {
return true;
}
logger("Start", LOGGER_DEBUG);
// Check if the first step is done (Setting "author-id" and "owner-id" in the item table)
$fields = ['author-link', 'author-name', 'author-avatar', 'owner-link', 'owner-name', 'owner-avatar', 'network', 'uid'];
$r = DBA::select('item', $fields, ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);
if (!$r) {
// Are there unfinished entries in the thread table?
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
INNER JOIN `item` ON `item`.`id` =`thread`.`iid`
WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
if ($r && ($r[0]["total"] == 0)) {
Config::set("system", "post_update_version", 1198);
logger("Done", LOGGER_DEBUG);
return true;
}
// Update the thread table from the item table
$r = q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`
SET `thread`.`author-id` = `item`.`author-id`,
`thread`.`owner-id` = `item`.`owner-id`
WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
logger("Updated threads", LOGGER_DEBUG);
if (DBA::isResult($r)) {
Config::set("system", "post_update_version", 1198);
logger("Done", LOGGER_DEBUG);
return true;
}
return false;
}
logger("Query done", LOGGER_DEBUG);
$item_arr = [];
foreach ($r as $item) {
$index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"];
$item_arr[$index] = ["author-link" => $item["author-link"],
"owner-link" => $item["owner-link"],
"uid" => $item["uid"]];
}
// Set the "author-id" and "owner-id" in the item table and add a new public contact entry if needed
foreach ($item_arr as $item) {
$default = ['url' => $item['author-link'], 'name' => $item['author-name'],
'photo' => $item['author-avatar'], 'network' => $item['network']];
$author_id = Contact::getIdForURL($item["author-link"], 0, false, $default);
$default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
'photo' => $item['owner-avatar'], 'network' => $item['network']];
$owner_id = Contact::getIdForURL($item["owner-link"], 0, false, $default);
if ($author_id == 0) {
$author_id = -1;
}
if ($owner_id == 0) {
$owner_id = -1;
}
DBA::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]);
}
logger("Updated items", LOGGER_DEBUG);
return false;
}
/**
* @brief update the "last-item" field in the "self" contact
*
@ -253,6 +168,12 @@ class PostUpdate
$condition = ["`id` > ?", $id];
$params = ['order' => ['id'], 'limit' => 10000];
$items = Item::select($fields, $condition, $params);
if (DBA::errorNo() != 0) {
logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage());
return false;
}
while ($item = Item::fetch($items)) {
$id = $item['id'];
@ -394,6 +315,12 @@ class PostUpdate
$condition = ["`id` > ?", $id];
$params = ['order' => ['id'], 'limit' => 10000];
$items = DBA::select('item', $fields, $condition, $params);
if (DBA::errorNo() != 0) {
logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage());
return false;
}
while ($item = DBA::fetch($items)) {
$id = $item['id'];

View file

@ -17,6 +17,7 @@ use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
@ -528,13 +529,16 @@ class Contact extends BaseObject
/**
* @brief Sends an unfriend message. Does not remove the contact
*
* @param array $user User unfriending
* @param array $contact Contact unfriended
* @param array $user User unfriending
* @param array $contact Contact unfriended
* @param boolean $dissolve Remove the contact on the remote side
* @return void
*/
public static function terminateFriendship(array $user, array $contact)
public static function terminateFriendship(array $user, array $contact, $dissolve = false)
{
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
if (($contact['network'] == Protocol::DFRN) && $dissolve) {
DFRN::deliver($user, $contact, 'placeholder', true);
} elseif (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
// create an unfollow slap
$item = [];
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
@ -1076,6 +1080,11 @@ class Contact extends BaseObject
if (empty($data)) {
$data = Probe::uri($url, "", $uid);
// Ensure that there is a gserver entry
if (!empty($data['baseurl']) && ($data['network'] != Protocol::PHANTOM)) {
PortableContact::checkServer($data['baseurl']);
}
}
// Last try in gcontact for unsupported networks

View file

@ -12,6 +12,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
@ -589,6 +590,12 @@ class Event extends BaseObject
$title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
}
$author_link = $event['author-link'];
$plink = $event['plink'];
$event['author-link'] = Contact::magicLink($author_link);
$event['plink'] = Contact::magicLink($author_link, $plink);
$html = self::getHTML($event);
$event['desc'] = BBCode::convert($event['desc']);
$event['location'] = BBCode::convert($event['location']);

View file

@ -1462,15 +1462,6 @@ class Item extends BaseObject
return 0;
}
// These fields aren't stored anymore in the item table, they are fetched upon request
unset($item['author-link']);
unset($item['author-name']);
unset($item['author-avatar']);
unset($item['owner-link']);
unset($item['owner-name']);
unset($item['owner-avatar']);
if ($item['network'] == Protocol::PHANTOM) {
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
@ -1708,6 +1699,15 @@ class Item extends BaseObject
unset($item['postopts']);
unset($item['inform']);
// These fields aren't stored anymore in the item table, they are fetched upon request
unset($item['author-link']);
unset($item['author-name']);
unset($item['author-avatar']);
unset($item['owner-link']);
unset($item['owner-name']);
unset($item['owner-avatar']);
DBA::transaction();
$ret = DBA::insert('item', $item);

View file

@ -361,7 +361,7 @@ class Profile
if ($r) {
$remote_url = $r[0]['url'];
$message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
$wallmessage_link = $message_path . base64_encode($profile['addr']);
$wallmessage_link = $message_path . base64_encode(defaults($profile, 'addr', ''));
} else if (!empty($profile['nickname'])) {
$wallmessage_link = 'wallmessage/' . $profile['nickname'];
}
@ -492,7 +492,7 @@ class Profile
if (isset($p['address'])) {
$p['address'] = BBCode::convert($p['address']);
} else {
} elseif (isset($p['location'])) {
$p['address'] = BBCode::convert($p['location']);
}

View file

@ -730,7 +730,7 @@ class User
DBA::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc($t . " + 7 day")], ['uid' => $uid]);
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc(DateTimeFormat::utcNow() . " + 7 day")], ['uid' => $uid]);
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory

View file

@ -20,7 +20,7 @@ use Friendica\Protocol\OStatus;
*
* @brief Provides public Atom feeds
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Feed extends BaseModule
{

View file

@ -22,7 +22,7 @@ require_once 'include/text.php';
/**
* Login module
*
* @author Hypolite Petovan mrpetovan@gmail.com
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Login extends BaseModule
{

View file

@ -14,7 +14,7 @@ require_once 'include/security.php';
/**
* Logout module
*
* @author Hypolite Petovan mrpetovan@gmail.com
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Logout extends BaseModule
{

View file

@ -12,7 +12,7 @@ use Friendica\Content;
*
* Example: /oembed/aHR0cHM6Ly9...
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Oembed extends BaseModule
{

View file

@ -8,6 +8,7 @@ namespace Friendica\Module;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Photo;
@ -133,6 +134,10 @@ class Proxy extends BaseModule
$direct_cache = false;
}
if (empty($_REQUEST['url'])) {
System::httpExit(400, ["title" => L10n::t('Bad Request.')]);
}
if (!$direct_cache) {
$urlhash = 'pic:' . sha1($_REQUEST['url']);

View file

@ -967,23 +967,23 @@ class Probe
$hcard_url = "";
$data = [];
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) {
if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) {
$data["network"] = Protocol::DFRN;
} elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
$hcard_url = $link["href"];
} elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) {
} elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
$data["poco"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
$data["photo"] = $link["href"];
} elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
$data["baseurl"] = trim($link["href"], '/');
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
$data["guid"] = $link["href"];
} elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) {
} elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
$data["pubkey"] = base64_decode($link["href"]);
//if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
@ -1170,21 +1170,21 @@ class Probe
$hcard_url = "";
$data = [];
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) {
if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
$hcard_url = $link["href"];
} elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) {
$data["baseurl"] = trim($link["href"], '/');
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
$data["guid"] = $link["href"];
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
} elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) {
} elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
$data["poco"] = $link["href"];
} elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
$data["notify"] = $link["href"];
} elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) {
} elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) {
$data["pubkey"] = base64_decode($link["href"]);
//if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA"))
@ -1272,15 +1272,15 @@ class Probe
if (is_array($webfinger["links"])) {
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
&& ($link["type"] == "text/html")
&& (defaults($link, "type", "") == "text/html")
&& ($link["href"] != "")
) {
$data["url"] = $link["href"];
} elseif (($link["rel"] == "salmon") && ($link["href"] != "")) {
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
$data["notify"] = $link["href"];
} elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
$data["poll"] = $link["href"];
} elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) {
} elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
$pubkey = $link["href"];
if (substr($pubkey, 0, 5) === 'data:') {
@ -1436,7 +1436,7 @@ class Probe
$data = [];
foreach ($webfinger["links"] as $link) {
if (($link["rel"] == "http://webfinger.net/rel/profile-page")
&& ($link["type"] == "text/html")
&& (defaults($link, "type", "") == "text/html")
&& ($link["href"] != "")
) {
$data["url"] = $link["href"];

View file

@ -792,7 +792,7 @@ class Image
try {
if (function_exists("getimagesizefromstring")) {
$data = getimagesizefromstring($img_str);
$data = @getimagesizefromstring($img_str);
} else {
$tempfile = tempnam(get_temppath(), "cache");

View file

@ -7,7 +7,7 @@ namespace Friendica\Object;
*
* @see https://oembed.com/#section2.3
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class OEmbed
{

View file

@ -81,7 +81,8 @@ class DFRN
return [];
}
$user['importer_uid'] = $user['uid'];
$user['importer_uid'] = $user['uid'];
$user['uprvkey'] = $user['prvkey'];
} else {
$user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC',
'nickname' => '', 'sprvkey' => '', 'spubkey' => '',
@ -1163,15 +1164,17 @@ class DFRN
* @return int Deliver status. Negative values mean an error.
* @todo Add array type-hint for $owner, $contact
*/
public static function deliver($owner, $contact, $atom, $dissolve = false)
public static function deliver($owner, $contact, $atom, $dissolve = false, $legacy_transport = false)
{
$a = get_app();
// At first try the Diaspora transport layer
$ret = self::transmit($owner, $contact, $atom);
if ($ret >= 200) {
logger('Delivery via Diaspora transport layer was successful with status ' . $ret);
return $ret;
if (!$dissolve && !$legacy_transport) {
$ret = self::transmit($owner, $contact, $atom);
if ($ret >= 200) {
logger('Delivery via Diaspora transport layer was successful with status ' . $ret);
return $ret;
}
}
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
@ -2252,6 +2255,11 @@ class DFRN
if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
$item['id'] = $posted_id;
$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]);
$item["parent"] = $parent['id'];
// send a notification
notification(
[
@ -2402,8 +2410,11 @@ class DFRN
break;
case "enclosure":
$enclosure = $href;
if (strlen($item["attach"])) {
if (!empty($item["attach"])) {
$item["attach"] .= ",";
} else {
$item["attach"] = "";
}
$item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/attach]';

View file

@ -365,15 +365,16 @@ class Diaspora
/**
* @brief: Decodes incoming Diaspora message in the new format
*
* @param array $importer Array of the importer user
* @param string $raw raw post message
* @param array $importer Array of the importer user
* @param string $raw raw post message
* @param boolean $no_exit Don't do an http exit on error
*
* @return array
* 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8)
*/
public static function decodeRaw(array $importer, $raw)
public static function decodeRaw(array $importer, $raw, $no_exit = false)
{
$data = json_decode($raw);
@ -388,7 +389,11 @@ class Diaspora
if (!is_object($j_outer_key_bundle)) {
logger('Outer Salmon did not verify. Discarding.');
System::httpExit(400);
if ($no_exit) {
return false;
} else {
System::httpExit(400);
}
}
$outer_iv = base64_decode($j_outer_key_bundle->iv);
@ -403,7 +408,11 @@ class Diaspora
if (!is_object($basedom)) {
logger('Received data does not seem to be an XML. Discarding. '.$xml);
System::httpExit(400);
if ($no_exit) {
return false;
} else {
System::httpExit(400);
}
}
$base = $basedom->children(NAMESPACE_SALMON_ME);
@ -425,19 +434,31 @@ class Diaspora
$author_addr = base64_decode($key_id);
if ($author_addr == '') {
logger('No author could be decoded. Discarding. Message: ' . $xml);
System::httpExit(400);
if ($no_exit) {
return false;
} else {
System::httpExit(400);
}
}
$key = self::key($author_addr);
if ($key == '') {
logger("Couldn't get a key for handle " . $author_addr . ". Discarding.");
System::httpExit(400);
if ($no_exit) {
return false;
} else {
System::httpExit(400);
}
}
$verify = Crypto::rsaVerify($signed_data, $signature, $key);
if (!$verify) {
logger('Message did not verify. Discarding.');
System::httpExit(400);
if ($no_exit) {
return false;
} else {
System::httpExit(400);
}
}
return ['message' => (string)base64url_decode($base->data),
@ -3475,7 +3496,7 @@ class Diaspora
$myaddr = self::myHandle($owner);
$public = (($item["private"]) ? "false" : "true");
$public = ($item["private"] ? "false" : "true");
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);

View file

@ -271,9 +271,14 @@ class Feed {
}
$updated = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry);
if (empty($updated)) {
if (empty($updated) && !empty($published)) {
$updated = $published;
}
if (empty($published) && !empty($updated)) {
$published = $updated;
}
if ($published != "") {
$item["created"] = $published;
}

View file

@ -74,6 +74,16 @@ class OStatus
$author["contact-id"] = $contact["id"];
$contact = null;
/*
This here would be better, but we would get problems with contacts from the statusnet addon
This is kept here as a reminder for the future
$cid = Contact::getIdForURL($author["author-link"], $importer["uid"]);
if ($cid) {
$contact = DBA::selectFirst('contact', [], ['id' => $cid]);
}
*/
if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, Protocol::STATUSNET,
@ -219,7 +229,7 @@ class OStatus
$gcid = GContact::update($contact);
GContact::link($gcid, $contact["uid"], $contact["id"]);
} else {
} elseif ($contact["network"] != Protocol::DFRN) {
$contact = null;
}
@ -312,7 +322,7 @@ class OStatus
self::$conv_list = [];
}
logger("Import OStatus message", LOGGER_DEBUG);
logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG);
if ($xml == "") {
return false;
@ -351,7 +361,7 @@ class OStatus
$header["origin"] = 0;
$header["gravity"] = GRAVITY_COMMENT;
if (!is_object($doc->firstChild)) {
if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
return false;
}

View file

@ -1157,9 +1157,9 @@ class PortableContact
if (isset($data['version'])) {
$platform = "Mastodon";
$version = $data['version'];
$site_name = $data['title'];
$info = $data['description'];
$version = defaults($data, 'version', '');
$site_name = defaults($data, 'title', '');
$info = defaults($data, 'description', '');
$network = Protocol::OSTATUS;
}

View file

@ -9,7 +9,7 @@ use Smarty;
/**
* Friendica extension of the Smarty3 template engine
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class FriendicaSmarty extends Smarty
{

View file

@ -9,7 +9,7 @@ use Friendica\Core\Addon;
/**
* Smarty implementation of the Friendica template engine interface
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class FriendicaSmartyEngine implements ITemplateEngine
{

View file

@ -49,7 +49,7 @@ class Emailer
.rand(10000, 99999);
// generate a multipart/alternative message header
$messageHeader = $params['additionalMailHeader'] .
$messageHeader = defaults($params, 'additionalMailHeader', '') .
"From: $fromName <{$params['fromEmail']}>\n" .
"Reply-To: $fromName <{$params['replyTo']}>\n" .
"MIME-Version: 1.0\n" .

View file

@ -125,6 +125,8 @@ class HTTPSignature
$key = $key($sig_block['keyId']);
}
logger('Got keyID ' . $sig_block['keyId']);
// We don't use Activity Pub at the moment.
// if (!$key) {
// $result['signer'] = $sig_block['keyId'];

View file

@ -118,13 +118,13 @@ class ParseUrl
// Check if the URL does contain a scheme
$scheme = parse_url($url, PHP_URL_SCHEME);
if ($scheme == "") {
$url = "http://".trim($url, "/");
if ($scheme == '') {
$url = 'http://' . trim($url, '/');
}
if ($count > 10) {
logger("parseurl_getsiteinfo: Endless loop detected for ".$url, LOGGER_DEBUG);
return($siteinfo);
logger('Endless loop detected for ' . $url, LOGGER_DEBUG);
return $siteinfo;
}
$url = trim($url, "'");
@ -132,220 +132,223 @@ class ParseUrl
$url = Network::stripTrackingQueryParams($url);
$siteinfo["url"] = $url;
$siteinfo["type"] = "link";
$siteinfo['url'] = $url;
$siteinfo['type'] = 'link';
$data = Network::curl($url);
if (!$data['success']) {
return($siteinfo);
return $siteinfo;
}
// If the file is too large then exit
if ($data["info"]["download_content_length"] > 1000000) {
return($siteinfo);
if ($data['info']['download_content_length'] > 1000000) {
return $siteinfo;
}
// If it isn't a HTML file then exit
if (($data["info"]["content_type"] != "") && !strstr(strtolower($data["info"]["content_type"]), "html")) {
return($siteinfo);
if (($data['info']['content_type'] != '') && !strstr(strtolower($data['info']['content_type']), 'html')) {
return $siteinfo;
}
$header = $data["header"];
$body = $data["body"];
$header = $data['header'];
$body = $data['body'];
if ($do_oembed) {
$oembed_data = OEmbed::fetchURL($url);
if (!empty($oembed_data->type)) {
if (!in_array($oembed_data->type, ["error", "rich", ""])) {
$siteinfo["type"] = $oembed_data->type;
if (!in_array($oembed_data->type, ['error', 'rich', ''])) {
$siteinfo['type'] = $oembed_data->type;
}
if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) {
// See https://github.com/friendica/friendica/pull/5763#discussion_r217913178
if ($siteinfo['type'] != 'photo') {
if (isset($oembed_data->title)) {
$siteinfo["title"] = trim($oembed_data->title);
$siteinfo['title'] = trim($oembed_data->title);
}
if (isset($oembed_data->description)) {
$siteinfo["text"] = trim($oembed_data->description);
$siteinfo['text'] = trim($oembed_data->description);
}
if (isset($oembed_data->thumbnail_url)) {
$siteinfo["image"] = $oembed_data->thumbnail_url;
$siteinfo['image'] = $oembed_data->thumbnail_url;
}
}
}
}
// Fetch the first mentioned charset. Can be in body or header
$charset = "";
if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches)) {
$charset = '';
if (preg_match('/charset=(.*?)[\'"\s\n]/', $header, $matches)) {
$charset = trim(trim(trim(array_pop($matches)), ';,'));
}
if ($charset == "") {
$charset = "utf-8";
if ($charset == '') {
$charset = 'utf-8';
}
if (($charset != "") && (strtoupper($charset) != "UTF-8")) {
logger("parseurl_getsiteinfo: detected charset ".$charset, LOGGER_DEBUG);
//$body = mb_convert_encoding($body, "UTF-8", $charset);
$body = iconv($charset, "UTF-8//TRANSLIT", $body);
if (($charset != '') && (strtoupper($charset) != 'UTF-8')) {
logger('detected charset ' . $charset, LOGGER_DEBUG);
$body = iconv($charset, 'UTF-8//TRANSLIT', $body);
}
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
$body = mb_convert_encoding($body, 'HTML-ENTITIES', 'UTF-8');
$doc = new DOMDocument();
@$doc->loadHTML($body);
XML::deleteNode($doc, "style");
XML::deleteNode($doc, "script");
XML::deleteNode($doc, "option");
XML::deleteNode($doc, "h1");
XML::deleteNode($doc, "h2");
XML::deleteNode($doc, "h3");
XML::deleteNode($doc, "h4");
XML::deleteNode($doc, "h5");
XML::deleteNode($doc, "h6");
XML::deleteNode($doc, "ol");
XML::deleteNode($doc, "ul");
XML::deleteNode($doc, 'style');
XML::deleteNode($doc, 'script');
XML::deleteNode($doc, 'option');
XML::deleteNode($doc, 'h1');
XML::deleteNode($doc, 'h2');
XML::deleteNode($doc, 'h3');
XML::deleteNode($doc, 'h4');
XML::deleteNode($doc, 'h5');
XML::deleteNode($doc, 'h6');
XML::deleteNode($doc, 'ol');
XML::deleteNode($doc, 'ul');
$xpath = new DOMXPath($doc);
$list = $xpath->query("//meta[@content]");
$list = $xpath->query('//meta[@content]');
foreach ($list as $node) {
$attr = [];
$meta_tag = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
$meta_tag[$attribute->name] = $attribute->value;
}
}
if (@$attr["http-equiv"] == "refresh") {
$path = $attr["content"];
$pathinfo = explode(";", $path);
$content = "";
if (@$meta_tag['http-equiv'] == 'refresh') {
$path = $meta_tag['content'];
$pathinfo = explode(';', $path);
$content = '';
foreach ($pathinfo as $value) {
if (substr(strtolower($value), 0, 4) == "url=") {
if (substr(strtolower($value), 0, 4) == 'url=') {
$content = substr($value, 4);
}
}
if ($content != "") {
if ($content != '') {
$siteinfo = self::getSiteinfo($content, $no_guessing, $do_oembed, ++$count);
return($siteinfo);
return $siteinfo;
}
}
}
$list = $xpath->query("//title");
$list = $xpath->query('//title');
if ($list->length > 0) {
$siteinfo["title"] = trim($list->item(0)->nodeValue);
$siteinfo['title'] = trim($list->item(0)->nodeValue);
}
//$list = $xpath->query("head/meta[@name]");
$list = $xpath->query("//meta[@name]");
$list = $xpath->query('//meta[@name]');
foreach ($list as $node) {
$attr = [];
$meta_tag = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
$meta_tag[$attribute->name] = $attribute->value;
}
}
if (!empty($attr["content"])) {
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
switch (strtolower($attr["name"])) {
case "fulltitle":
$siteinfo["title"] = trim($attr["content"]);
break;
case "description":
$siteinfo["text"] = trim($attr["content"]);
break;
case "thumbnail":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:image":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:image:src":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:card":
if (($siteinfo["type"] == "") || ($attr["content"] == "photo")) {
$siteinfo["type"] = $attr["content"];
}
break;
case "twitter:description":
$siteinfo["text"] = trim($attr["content"]);
break;
case "twitter:title":
$siteinfo["title"] = trim($attr["content"]);
break;
case "dc.title":
$siteinfo["title"] = trim($attr["content"]);
break;
case "dc.description":
$siteinfo["text"] = trim($attr["content"]);
break;
case "keywords":
$keywords = explode(",", $attr["content"]);
break;
case "news_keywords":
$keywords = explode(",", $attr["content"]);
break;
}
if (empty($meta_tag['content'])) {
continue;
}
if ($siteinfo["type"] == "summary") {
$siteinfo["type"] = "link";
$meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8'));
switch (strtolower($meta_tag['name'])) {
case 'fulltitle':
$siteinfo['title'] = trim($meta_tag['content']);
break;
case 'description':
$siteinfo['text'] = trim($meta_tag['content']);
break;
case 'thumbnail':
$siteinfo['image'] = $meta_tag['content'];
break;
case 'twitter:image':
$siteinfo['image'] = $meta_tag['content'];
break;
case 'twitter:image:src':
$siteinfo['image'] = $meta_tag['content'];
break;
case 'twitter:card':
// Detect photo pages
if ($meta_tag['content'] == 'summary_large_image') {
$siteinfo['type'] = 'photo';
}
break;
case 'twitter:description':
$siteinfo['text'] = trim($meta_tag['content']);
break;
case 'twitter:title':
$siteinfo['title'] = trim($meta_tag['content']);
break;
case 'dc.title':
$siteinfo['title'] = trim($meta_tag['content']);
break;
case 'dc.description':
$siteinfo['text'] = trim($meta_tag['content']);
break;
case 'keywords':
$keywords = explode(',', $meta_tag['content']);
break;
case 'news_keywords':
$keywords = explode(',', $meta_tag['content']);
break;
}
}
if (isset($keywords)) {
$siteinfo["keywords"] = [];
$siteinfo['keywords'] = [];
foreach ($keywords as $keyword) {
if (!in_array(trim($keyword), $siteinfo["keywords"])) {
$siteinfo["keywords"][] = trim($keyword);
if (!in_array(trim($keyword), $siteinfo['keywords'])) {
$siteinfo['keywords'][] = trim($keyword);
}
}
}
//$list = $xpath->query("head/meta[@property]");
$list = $xpath->query("//meta[@property]");
$list = $xpath->query('//meta[@property]');
foreach ($list as $node) {
$attr = [];
$meta_tag = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
$meta_tag[$attribute->name] = $attribute->value;
}
}
if (!empty($attr["content"])) {
$attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
if (!empty($meta_tag['content'])) {
$meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8'));
switch (strtolower($attr["property"])) {
case "og:image":
$siteinfo["image"] = $attr["content"];
switch (strtolower($meta_tag['property'])) {
case 'og:image':
$siteinfo['image'] = $meta_tag['content'];
break;
case "og:title":
$siteinfo["title"] = trim($attr["content"]);
case 'og:title':
$siteinfo['title'] = trim($meta_tag['content']);
break;
case "og:description":
$siteinfo["text"] = trim($attr["content"]);
case 'og:description':
$siteinfo['text'] = trim($meta_tag['content']);
break;
}
}
}
if ((@$siteinfo["image"] == "") && !$no_guessing) {
$list = $xpath->query("//img[@src]");
// Prevent to have a photo type without an image
if ((empty($siteinfo['image']) || !empty($siteinfo['text'])) && ($siteinfo['type'] == 'photo')) {
$siteinfo['type'] = 'link';
}
if (empty($siteinfo['image']) && !$no_guessing) {
$list = $xpath->query('//img[@src]');
foreach ($list as $node) {
$attr = [];
$img_tag = [];
if ($node->attributes->length) {
foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value;
$img_tag[$attribute->name] = $attribute->value;
}
}
$src = self::completeUrl($attr["src"], $url);
$src = self::completeUrl($img_tag['src'], $url);
$photodata = Image::getInfoFromURL($src);
if (($photodata) && ($photodata[0] > 150) && ($photodata[1] > 150)) {
@ -357,70 +360,72 @@ class ParseUrl
$photodata[0] = round($photodata[0] * (300 / $photodata[1]));
$photodata[1] = 300;
}
$siteinfo["images"][] = ["src" => $src,
"width" => $photodata[0],
"height" => $photodata[1]];
$siteinfo['images'][] = [
'src' => $src,
'width' => $photodata[0],
'height' => $photodata[1]
];
}
}
} elseif (!empty($siteinfo["image"])) {
$src = self::completeUrl($siteinfo["image"], $url);
} elseif (!empty($siteinfo['image'])) {
$src = self::completeUrl($siteinfo['image'], $url);
unset($siteinfo["image"]);
unset($siteinfo['image']);
$photodata = Image::getInfoFromURL($src);
if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) {
$siteinfo["images"][] = ["src" => $src,
"width" => $photodata[0],
"height" => $photodata[1]];
$siteinfo['images'][] = ['src' => $src,
'width' => $photodata[0],
'height' => $photodata[1]];
}
}
if ((@$siteinfo["text"] == "") && (@$siteinfo["title"] != "") && !$no_guessing) {
$text = "";
if ((@$siteinfo['text'] == '') && (@$siteinfo['title'] != '') && !$no_guessing) {
$text = '';
$list = $xpath->query("//div[@class='article']");
$list = $xpath->query('//div[@class="article"]');
foreach ($list as $node) {
if (strlen($node->nodeValue) > 40) {
$text .= " ".trim($node->nodeValue);
$text .= ' ' . trim($node->nodeValue);
}
}
if ($text == "") {
$list = $xpath->query("//div[@class='content']");
if ($text == '') {
$list = $xpath->query('//div[@class="content"]');
foreach ($list as $node) {
if (strlen($node->nodeValue) > 40) {
$text .= " ".trim($node->nodeValue);
$text .= ' ' . trim($node->nodeValue);
}
}
}
// If none text was found then take the paragraph content
if ($text == "") {
$list = $xpath->query("//p");
if ($text == '') {
$list = $xpath->query('//p');
foreach ($list as $node) {
if (strlen($node->nodeValue) > 40) {
$text .= " ".trim($node->nodeValue);
$text .= ' ' . trim($node->nodeValue);
}
}
}
if ($text != "") {
$text = trim(str_replace(["\n", "\r"], [" ", " "], $text));
if ($text != '') {
$text = trim(str_replace(["\n", "\r"], [' ', ' '], $text));
while (strpos($text, " ")) {
$text = trim(str_replace(" ", " ", $text));
while (strpos($text, ' ')) {
$text = trim(str_replace(' ', ' ', $text));
}
$siteinfo["text"] = trim(html_entity_decode(substr($text, 0, 350), ENT_QUOTES, "UTF-8").'...');
$siteinfo['text'] = trim(html_entity_decode(substr($text, 0, 350), ENT_QUOTES, 'UTF-8') . '...');
}
}
logger("parseurl_getsiteinfo: Siteinfo for ".$url." ".print_r($siteinfo, true), LOGGER_DEBUG);
logger('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG);
Addon::callHooks("getsiteinfo", $siteinfo);
Addon::callHooks('getsiteinfo', $siteinfo);
return($siteinfo);
return $siteinfo;
}
/**
@ -482,21 +487,23 @@ class ParseUrl
$complete = $schemearr["scheme"]."://".$schemearr["host"];
if (@$schemearr["port"] != "") {
if (!empty($schemearr["port"])) {
$complete .= ":".$schemearr["port"];
}
if (strpos($urlarr["path"], "/") !== 0) {
$complete .= "/";
if (!empty($urlarr["path"])) {
if (strpos($urlarr["path"], "/") !== 0) {
$complete .= "/";
}
$complete .= $urlarr["path"];
}
$complete .= $urlarr["path"];
if (@$urlarr["query"] != "") {
if (!empty($urlarr["query"])) {
$complete .= "?".$urlarr["query"];
}
if (@$urlarr["fragment"] != "") {
if (!empty($urlarr["fragment"])) {
$complete .= "#".$urlarr["fragment"];
}

View file

@ -292,8 +292,10 @@ class Delivery extends BaseObject
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
return;
}
} else {
} elseif ($cmd != self::RELOCATION) {
$deliver_status = DFRN::deliver($owner, $contact, $atom);
} else {
$deliver_status = DFRN::deliver($owner, $contact, $atom, false, true);
}
logger('Delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);

View file

@ -96,7 +96,7 @@ class Notifier
return;
}
foreach ($r as $contact) {
Contact::terminateFriendship($user, $contact);
Contact::terminateFriendship($user, $contact, true);
}
return;
} elseif ($cmd == Delivery::RELOCATION) {
@ -217,24 +217,16 @@ class Notifier
}
// Special treatment for forum posts
if (($target_item['author-id'] != $target_item['owner-id']) &&
($owner['id'] != $target_item['contact-id']) &&
($target_item['uri'] === $target_item['parent-uri'])) {
$fields = ['forum', 'prv'];
$condition = ['id' => $target_item['contact-id']];
$contact = DBA::selectFirst('contact', $fields, $condition);
if (!DBA::isResult($contact)) {
// Should never happen
return false;
}
// Is the post from a forum?
if ($contact['forum'] || $contact['prv']) {
$relay_to_owner = true;
$direct_forum_delivery = true;
}
if (self::isForumPost($target_item, $owner)) {
$relay_to_owner = true;
$direct_forum_delivery = true;
}
// Avoid that comments in a forum thread are sent to OStatus
if (self::isForumPost($parent, $owner)) {
$direct_forum_delivery = true;
}
if ($relay_to_owner) {
// local followup to remote post
$followup = true;
@ -504,4 +496,23 @@ class Notifier
return;
}
private static function isForumPost($item, $owner) {
if (($item['author-id'] == $item['owner-id']) ||
($owner['id'] == $item['contact-id']) ||
($item['uri'] != $item['parent-uri'])) {
return false;
}
$fields = ['forum', 'prv'];
$condition = ['id' => $item['contact-id']];
$contact = DBA::selectFirst('contact', $fields, $condition);
if (!DBA::isResult($contact)) {
// Should never happen
return false;
}
// Is the post from a forum?
return ($contact['forum'] || $contact['prv']);
}
}

View file

@ -13,8 +13,8 @@ require_once 'include/dba.php';
class RemoveContact {
public static function execute($id) {
// Only delete if the contact is archived
$condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id];
// Only delete if the contact is to be deleted
$condition = ['network' => Protocol::PHANTOM, 'id' => $id];
$r = DBA::exists('contact', $condition);
if (!DBA::isResult($r)) {
return;

View file

@ -5,6 +5,7 @@ Adam Clark
Adam Jurkiewicz
Adam Magness
Aditoo
Aditoo17
AgnesElisa
Albert
Alberto Díaz Tormo
@ -99,6 +100,7 @@ hoergen
Hubert Kościański
Hypolite Petovan
Ilmari
ImgBotApp
irhen
Jak
Jakob
@ -161,6 +163,7 @@ Pascal Deklerck
Pavel Morozov
PerigGouanvic
peturisfeld
Philipp
Philipp Holzer
Pierre Rudloff
Piotr Blonkowski
@ -195,6 +198,7 @@ Simó Albert i Beltran
soko1
St John Karp
Stanislav N.
Steffen K9
StefOfficiel
Sveinn í Felli
Sven Anders
@ -211,6 +215,7 @@ thorsten23
Tino
Tobias Diekershoff
Tobias Hößl
tomacat
tomamplius
tomtom84
Tony Baldwin
@ -221,6 +226,7 @@ Tubuntu
Tupambae.org
U-SOUND\mike
ufic
Unknown
Vasudev Kamath
Vasya Novikov
vislav

View file

@ -248,7 +248,6 @@ span.oembed, h4 {
}
code {
display: block;
background-color: #eee;
color: #666;
padding: 1em;

View file

@ -81,6 +81,11 @@ $(function() {
Dialog.doImageBrowser("comment", id);
return;
}
if (bbcode == "imgprv") {
bbcode = "img";
}
insertFormatting(bbcode, id);
});
@ -305,7 +310,9 @@ $(function() {
// Asynchronous calls are deferred until the very end of the page load to ease on slower connections
window.addEventListener("load", function(){
NavUpdate();
acl.get(0, 100);
if (typeof acl !== 'undefined') {
acl.get(0, 100);
}
});
// Allow folks to stop the ajax page updates with the pause/break key

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