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) Version 2018.05 (2018-06-01)
Friendica Core: Friendica Core:
Update to the translations (DE, EN-GB, EN-US, FI, IS, IT, NL, PL, RU, ZN CH) [translation teams] 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_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); 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('DFRN_PROTOCOL_VERSION', '2.23');
define('DB_UPDATE_VERSION', 1283); define('DB_UPDATE_VERSION', 1283);
define('NEW_UPDATE_ROUTINE_VERSION', 1170); define('NEW_UPDATE_ROUTINE_VERSION', 1170);

View file

@ -18,13 +18,12 @@
"asika/simple-console": "^1.0", "asika/simple-console": "^1.0",
"divineomega/password_exposed": "^2.4", "divineomega/password_exposed": "^2.4",
"ezyang/htmlpurifier": "~4.7.0", "ezyang/htmlpurifier": "~4.7.0",
"league/html-to-markdown": "~4.4.1", "league/html-to-markdown": "~4.8.0",
"lightopenid/lightopenid": "dev-master", "lightopenid/lightopenid": "dev-master",
"michelf/php-markdown": "^1.7", "michelf/php-markdown": "^1.7",
"mobiledetect/mobiledetectlib": "2.8.*", "mobiledetect/mobiledetectlib": "2.8.*",
"paragonie/random_compat": "^2.0", "paragonie/random_compat": "^2.0",
"pear/Text_LanguageDetect": "1.*", "pear/Text_LanguageDetect": "1.*",
"pear/Text_Highlighter": "dev-master",
"seld/cli-prompt": "^1.0", "seld/cli-prompt": "^1.0",
"smarty/smarty": "^3.1", "smarty/smarty": "^3.1",
"fxp/composer-asset-plugin": "~1.3", "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d62c3e3d6971ee63a862a22ff3cd3768", "content-hash": "5f6a43237dc52758484cd21cd76e8ce6",
"packages": [ "packages": [
{ {
"name": "asika/simple-console", "name": "asika/simple-console",
@ -483,16 +483,16 @@
}, },
{ {
"name": "league/html-to-markdown", "name": "league/html-to-markdown",
"version": "4.4.1", "version": "4.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git", "url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186" "reference": "f9a879a068c68ff47b722de63f58bec79e448f9d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/82ea375b5b2b1da1da222644c0565c695bf88186", "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/f9a879a068c68ff47b722de63f58bec79e448f9d",
"reference": "82ea375b5b2b1da1da222644c0565c695bf88186", "reference": "f9a879a068c68ff47b722de63f58bec79e448f9d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -511,7 +511,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.5-dev" "dev-master": "4.9-dev"
} }
}, },
"autoload": { "autoload": {
@ -524,17 +524,17 @@
"MIT" "MIT"
], ],
"authors": [ "authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{ {
"name": "Nick Cernis", "name": "Nick Cernis",
"email": "nick@cern.is", "email": "nick@cern.is",
"homepage": "http://modernnerd.net", "homepage": "http://modernnerd.net",
"role": "Original Author" "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", "description": "An HTML-to-markdown conversion helper for PHP",
@ -543,7 +543,7 @@
"html", "html",
"markdown" "markdown"
], ],
"time": "2017-03-16T00:45:59+00:00" "time": "2018-09-18T12:18:08+00:00"
}, },
{ {
"name": "lightopenid/lightopenid", "name": "lightopenid/lightopenid",
@ -1669,204 +1669,6 @@
], ],
"time": "2018-02-15T05:50:20+00:00" "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", "name": "pear/text_languagedetect",
"version": "v1.0.0", "version": "v1.0.0",
@ -3145,7 +2947,7 @@
} }
], ],
"description": "Provides the functionality to compare PHP values for equality", "description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator", "homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [ "keywords": [
"comparator", "comparator",
"compare", "compare",
@ -3247,7 +3049,7 @@
} }
], ],
"description": "Provides functionality to handle HHVM/PHP environments", "description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "https://github.com/sebastianbergmann/environment", "homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [ "keywords": [
"Xdebug", "Xdebug",
"environment", "environment",
@ -3315,7 +3117,7 @@
} }
], ],
"description": "Provides the functionality to export PHP variables for visualization", "description": "Provides the functionality to export PHP variables for visualization",
"homepage": "https://github.com/sebastianbergmann/exporter", "homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [ "keywords": [
"export", "export",
"exporter" "exporter"
@ -3367,7 +3169,7 @@
} }
], ],
"description": "Snapshotting of global state", "description": "Snapshotting of global state",
"homepage": "https://github.com/sebastianbergmann/global-state", "homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [ "keywords": [
"global state" "global state"
], ],
@ -3469,7 +3271,7 @@
} }
], ],
"description": "Provides functionality to recursively process PHP variables", "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" "time": "2016-11-19T07:33:16+00:00"
}, },
{ {
@ -3669,8 +3471,7 @@
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"lightopenid/lightopenid": 20, "lightopenid/lightopenid": 20
"pear/text_highlighter": 20
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": 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? Are you good at designing things?
If you have seen Friendica you probably have ideas to improve it, haven't you? 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. * 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. * 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. 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>. 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> <a name="help"></a>
### Wo finde ich Hilfe? ### 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 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: 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** **Externe Ressourcen**
* [Haupt-Webseite](https://friendi.ca) * [Haupt-Webseite](https://friendi.ca)
* [Deutsches Friendica-Wiki](http://wiki.toktan.org/doku.php) * [Deutsches Friendica-Wiki](https://friendica-wiki.de)
* Support Kanäle * Support Kanäle
* [Friendica Support Forum](https://forum.friendi.ca/~helpers) * [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 * [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)) { if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api); $argid = count($called_api);
if (!empty($a->argv[$argid])) { 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)) { if (is_numeric($user)) {
$user = DBA::escape(api_unique_id_to_nurl(intval($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. // 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]"; $_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). // output the post that we just posted.
return api_status_show($type); return api_status_show($type, $item_id);
} }
/// @TODO move this to top of file or somewhere better! /// @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) function api_statuses_update($type)
{ {
$a = get_app(); $a = get_app();
if (api_user() === false) { if (api_user() === false) {
@ -1129,8 +1131,8 @@ function api_statuses_update($type)
if ($throttle_day > 0) { if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_day = DBA::count('item', $condition); $posts_day = DBA::count('thread', $condition);
if ($posts_day > $throttle_day) { if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1143,8 +1145,8 @@ function api_statuses_update($type)
if ($throttle_week > 0) { if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_week = DBA::count('item', $condition); $posts_week = DBA::count('thread', $condition);
if ($posts_week > $throttle_week) { if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@ -1157,8 +1159,8 @@ function api_statuses_update($type)
if ($throttle_month > 0) { if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
$posts_month = DBA::count('item', $condition); $posts_month = DBA::count('thread', $condition);
if ($posts_month > $throttle_month) { if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); 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 // call out normal post function
item_post($a); $item_id = item_post($a);
// this should output the last post (the one we just posted). // output the post that we just posted.
return api_status_show($type); return api_status_show($type, $item_id);
} }
/// @TODO move to top of file or somewhere better /// @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 * @return array|string
*/ */
function api_status_show($type) function api_status_show($type, $item_id = 0)
{ {
$a = get_app(); $a = get_app();
@ -1274,9 +1276,14 @@ function api_status_show($type)
$privacy_sql = ""; $privacy_sql = "";
} }
// get last public wall message if (!empty($item_id)) {
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(), // Get the item with the given id
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]; $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]]); $lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
if (DBA::isResult($lastwall)) { if (DBA::isResult($lastwall)) {
@ -1993,14 +2000,14 @@ function api_statuses_repeat($type)
$_REQUEST["source"] = api_source(); $_REQUEST["source"] = api_source();
} }
item_post($a); $item_id = item_post($a);
} else { } else {
throw new ForbiddenException(); throw new ForbiddenException();
} }
// this should output the last post (the one we just posted). // output the post that we just posted.
$called_api = []; $called_api = [];
return api_status_show($type); return api_status_show($type, $item_id);
} }
/// @TODO move to top of file or somewhere better /// @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 == "") { if ($filetype == "") {
$filetype=Image::guessType($filename); $filetype=Image::guessType($filename);
} }
$imagedata = getimagesize($src); $imagedata = @getimagesize($src);
if ($imagedata) { if ($imagedata) {
$filetype = $imagedata['mime']; $filetype = $imagedata['mime'];
} }

View file

@ -229,12 +229,12 @@ function localize_item(&$item)
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = XML::parseString($xmlhead.$item['object']); $obj = XML::parseString($xmlhead.$item['object']);
$links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title; $Bname = $obj->title;
$Blink = ""; $Blink = $obj->id;
$Bphoto = ""; $Bphoto = "";
foreach ($links->link as $l) {
foreach ($obj->link as $l) {
$atts = $l->attributes(); $atts = $l->attributes();
switch ($atts['rel']) { switch ($atts['rel']) {
case "alternate": $Blink = $atts['href']; case "alternate": $Blink = $atts['href'];
@ -1454,7 +1454,7 @@ function get_responses(array $conv_responses, array $response_verbs, $ob, array
$ret = []; $ret = [];
foreach ($response_verbs as $v) { foreach ($response_verbs as $v) {
$ret[$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]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', []);
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0'); $ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
if (count($ret[$v]['list']) > MAX_LIKERS) { 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"]."'"; $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)); $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 // 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) // 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; 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\Content\Text;
use Friendica\Core\L10n; 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() function babel_content()
@ -20,19 +22,19 @@ function babel_content()
$bbcode = trim($_REQUEST['text']); $bbcode = trim($_REQUEST['text']);
$results[] = [ $results[] = [
'title' => L10n::t('Source input'), 'title' => L10n::t('Source input'),
'content' => visible_lf($bbcode) 'content' => visible_whitespace($bbcode)
]; ];
$plain = Text\BBCode::toPlaintext($bbcode, false); $plain = Text\BBCode::toPlaintext($bbcode, false);
$results[] = [ $results[] = [
'title' => L10n::t('BBCode::toPlaintext'), 'title' => L10n::t('BBCode::toPlaintext'),
'content' => visible_lf($plain) 'content' => visible_whitespace($plain)
]; ];
$html = Text\BBCode::convert($bbcode); $html = Text\BBCode::convert($bbcode);
$results[] = [ $results[] = [
'title' => L10n::t("BBCode::convert \x28raw HTML\x29"), 'title' => L10n::t('BBCode::convert (raw HTML)'),
'content' => htmlspecialchars($html) 'content' => visible_whitespace(htmlspecialchars($html))
]; ];
$results[] = [ $results[] = [
@ -43,13 +45,13 @@ function babel_content()
$bbcode2 = Text\HTML::toBBCode($html); $bbcode2 = Text\HTML::toBBCode($html);
$results[] = [ $results[] = [
'title' => L10n::t('BBCode::convert => HTML::toBBCode'), 'title' => L10n::t('BBCode::convert => HTML::toBBCode'),
'content' => visible_lf($bbcode2) 'content' => visible_whitespace($bbcode2)
]; ];
$markdown = Text\BBCode::toMarkdown($bbcode); $markdown = Text\BBCode::toMarkdown($bbcode);
$results[] = [ $results[] = [
'title' => L10n::t('BBCode::toMarkdown'), 'title' => L10n::t('BBCode::toMarkdown'),
'content' => visible_lf($markdown) 'content' => visible_whitespace($markdown)
]; ];
$html2 = Text\Markdown::convert($markdown); $html2 = Text\Markdown::convert($markdown);
@ -61,22 +63,33 @@ function babel_content()
$bbcode3 = Text\Markdown::toBBCode($markdown); $bbcode3 = Text\Markdown::toBBCode($markdown);
$results[] = [ $results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'), 'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
'content' => visible_lf($bbcode3) 'content' => visible_whitespace($bbcode3)
]; ];
$bbcode4 = Text\HTML::toBBCode($html2); $bbcode4 = Text\HTML::toBBCode($html2);
$results[] = [ $results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'), 'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
'content' => visible_lf($bbcode4) 'content' => visible_whitespace($bbcode4)
]; ];
break; break;
case 'markdown': case 'markdown':
$markdown = trim($_REQUEST['text']); $markdown = trim($_REQUEST['text']);
$results[] = [ $results[] = [
'title' => L10n::t('Source input \x28Diaspora format\x29'), 'title' => L10n::t('Source input (Diaspora format)'),
'content' => '<pre>' . $markdown . '</pre>' '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); $bbcode = Text\Markdown::toBBCode($markdown);
$results[] = [ $results[] = [
'title' => L10n::t('Markdown::toBBCode'), 'title' => L10n::t('Markdown::toBBCode'),
@ -86,7 +99,7 @@ function babel_content()
case 'html' : case 'html' :
$html = trim($_REQUEST['text']); $html = trim($_REQUEST['text']);
$results[] = [ $results[] = [
'title' => L10n::t("Raw HTML input"), 'title' => L10n::t('Raw HTML input'),
'content' => htmlspecialchars($html) 'content' => htmlspecialchars($html)
]; ];
@ -98,7 +111,13 @@ function babel_content()
$bbcode = Text\HTML::toBBCode($html); $bbcode = Text\HTML::toBBCode($html);
$results[] = [ $results[] = [
'title' => L10n::t('HTML::toBBCode'), '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); $text = Text\HTML::toPlaintext($html);
@ -111,7 +130,7 @@ function babel_content()
$tpl = get_markup_template('babel.tpl'); $tpl = get_markup_template('babel.tpl');
$o = replace_macros($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_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'], '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'], '$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"); $page = normalise_link(System::baseUrl() . "/bookmarklet");
if (!strstr($referer, $page)) { if (!strstr($referer, $page)) {
if (empty($_REQUEST["url"])) {
System::httpExit(400, ["title" => L10n::t('Bad Request')]);
}
$content = add_page_info($_REQUEST["url"]); $content = add_page_info($_REQUEST["url"]);
$x = [ $x = [

View file

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

View file

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

View file

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

View file

@ -25,7 +25,7 @@ function fetch_init(App $a)
// Fetch the item // Fetch the item
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network', $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]]; $condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst($fields, $condition); $item = Item::selectFirst($fields, $condition);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {

View file

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

View file

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

View file

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

View file

@ -70,8 +70,11 @@ function notes_content(App $a, $update = false)
$count = 0; $count = 0;
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
$count = count($r); $notes = DBA::toArray($r);
$o .= conversation($a, DBA::toArray($r), 'notes', $update);
$count = count($notes);
$o .= conversation($a, $notes, 'notes', $update);
} }
$o .= alt_pager($a, $count); $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); $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
if ($request_id === "all") { if ($request_id === 'all') {
return; return;
} }
@ -68,8 +68,8 @@ function notifications_content(App $a)
return; return;
} }
$page = (x($_REQUEST,'page') ? $_REQUEST['page'] : 1); $page = defaults($_REQUEST, 'page', 1);
$show = (x($_REQUEST,'show') ? $_REQUEST['show'] : 0); $show = defaults($_REQUEST, 'show', 0);
Nav::setSelected('notifications'); Nav::setSelected('notifications');
@ -87,10 +87,11 @@ function notifications_content(App $a)
$perpage = 20; $perpage = 20;
$startrec = ($page * $perpage) - $perpage; $startrec = ($page * $perpage) - $perpage;
$notif_header = L10n::t('Notifications');
// Get introductions // Get introductions
if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
Nav::setSelected('introductions'); Nav::setSelected('introductions');
$notif_header = L10n::t('Notifications');
$all = (($a->argc > 2) && ($a->argv[2] == 'all')); $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')) { } elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
$notif_header = L10n::t('Home Notifications'); $notif_header = L10n::t('Home Notifications');
$notifs = $nm->homeNotifs($show, $startrec, $perpage); $notifs = $nm->homeNotifs($show, $startrec, $perpage);
} }
// Set the pager // Set the pager
$a->set_pager_itemspage($perpage); $a->set_pager_itemspage($perpage);
@ -133,14 +132,15 @@ function notifications_content(App $a)
$notif_tpl = get_markup_template('notifications.tpl'); $notif_tpl = get_markup_template('notifications.tpl');
if (!isset($notifs['ident'])) { $notif_show_lnk = [
logger('Missing data in notifs: ' . System::callstack(20), LOGGER_DEBUG); '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 // Process the data for template creation
if ($notifs['ident'] === 'introductions') { if (defaults($notifs, 'ident', '') === 'introductions') {
$sugg = get_markup_template('suggestions.tpl'); $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 // The link to switch between ignored and normal connection requests
$notif_show_lnk = [ $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 // Loop through all introduction notifications.This creates an array with the output html for each
// introduction // 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. // 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. // We have to distinguish between these two because they use different data.
switch ($it['label']) { switch ($notif['label']) {
case 'friend_suggestion': case 'friend_suggestion':
$notif_content[] = replace_macros($sugg, [ $notif_content[] = replace_macros($sugg, [
'$type' => $it['label'], '$type' => $notif['label'],
'$str_notifytype' => L10n::t('Notification type:'), '$str_notifytype' => L10n::t('Notification type:'),
'$notify_type' => $it['notify_type'], '$notify_type'=> $notif['notify_type'],
'$intro_id' => $it['intro_id'], '$intro_id' => $notif['intro_id'],
'$lbl_madeby' => L10n::t('Suggested by:'), '$lbl_madeby' => L10n::t('Suggested by:'),
'$madeby' => $it['madeby'], '$madeby' => $notif['madeby'],
'$madeby_url' => $it['madeby_url'], '$madeby_url' => $notif['madeby_url'],
'$madeby_zrl' => $it['madeby_zrl'], '$madeby_zrl' => $notif['madeby_zrl'],
'$madeby_addr' => $it['madeby_addr'], '$madeby_addr'=> $notif['madeby_addr'],
'$contact_id' => $it['contact_id'], '$contact_id' => $notif['contact_id'],
'$photo' => $it['photo'], '$photo' => $notif['photo'],
'$fullname' => $it['name'], '$fullname' => $notif['name'],
'$url' => $it['url'], '$url' => $notif['url'],
'$zrl' => $it['zrl'], '$zrl' => $notif['zrl'],
'$lbl_url' => L10n::t('Profile URL'), '$lbl_url' => L10n::t('Profile URL'),
'$addr' => $it['addr'], '$addr' => $notif['addr'],
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$knowyou' => $notif['knowyou'],
'$knowyou' => $it['knowyou'], '$approve' => L10n::t('Approve'),
'$approve' => L10n::t('Approve'), '$note' => $notif['note'],
'$note' => $it['note'], '$request' => $notif['request'],
'$request' => $it['request'], '$ignore' => L10n::t('Ignore'),
'$ignore' => L10n::t('Ignore'), '$discard' => L10n::t('Discard'),
'$discard' => L10n::t('Discard'),
]); ]);
break; break;
// Normal connection requests // Normal connection requests
default: default:
$friend_selected = (($it['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled '); $friend_selected = (($notif['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($it['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : ''); $fan_selected = (($notif['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$dfrn_tpl = get_markup_template('netfriend.tpl');
$knowyou = '';
$lbl_knowyou = ''; $lbl_knowyou = '';
$dfrn_text = ''; $knowyou = '';
$helptext = ''; $helptext = '';
$helptext2 = ''; $helptext2 = '';
$helptext3 = ''; $helptext3 = '';
if ($it['network'] === Protocol::DFRN || $it['network'] === Protocol::DIASPORA) { if ($notif['network'] === Protocol::DFRN) {
if ($it['network'] === Protocol::DFRN) { $lbl_knowyou = L10n::t('Claims to be known to you: ');
$lbl_knowyou = L10n::t('Claims to be known to you: '); $knowyou = (($notif['knowyou']) ? L10n::t('yes') : L10n::t('no'));
$knowyou = (($it['knowyou']) ? L10n::t('yes') : L10n::t('no')); $helptext = L10n::t('Shall your connection be bidirectional or not?');
$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']);
$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.', $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.', $it['name']); } elseif ($notif['network'] === Protocol::DIASPORA) {
} else { $helptext = L10n::t('Shall your connection be bidirectional or not?');
$knowyou = ''; $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']);
$helptext = L10n::t('Shall your connection be bidirectional or not?'); $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']);
$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']);
}
} }
$dfrn_text = replace_macros($dfrn_tpl,[ $dfrn_tpl = get_markup_template('netfriend.tpl');
'$intro_id' => $it['intro_id'], $dfrn_text = replace_macros($dfrn_tpl, [
'$intro_id' => $notif['intro_id'],
'$friend_selected' => $friend_selected, '$friend_selected' => $friend_selected,
'$fan_selected' => $fan_selected, '$fan_selected'=> $fan_selected,
'$approve_as1' => $helptext, '$approve_as1' => $helptext,
'$approve_as2' => $helptext2, '$approve_as2' => $helptext2,
'$approve_as3' => $helptext3, '$approve_as3' => $helptext3,
'$as_friend' => L10n::t('Friend'), '$as_friend' => L10n::t('Friend'),
'$as_fan' => (($it['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber')) '$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
]); ]);
$header = $it["name"]; $header = $notif['name'];
if ($it["addr"] != "") { if ($notif['addr'] != '') {
$header .= " <".$it["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'); $discard = L10n::t('Discard');
} else { } else {
$discard = ''; $discard = '';
} }
$notif_content[] = replace_macros($tpl, [ $notif_content[] = replace_macros($tpl, [
'$type' => $it['label'], '$type' => $notif['label'],
'$header' => htmlentities($header), '$header' => htmlentities($header),
'$str_notifytype' => L10n::t('Notification type:'), '$str_notifytype' => L10n::t('Notification type:'),
'$notify_type' => $it['notify_type'], '$notify_type' => $notif['notify_type'],
'$dfrn_text' => $dfrn_text, '$dfrn_text' => $dfrn_text,
'$dfrn_id' => $it['dfrn_id'], '$dfrn_id' => $notif['dfrn_id'],
'$uid' => $it['uid'], '$uid' => $notif['uid'],
'$intro_id' => $it['intro_id'], '$intro_id' => $notif['intro_id'],
'$contact_id' => $it['contact_id'], '$contact_id' => $notif['contact_id'],
'$photo' => $it['photo'], '$photo' => $notif['photo'],
'$fullname' => $it['name'], '$fullname' => $notif['name'],
'$location' => $it['location'], '$location' => $notif['location'],
'$lbl_location' => L10n::t('Location:'), '$lbl_location'=> L10n::t('Location:'),
'$about' => $it['about'], '$about' => $notif['about'],
'$lbl_about' => L10n::t('About:'), '$lbl_about' => L10n::t('About:'),
'$keywords' => $it['keywords'], '$keywords' => $notif['keywords'],
'$lbl_keywords' => L10n::t('Tags:'), '$lbl_keywords'=> L10n::t('Tags:'),
'$gender' => $it['gender'], '$gender' => $notif['gender'],
'$lbl_gender' => L10n::t('Gender:'), '$lbl_gender' => L10n::t('Gender:'),
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$url' => $it['url'], '$url' => $notif['url'],
'$zrl' => $it['zrl'], '$zrl' => $notif['zrl'],
'$lbl_url' => L10n::t('Profile URL'), '$lbl_url' => L10n::t('Profile URL'),
'$addr' => $it['addr'], '$addr' => $notif['addr'],
'$lbl_knowyou' => $lbl_knowyou, '$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => L10n::t('Network:'), '$lbl_network' => L10n::t('Network:'),
'$network' => ContactSelector::networkToName($it['network'], $it['url']), '$network' => ContactSelector::networkToName($notif['network'], $notif['url']),
'$knowyou' => $knowyou, '$knowyou' => $knowyou,
'$approve' => L10n::t('Approve'), '$approve' => L10n::t('Approve'),
'$note' => $it['note'], '$note' => $notif['note'],
'$ignore' => L10n::t('Ignore'), '$ignore' => L10n::t('Ignore'),
'$discard' => $discard, '$discard' => $discard,
]); ]);
break; break;
} }
@ -280,57 +274,47 @@ function notifications_content(App $a)
info(L10n::t('No introductions.') . EOL); info(L10n::t('No introductions.') . EOL);
} }
// Normal notifications (no introductions) // Normal notifications (no introductions)
} else { } elseif (!empty($notifs['notifications'])) {
// 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';
// Loop trough ever notification This creates an array with the output html for each // 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). // 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_notif = get_markup_template($notification_templates[$notif['label']]);
$tpl_var_name = 'tpl_item_'.$it['label'];
$tpl_notif = get_markup_template($$tpl_var_name);
$notif_content[] = replace_macros($tpl_notif,[ $notif_content[] = replace_macros($tpl_notif, [
'$item_label' => $it['label'], '$item_label' => $notif['label'],
'$item_link' => $it['link'], '$item_link' => $notif['link'],
'$item_image' => $it['image'], '$item_image' => $notif['image'],
'$item_url' => $it['url'], '$item_url' => $notif['url'],
'$item_text' => $it['text'], '$item_text' => $notif['text'],
'$item_when' => $it['when'], '$item_when' => $notif['when'],
'$item_ago' => $it['ago'], '$item_ago' => $notif['ago'],
'$item_seen' => $it['seen'], '$item_seen' => $notif['seen'],
]); ]);
} }
} else {
$notif_show_lnk = [ $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']);
'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']);
}
} }
$o .= replace_macros($notif_tpl, [ $o .= replace_macros($notif_tpl, [
'$notif_header' => $notif_header, '$notif_header' => $notif_header,
'$tabs' => $tabs, '$tabs' => $tabs,
'$notif_content' => $notif_content, '$notif_content' => $notif_content,
'$notif_nocontent' => $notif_nocontent, '$notif_nocontent' => $notif_nocontent,
'$notif_show_lnk' => $notif_show_lnk, '$notif_show_lnk' => $notif_show_lnk,
'$notif_paginate' => alt_pager($a, count($notif_content)) '$notif_paginate' => alt_pager($a, count($notif_content))
]); ]);
return $o; return $o;

View file

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

View file

@ -212,7 +212,7 @@ function photos_post(App $a)
} }
// Check if the user has responded to a delete confirmation query // Check if the user has responded to a delete confirmation query
if ($_REQUEST['canceled']) { if (!empty($_REQUEST['canceled'])) {
goaway($_SESSION['photo_return']); goaway($_SESSION['photo_return']);
} }
@ -762,12 +762,14 @@ function photos_post(App $a)
$filesize = $ret['filesize']; $filesize = $ret['filesize'];
$type = $ret['type']; $type = $ret['type'];
$error = UPLOAD_ERR_OK; $error = UPLOAD_ERR_OK;
} else { } elseif (!empty($_FILES['userfile'])) {
$src = $_FILES['userfile']['tmp_name']; $src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']); $filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']); $filesize = intval($_FILES['userfile']['size']);
$type = $_FILES['userfile']['type']; $type = $_FILES['userfile']['type'];
$error = $_FILES['userfile']['error']; $error = $_FILES['userfile']['error'];
} else {
$error = UPLOAD_ERR_NO_FILE;
} }
if ($error !== UPLOAD_ERR_OK) { if ($error !== UPLOAD_ERR_OK) {
@ -1633,7 +1635,7 @@ function photos_content(App $a)
'$paginate' => $paginate, '$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:title" content="' . $photo["album"] . '" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="' . $photo["href"] . '" />' . "\n"; $a->page['htmlhead'] .= '<meta name="twitter:image" content="' . $photo["href"] . '" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:image:width" content="' . $photo["width"] . '" />' . "\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 * @brief Backward-compatible XML formatting for ping.php output
* @deprecated * @deprecated
* *
* @param array $data The initial ping data array * @param array $data The initial ping data array
* @param int $sysnotify Number of unseen system notifications * @param int $sysnotify_count Number of unseen system notifications
* @param array $notifs Complete list of notification * @param array $notifs Complete list of notification
* @param array $sysmsgs List of system notice messages * @param array $sysmsgs List of system notice messages
* @param array $sysmsgs_info List of system info messages * @param array $sysmsgs_info List of system info messages
* @param int $groups_unseen Number of unseen group items * @param int $groups_unseen Number of unseen group items
* @param int $forums_unseen Number of unseen forum items * @param int $forums_unseen Number of unseen forum items
*
* @return array XML-transform ready data array * @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 = []; $notifications = [];
foreach ($notifs as $key => $notif) { foreach ($notifs as $key => $notif) {

View file

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

View file

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

View file

@ -10,53 +10,67 @@ use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User;
function unfollow_post(App $a) function unfollow_post()
{ {
$return_url = $_SESSION['return_url'];
if (!local_user()) { if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL); notice(L10n::t('Permission denied.'));
goaway($_SESSION['return_url']); goaway($return_url);
// NOTREACHED // NOTREACHED
} }
if ($_REQUEST['cancel']) { if (!empty($_REQUEST['cancel'])) {
goaway($_SESSION['return_url']); goaway($return_url);
} }
$uid = local_user(); $uid = local_user();
$url = notags(trim($_REQUEST['url'])); $url = notags(trim(defaults($_REQUEST, 'url', '')));
$return_url = $_SESSION['return_url'];
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::FRIEND, normalise_link($url), $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, Protocol::STATUSNET]; normalise_link($url), $url];
$contact = DBA::selectFirst('contact', [], $condition); $contact = DBA::selectFirst('contact', [], $condition);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
notice(L10n::t("Contact wasn't found or can't be unfollowed.")); notice(L10n::t("You aren't following this contact."));
} else { goaway($return_url);
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) { // NOTREACHED
$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']);
} }
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 // NOTREACHED
} }
function unfollow_content(App $a) function unfollow_content(App $a)
{ {
if (! local_user()) { if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL); notice(L10n::t('Permission denied.'));
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
// NOTREACHED // NOTREACHED
} }
@ -64,78 +78,74 @@ function unfollow_content(App $a)
$uid = local_user(); $uid = local_user();
$url = notags(trim($_REQUEST['url'])); $url = notags(trim($_REQUEST['url']));
$submit = L10n::t('Submit Request'); $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url),
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", normalise_link($url), $url];
local_user(), Contact::FRIEND, normalise_link($url),
normalise_link($url), $url, Protocol::STATUSNET];
$contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition); $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't a friend of this contact.").EOL); notice(L10n::t("You aren't following this contact."));
$submit = ""; goaway('contacts');
// NOTREACHED // NOTREACHED
} }
if (!in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) { if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t("Unfollowing is currently not supported by your network.").EOL); notice(L10n::t('Unfollowing is currently not supported by your network.'));
$submit = ""; goaway('contacts/' . $contact['id']);
// NOTREACHED // NOTREACHED
} }
$request = System::baseUrl()."/unfollow"; $request = System::baseUrl() . '/unfollow';
$tpl = get_markup_template('auto_request.tpl'); $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) { if (!DBA::isResult($self)) {
notice(L10n::t('Permission denied.') . EOL); notice(L10n::t('Permission denied.'));
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
// NOTREACHED // NOTREACHED
} }
$myaddr = $r[0]["url"];
// Makes the connection request for friendica contacts easier // 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, [ $o = replace_macros($tpl, [
'$header' => htmlentities($header), '$header' => htmlentities($header),
'$desc' => "", '$desc' => '',
'$pls_answer' => "", '$pls_answer' => '',
'$does_know_you' => "", '$does_know_you' => '',
'$add_note' => "", '$add_note' => '',
'$page_desc' => "", '$page_desc' => '',
'$friendica' => "", '$friendica' => '',
'$statusnet' => "", '$statusnet' => '',
'$diaspora' => "", '$diaspora' => '',
'$diasnote' => "", '$diasnote' => '',
'$your_address' => L10n::t('Your Identity Address:'), '$your_address' => L10n::t('Your Identity Address:'),
'$invite_desc' => "", '$invite_desc' => '',
'$emailnet' => "", '$emailnet' => '',
'$submit' => $submit, '$submit' => L10n::t('Submit Request'),
'$cancel' => L10n::t('Cancel'), '$cancel' => L10n::t('Cancel'),
'$nickname' => "", '$nickname' => '',
'$name' => $contact["name"], '$name' => $contact['name'],
'$url' => $contact["url"], '$url' => $contact['url'],
'$zrl' => Contact::magicLink($contact["url"]), '$zrl' => Contact::magicLink($contact['url']),
'$url_label' => L10n::t("Profile URL"), '$url_label' => L10n::t('Profile URL'),
'$myaddr' => $myaddr, '$myaddr' => $self['url'],
'$request' => $request, '$request' => $request,
'$keywords' => "", '$keywords' => '',
'$keywords_label' => "" '$keywords_label'=> ''
]); ]);
$a->page['aside'] = ""; $a->page['aside'] = '';
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"])); Profile::load($a, '', 0, Contact::getDetailsByURL($contact['url']));
$o .= replace_macros(get_markup_template('section_title.tpl'), ['$title' => L10n::t('Status Messages and Posts')]); $o .= replace_macros(get_markup_template('section_title.tpl'), ['$title' => L10n::t('Status Messages and Posts')]);
// Show last public posts // Show last public posts
$o .= Contact::getPostsFromUrl($contact["url"]); $o .= Contact::getPostsFromUrl($contact['url']);
return $o; 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) { foreach ($r as $rr) {
$alt_e = $rr['filename']; $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. /// @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']; $name_e = $rr['album'];
$videos[] = [ $videos[] = [
'id' => $rr['id'], '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'), 'title' => L10n::t('View Video'),
'src' => System::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0', 'src' => System::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0',
'alt' => $alt_e, 'alt' => $alt_e,

View file

@ -23,7 +23,7 @@ function webfinger_content(App $a)
$o = '<h3>Webfinger Diagnostic</h3>'; $o = '<h3>Webfinger Diagnostic</h3>';
$o .= '<form action="webfinger" method="get">'; $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 .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />'; $o .= '<br /><br />';

View file

@ -372,13 +372,13 @@ class App
} }
if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) { 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. * 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: * The config format is INI and the template for configuration files is the following:
* *
@ -391,9 +391,10 @@ class App
* // Keep this line * // Keep this line
* *
* @param type $filepath * @param type $filepath
* @param bool $overwrite Force value overwrite if the config key already exists
* @throws Exception * @throws Exception
*/ */
public function loadConfigFile($filepath) public function loadConfigFile($filepath, $overwrite = false)
{ {
if (!file_exists($filepath)) { if (!file_exists($filepath)) {
throw new Exception('Error parsing non-existent config file ' . $filepath); throw new Exception('Error parsing non-existent config file ' . $filepath);
@ -409,7 +410,11 @@ class App
foreach ($config as $category => $values) { foreach ($config as $category => $values) {
foreach ($values as $key => $value) { 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 // 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')) { 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 = []; $meminfo = [];
foreach ($memdata as $line) { 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) trim(str_replace('kB', '', $val));
$meminfo[$key] = (int) ($meminfo[$key] / 1024); $meminfo[$key] = (int) ($meminfo[$key] / 1024);
} }
@ -1240,6 +1249,20 @@ class App
return $return; 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 * 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 * The filename of the module in src/Module needs to match the class name
* exactly to make the module available. * exactly to make the module available.
* *
* @author Hypolite Petovan mrpetovan@gmail.com * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
abstract class BaseModule extends BaseObject abstract class BaseModule extends BaseObject
{ {

View file

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

View file

@ -25,7 +25,6 @@ use Friendica\Util\Map;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
use League\HTMLToMarkdown\HtmlConverter;
class BBCode extends BaseObject class BBCode extends BaseObject
{ {
@ -348,7 +347,7 @@ class BBCode extends BaseObject
*/ */
public static function toPlaintext($text, $keep_urls = true) public static function toPlaintext($text, $keep_urls = true)
{ {
$naked_text = preg_replace('/\[(.+?)\]/','', $text); $naked_text = preg_replace('/\[(.+?)\]\s*/','', $text);
if (!$keep_urls) { if (!$keep_urls) {
$naked_text = preg_replace('#https?\://[^\s<]+[^\s\.\)]#i', '', $naked_text); $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"]); $return = sprintf('<div class="type-%s">', $data["type"]);
} }
if (!empty($data["image"])) { if (!empty($data['title']) && !empty($data['url'])) {
$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"]); if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) {
} elseif (!empty($data["preview"])) { $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"]);
$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"]); } 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"]);
if (($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) { } elseif (!empty($data["preview"])) {
$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"]); $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"]);
} else { }
$return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']); $return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
}
} }
if (!empty($data["description"]) && $data["description"] != $data["title"]) { if (!empty($data["description"]) && $data["description"] != $data["title"]) {
@ -589,7 +589,8 @@ class BBCode extends BaseObject
$bbcode = HTML::toBBCode($data["description"]); $bbcode = HTML::toBBCode($data["description"]);
$return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode))); $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)); $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; 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 * @brief Converts a BBCode message to HTML message
* *
@ -1225,6 +1211,22 @@ class BBCode extends BaseObject
return $return; 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 // Hide all [noparse] contained bbtags by spacefying them
// POSSIBLE BUG --> Will the 'preg' functions crash if there's an embedded image? // 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); $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 // Convert new line chars to html <br /> tags
// nlbr seems to be hopelessly messed up // nlbr seems to be hopelessly messed up
@ -1769,6 +1766,18 @@ class BBCode extends BaseObject
$text = self::interpolateSavedImagesIntoItemBody($text, $saved_image); $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. // Clean up the HTML by loading and saving the HTML with the DOM.
// Bad structured html can break a whole page. // Bad structured html can break a whole page.
// For performance reasons do it only with ativated item cache or at export. // 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. // 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); $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 // Convert it to HTML - don't try oembed
if ($for_diaspora) { if ($for_diaspora) {
$text = self::convert($text, false, 3); $text = self::convert($text, false, 3);
@ -1949,8 +1941,7 @@ class BBCode extends BaseObject
$stamp1 = microtime(true); $stamp1 = microtime(true);
// Now convert HTML to Markdown // Now convert HTML to Markdown
$converter = new HtmlConverter(); $text = HTML::toMarkdown($text);
$text = $converter->convert($text);
// unmask the special chars back to HTML // unmask the special chars back to HTML
$text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['&lt;', '&gt;', '&amp;'], $text); $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); Addon::callHooks('bb2diaspora', $text);
return $text; return $text;

View file

@ -11,6 +11,7 @@ use DOMXPath;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use League\HTMLToMarkdown\HtmlConverter;
class HTML class HTML
{ {
@ -122,7 +123,7 @@ class HTML
// Removing code blocks before the whitespace removal processing below // Removing code blocks before the whitespace removal processing below
$codeblocks = []; $codeblocks = [];
$message = preg_replace_callback( $message = preg_replace_callback(
'#<pre><code(?: class="([^"]*)")?>(.*)</code></pre>#iUs', '#<pre><code(?: class="language-([^"]*)")?>(.*)</code></pre>#iUs',
function ($matches) use (&$codeblocks) { function ($matches) use (&$codeblocks) {
$return = '[codeblock-' . count($codeblocks) . ']'; $return = '[codeblock-' . count($codeblocks) . ']';
@ -131,7 +132,7 @@ class HTML
$prefix = '[code=' . $matches[1] . ']'; $prefix = '[code=' . $matches[1] . ']';
} }
$codeblocks[] = $prefix . trim($matches[2]) . '[/code]'; $codeblocks[] = $prefix . PHP_EOL . trim($matches[2]) . PHP_EOL . '[/code]';
return $return; return $return;
}, },
$message $message
@ -672,4 +673,19 @@ class HTML
return trim($message); 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 * Friendica-specific usage of Markdown
* *
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class Markdown extends BaseObject class Markdown extends BaseObject
{ {
@ -32,6 +32,7 @@ class Markdown extends BaseObject
$MarkdownParser = new MarkdownExtra(); $MarkdownParser = new MarkdownExtra();
$MarkdownParser->hard_wrap = $hardwrap; $MarkdownParser->hard_wrap = $hardwrap;
$MarkdownParser->code_class_prefix = 'language-';
$html = $MarkdownParser->transform($text); $html = $MarkdownParser->transform($text);
self::getApp()->save_timestamp($stamp1, "parser"); self::getApp()->save_timestamp($stamp1, "parser");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,7 +10,7 @@ use Redis;
/** /**
* Redis Cache Driver. This driver is based on Memcache driver * 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> * @author Roland Haeder <roland@mxchange.org>
*/ */
class RedisCacheDriver extends AbstractCacheDriver implements IMemoryCacheDriver 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 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. * 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 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. * 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 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. * 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 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. * 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 class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
{ {

View file

@ -5,7 +5,7 @@ namespace Friendica\Core;
/** /**
* Description of Console * Description of Console
* *
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class Console extends \Asika\SimpleConsole\Console 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 * set to the value of the last parameter. (e.g. "system loglevel 0" will
* disable logging) * disable logging)
* *
* @author Tobias Diekershoff * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class Config extends \Asika\SimpleConsole\Console class Config extends \Asika\SimpleConsole\Console
{ {

View file

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

View file

@ -11,9 +11,9 @@ require_once 'boot.php';
require_once 'include/dba.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 class DatabaseStructure extends \Asika\SimpleConsole\Console
{ {
@ -22,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
protected function getHelp() protected function getHelp()
{ {
$help = <<<HELP $help = <<<HELP
console dbstructure - Does database updates console dbstructure - Performs database updates
Usage Usage
bin/console dbstructure <command> [-h|--help|-?] [-v] 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. * This is done for all files, so, in the end removing one file leads to a working doc build.
* *
* @author Alexander Kampmann * @author Alexander Kampmann
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class DocBloxErrorChecker extends \Asika\SimpleConsole\Console 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 * 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 class Extract extends \Asika\SimpleConsole\Console
{ {

View file

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

View file

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

View file

@ -10,7 +10,7 @@ require_once 'include/dba.php';
/** /**
* @brief Sets maintenance mode for this node * @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 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 * 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 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 * 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 class PoToPhp extends \Asika\SimpleConsole\Console
{ {

View file

@ -3,26 +3,51 @@
namespace Friendica\Core\Console; namespace Friendica\Core\Console;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Config;
/** /**
* @brief tool to block an account from the node * Performs database post updates
*
* 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.
* *
* License: AGPLv3 or later, same as Friendica * License: AGPLv3 or later, same as Friendica
* *
* @author Tobias Diekershoff <mrpetovan@gmail.com> * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class PostUpdate extends \Asika\SimpleConsole\Console 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() protected function doExecute()
{ {
$a = get_app(); $a = get_app();
if (count($this->args) > 0) { if ($this->getOption($this->helpOptions)) {
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); $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()) { if ($a->isInstallMode()) {

View file

@ -6,7 +6,7 @@ namespace Friendica\Core\Console;
* Tired of chasing typos and finding them after a commit. * 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. * 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 class Typo extends \Asika\SimpleConsole\Console
{ {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,9 +27,6 @@ class PostUpdate
if (!self::update1194()) { if (!self::update1194()) {
return false; return false;
} }
if (!self::update1198()) {
return false;
}
if (!self::update1206()) { if (!self::update1206()) {
return false; return false;
} }
@ -111,88 +108,6 @@ class PostUpdate
logger("Done", LOGGER_DEBUG); 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 * @brief update the "last-item" field in the "self" contact
* *
@ -253,6 +168,12 @@ class PostUpdate
$condition = ["`id` > ?", $id]; $condition = ["`id` > ?", $id];
$params = ['order' => ['id'], 'limit' => 10000]; $params = ['order' => ['id'], 'limit' => 10000];
$items = Item::select($fields, $condition, $params); $items = Item::select($fields, $condition, $params);
if (DBA::errorNo() != 0) {
logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage());
return false;
}
while ($item = Item::fetch($items)) { while ($item = Item::fetch($items)) {
$id = $item['id']; $id = $item['id'];
@ -394,6 +315,12 @@ class PostUpdate
$condition = ["`id` > ?", $id]; $condition = ["`id` > ?", $id];
$params = ['order' => ['id'], 'limit' => 10000]; $params = ['order' => ['id'], 'limit' => 10000];
$items = DBA::select('item', $fields, $condition, $params); $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)) { while ($item = DBA::fetch($items)) {
$id = $item['id']; $id = $item['id'];

View file

@ -17,6 +17,7 @@ use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon; use Friendica\Protocol\Salmon;
@ -528,13 +529,16 @@ class Contact extends BaseObject
/** /**
* @brief Sends an unfriend message. Does not remove the contact * @brief Sends an unfriend message. Does not remove the contact
* *
* @param array $user User unfriending * @param array $user User unfriending
* @param array $contact Contact unfriended * @param array $contact Contact unfriended
* @param boolean $dissolve Remove the contact on the remote side
* @return void * @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 // create an unfollow slap
$item = []; $item = [];
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow"; $item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
@ -1076,6 +1080,11 @@ class Contact extends BaseObject
if (empty($data)) { if (empty($data)) {
$data = Probe::uri($url, "", $uid); $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 // Last try in gcontact for unsupported networks

View file

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

View file

@ -1462,15 +1462,6 @@ class Item extends BaseObject
return 0; 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) { if ($item['network'] == Protocol::PHANTOM) {
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
@ -1708,6 +1699,15 @@ class Item extends BaseObject
unset($item['postopts']); unset($item['postopts']);
unset($item['inform']); 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(); DBA::transaction();
$ret = DBA::insert('item', $item); $ret = DBA::insert('item', $item);

View file

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

View file

@ -730,7 +730,7 @@ class User
DBA::insert('userd', ['username' => $user['nickname']]); DBA::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php) // 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); Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory // Send an update to the directory

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -81,7 +81,8 @@ class DFRN
return []; return [];
} }
$user['importer_uid'] = $user['uid']; $user['importer_uid'] = $user['uid'];
$user['uprvkey'] = $user['prvkey'];
} else { } else {
$user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC', $user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC',
'nickname' => '', 'sprvkey' => '', 'spubkey' => '', 'nickname' => '', 'sprvkey' => '', 'spubkey' => '',
@ -1163,15 +1164,17 @@ class DFRN
* @return int Deliver status. Negative values mean an error. * @return int Deliver status. Negative values mean an error.
* @todo Add array type-hint for $owner, $contact * @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(); $a = get_app();
// At first try the Diaspora transport layer // At first try the Diaspora transport layer
$ret = self::transmit($owner, $contact, $atom); if (!$dissolve && !$legacy_transport) {
if ($ret >= 200) { $ret = self::transmit($owner, $contact, $atom);
logger('Delivery via Diaspora transport layer was successful with status ' . $ret); if ($ret >= 200) {
return $ret; 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']); $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"])) { if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]); $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 // send a notification
notification( notification(
[ [
@ -2402,8 +2410,11 @@ class DFRN
break; break;
case "enclosure": case "enclosure":
$enclosure = $href; $enclosure = $href;
if (strlen($item["attach"])) {
if (!empty($item["attach"])) {
$item["attach"] .= ","; $item["attach"] .= ",";
} else {
$item["attach"] = "";
} }
$item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/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 * @brief: Decodes incoming Diaspora message in the new format
* *
* @param array $importer Array of the importer user * @param array $importer Array of the importer user
* @param string $raw raw post message * @param string $raw raw post message
* @param boolean $no_exit Don't do an http exit on error
* *
* @return array * @return array
* 'message' -> decoded Diaspora XML message * 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle * 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8) * '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); $data = json_decode($raw);
@ -388,7 +389,11 @@ class Diaspora
if (!is_object($j_outer_key_bundle)) { if (!is_object($j_outer_key_bundle)) {
logger('Outer Salmon did not verify. Discarding.'); 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); $outer_iv = base64_decode($j_outer_key_bundle->iv);
@ -403,7 +408,11 @@ class Diaspora
if (!is_object($basedom)) { if (!is_object($basedom)) {
logger('Received data does not seem to be an XML. Discarding. '.$xml); 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); $base = $basedom->children(NAMESPACE_SALMON_ME);
@ -425,19 +434,31 @@ class Diaspora
$author_addr = base64_decode($key_id); $author_addr = base64_decode($key_id);
if ($author_addr == '') { if ($author_addr == '') {
logger('No author could be decoded. Discarding. Message: ' . $xml); 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); $key = self::key($author_addr);
if ($key == '') { if ($key == '') {
logger("Couldn't get a key for handle " . $author_addr . ". Discarding."); 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); $verify = Crypto::rsaVerify($signed_data, $signature, $key);
if (!$verify) { if (!$verify) {
logger('Message did not verify. Discarding.'); 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), return ['message' => (string)base64url_decode($base->data),
@ -3475,7 +3496,7 @@ class Diaspora
$myaddr = self::myHandle($owner); $myaddr = self::myHandle($owner);
$public = (($item["private"]) ? "false" : "true"); $public = ($item["private"] ? "false" : "true");
$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);

View file

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

View file

@ -74,6 +74,16 @@ class OStatus
$author["contact-id"] = $contact["id"]; $author["contact-id"] = $contact["id"];
$contact = null; $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 != '') { if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)", $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, Protocol::STATUSNET, $importer["uid"], $aliaslink, Protocol::STATUSNET,
@ -219,7 +229,7 @@ class OStatus
$gcid = GContact::update($contact); $gcid = GContact::update($contact);
GContact::link($gcid, $contact["uid"], $contact["id"]); GContact::link($gcid, $contact["uid"], $contact["id"]);
} else { } elseif ($contact["network"] != Protocol::DFRN) {
$contact = null; $contact = null;
} }
@ -312,7 +322,7 @@ class OStatus
self::$conv_list = []; self::$conv_list = [];
} }
logger("Import OStatus message", LOGGER_DEBUG); logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG);
if ($xml == "") { if ($xml == "") {
return false; return false;
@ -351,7 +361,7 @@ class OStatus
$header["origin"] = 0; $header["origin"] = 0;
$header["gravity"] = GRAVITY_COMMENT; $header["gravity"] = GRAVITY_COMMENT;
if (!is_object($doc->firstChild)) { if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) {
return false; return false;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -96,7 +96,7 @@ class Notifier
return; return;
} }
foreach ($r as $contact) { foreach ($r as $contact) {
Contact::terminateFriendship($user, $contact); Contact::terminateFriendship($user, $contact, true);
} }
return; return;
} elseif ($cmd == Delivery::RELOCATION) { } elseif ($cmd == Delivery::RELOCATION) {
@ -217,24 +217,16 @@ class Notifier
} }
// Special treatment for forum posts // Special treatment for forum posts
if (($target_item['author-id'] != $target_item['owner-id']) && if (self::isForumPost($target_item, $owner)) {
($owner['id'] != $target_item['contact-id']) && $relay_to_owner = true;
($target_item['uri'] === $target_item['parent-uri'])) { $direct_forum_delivery = true;
$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;
}
} }
// Avoid that comments in a forum thread are sent to OStatus
if (self::isForumPost($parent, $owner)) {
$direct_forum_delivery = true;
}
if ($relay_to_owner) { if ($relay_to_owner) {
// local followup to remote post // local followup to remote post
$followup = true; $followup = true;
@ -504,4 +496,23 @@ class Notifier
return; 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 { class RemoveContact {
public static function execute($id) { public static function execute($id) {
// Only delete if the contact is archived // Only delete if the contact is to be deleted
$condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id]; $condition = ['network' => Protocol::PHANTOM, 'id' => $id];
$r = DBA::exists('contact', $condition); $r = DBA::exists('contact', $condition);
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
return; return;

View file

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

View file

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

View file

@ -81,6 +81,11 @@ $(function() {
Dialog.doImageBrowser("comment", id); Dialog.doImageBrowser("comment", id);
return; return;
} }
if (bbcode == "imgprv") {
bbcode = "img";
}
insertFormatting(bbcode, id); 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 // Asynchronous calls are deferred until the very end of the page load to ease on slower connections
window.addEventListener("load", function(){ window.addEventListener("load", function(){
NavUpdate(); 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 // 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