X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=5c0bb047ae63cf60d1d09b44d3ff6a4ec5798a9f;hb=714eb1a296b2529a1d1b410c0225fc1c6a3e48d0;hp=f8c3149d589dc9811b4df4030dc7a835ea3e5249;hpb=be5267edda51eb4b523324c001bcf90ca60e1fa5;p=friendica.git diff --git a/include/items.php b/include/items.php index f8c3149d58..5c0bb047ae 100644 --- a/include/items.php +++ b/include/items.php @@ -18,6 +18,7 @@ require_once('include/Contact.php'); require_once('mod/share.php'); require_once('include/enotify.php'); require_once('include/dfrn.php'); +require_once('include/group.php'); require_once('library/defuse/php-encryption-1.2.1/Crypto.php'); @@ -160,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"])) { @@ -191,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 = "") { @@ -383,9 +391,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // Converting the plink if ($arr['network'] == NETWORK_OSTATUS) { if (isset($arr['plink'])) - $arr['plink'] = ostatus_convert_href($arr['plink']); + $arr['plink'] = ostatus::convert_href($arr['plink']); elseif (isset($arr['uri'])) - $arr['plink'] = ostatus_convert_href($arr['uri']); + $arr['plink'] = ostatus::convert_href($arr['uri']); } if(x($arr, 'gravity')) @@ -707,9 +715,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa if ($arr["uid"] == 0) { $arr["global"] = true; - q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($arr["guid"])); + q("UPDATE `item` SET `global` = 1 WHERE `uri` = '%s'", dbesc($arr["uri"])); } else { - $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `guid` = '%s'", dbesc($arr["guid"])); + $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"])); $arr["global"] = (count($isglobal) > 0); } @@ -1243,7 +1251,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) //$tempfile = tempnam(get_temppath(), "ostatus2"); //file_put_contents($tempfile, $xml); logger("Consume OStatus messages ", LOGGER_DEBUG); - ostatus_import($xml,$importer,$contact, $hub); + ostatus::import($xml,$importer,$contact, $hub); } return; } @@ -1260,17 +1268,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); @@ -1378,7 +1386,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) { dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS), intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER) ); - $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", + $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", intval($importer['uid']), dbesc($url) ); @@ -1415,10 +1423,10 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) { ); } - if(intval($r[0]['def_gid'])) { - require_once('include/group.php'); - group_add_member($r[0]['uid'],'',$contact_record['id'],$r[0]['def_gid']); - } + $def_gid = get_default_group($importer['uid'], $contact_record["network"]); + + if(intval($def_gid)) + group_add_member($importer['uid'],'',$contact_record['id'],$def_gid); if(($r[0]['notify-flags'] & NOTIFY_INTRO) && in_array($r[0]['page-flags'], array(PAGE_NORMAL))) { @@ -1648,7 +1656,6 @@ function compare_permissions($obj1,$obj2) { // returns an array of contact-ids that are allowed to see this object function enumerate_permissions($obj) { - require_once('include/group.php'); $allow_people = expand_acl($obj['allow_cid']); $allow_groups = expand_groups(expand_acl($obj['allow_gid'])); $deny_people = expand_acl($obj['deny_cid']);