X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=1d2a775c49d27c822ef474bec1fa0093ea808393;hb=75be187216255c7c45421cb5f9596118a954f878;hp=b32ed2b16f1227baef96c70a942f77920462d02a;hpb=bbd5878734e658cbc514cacc20e231e843015d04;p=friendica.git diff --git a/include/items.php b/include/items.php index b32ed2b16f..1d2a775c49 100644 --- a/include/items.php +++ b/include/items.php @@ -161,24 +161,31 @@ function add_page_info_data($data) { if ($no_photos AND ($data["type"] == "photo")) return(""); - // If the link contains BBCode stuff, make a short link out of this to avoid parsing problems - if (strpos($data["url"], '[') OR strpos($data["url"], ']')) { - require_once("include/network.php"); - $data["url"] = short_link($data["url"]); - } - - if (($data["type"] != "photo") AND is_string($data["title"])) - $text .= "[bookmark=".$data["url"]."]".trim($data["title"])."[/bookmark]"; - - if (($data["type"] != "video") AND ($photo != "")) - $text .= '[img]'.$photo.'[/img]'; - elseif (($data["type"] != "video") AND (sizeof($data["images"]) > 0)) { - $imagedata = $data["images"][0]; - $text .= '[img]'.$imagedata["src"].'[/img]'; + if (sizeof($data["images"]) > 0) + $preview = $data["images"][0]; + else + $preview = ""; + + // Escape some bad characters + $data["url"] = str_replace(array("[", "]"), array("[", "]"), htmlentities($data["url"], ENT_QUOTES, 'UTF-8', false)); + $data["title"] = str_replace(array("[", "]"), array("[", "]"), htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false)); + + $text = "[attachment type='".$data["type"]."'"; + + if ($data["url"] != "") + $text .= " url='".$data["url"]."'"; + if ($data["title"] != "") + $text .= " title='".$data["title"]."'"; + if (sizeof($data["images"]) > 0) { + $preview = str_replace(array("[", "]"), array("[", "]"), 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) + if (($data["images"][0]["width"] >= 500) AND ($data["images"][0]["width"] >= $data["images"][0]["height"])) + $text .= " image='".$preview."'"; + else + $text .= " preview='".$preview."'"; } - - if (($data["type"] != "photo") AND is_string($data["text"])) - $text .= "[quote]".$data["text"]."[/quote]"; + $text .= "]".$data["text"]."[/attachment]"; $hashtags = ""; if (isset($data["keywords"]) AND count($data["keywords"])) { @@ -192,7 +199,7 @@ function add_page_info_data($data) { } } - return("\n[class=type-".$data["type"]."]".$text."[/class]".$hashtags); + return "\n".$text.$hashtags; } function query_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") { @@ -500,6 +507,13 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $arr['inform'] = ((x($arr,'inform')) ? trim($arr['inform']) : ''); $arr['file'] = ((x($arr,'file')) ? trim($arr['file']) : ''); + // Items cannot be stored before they happen ... + if ($arr['created'] > datetime_convert()) + $arr['created'] = datetime_convert(); + + // We haven't invented time travel by now. + if ($arr['edited'] > datetime_convert()) + $arr['edited'] = datetime_convert(); if (($arr['author-link'] == "") AND ($arr['owner-link'] == "")) logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG); @@ -570,6 +584,12 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa "photo" => $arr['author-avatar'], "name" => $arr['author-name'])); } + if ($arr["author-id"] == 0) + $arr["author-id"] = get_contact($arr["author-link"], 0); + + if ($arr["owner-id"] == 0) + $arr["owner-id"] = get_contact($arr["owner-link"], 0); + if ($arr['guid'] != "") { // Checking if there is already an item with the same guid logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG); @@ -1261,17 +1281,17 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) logger("Consume DFRN messages", LOGGER_DEBUG); $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, - `contact`.`pubkey` AS `cpubkey`, - `contact`.`prvkey` AS `cprvkey`, - `contact`.`thumb` AS `thumb`, - `contact`.`url` as `url`, - `contact`.`name` as `senderName`, - `user`.* - FROM `contact` - LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `contact`.`id` = %d AND `user`.`uid` = %d", - dbesc($contact["id"]), dbesc($importer["uid"]) - ); + `contact`.`pubkey` AS `cpubkey`, + `contact`.`prvkey` AS `cprvkey`, + `contact`.`thumb` AS `thumb`, + `contact`.`url` as `url`, + `contact`.`name` as `senderName`, + `user`.* + FROM `contact` + LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `contact`.`id` = %d AND `user`.`uid` = %d", + dbesc($contact["id"]), dbesc($importer["uid"]) + ); if ($r) { logger("Now import the DFRN feed"); dfrn::import($xml,$r[0], true); @@ -1384,16 +1404,8 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) { dbesc($url) ); if(count($r)) { - $contact_record = $r[0]; - - $photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]); - - q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - intval($contact_record["id"]) - ); + $contact_record = $r[0]; + update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true); }