X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fitems.php;h=16fe897bed3253b73b812ee34a5f38d21cc46ec4;hb=912ff069c06ae7697431bd104cd4c50677f0e033;hp=14a74c8e51ea5afa0ff7e91cda3cd9aead2419b3;hpb=4e44b07dfe07dde78fe8a095fbb43d9ec1ffcb53;p=friendica.git
diff --git a/include/items.php b/include/items.php
index 14a74c8e51..16fe897bed 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1,483 +1,74 @@
= 500)
- && ($data["images"][0]["width"] >= $data["images"][0]["height"])) {
- $text .= " image='".$preview."'";
- } else {
- $text .= " preview='".$preview."'";
- }
- }
-
- $text .= "]".$data["text"]."[/attachment]";
-
- $hashtags = "";
- if (isset($data["keywords"]) && count($data["keywords"])) {
- $hashtags = "\n";
- foreach ($data["keywords"] AS $keyword) {
- /// @TODO make a positive list of allowed characters
- $hashtag = str_replace([" ", "+", "/", ".", "#", "'", "â", "`", "(", ")", "â", "â"],
- ["", "", "", "", "", "", "", "", "", "", "", ""], $keyword);
- $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] ";
- }
- }
-
- return "\n".$text.$hashtags;
-}
-
-function query_page_info($url, $photo = "", $keywords = false, $keyword_blacklist = "") {
-
- $data = ParseUrl::getSiteinfoCached($url, true);
-
- if ($photo != "") {
- $data["images"][0]["src"] = $photo;
- }
-
- logger('fetch page info for ' . $url . ' ' . print_r($data, true), LOGGER_DEBUG);
-
- if (!$keywords && isset($data["keywords"])) {
- unset($data["keywords"]);
- }
-
- if (($keyword_blacklist != "") && isset($data["keywords"])) {
- $list = explode(", ", $keyword_blacklist);
- foreach ($list AS $keyword) {
- $keyword = trim($keyword);
- $index = array_search($keyword, $data["keywords"]);
- if ($index !== false) {
- unset($data["keywords"][$index]);
- }
- }
- }
-
- return $data;
-}
-
-function add_page_keywords($url, $photo = "", $keywords = false, $keyword_blacklist = "") {
- $data = query_page_info($url, $photo, $keywords, $keyword_blacklist);
-
- $tags = "";
- if (isset($data["keywords"]) && count($data["keywords"])) {
- foreach ($data["keywords"] AS $keyword) {
- $hashtag = str_replace([" ", "+", "/", ".", "#", "'"],
- ["", "", "", "", "", ""], $keyword);
-
- if ($tags != "") {
- $tags .= ", ";
- }
-
- $tags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url]";
- }
- }
-
- return $tags;
-}
-
-function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
- $data = query_page_info($url, $photo, $keywords, $keyword_blacklist);
-
- $text = add_page_info_data($data, $no_photos);
-
- return $text;
-}
-
-function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
-
- logger('add_page_info_to_body: fetch page info for body ' . $body, LOGGER_DEBUG);
-
- $URLSearchString = "^\[\]";
-
- // Fix for Mastodon where the mentions are in a different format
- $body = preg_replace("/\[url\=([$URLSearchString]*)\]([#!@])(.*?)\[\/url\]/ism",
- '$2[url=$1]$3[/url]', $body);
-
- // Adding these spaces is a quick hack due to my problems with regular expressions :)
- preg_match("/[^!#@]\[url\]([$URLSearchString]*)\[\/url\]/ism", " " . $body, $matches);
-
- if (!$matches) {
- preg_match("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", " " . $body, $matches);
- }
-
- // Convert urls without bbcode elements
- if (!$matches && $texturl) {
- preg_match("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", " ".$body, $matches);
-
- // Yeah, a hack. I really hate regular expressions :)
- if ($matches) {
- $matches[1] = $matches[2];
- }
- }
-
- if ($matches) {
- $footer = add_page_info($matches[1], $no_photos);
- }
-
- // Remove the link from the body if the link is attached at the end of the post
- if (isset($footer) && (trim($footer) != "") && (strpos($footer, $matches[1]))) {
- $removedlink = trim(str_replace($matches[1], "", $body));
- if (($removedlink == "") || strstr($body, $removedlink)) {
- $body = $removedlink;
- }
-
- $url = str_replace(['/', '.'], ['\/', '\.'], $matches[1]);
- $removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body);
- if (($removedlink == "") || strstr($body, $removedlink)) {
- $body = $removedlink;
- }
- }
-
- // Add the page information to the bottom
- if (isset($footer) && (trim($footer) != "")) {
- $body .= $footer;
- }
-
- return $body;
-}
-
-/**
+ * @copyright Copyright (C) 2020, Friendica
*
- * consume_feed - process atom feed and update anything/everything we might need to update
+ * @license GNU AGPL version 3 or any later version
*
- * $xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
- * $importer = the contact_record (joined to user_record) of the local user who owns this relationship.
- * It is this person's stuff that is going to be updated.
- * $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity
- * from an external network and MAY create an appropriate contact record. Otherwise, we MUST
- * have a contact record.
- * $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or
- * might not) try and subscribe to it.
- * $datedir sorts in reverse order
- * $pass - by default ($pass = 0) we cannot guarantee that a parent item has been
- * imported prior to its children being seen in the stream unless we are certain
- * of how the feed is arranged/ordered.
- * With $pass = 1, we only pull parent items out of the stream.
- * With $pass = 2, we only pull children (comments/likes).
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
*
- * So running this twice, first with pass 1 and then with pass 2 will do the right
- * thing regardless of feed ordering. This won't be adequate in a fully-threaded
- * model where comments can have sub-threads. That would require some massive sorting
- * to get all the feed items into a mostly linear ordering, and might still require
- * recursion.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see