diff --git a/VERSION b/VERSION
index 607ef5eb6..40284ee69 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2018.08-dev
+2018.08-rc
diff --git a/boot.php b/boot.php
index b1e98270c..2236a4d5d 100644
--- a/boot.php
+++ b/boot.php
@@ -39,7 +39,7 @@ require_once 'include/text.php';
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
-define('FRIENDICA_VERSION', '2018.08-dev');
+define('FRIENDICA_VERSION', '2018.08-rc');
define('DFRN_PROTOCOL_VERSION', '2.23');
define('DB_UPDATE_VERSION', 1283);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
diff --git a/composer.json b/composer.json
index 04e4b655d..c71777550 100644
--- a/composer.json
+++ b/composer.json
@@ -18,13 +18,12 @@
"asika/simple-console": "^1.0",
"divineomega/password_exposed": "^2.4",
"ezyang/htmlpurifier": "~4.7.0",
- "league/html-to-markdown": "~4.4.1",
+ "league/html-to-markdown": "~4.8.0",
"lightopenid/lightopenid": "dev-master",
"michelf/php-markdown": "^1.7",
"mobiledetect/mobiledetectlib": "2.8.*",
"paragonie/random_compat": "^2.0",
"pear/Text_LanguageDetect": "1.*",
- "pear/Text_Highlighter": "dev-master",
"seld/cli-prompt": "^1.0",
"smarty/smarty": "^3.1",
"fxp/composer-asset-plugin": "~1.3",
diff --git a/composer.lock b/composer.lock
index 76c20a1b9..b0ff745c6 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "d62c3e3d6971ee63a862a22ff3cd3768",
+ "content-hash": "5f6a43237dc52758484cd21cd76e8ce6",
"packages": [
{
"name": "asika/simple-console",
@@ -483,16 +483,16 @@
},
{
"name": "league/html-to-markdown",
- "version": "4.4.1",
+ "version": "4.8.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
- "reference": "82ea375b5b2b1da1da222644c0565c695bf88186"
+ "reference": "f9a879a068c68ff47b722de63f58bec79e448f9d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/82ea375b5b2b1da1da222644c0565c695bf88186",
- "reference": "82ea375b5b2b1da1da222644c0565c695bf88186",
+ "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/f9a879a068c68ff47b722de63f58bec79e448f9d",
+ "reference": "f9a879a068c68ff47b722de63f58bec79e448f9d",
"shasum": ""
},
"require": {
@@ -511,7 +511,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "4.5-dev"
+ "dev-master": "4.9-dev"
}
},
"autoload": {
@@ -524,17 +524,17 @@
"MIT"
],
"authors": [
- {
- "name": "Colin O'Dell",
- "email": "colinodell@gmail.com",
- "homepage": "http://www.colinodell.com",
- "role": "Lead Developer"
- },
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
+ },
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com",
+ "role": "Lead Developer"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
@@ -543,7 +543,7 @@
"html",
"markdown"
],
- "time": "2017-03-16T00:45:59+00:00"
+ "time": "2018-09-18T12:18:08+00:00"
},
{
"name": "lightopenid/lightopenid",
@@ -1669,204 +1669,6 @@
],
"time": "2018-02-15T05:50:20+00:00"
},
- {
- "name": "pear/console_getopt",
- "version": "v1.4.1",
- "source": {
- "type": "git",
- "url": "https://github.com/pear/Console_Getopt.git",
- "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
- "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Console": "./"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- "./"
- ],
- "license": [
- "BSD-2-Clause"
- ],
- "authors": [
- {
- "name": "Greg Beaver",
- "email": "cellog@php.net",
- "role": "Helper"
- },
- {
- "name": "Andrei Zmievski",
- "email": "andrei@php.net",
- "role": "Lead"
- },
- {
- "name": "Stig Bakken",
- "email": "stig@php.net",
- "role": "Developer"
- }
- ],
- "description": "More info available on: http://pear.php.net/package/Console_Getopt",
- "time": "2015-07-20T20:28:12+00:00"
- },
- {
- "name": "pear/pear-core-minimal",
- "version": "v1.10.3",
- "source": {
- "type": "git",
- "url": "https://github.com/pear/pear-core-minimal.git",
- "reference": "070f0b600b2caca2501e2c9b7e553016e4b0d115"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/070f0b600b2caca2501e2c9b7e553016e4b0d115",
- "reference": "070f0b600b2caca2501e2c9b7e553016e4b0d115",
- "shasum": ""
- },
- "require": {
- "pear/console_getopt": "~1.4",
- "pear/pear_exception": "~1.0"
- },
- "replace": {
- "rsky/pear-core-min": "self.version"
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- "src/"
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Christian Weiske",
- "email": "cweiske@php.net",
- "role": "Lead"
- }
- ],
- "description": "Minimal set of PEAR core files to be used as composer dependency",
- "time": "2017-02-28T16:46:11+00:00"
- },
- {
- "name": "pear/pear_exception",
- "version": "v1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/pear/PEAR_Exception.git",
- "reference": "8c18719fdae000b690e3912be401c76e406dd13b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b",
- "reference": "8c18719fdae000b690e3912be401c76e406dd13b",
- "shasum": ""
- },
- "require": {
- "php": ">=4.4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "*"
- },
- "type": "class",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "PEAR": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- "."
- ],
- "license": [
- "BSD-2-Clause"
- ],
- "authors": [
- {
- "name": "Helgi Thormar",
- "email": "dufuz@php.net"
- },
- {
- "name": "Greg Beaver",
- "email": "cellog@php.net"
- }
- ],
- "description": "The PEAR Exception base class.",
- "homepage": "https://github.com/pear/PEAR_Exception",
- "keywords": [
- "exception"
- ],
- "time": "2015-02-10T20:07:52+00:00"
- },
- {
- "name": "pear/text_highlighter",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/pear/Text_Highlighter.git",
- "reference": "2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/pear/Text_Highlighter/zipball/2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855",
- "reference": "2ccac2d9eaf55dc08bbbdb7136c93fb399d0f855",
- "shasum": ""
- },
- "require": {
- "pear/pear-core-minimal": "~1.10.0",
- "php": ">=5.4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "@stable"
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Text": "./"
- }
- },
- "include-path": [
- "./"
- ],
- "license": [
- "PHP-3.01"
- ],
- "authors": [
- {
- "email": "ssttoo@gmail.com",
- "name": "Stoyan Stefanov",
- "role": "Lead"
- },
- {
- "email": "demenev@gmail.com",
- "name": "Andrey Demenev",
- "role": "Lead"
- }
- ],
- "description": "More info available on: http://pear.php.net/package/Text_Highlighter",
- "support": {
- "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Text_Highlighter",
- "source": "https://github.com/pear/Text_Highlighter"
- },
- "time": "2018-01-27T08:24:15+00:00"
- },
{
"name": "pear/text_languagedetect",
"version": "v1.0.0",
@@ -3145,7 +2947,7 @@
}
],
"description": "Provides the functionality to compare PHP values for equality",
- "homepage": "https://github.com/sebastianbergmann/comparator",
+ "homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
@@ -3247,7 +3049,7 @@
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "https://github.com/sebastianbergmann/environment",
+ "homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
@@ -3315,7 +3117,7 @@
}
],
"description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "https://github.com/sebastianbergmann/exporter",
+ "homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
@@ -3367,7 +3169,7 @@
}
],
"description": "Snapshotting of global state",
- "homepage": "https://github.com/sebastianbergmann/global-state",
+ "homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
@@ -3469,7 +3271,7 @@
}
],
"description": "Provides functionality to recursively process PHP variables",
- "homepage": "https://github.com/sebastianbergmann/recursion-context",
+ "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-11-19T07:33:16+00:00"
},
{
@@ -3669,8 +3471,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
- "lightopenid/lightopenid": 20,
- "pear/text_highlighter": 20
+ "lightopenid/lightopenid": 20
},
"prefer-stable": false,
"prefer-lowest": false,
diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md
index 1e077902d..5deaf98ff 100644
--- a/doc/Developers-Intro.md
+++ b/doc/Developers-Intro.md
@@ -33,7 +33,7 @@ If you don't want to translate the UI, or it is already done to your satisfactio
Are you good at designing things?
If you have seen Friendica you probably have ideas to improve it, haven't you?
-* If you would like to work with us on enhancing the user interface, please join the [UX Watchdogs forum](https://fc.oscp.info/profile/ux-watchdogs)
+* If you would like to work with us on enhancing the user interface, please join the [forum for Friendica development](https://forum.friendi.ca/profile/developers).
* Make plans for a better Friendica interface design and share them with us.
* Tell us if you are able to realize your ideas or what kind of help you need.
We can't promise we have the right skills in the group but we'll try.
diff --git a/doc/Quick-Start-groupsandpages.md b/doc/Quick-Start-groupsandpages.md
index 652407d64..d4680f65f 100644
--- a/doc/Quick-Start-groupsandpages.md
+++ b/doc/Quick-Start-groupsandpages.md
@@ -15,6 +15,6 @@ Remember the link at the top of this page will bring you back here.
Once you've added some groups, move on to the next section.
-
+
diff --git a/include/api.php b/include/api.php
index f40674b89..5510eddb4 100644
--- a/include/api.php
+++ b/include/api.php
@@ -581,7 +581,10 @@ function api_get_user(App $a, $contact_id = null)
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
if (!empty($a->argv[$argid])) {
- list($user, $null) = explode(".", $a->argv[$argid]);
+ $data = explode(".", $a->argv[$argid]);
+ if (count($data) > 1) {
+ list($user, $null) = $data;
+ }
}
if (is_numeric($user)) {
$user = DBA::escape(api_unique_id_to_nurl(intval($user)));
@@ -1056,10 +1059,10 @@ function api_statuses_mediap($type)
// now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]";
- item_post($a);
+ $item_id = item_post($a);
- // this should output the last post (the one we just posted).
- return api_status_show($type);
+ // output the post that we just posted.
+ return api_status_show($type, $item_id);
}
/// @TODO move this to top of file or somewhere better!
@@ -1075,7 +1078,6 @@ api_register_func('api/statuses/mediap', 'api_statuses_mediap', true, API_METHOD
*/
function api_statuses_update($type)
{
-
$a = get_app();
if (api_user() === false) {
@@ -1129,8 +1131,8 @@ function api_statuses_update($type)
if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_day = DBA::count('item', $condition);
+ $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
+ $posts_day = DBA::count('thread', $condition);
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
@@ -1143,8 +1145,8 @@ function api_statuses_update($type)
if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_week = DBA::count('item', $condition);
+ $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
+ $posts_week = DBA::count('thread', $condition);
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@@ -1157,8 +1159,8 @@ function api_statuses_update($type)
if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
- $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_month = DBA::count('item', $condition);
+ $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom];
+ $posts_month = DBA::count('thread', $condition);
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
@@ -1200,10 +1202,10 @@ function api_statuses_update($type)
}
// call out normal post function
- item_post($a);
+ $item_id = item_post($a);
- // this should output the last post (the one we just posted).
- return api_status_show($type);
+ // output the post that we just posted.
+ return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better
@@ -1260,7 +1262,7 @@ api_register_func('api/media/upload', 'api_media_upload', true, API_METHOD_POST)
*
* @return array|string
*/
-function api_status_show($type)
+function api_status_show($type, $item_id = 0)
{
$a = get_app();
@@ -1274,9 +1276,14 @@ function api_status_show($type)
$privacy_sql = "";
}
- // get last public wall message
- $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
- 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+ if (!empty($item_id)) {
+ // Get the item with the given id
+ $condition = ['id' => $item_id];
+ } else {
+ // get last public wall message
+ $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
+ 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
+ }
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
if (DBA::isResult($lastwall)) {
@@ -1993,14 +2000,14 @@ function api_statuses_repeat($type)
$_REQUEST["source"] = api_source();
}
- item_post($a);
+ $item_id = item_post($a);
} else {
throw new ForbiddenException();
}
- // this should output the last post (the one we just posted).
+ // output the post that we just posted.
$called_api = [];
- return api_status_show($type);
+ return api_status_show($type, $item_id);
}
/// @TODO move to top of file or somewhere better
@@ -4396,7 +4403,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
if ($filetype == "") {
$filetype=Image::guessType($filename);
}
- $imagedata = getimagesize($src);
+ $imagedata = @getimagesize($src);
if ($imagedata) {
$filetype = $imagedata['mime'];
}
diff --git a/include/conversation.php b/include/conversation.php
index ca01997f6..45e5d1caa 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -229,12 +229,12 @@ function localize_item(&$item)
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = XML::parseString($xmlhead.$item['object']);
- $links = XML::parseString($xmlhead."".unxmlify($obj->link)."");
$Bname = $obj->title;
- $Blink = "";
+ $Blink = $obj->id;
$Bphoto = "";
- foreach ($links->link as $l) {
+
+ foreach ($obj->link as $l) {
$atts = $l->attributes();
switch ($atts['rel']) {
case "alternate": $Blink = $atts['href'];
diff --git a/include/items.php b/include/items.php
index 2d7597dcd..9fd557a77 100644
--- a/include/items.php
+++ b/include/items.php
@@ -72,7 +72,8 @@ function add_page_info_data(array $data, $no_photos = false)
$text .= " title='".$data["title"]."'";
}
- if (!empty($data["images"])) {
+ // Only embedd a picture link when it seems to be a valid picture ("width" is set)
+ if (!empty($data["images"]) && !empty($data["images"][0]["width"])) {
$preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
// if the preview picture is larger than 500 pixels then show it in a larger mode
// But only, if the picture isn't higher than large (To prevent huge posts)
diff --git a/include/text.php b/include/text.php
index d251824e2..97baee7f6 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1911,58 +1911,3 @@ function format_network_name($network, $url = 0) {
return $network_name;
}
}
-
-/**
- * @brief Syntax based code highlighting for popular languages.
- * @param string $s Code block
- * @param string $lang Programming language
- * @return string Formated html
- */
-function text_highlight($s, $lang) {
- if ($lang === 'js') {
- $lang = 'javascript';
- }
-
- if ($lang === 'bash') {
- $lang = 'sh';
- }
-
- // @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php
-
- // Autoload the library to make constants available
- class_exists('Text_Highlighter_Renderer_Html');
-
- $options = [
- 'numbers' => HL_NUMBERS_LI,
- 'tabsize' => 4,
- ];
-
- $tag_added = false;
- $s = trim(html_entity_decode($s, ENT_COMPAT));
- $s = str_replace(' ', "\t", $s);
-
- /*
- * The highlighter library insists on an opening php tag for php code blocks. If
- * it isn't present, nothing is highlighted. So we're going to see if it's present.
- * If not, we'll add it, and then quietly remove it after we get the processed output back.
- */
- if ($lang === 'php' && strpos($s, 'factory($lang);
- $hl->setRenderer($renderer);
- $o = $hl->highlight($s);
- $o = str_replace("\n", '', $o);
-
- if ($tag_added) {
- $b = substr($o, 0, strpos($o, '
'));
- $e = substr($o, strpos($o, ''));
- $o = $b . $e;
- }
-
- return '' . $o . '
';
-}
diff --git a/mod/babel.php b/mod/babel.php
index 3352366bd..e5ae96be7 100644
--- a/mod/babel.php
+++ b/mod/babel.php
@@ -6,9 +6,11 @@
use Friendica\Content\Text;
use Friendica\Core\L10n;
-function visible_lf($s)
+function visible_whitespace($s)
{
- return str_replace("\n", '
', $s);
+ $s = str_replace(' ', ' ', $s);
+
+ return str_replace(["\r\n", "\n", "\r"], '
', $s);
}
function babel_content()
@@ -20,19 +22,19 @@ function babel_content()
$bbcode = trim($_REQUEST['text']);
$results[] = [
'title' => L10n::t('Source input'),
- 'content' => visible_lf($bbcode)
+ 'content' => visible_whitespace($bbcode)
];
$plain = Text\BBCode::toPlaintext($bbcode, false);
$results[] = [
'title' => L10n::t('BBCode::toPlaintext'),
- 'content' => visible_lf($plain)
+ 'content' => visible_whitespace($plain)
];
$html = Text\BBCode::convert($bbcode);
$results[] = [
- 'title' => L10n::t("BBCode::convert \x28raw HTML\x29"),
- 'content' => htmlspecialchars($html)
+ 'title' => L10n::t('BBCode::convert (raw HTML)'),
+ 'content' => visible_whitespace(htmlspecialchars($html))
];
$results[] = [
@@ -43,13 +45,13 @@ function babel_content()
$bbcode2 = Text\HTML::toBBCode($html);
$results[] = [
'title' => L10n::t('BBCode::convert => HTML::toBBCode'),
- 'content' => visible_lf($bbcode2)
+ 'content' => visible_whitespace($bbcode2)
];
$markdown = Text\BBCode::toMarkdown($bbcode);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown'),
- 'content' => visible_lf($markdown)
+ 'content' => visible_whitespace($markdown)
];
$html2 = Text\Markdown::convert($markdown);
@@ -61,22 +63,33 @@ function babel_content()
$bbcode3 = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
- 'content' => visible_lf($bbcode3)
+ 'content' => visible_whitespace($bbcode3)
];
$bbcode4 = Text\HTML::toBBCode($html2);
$results[] = [
'title' => L10n::t('BBCode::toMarkdown => Markdown::convert => HTML::toBBCode'),
- 'content' => visible_lf($bbcode4)
+ 'content' => visible_whitespace($bbcode4)
];
break;
case 'markdown':
$markdown = trim($_REQUEST['text']);
$results[] = [
- 'title' => L10n::t('Source input \x28Diaspora format\x29'),
+ 'title' => L10n::t('Source input (Diaspora format)'),
'content' => '' . $markdown . '
'
];
+ $html = Text\Markdown::convert($markdown);
+ $results[] = [
+ 'title' => L10n::t('Markdown::convert (raw HTML)'),
+ 'content' => htmlspecialchars($html)
+ ];
+
+ $results[] = [
+ 'title' => L10n::t('Markdown::convert'),
+ 'content' => $html
+ ];
+
$bbcode = Text\Markdown::toBBCode($markdown);
$results[] = [
'title' => L10n::t('Markdown::toBBCode'),
@@ -86,7 +99,7 @@ function babel_content()
case 'html' :
$html = trim($_REQUEST['text']);
$results[] = [
- 'title' => L10n::t("Raw HTML input"),
+ 'title' => L10n::t('Raw HTML input'),
'content' => htmlspecialchars($html)
];
@@ -98,7 +111,13 @@ function babel_content()
$bbcode = Text\HTML::toBBCode($html);
$results[] = [
'title' => L10n::t('HTML::toBBCode'),
- 'content' => visible_lf($bbcode)
+ 'content' => visible_whitespace($bbcode)
+ ];
+
+ $markdown = Text\HTML::toMarkdown($html);
+ $results[] = [
+ 'title' => L10n::t('HTML::toMarkdown'),
+ 'content' => visible_whitespace($markdown)
];
$text = Text\HTML::toPlaintext($html);
@@ -111,7 +130,7 @@ function babel_content()
$tpl = get_markup_template('babel.tpl');
$o = replace_macros($tpl, [
- '$text' => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
+ '$text' => ['text', L10n::t('Source text'), htmlentities(defaults($_REQUEST, 'text', '')), ''],
'$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php
index 21b2039c5..e1ae9aa64 100644
--- a/mod/bookmarklet.php
+++ b/mod/bookmarklet.php
@@ -30,6 +30,10 @@ function bookmarklet_content(App $a)
$page = normalise_link(System::baseUrl() . "/bookmarklet");
if (!strstr($referer, $page)) {
+ if (empty($_REQUEST["url"])) {
+ System::httpExit(400, ["title" => L10n::t('Bad Request')]);
+ }
+
$content = add_page_info($_REQUEST["url"]);
$x = [
diff --git a/mod/contacts.php b/mod/contacts.php
index 4e8769717..1604f0b66 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -47,6 +47,11 @@ function contacts_init(App $a)
if (!DBA::isResult($contact)) {
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]);
}
+
+ // Don't display contacts that are about to be deleted
+ if ($contact['network'] == Protocol::PHANTOM) {
+ $contact = false;
+ }
}
if (DBA::isResult($contact)) {
@@ -122,11 +127,12 @@ function contacts_init(App $a)
function contacts_batch_actions(App $a)
{
- $contacts_id = $_POST['contact_batch'];
- if (!is_array($contacts_id)) {
+ if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) {
return;
}
+ $contacts_id = $_POST['contact_batch'];
+
$orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
implode(",", $contacts_id),
intval(local_user())
@@ -367,7 +373,7 @@ function _contact_drop($orig_record)
return;
}
- Contact::terminateFriendship($r[0], $orig_record);
+ Contact::terminateFriendship($r[0], $orig_record, true);
Contact::remove($orig_record['id']);
}
@@ -595,17 +601,12 @@ function contacts_content(App $a, $update = 0)
/// @todo Only show the following link with DFRN when the remote version supports it
$follow = '';
$follow_text = '';
- if (in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
- if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
+ if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
+ if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
$follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Disconnect/Unfollow");
- } else {
- $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
- $follow_text = L10n::t("Connect/Follow");
}
- }
-
- if ($contact['uid'] == 0) {
+ } else {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Connect/Follow");
}
@@ -723,6 +724,8 @@ function contacts_content(App $a, $update = 0)
$sql_extra = " AND `blocked` = 0 ";
}
+ $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
+
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
$nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : '';
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 88f706385..8a53ac09b 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -79,13 +79,13 @@ function dfrn_notify_post(App $a) {
$condition = [];
switch ($direction) {
case (-1):
- $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id];
+ $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
break;
case 0:
- $condition = ['issued-id' => $dfrn_id, 'duplex' => true];
+ $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break;
case 1:
- $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true];
+ $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
break;
default:
System::xmlExit(3, 'Invalid direction');
@@ -182,7 +182,7 @@ function dfrn_notify_post(App $a) {
function dfrn_dispatch_public($postdata)
{
- $msg = Diaspora::decodeRaw([], $postdata);
+ $msg = Diaspora::decodeRaw([], $postdata, true);
if (!$msg) {
// We have to fail silently to be able to hand it over to the salmon parser
return false;
@@ -287,15 +287,15 @@ function dfrn_notify_content(App $a) {
$condition = [];
switch ($direction) {
case (-1):
- $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id];
+ $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']];
$my_id = $dfrn_id;
break;
case 0:
- $condition = ['issued-id' => $dfrn_id, 'duplex' => true];
+ $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '1:' . $dfrn_id;
break;
case 1:
- $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true];
+ $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']];
$my_id = '0:' . $dfrn_id;
break;
default:
@@ -322,8 +322,8 @@ function dfrn_notify_content(App $a) {
$encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999);
- $prv_key = trim($importer['prvkey']);
- $pub_key = trim($importer['pubkey']);
+ $prv_key = trim($importer['cprvkey']);
+ $pub_key = trim($importer['cpubkey']);
$dplx = intval($importer['duplex']);
if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) {
diff --git a/mod/dirfind.php b/mod/dirfind.php
index f4ddba45d..332fe90f6 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -44,7 +44,7 @@ function dirfind_content(App $a, $prefix = "") {
$local = Config::get('system','poco_local_search');
- $search = $prefix.notags(trim($_REQUEST['search']));
+ $search = $prefix.notags(trim(defaults($_REQUEST, 'search', '')));
$header = '';
diff --git a/mod/events.php b/mod/events.php
index 91474022f..38b632cf4 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -20,7 +20,8 @@ use Friendica\Util\Temporal;
require_once 'include/items.php';
-function events_init(App $a) {
+function events_init(App $a)
+{
if (!local_user()) {
return;
}
@@ -42,7 +43,8 @@ function events_init(App $a) {
return;
}
-function events_post(App $a) {
+function events_post(App $a)
+{
logger('post: ' . print_r($_REQUEST, true), LOGGER_DATA);
@@ -50,15 +52,15 @@ function events_post(App $a) {
return;
}
- $event_id = (x($_POST, 'event_id') ? intval($_POST['event_id']) : 0);
- $cid = (x($_POST, 'cid') ? intval($_POST['cid']) : 0);
+ $event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
+ $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user();
- $start_text = escape_tags($_REQUEST['start_text']);
- $finish_text = escape_tags($_REQUEST['finish_text']);
+ $start_text = escape_tags(defaults($_REQUEST, 'start_text', ''));
+ $finish_text = escape_tags(defaults($_REQUEST, 'finish_text', ''));
- $adjust = intval($_POST['adjust']);
- $nofinish = intval($_POST['nofinish']);
+ $adjust = intval(defaults($_POST, 'adjust', 0));
+ $nofinish = intval(defaults($_POST, 'nofinish', 0));
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
@@ -91,9 +93,9 @@ function events_post(App $a) {
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
- $summary = escape_tags(trim($_POST['summary']));
- $desc = escape_tags(trim($_POST['desc']));
- $location = escape_tags(trim($_POST['location']));
+ $summary = escape_tags(trim(defaults($_POST, 'summary', '')));
+ $desc = escape_tags(trim(defaults($_POST, 'desc', '')));
+ $location = escape_tags(trim(defaults($_POST, 'location', '')));
$type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
@@ -117,7 +119,7 @@ function events_post(App $a) {
goaway($onerror_url);
}
- $share = (intval($_POST['share']) ? intval($_POST['share']) : 0);
+ $share = intval(defaults($_POST, 'share', 0));
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
@@ -137,7 +139,7 @@ function events_post(App $a) {
$str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : '';
// Undo the pseudo-contact of self, since there are real contacts now
- if (strpos($str_contact_allow, '<' . $self . '>') !== false ) {
+ if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
$str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
}
// Make sure to set the `private` field as true. This is necessary to
@@ -187,8 +189,8 @@ function events_post(App $a) {
goaway($_SESSION['return_url']);
}
-function events_content(App $a) {
-
+function events_content(App $a)
+{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
@@ -244,7 +246,7 @@ function events_content(App $a) {
$mode = 'view';
$y = 0;
$m = 0;
- $ignored = (x($_REQUEST, 'ignored') ? intval($_REQUEST['ignored']) : 0);
+ $ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0;
if ($a->argc > 1) {
if ($a->argc > 2 && $a->argv[1] == 'event') {
@@ -272,7 +274,6 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php
if ($mode == 'view') {
-
$thisyear = DateTimeFormat::localNow('Y');
$thismonth = DateTimeFormat::localNow('m');
if (!$y) {
@@ -312,10 +313,10 @@ function events_content(App $a) {
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
if ($a->argc > 1 && $a->argv[1] === 'json') {
- if (x($_GET, 'start')) {
- $start = $_GET['start'];
+ if (!empty($_GET['start'])) {
+ $start = $_GET['start'];
}
- if (x($_GET, 'end')) {
+ if (!empty($_GET['end'])) {
$finish = $_GET['end'];
}
}
@@ -349,7 +350,7 @@ function events_content(App $a) {
$r = Event::sortByDate($r);
foreach ($r as $rr) {
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
- if (!x($links,$j)) {
+ if (empty($links[$j])) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
}
@@ -363,12 +364,12 @@ function events_content(App $a) {
$events = Event::prepareListForTemplate($r);
}
- if ($a->argc > 1 && $a->argv[1] === 'json'){
+ if ($a->argc > 1 && $a->argv[1] === 'json') {
echo json_encode($events);
killme();
}
- if (x($_GET, 'id')) {
+ if (!empty($_GET['id'])) {
$tpl = get_markup_template("event.tpl");
} else {
$tpl = get_markup_template("events_js.tpl");
@@ -378,7 +379,7 @@ function events_content(App $a) {
foreach ($events as $key => $event) {
$event_item = [];
foreach ($event['item'] as $k => $v) {
- $k = str_replace('-' ,'_', $k);
+ $k = str_replace('-', '_', $k);
$event_item[$k] = $v;
}
$events[$key]['item'] = $event_item;
@@ -403,7 +404,7 @@ function events_content(App $a) {
'$list' => L10n::t('list'),
]);
- if (x($_GET, 'id')) {
+ if (!empty($_GET['id'])) {
echo $o;
killme();
}
@@ -428,41 +429,45 @@ function events_content(App $a) {
}
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
- if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
- if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];}
- if (x($_REQUEST, 'summary')) {$orig_event['summary'] = $_REQUEST['summary'];}
- if (x($_REQUEST, 'description')) {$orig_event['description'] = $_REQUEST['description'];}
- if (x($_REQUEST, 'location')) {$orig_event['location'] = $_REQUEST['location'];}
- if (x($_REQUEST, 'start')) {$orig_event['start'] = $_REQUEST['start'];}
- if (x($_REQUEST, 'finish')) {$orig_event['finish'] = $_REQUEST['finish'];}
- if (x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
+ if (!empty($_REQUEST['nofinish'])) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
+ if (!empty($_REQUEST['adjust'])) {$orig_event['adjust'] = $_REQUEST['adjust'];}
+ if (!empty($_REQUEST['summary'])) {$orig_event['summary'] = $_REQUEST['summary'];}
+ if (!empty($_REQUEST['description'])) {$orig_event['description'] = $_REQUEST['description'];}
+ if (!empty($_REQUEST['location'])) {$orig_event['location'] = $_REQUEST['location'];}
+ if (!empty($_REQUEST['start'])) {$orig_event['start'] = $_REQUEST['start'];}
+ if (!empty($_REQUEST['finish'])) {$orig_event['finish'] = $_REQUEST['finish'];}
- $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
- $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
+ $n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : '');
+ $a_checked = (!empty($orig_event['adjust']) ? ' checked="checked" ' : '');
- $t_orig = (x($orig_event) ? $orig_event['summary'] : '');
- $d_orig = (x($orig_event) ? $orig_event['desc'] : '');
- $l_orig = (x($orig_event) ? $orig_event['location'] : '');
- $eid = (x($orig_event) ? $orig_event['id'] : 0);
- $cid = (x($orig_event) ? $orig_event['cid'] : 0);
- $uri = (x($orig_event) ? $orig_event['uri'] : '');
+ $t_orig = !empty($orig_event) ? $orig_event['summary'] : '';
+ $d_orig = !empty($orig_event) ? $orig_event['desc'] : '';
+ $l_orig = !empty($orig_event) ? $orig_event['location'] : '';
+ $eid = !empty($orig_event) ? $orig_event['id'] : 0;
+ $cid = !empty($orig_event) ? $orig_event['cid'] : 0;
+ $uri = !empty($orig_event) ? $orig_event['uri'] : '';
$sh_disabled = '';
- $sh_checked = '';
+ $sh_checked = '';
- if (x($orig_event)) {
- $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid']) ? '' : ' checked="checked" ');
+ if (!empty($orig_event)
+ && ($orig_event['allow_cid'] !== '<' . local_user() . '>'
+ || $orig_event['allow_gid']
+ || $orig_event['deny_cid']
+ || $orig_event['deny_gid']))
+ {
+ $sh_checked = ' checked="checked" ';
}
if ($cid || $mode === 'edit') {
$sh_disabled = 'disabled="disabled"';
}
- $sdt = (x($orig_event) ? $orig_event['start'] : 'now');
- $fdt = (x($orig_event) ? $orig_event['finish'] : 'now');
+ $sdt = !empty($orig_event) ? $orig_event['start'] : 'now';
+ $fdt = !empty($orig_event) ? $orig_event['finish'] : 'now';
$tz = date_default_timezone_get();
- if (x($orig_event)) {
+ if (!empty($orig_event)) {
$tz = ($orig_event['adjust'] ? date_default_timezone_get() : 'UTC');
}
@@ -470,20 +475,22 @@ function events_content(App $a) {
$smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm');
$sday = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd');
- $shour = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00');
- $sminute = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00');
+ $shour = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00';
+ $sminute = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00';
$fyear = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y');
$fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm');
$fday = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd');
- $fhour = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00');
- $fminute = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00');
+ $fhour = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00';
+ $fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00';
$perms = ACL::getDefaultUserPermissions($orig_event);
- if ($mode === 'new' || $mode === 'copy') {
- $acl = ($cid ? '' : ACL::getFullSelectorHTML($a->user, false, $orig_event));
+ if (!$cid && in_array($mode, ['new', 'copy'])) {
+ $acl = ACL::getFullSelectorHTML($a->user, false, $orig_event);
+ } else {
+ $acl = '';
}
// If we copy an old event, we need to remove the ID and URI
@@ -495,7 +502,7 @@ function events_content(App $a) {
$tpl = get_markup_template('event_form.tpl');
- $o .= replace_macros($tpl,[
+ $o .= replace_macros($tpl, [
'$post' => System::baseUrl() . '/events',
'$eid' => $eid,
'$cid' => $cid,
@@ -509,11 +516,31 @@ function events_content(App $a) {
'$title' => L10n::t('Event details'),
'$desc' => L10n::t('Starting date and Title are required.'),
'$s_text' => L10n::t('Event Starts:') . ' *',
- '$s_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $syear+5), DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), L10n::t('Event Starts:'), 'start_text', true, true, '', '', true),
+ '$s_dsel' => Temporal::getDateTimeField(
+ new DateTime(),
+ DateTime::createFromFormat('Y', $syear+5),
+ DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
+ L10n::t('Event Starts:'),
+ 'start_text',
+ true,
+ true,
+ '',
+ '',
+ true
+ ),
'$n_text' => L10n::t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked,
'$f_text' => L10n::t('Event Finishes:'),
- '$f_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $fyear+5), DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), L10n::t('Event Finishes:'), 'finish_text', true, true, 'start_text'),
+ '$f_dsel' => Temporal::getDateTimeField(
+ new DateTime(),
+ DateTime::createFromFormat('Y', $fyear+5),
+ DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
+ L10n::t('Event Finishes:'),
+ 'finish_text',
+ true,
+ true,
+ 'start_text'
+ ),
'$a_text' => L10n::t('Adjust for viewer timezone'),
'$a_checked' => $a_checked,
'$d_text' => L10n::t('Description:'),
@@ -534,7 +561,6 @@ function events_content(App $a) {
'$basic' => L10n::t('Basic'),
'$advanced' => L10n::t('Advanced'),
'$permissions' => L10n::t('Permissions'),
-
]);
return $o;
diff --git a/mod/fetch.php b/mod/fetch.php
index 35455e282..4e7d8c751 100644
--- a/mod/fetch.php
+++ b/mod/fetch.php
@@ -25,7 +25,7 @@ function fetch_init(App $a)
// Fetch the item
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network',
- 'event-id', 'resource-id', 'author-link', 'owner-link', 'attach'];
+ 'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'attach'];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
diff --git a/mod/item.php b/mod/item.php
index 733c6aee8..213a99078 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -39,7 +39,7 @@ require_once 'include/items.php';
function item_post(App $a) {
if (!local_user() && !remote_user()) {
- return;
+ return 0;
}
require_once 'include/security.php';
@@ -154,7 +154,7 @@ function item_post(App $a) {
if (($message_id != '') && ($profile_uid != 0)) {
if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) {
logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
- return;
+ return 0;
}
}
@@ -183,7 +183,7 @@ function item_post(App $a) {
$user = DBA::selectFirst('user', [], ['uid' => $profile_uid]);
if (!DBA::isResult($user) && !$parent) {
- return;
+ return 0;
}
$categories = '';
@@ -843,6 +843,10 @@ function item_post(App $a) {
logger('post_complete');
+ if ($api_source) {
+ return $post_id;
+ }
+
item_post_return(System::baseUrl(), $api_source, $return_path);
// NOTREACHED
}
diff --git a/mod/lockview.php b/mod/lockview.php
index 893764c4d..a2301b4cc 100644
--- a/mod/lockview.php
+++ b/mod/lockview.php
@@ -8,27 +8,31 @@ use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\Model\Item;
-function lockview_content(App $a) {
-
+function lockview_content(App $a)
+{
$type = (($a->argc > 1) ? $a->argv[1] : 0);
if (is_numeric($type)) {
$item_id = intval($type);
- $type='item';
+ $type = 'item';
} else {
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
}
- if (!$item_id)
+ if (!$item_id) {
killme();
+ }
- if (!in_array($type, ['item','photo','event']))
+ if (!in_array($type, ['item','photo','event'])) {
killme();
+ }
- $fields = ['uid', 'private', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
+ $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
$condition = ['id' => $item_id];
+
if ($type != 'item') {
$item = DBA::selectFirst($type, $fields, $condition);
} else {
+ $fields[] = 'private';
$item = Item::selectFirst($fields, $condition);
}
@@ -43,18 +47,21 @@ function lockview_content(App $a) {
killme();
}
-
- if (($item['private'] == 1) && empty($item['allow_cid']) && empty($item['allow_gid'])
- && empty($item['deny_cid']) && empty($item['deny_gid'])) {
-
+ if (isset($item['private'])
+ && $item['private'] == 1
+ && empty($item['allow_cid'])
+ && empty($item['allow_gid'])
+ && empty($item['deny_cid'])
+ && empty($item['deny_gid']))
+ {
echo L10n::t('Remote privacy information not available.') . '
';
killme();
}
- $allowed_users = expand_acl($item['allow_cid']);
+ $allowed_users = expand_acl($item['allow_cid']);
$allowed_groups = expand_acl($item['allow_gid']);
- $deny_users = expand_acl($item['deny_cid']);
- $deny_groups = expand_acl($item['deny_gid']);
+ $deny_users = expand_acl($item['deny_cid']);
+ $deny_groups = expand_acl($item['deny_gid']);
$o = L10n::t('Visible to:') . '
';
$l = [];
@@ -63,36 +70,44 @@ function lockview_content(App $a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $allowed_groups))
);
- if (DBA::isResult($r))
- foreach($r as $rr)
+ if (DBA::isResult($r)) {
+ foreach ($r as $rr) {
$l[] = '' . $rr['name'] . '';
+ }
+ }
}
+
if (count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ',$allowed_users))
+ DBA::escape(implode(', ', $allowed_users))
);
- if (DBA::isResult($r))
- foreach($r as $rr)
+ if (DBA::isResult($r)) {
+ foreach ($r as $rr) {
$l[] = $rr['name'];
-
+ }
+ }
}
if (count($deny_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
DBA::escape(implode(', ', $deny_groups))
);
- if (DBA::isResult($r))
- foreach($r as $rr)
+ if (DBA::isResult($r)) {
+ foreach ($r as $rr) {
$l[] = '' . $rr['name'] . '';
+ }
+ }
}
+
if (count($deny_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
- DBA::escape(implode(', ',$deny_users))
+ DBA::escape(implode(', ', $deny_users))
);
- if (DBA::isResult($r))
- foreach($r as $rr)
+ if (DBA::isResult($r)) {
+ foreach ($r as $rr) {
$l[] = '' . $rr['name'] . '';
-
+ }
+ }
}
echo $o . implode(', ', $l);
diff --git a/mod/message.php b/mod/message.php
index 8c9aa657d..223976ddb 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -488,7 +488,7 @@ function render_messages(array $msg, $t)
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
- '$from_addr' => $contact['addr'],
+ '$from_addr' => defaults($contact, 'addr', ''),
'$sparkle' => ' sparkle',
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'$subject' => $subject_e,
diff --git a/mod/notes.php b/mod/notes.php
index 68a870e9d..01f283870 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -70,8 +70,11 @@ function notes_content(App $a, $update = false)
$count = 0;
if (DBA::isResult($r)) {
- $count = count($r);
- $o .= conversation($a, DBA::toArray($r), 'notes', $update);
+ $notes = DBA::toArray($r);
+
+ $count = count($notes);
+
+ $o .= conversation($a, $notes, 'notes', $update);
}
$o .= alt_pager($a, $count);
diff --git a/mod/notifications.php b/mod/notifications.php
index 145c38435..3934a3235 100644
--- a/mod/notifications.php
+++ b/mod/notifications.php
@@ -21,7 +21,7 @@ function notifications_post(App $a)
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
- if ($request_id === "all") {
+ if ($request_id === 'all') {
return;
}
@@ -68,8 +68,8 @@ function notifications_content(App $a)
return;
}
- $page = (x($_REQUEST,'page') ? $_REQUEST['page'] : 1);
- $show = (x($_REQUEST,'show') ? $_REQUEST['show'] : 0);
+ $page = defaults($_REQUEST, 'page', 1);
+ $show = defaults($_REQUEST, 'show', 0);
Nav::setSelected('notifications');
@@ -87,10 +87,11 @@ function notifications_content(App $a)
$perpage = 20;
$startrec = ($page * $perpage) - $perpage;
+ $notif_header = L10n::t('Notifications');
+
// Get introductions
if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
Nav::setSelected('introductions');
- $notif_header = L10n::t('Notifications');
$all = (($a->argc > 2) && ($a->argv[2] == 'all'));
@@ -115,10 +116,8 @@ function notifications_content(App $a)
} elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
$notif_header = L10n::t('Home Notifications');
$notifs = $nm->homeNotifs($show, $startrec, $perpage);
-
}
-
// Set the pager
$a->set_pager_itemspage($perpage);
@@ -133,14 +132,15 @@ function notifications_content(App $a)
$notif_tpl = get_markup_template('notifications.tpl');
- if (!isset($notifs['ident'])) {
- logger('Missing data in notifs: ' . System::callstack(20), LOGGER_DEBUG);
- }
+ $notif_show_lnk = [
+ 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ),
+ 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')),
+ ];
// Process the data for template creation
- if ($notifs['ident'] === 'introductions') {
+ if (defaults($notifs, 'ident', '') === 'introductions') {
$sugg = get_markup_template('suggestions.tpl');
- $tpl = get_markup_template("intros.tpl");
+ $tpl = get_markup_template('intros.tpl');
// The link to switch between ignored and normal connection requests
$notif_show_lnk = [
@@ -150,127 +150,121 @@ function notifications_content(App $a)
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
- foreach ($notifs['notifications'] as $it) {
+ foreach ($notifs['notifications'] as $notif) {
// There are two kind of introduction. Contacts suggested by other contacts and normal connection requests.
// We have to distinguish between these two because they use different data.
- switch ($it['label']) {
+ switch ($notif['label']) {
case 'friend_suggestion':
$notif_content[] = replace_macros($sugg, [
- '$type' => $it['label'],
+ '$type' => $notif['label'],
'$str_notifytype' => L10n::t('Notification type:'),
- '$notify_type' => $it['notify_type'],
- '$intro_id' => $it['intro_id'],
+ '$notify_type'=> $notif['notify_type'],
+ '$intro_id' => $notif['intro_id'],
'$lbl_madeby' => L10n::t('Suggested by:'),
- '$madeby' => $it['madeby'],
- '$madeby_url' => $it['madeby_url'],
- '$madeby_zrl' => $it['madeby_zrl'],
- '$madeby_addr' => $it['madeby_addr'],
- '$contact_id' => $it['contact_id'],
- '$photo' => $it['photo'],
- '$fullname' => $it['name'],
- '$url' => $it['url'],
- '$zrl' => $it['zrl'],
- '$lbl_url' => L10n::t('Profile URL'),
- '$addr' => $it['addr'],
- '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
-
- '$knowyou' => $it['knowyou'],
- '$approve' => L10n::t('Approve'),
- '$note' => $it['note'],
- '$request' => $it['request'],
- '$ignore' => L10n::t('Ignore'),
- '$discard' => L10n::t('Discard'),
+ '$madeby' => $notif['madeby'],
+ '$madeby_url' => $notif['madeby_url'],
+ '$madeby_zrl' => $notif['madeby_zrl'],
+ '$madeby_addr'=> $notif['madeby_addr'],
+ '$contact_id' => $notif['contact_id'],
+ '$photo' => $notif['photo'],
+ '$fullname' => $notif['name'],
+ '$url' => $notif['url'],
+ '$zrl' => $notif['zrl'],
+ '$lbl_url' => L10n::t('Profile URL'),
+ '$addr' => $notif['addr'],
+ '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
+ '$knowyou' => $notif['knowyou'],
+ '$approve' => L10n::t('Approve'),
+ '$note' => $notif['note'],
+ '$request' => $notif['request'],
+ '$ignore' => L10n::t('Ignore'),
+ '$discard' => L10n::t('Discard'),
]);
break;
// Normal connection requests
default:
- $friend_selected = (($it['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
- $fan_selected = (($it['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
- $dfrn_tpl = get_markup_template('netfriend.tpl');
+ $friend_selected = (($notif['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
+ $fan_selected = (($notif['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
- $knowyou = '';
$lbl_knowyou = '';
- $dfrn_text = '';
- $helptext = '';
- $helptext2 = '';
- $helptext3 = '';
+ $knowyou = '';
+ $helptext = '';
+ $helptext2 = '';
+ $helptext3 = '';
- if ($it['network'] === Protocol::DFRN || $it['network'] === Protocol::DIASPORA) {
- if ($it['network'] === Protocol::DFRN) {
- $lbl_knowyou = L10n::t('Claims to be known to you: ');
- $knowyou = (($it['knowyou']) ? L10n::t('yes') : L10n::t('no'));
- $helptext = L10n::t('Shall your connection be bidirectional or not?');
- $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']);
- $helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']);
- } else {
- $knowyou = '';
- $helptext = L10n::t('Shall your connection be bidirectional or not?');
- $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']);
- $helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']);
- }
+ if ($notif['network'] === Protocol::DFRN) {
+ $lbl_knowyou = L10n::t('Claims to be known to you: ');
+ $knowyou = (($notif['knowyou']) ? L10n::t('yes') : L10n::t('no'));
+ $helptext = L10n::t('Shall your connection be bidirectional or not?');
+ $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
+ $helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
+ } elseif ($notif['network'] === Protocol::DIASPORA) {
+ $helptext = L10n::t('Shall your connection be bidirectional or not?');
+ $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
+ $helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
}
- $dfrn_text = replace_macros($dfrn_tpl,[
- '$intro_id' => $it['intro_id'],
+ $dfrn_tpl = get_markup_template('netfriend.tpl');
+ $dfrn_text = replace_macros($dfrn_tpl, [
+ '$intro_id' => $notif['intro_id'],
'$friend_selected' => $friend_selected,
- '$fan_selected' => $fan_selected,
+ '$fan_selected'=> $fan_selected,
'$approve_as1' => $helptext,
'$approve_as2' => $helptext2,
'$approve_as3' => $helptext3,
- '$as_friend' => L10n::t('Friend'),
- '$as_fan' => (($it['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
+ '$as_friend' => L10n::t('Friend'),
+ '$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
]);
- $header = $it["name"];
+ $header = $notif['name'];
- if ($it["addr"] != "") {
- $header .= " <".$it["addr"].">";
+ if ($notif['addr'] != '') {
+ $header .= ' <' . $notif['addr'] . '>';
}
- $header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
+ $header .= ' (' . ContactSelector::networkToName($notif['network'], $notif['url']) . ')';
- if ($it['network'] != Protocol::DIASPORA) {
+ if ($notif['network'] != Protocol::DIASPORA) {
$discard = L10n::t('Discard');
} else {
$discard = '';
}
$notif_content[] = replace_macros($tpl, [
- '$type' => $it['label'],
- '$header' => htmlentities($header),
+ '$type' => $notif['label'],
+ '$header' => htmlentities($header),
'$str_notifytype' => L10n::t('Notification type:'),
- '$notify_type' => $it['notify_type'],
- '$dfrn_text' => $dfrn_text,
- '$dfrn_id' => $it['dfrn_id'],
- '$uid' => $it['uid'],
- '$intro_id' => $it['intro_id'],
- '$contact_id' => $it['contact_id'],
- '$photo' => $it['photo'],
- '$fullname' => $it['name'],
- '$location' => $it['location'],
- '$lbl_location' => L10n::t('Location:'),
- '$about' => $it['about'],
- '$lbl_about' => L10n::t('About:'),
- '$keywords' => $it['keywords'],
- '$lbl_keywords' => L10n::t('Tags:'),
- '$gender' => $it['gender'],
- '$lbl_gender' => L10n::t('Gender:'),
- '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
- '$url' => $it['url'],
- '$zrl' => $it['zrl'],
- '$lbl_url' => L10n::t('Profile URL'),
- '$addr' => $it['addr'],
+ '$notify_type' => $notif['notify_type'],
+ '$dfrn_text' => $dfrn_text,
+ '$dfrn_id' => $notif['dfrn_id'],
+ '$uid' => $notif['uid'],
+ '$intro_id' => $notif['intro_id'],
+ '$contact_id' => $notif['contact_id'],
+ '$photo' => $notif['photo'],
+ '$fullname' => $notif['name'],
+ '$location' => $notif['location'],
+ '$lbl_location'=> L10n::t('Location:'),
+ '$about' => $notif['about'],
+ '$lbl_about' => L10n::t('About:'),
+ '$keywords' => $notif['keywords'],
+ '$lbl_keywords'=> L10n::t('Tags:'),
+ '$gender' => $notif['gender'],
+ '$lbl_gender' => L10n::t('Gender:'),
+ '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
+ '$url' => $notif['url'],
+ '$zrl' => $notif['zrl'],
+ '$lbl_url' => L10n::t('Profile URL'),
+ '$addr' => $notif['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => L10n::t('Network:'),
- '$network' => ContactSelector::networkToName($it['network'], $it['url']),
- '$knowyou' => $knowyou,
- '$approve' => L10n::t('Approve'),
- '$note' => $it['note'],
- '$ignore' => L10n::t('Ignore'),
- '$discard' => $discard,
-
+ '$network' => ContactSelector::networkToName($notif['network'], $notif['url']),
+ '$knowyou' => $knowyou,
+ '$approve' => L10n::t('Approve'),
+ '$note' => $notif['note'],
+ '$ignore' => L10n::t('Ignore'),
+ '$discard' => $discard,
]);
break;
}
@@ -280,57 +274,47 @@ function notifications_content(App $a)
info(L10n::t('No introductions.') . EOL);
}
- // Normal notifications (no introductions)
- } else {
- // The template files we need in different cases for formatting the content
- $tpl_item_like = 'notifications_likes_item.tpl';
- $tpl_item_dislike = 'notifications_dislikes_item.tpl';
- $tpl_item_attend = 'notifications_attend_item.tpl';
- $tpl_item_attendno = 'notifications_attend_item.tpl';
- $tpl_item_attendmaybe = 'notifications_attend_item.tpl';
- $tpl_item_friend = 'notifications_friends_item.tpl';
- $tpl_item_comment = 'notifications_comments_item.tpl';
- $tpl_item_post = 'notifications_posts_item.tpl';
- $tpl_item_notify = 'notify.tpl';
-
+ // Normal notifications (no introductions)
+ } elseif (!empty($notifs['notifications'])) {
// Loop trough ever notification This creates an array with the output html for each
// notification and apply the correct template according to the notificationtype (label).
- foreach ($notifs['notifications'] as $it) {
+ foreach ($notifs['notifications'] as $notif) {
+ $notification_templates = [
+ 'like' => 'notifications_likes_item.tpl',
+ 'dislike' => 'notifications_dislikes_item.tpl',
+ 'attend' => 'notifications_attend_item.tpl',
+ 'attendno' => 'notifications_attend_item.tpl',
+ 'attendmaybe' => 'notifications_attend_item.tpl',
+ 'friend' => 'notifications_friends_item.tpl',
+ 'comment' => 'notifications_comments_item.tpl',
+ 'post' => 'notifications_posts_item.tpl',
+ 'notify' => 'notify.tpl',
+ ];
- // We use the notification label to get the correct template file
- $tpl_var_name = 'tpl_item_'.$it['label'];
- $tpl_notif = get_markup_template($$tpl_var_name);
+ $tpl_notif = get_markup_template($notification_templates[$notif['label']]);
- $notif_content[] = replace_macros($tpl_notif,[
- '$item_label' => $it['label'],
- '$item_link' => $it['link'],
- '$item_image' => $it['image'],
- '$item_url' => $it['url'],
- '$item_text' => $it['text'],
- '$item_when' => $it['when'],
- '$item_ago' => $it['ago'],
- '$item_seen' => $it['seen'],
+ $notif_content[] = replace_macros($tpl_notif, [
+ '$item_label' => $notif['label'],
+ '$item_link' => $notif['link'],
+ '$item_image' => $notif['image'],
+ '$item_url' => $notif['url'],
+ '$item_text' => $notif['text'],
+ '$item_when' => $notif['when'],
+ '$item_ago' => $notif['ago'],
+ '$item_seen' => $notif['seen'],
]);
}
-
- $notif_show_lnk = [
- 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
- 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')),
- ];
-
- // Output if there aren't any notifications available
- if (count($notifs['notifications']) == 0) {
- $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']);
- }
+ } else {
+ $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']);
}
$o .= replace_macros($notif_tpl, [
- '$notif_header' => $notif_header,
- '$tabs' => $tabs,
- '$notif_content' => $notif_content,
+ '$notif_header' => $notif_header,
+ '$tabs' => $tabs,
+ '$notif_content' => $notif_content,
'$notif_nocontent' => $notif_nocontent,
- '$notif_show_lnk' => $notif_show_lnk,
- '$notif_paginate' => alt_pager($a, count($notif_content))
+ '$notif_show_lnk' => $notif_show_lnk,
+ '$notif_paginate' => alt_pager($a, count($notif_content))
]);
return $o;
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 3309a74b9..ebe34875b 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -8,128 +8,127 @@
* information and does format this information to BBCode
*
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
-*/
-
+ */
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
-require_once("include/items.php");
-
-function parse_url_content(App $a) {
+require_once 'include/items.php';
+function parse_url_content(App $a)
+{
$text = null;
- $str_tags = "";
+ $str_tags = '';
$br = "\n";
- if (!empty($_GET["binurl"])) {
- $url = trim(hex2bin($_GET["binurl"]));
+ if (!empty($_GET['binurl'])) {
+ $url = trim(hex2bin($_GET['binurl']));
} else {
- $url = trim($_GET["url"]);
+ $url = trim($_GET['url']);
}
- if (!empty($_GET["title"])) {
- $title = strip_tags(trim($_GET["title"]));
+ if (!empty($_GET['title'])) {
+ $title = strip_tags(trim($_GET['title']));
}
- if (!empty($_GET["description"])) {
- $text = strip_tags(trim($_GET["description"]));
+ if (!empty($_GET['description'])) {
+ $text = strip_tags(trim($_GET['description']));
}
- if (!empty($_GET["tags"])) {
- $arr_tags = ParseUrl::convertTagsToArray($_GET["tags"]);
+ if (!empty($_GET['tags'])) {
+ $arr_tags = ParseUrl::convertTagsToArray($_GET['tags']);
if (count($arr_tags)) {
- $str_tags = $br . implode(" ", $arr_tags) . $br;
+ $str_tags = $br . implode(' ', $arr_tags) . $br;
}
}
// Add url scheme if it is missing
$arrurl = parse_url($url);
- if (!x($arrurl, "scheme")) {
- if (x($arrurl, "host")) {
- $url = "http:".$url;
+ if (!x($arrurl, 'scheme')) {
+ if (x($arrurl, 'host')) {
+ $url = 'http:' . $url;
} else {
- $url = "http://".$url;
+ $url = 'http://' . $url;
}
}
- logger("prse_url: " . $url);
+ logger($url);
// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
$redirects = 0;
// Fetch the header of the URL
- $result = Network::curl($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
- if($result["success"]) {
+ $result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
+
+ if ($result['success']) {
// Convert the header fields into an array
$hdrs = [];
- $h = explode("\n", $result["header"]);
+ $h = explode("\n", $result['header']);
foreach ($h as $l) {
- $header = array_map("trim", explode(":", trim($l), 2));
+ $header = array_map('trim', explode(':', trim($l), 2));
if (count($header) == 2) {
- list($k,$v) = $header;
+ list($k, $v) = $header;
$hdrs[$k] = $v;
}
}
- if (array_key_exists("Content-Type", $hdrs)) {
- $type = $hdrs["Content-Type"];
+ if (array_key_exists('Content-Type', $hdrs)) {
+ $type = $hdrs['Content-Type'];
}
if ($type) {
- if(stripos($type, "image/") !== false) {
- echo $br . "[img]" . $url . "[/img]" . $br;
- killme();
+ if (stripos($type, 'image/') !== false) {
+ echo $br . '[img]' . $url . '[/img]' . $br;
+ exit();
}
- if (stripos($type, "video/") !== false) {
- echo $br . "[video]" . $url . "[/video]" . $br;
- killme();
+ if (stripos($type, 'video/') !== false) {
+ echo $br . '[video]' . $url . '[/video]' . $br;
+ exit();
}
- if (stripos($type, "audio/") !== false) {
- echo $br . "[audio]" . $url . "[/audio]" . $br;
- killme();
+ if (stripos($type, 'audio/') !== false) {
+ echo $br . '[audio]' . $url . '[/audio]' . $br;
+ exit();
}
}
}
- $template = "[bookmark=%s]%s[/bookmark]%s";
+ $template = '[bookmark=%s]%s[/bookmark]%s';
- $arr = ["url" => $url, "text" => ""];
+ $arr = ['url' => $url, 'text' => ''];
- Addon::callHooks("parse_link", $arr);
+ Addon::callHooks('parse_link', $arr);
- if (strlen($arr["text"])) {
- echo $arr["text"];
- killme();
+ if (strlen($arr['text'])) {
+ echo $arr['text'];
+ exit();
}
// If there is already some content information submitted we don't
// need to parse the url for content.
if (!empty($url) && !empty($title) && !empty($text)) {
+ $title = str_replace(["\r", "\n"], ['', ''], $title);
- $title = str_replace(["\r","\n"],["",""],$title);
-
- $text = "[quote]" . trim($text) . "[/quote]" . $br;
+ $text = '[quote]' . trim($text) . '[/quote]' . $br;
$result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags;
- logger("parse_url (unparsed): returns: " . $result);
+ logger('(unparsed): returns: ' . $result);
echo $result;
- killme();
+ exit();
}
// Fetch the information directly from the webpage
$siteinfo = ParseUrl::getSiteinfo($url);
- unset($siteinfo["keywords"]);
+ unset($siteinfo['keywords']);
// Format it as BBCode attachment
$info = add_page_info_data($siteinfo);
echo $info;
- killme();
+ exit();
}
/**
@@ -151,7 +150,8 @@ function parse_url_content(App $a) {
* @todo Remove this function after all Addons has been changed to use
* ParseUrl::getSiteinfoCached
*/
-function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) {
+function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true)
+{
$siteinfo = ParseUrl::getSiteinfoCached($url, $no_guessing, $do_oembed);
return $siteinfo;
}
diff --git a/mod/photos.php b/mod/photos.php
index 5fb6ba368..e205d72c6 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -212,7 +212,7 @@ function photos_post(App $a)
}
// Check if the user has responded to a delete confirmation query
- if ($_REQUEST['canceled']) {
+ if (!empty($_REQUEST['canceled'])) {
goaway($_SESSION['photo_return']);
}
@@ -762,12 +762,14 @@ function photos_post(App $a)
$filesize = $ret['filesize'];
$type = $ret['type'];
$error = UPLOAD_ERR_OK;
- } else {
+ } elseif (!empty($_FILES['userfile'])) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$type = $_FILES['userfile']['type'];
$error = $_FILES['userfile']['error'];
+ } else {
+ $error = UPLOAD_ERR_NO_FILE;
}
if ($error !== UPLOAD_ERR_OK) {
@@ -1633,7 +1635,7 @@ function photos_content(App $a)
'$paginate' => $paginate,
]);
- $a->page['htmlhead'] .= "\n" . '' . "\n";
+ $a->page['htmlhead'] .= "\n" . '' . "\n";
$a->page['htmlhead'] .= '' . "\n";
$a->page['htmlhead'] .= '' . "\n";
$a->page['htmlhead'] .= '' . "\n";
diff --git a/mod/ping.php b/mod/ping.php
index 99ebde70c..968751a7d 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -510,16 +510,17 @@ function ping_get_notifications($uid)
* @brief Backward-compatible XML formatting for ping.php output
* @deprecated
*
- * @param array $data The initial ping data array
- * @param int $sysnotify Number of unseen system notifications
- * @param array $notifs Complete list of notification
- * @param array $sysmsgs List of system notice messages
- * @param array $sysmsgs_info List of system info messages
- * @param int $groups_unseen Number of unseen group items
- * @param int $forums_unseen Number of unseen forum items
+ * @param array $data The initial ping data array
+ * @param int $sysnotify_count Number of unseen system notifications
+ * @param array $notifs Complete list of notification
+ * @param array $sysmsgs List of system notice messages
+ * @param array $sysmsgs_info List of system info messages
+ * @param int $groups_unseen Number of unseen group items
+ * @param int $forums_unseen Number of unseen forum items
+ *
* @return array XML-transform ready data array
*/
-function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
+function ping_format_xml_data($data, $sysnotify_count, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{
$notifications = [];
foreach ($notifs as $key => $notif) {
diff --git a/mod/poke.php b/mod/poke.php
index a9dfc73f4..91f33c0de 100644
--- a/mod/poke.php
+++ b/mod/poke.php
@@ -24,19 +24,20 @@ use Friendica\Model\Item;
require_once 'include/security.php';
require_once 'include/items.php';
-function poke_init(App $a) {
-
+function poke_init(App $a)
+{
if (!local_user()) {
return;
}
$uid = local_user();
- $verb = notags(trim($_GET['verb']));
- if (!$verb) {
+ if (empty($_GET['verb'])) {
return;
}
+ $verb = notags(trim($_GET['verb']));
+
$verbs = get_poke_verbs();
if (!array_key_exists($verb, $verbs)) {
@@ -99,7 +100,7 @@ function poke_init(App $a) {
$arr['guid'] = System::createGUID(32);
$arr['uid'] = $uid;
$arr['uri'] = $uri;
- $arr['parent-uri'] = ($parent_uri ? $parent_uri : $uri);
+ $arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri);
$arr['wall'] = 1;
$arr['contact-id'] = $poster['id'];
$arr['owner-name'] = $poster['name'];
@@ -121,7 +122,7 @@ function poke_init(App $a) {
$arr['origin'] = 1;
$arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
- $arr['object'] = '