function appnet_create_entities($a, $b, $postdata) { require_once "include/bbcode.php"; require_once "include/plaintext.php"; $bbcode = $b["body"]; $bbcode = bb_remove_share_information($bbcode, false, true); // Change pure links in text to bbcode uris $bbcode = preg_replace("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); $URLSearchString = "^\\[\\]"; $bbcode = preg_replace("/#\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '#$2', $bbcode); $bbcode = preg_replace("/@\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '@$2', $bbcode); $bbcode = preg_replace("/\\[bookmark\\=([{$URLSearchString}]*)\\](.*?)\\[\\/bookmark\\]/ism", '[url=$1]$2[/url]', $bbcode); $bbcode = preg_replace("/\\[video\\](.*?)\\[\\/video\\]/ism", '[url=$1]$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\]https?:\\/\\/(.*?)\\[\\/youtube\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\]([A-Za-z0-9\\-_=]+)(.*?)\\[\\/youtube\\]/ism", '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\]https?:\\/\\/(.*?)\\[\\/vimeo\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\]([0-9]+)(.*?)\\[\\/vimeo\\]/ism", '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode); //$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode); $bbcode = preg_replace("/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism", '[img]$3[/img]', $bbcode); preg_match_all("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $bbcode, $urls, PREG_SET_ORDER); $bbcode = preg_replace("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '$1', $bbcode); $b["body"] = $bbcode; // To-Do: // Bilder // https://alpha.app.net/heluecht/post/32424376 // https://alpha.app.net/heluecht/post/32424307 $plaintext = plaintext($a, $b, 0, false, 6); $text = $plaintext["text"]; $start = 0; $entities = array(); foreach ($urls as $url) { $lenurl = iconv_strlen($url[1], "UTF-8"); $len = iconv_strlen($url[2], "UTF-8"); $pos = iconv_strpos($text, $url[1], $start, "UTF-8"); $pre = iconv_substr($text, 0, $pos, "UTF-8"); $post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8"); $mid = $url[2]; $html = bbcode($mid, false, false, 6); $mid = html2plain($html, 0, true); $mid = trim(html_entity_decode($mid, ENT_QUOTES, 'UTF-8')); $text = $pre . $mid . $post; if ($mid != "") { $entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid); } $start = $pos + 1; } if (isset($postdata["url"]) and isset($postdata["title"]) and $postdata["type"] != "photo") { $postdata["title"] = shortenmsg($postdata["title"], 90); $max = 256 - strlen($postdata["title"]); $text = shortenmsg($text, $max); $text .= "\n[" . $postdata["title"] . "](" . $postdata["url"] . ")"; } elseif (isset($postdata["url"]) and $postdata["type"] != "photo") { $postdata["url"] = short_link($postdata["url"]); $max = 240; $text = shortenmsg($text, $max); $text .= " [" . $postdata["url"] . "](" . $postdata["url"] . ")"; } else { $max = 256; $text = shortenmsg($text, $max); } if (iconv_strlen($text, "UTF-8") < $max) { $max = iconv_strlen($text, "UTF-8"); } krsort($entities); foreach ($entities as $entity) { //if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) { if ($entity["pos"] + $entity["len"] <= $max) { $pre = iconv_substr($text, 0, $entity["pos"], "UTF-8"); $post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8"); $text = $pre . "[" . $entity["text"] . "](" . $entity["url"] . ")" . $post; } } return $text; }
function twitter_post_hook(&$a, &$b) { /** * Post to Twitter */ require_once "include/network.php"; if (!get_pconfig($b["uid"], 'twitter', 'import')) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } } if ($b['parent'] != $b['id']) { logger("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a twitter post if (substr($b["parent-uri"], 0, 9) != "twitter::" and substr($b["extid"], 0, 9) != "twitter::" and substr($b["thr-parent"], 0, 9) != "twitter::") { logger("twitter_post_hook: no twitter post " . $b["parent"]); return; } $r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); if (!count($r)) { logger("twitter_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; $orig_post = $r[0]; } $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "\$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; logger("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if (strpos($b["body"], $nickname) === false and strpos($b["body"], $nicknameplain) === false) { $b["body"] = $nickname . " " . $b["body"]; } logger("twitter_post_hook: parent found " . print_r($orig_post, true), LOGGER_DATA); } else { $iscomment = false; if ($b['private'] or !strstr($b['postopts'], 'twitter')) { return; } } if ($b['verb'] == ACTIVITY_POST and $b['deleted']) { twitter_action($a, $b["uid"], substr($orig_post["uri"], 9), "delete"); } if ($b['verb'] == ACTIVITY_LIKE) { logger("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG); if ($b['deleted']) { twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike"); } else { twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like"); } return; } if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } // if post comes from twitter don't send it back if ($b['extid'] == NETWORK_TWITTER) { return; } if ($b['app'] == "Twitter") { return; } logger('twitter post invoked'); load_pconfig($b['uid'], 'twitter'); $ckey = get_config('twitter', 'consumerkey'); $csecret = get_config('twitter', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'twitter', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'twitter', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); // If it's a repeated message from twitter then do a native retweet and exit if (twitter_is_retweet($a, $b['uid'], $b['body'])) { return; } require_once 'library/twitteroauth.php'; require_once 'include/bbcode.php'; $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $max_char = 140; require_once "include/plaintext.php"; $msgarr = plaintext($a, $b, $max_char, true, 8); $msg = $msgarr["text"]; if ($msg == "" and isset($msgarr["title"])) { $msg = shortenmsg($msgarr["title"], $max_char - 50); } $image = ""; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { $msg .= "\n" . $msgarr["url"]; } elseif (isset($msgarr["image"]) and $msgarr["type"] != "video") { $image = $msgarr["image"]; } // and now tweet it :-) if (strlen($msg) and $image != "") { $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); // Twitter had changed something so that the old library doesn't work anymore // so we are using a new library for twitter // To-Do: // Switching completely to this library with all functions require_once "addon/twitter/codebird.php"; $cb = \Codebird\Codebird::getInstance(); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); $post = array('status' => $msg, 'media[]' => $tempfile); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $cb->statuses_updateWithMedia($post); unlink($tempfile); logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->source) { set_config("twitter", "application_name", strip_tags($result->source)); } if ($result->errors or $result->error) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); // Workaround: Remove the picture link so that the post can be reposted without it $msg .= " " . $image; $image = ""; } elseif ($iscomment) { logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", dbesc("twitter::" . $result->id_str), dbesc($result->text), intval($b['id'])); } } if (strlen($msg) and $image == "") { $url = 'statuses/update'; $post = array('status' => $msg); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $tweet->post($url, $post); logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->source) { set_config("twitter", "application_name", strip_tags($result->source)); } if ($result->errors) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid'])); if (count($r)) { $a->contact = $r[0]["id"]; } $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $post)); require_once 'include/queue_fn.php'; add_to_queue($a->contact, NETWORK_TWITTER, $s); notice(t('Twitter post failed. Queued for retry.') . EOL); } elseif ($iscomment) { logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", dbesc("twitter::" . $result->id_str), intval($b['id'])); //q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) //); } } } }
function buffer_send(&$a, &$b) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'buffer')) { return; } if ($b['parent'] != $b['id']) { return; } // if post comes from buffer don't send it back //if($b['app'] == "Buffer") // return; $client_id = get_config("buffer", "client_id"); $client_secret = get_config("buffer", "client_secret"); $access_token = get_pconfig($b['uid'], "buffer", "access_token"); if ($access_token) { $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token); require_once "include/plaintext.php"; require_once "include/network.php"; $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { logger("Will send these parameter " . print_r($b, true), LOGGER_DEBUG); foreach ($profiles as $profile) { if (!$profile->default) { continue; } $send = false; switch ($profile->service) { case 'appdotnet': $send = $b["extid"] != NETWORK_APPNET; $limit = 256; $markup = false; $includedlinks = true; $htmlmode = 6; break; case 'facebook': $send = $b["extid"] != NETWORK_FACEBOOK; $limit = 0; $markup = false; $includedlinks = false; $htmlmode = 9; break; case 'google': $send = $b["extid"] != NETWORK_GPLUS; $limit = 0; $markup = true; $includedlinks = false; $htmlmode = 9; break; case 'twitter': $send = $b["extid"] != NETWORK_TWITTER; $limit = 140; $markup = false; $includedlinks = true; $htmlmode = 8; break; case 'linkedin': $send = $b["extid"] != NETWORK_LINKEDIN; $limit = 700; $markup = false; $includedlinks = true; $htmlmode = 2; break; } if (!$send) { continue; } $item = $b; // Markup for Google+ if ($markup) { if ($item["title"] != "") { $item["title"] = "*" . $item["title"] . "*"; } $item["body"] = preg_replace("(\\[b\\](.*?)\\[\\/b\\])ism", '*$1*', $item["body"]); $item["body"] = preg_replace("(\\[i\\](.*?)\\[\\/i\\])ism", '_$1_', $item["body"]); $item["body"] = preg_replace("(\\[s\\](.*?)\\[\\/s\\])ism", '-$1-', $item["body"]); } $post = plaintext($a, $item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message " . $b["id"] . " result: " . print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures require_once "mod/proxy.php"; if (isset($post["image"])) { $post["image"] = proxy_url($post["image"]); } if (isset($post["preview"])) { $post["preview"] = proxy_url($post["preview"]); } //if ($profile->service == "twitter") { if ($includedlinks) { if (isset($post["url"])) { $post["url"] = short_link($post["url"]); } if (isset($post["image"])) { $post["image"] = short_link($post["image"]); } if (isset($post["preview"])) { $post["preview"] = short_link($post["preview"]); } } // Seems like a bug to me // Buffer doesn't add links to Twitter and App.net (but pictures) //if ($includedlinks AND isset($post["url"])) if ($profile->service == "twitter" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and isset($post["title"]) and $post["type"] != "photo") { $post["title"] = shortenmsg($post["title"], 90); $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[" . $post["title"] . "](" . $post["url"] . ")"; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "google") { $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); } // Send a special blank to identify the post through the "fromgplus" addon $message = array(); $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false; $message["now"] = true; if (isset($post["title"])) { $message["media[title]"] = $post["title"]; } if (isset($post["description"])) { $message["media[description]"] = $post["description"]; } if (isset($post["url"]) and $post["type"] != "photo") { $message["media[link]"] = $post["url"]; } if (isset($post["image"])) { $message["media[picture]"] = $post["image"]; if ($post["type"] == "photo") { $message["media[thumbnail]"] = $post["image"]; } } if (isset($post["preview"])) { $message["media[thumbnail]"] = $post["preview"]; } //print_r($message); logger("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); $ret = $buffer->go('/updates/create', $message); logger("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); } } } }
function statusnet_post_hook(&$a, &$b) { /** * Post to GNU Social */ if (!get_pconfig($b["uid"], 'statusnet', 'import')) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } } $api = get_pconfig($b["uid"], 'statusnet', 'baseapi'); $hostname = preg_replace("=https?://([\\w\\.]*)/.*=ism", "\$1", $api); if ($b['parent'] != $b['id']) { logger("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a GNU Social post $hostlength = strlen($hostname) + 2; if (substr($b["parent-uri"], 0, $hostlength) != $hostname . "::" and substr($b["extid"], 0, $hostlength) != $hostname . "::" and substr($b["thr-parent"], 0, $hostlength) != $hostname . "::") { logger("statusnet_post_hook: no GNU Social post " . $b["parent"]); return; } $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); if (!count($r)) { logger("statusnet_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; $orig_post = $r[0]; } //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; //$nicknameplain = "@".$orig_post["contact_nick"]; $nick = preg_replace("=https?://(.*)/(.*)=ism", "\$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nicknameplain = "@" . $nick; logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if (strpos($b["body"], $nickname) === false and strpos($b["body"], $nicknameplain) === false) { $b["body"] = $nickname . " " . $b["body"]; } logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; if ($b['private'] or !strstr($b['postopts'], 'statusnet')) { return; } } if ($b['verb'] == ACTIVITY_POST and $b['deleted']) { statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete"); } if ($b['verb'] == ACTIVITY_LIKE) { logger("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); if ($b['deleted']) { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike"); } else { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like"); } return; } if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } // if posts comes from GNU Social don't send it back if ($b['extid'] == NETWORK_STATUSNET) { return; } if ($b['app'] == "StatusNet") { return; } logger('GNU Socialpost invoked'); load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { // If it's a repeated message from GNU Social then do a native retweet and exit if (statusnet_is_retweet($a, $b['uid'], $b['body'])) { return; } require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char); $tempfile = ""; require_once "include/plaintext.php"; require_once "include/network.php"; $msgarr = plaintext($a, $b, $max_char, true, 7); $msg = $msgarr["text"]; if ($msg == "" and isset($msgarr["title"])) { $msg = shortenmsg($msgarr["title"], $max_char - 50); } $image = ""; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { if (strlen($msgarr["url"]) > 20 and strlen($msg . " \n" . $msgarr["url"]) > $max_char) { $msg .= " \n" . short_link($msgarr["url"]); } else { $msg .= " \n" . $msgarr["url"]; } } elseif (isset($msgarr["image"]) and $msgarr["type"] != "video") { $image = $msgarr["image"]; } if ($image != "") { $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = array("status" => $msg, "media[]" => $tempfile); } else { $postdata = array("status" => $msg); } // and now dent it :-) if (strlen($msg)) { if ($iscomment) { $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength); logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); } // New code that is able to post pictures require_once "addon/statusnet/codebird.php"; $cb = \CodebirdSN\CodebirdSN::getInstance(); $cb->setAPIEndpoint($api); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if ($result->source) { set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source)); } if ($result->error) { logger('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", dbesc($hostname . "::" . $result->id), dbesc($result->text), intval($b['id'])); } } if ($tempfile != "") { unlink($tempfile); } } }
function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) { require_once "include/bbcode.php"; require_once "include/html2plain.php"; require_once "include/network.php"; // At first look at data that is attached via "type-..." stuff // This will hopefully replaced with a dedicated bbcode later $post = get_attached_data($b["body"]); if ($b["title"] != "" and $post["text"] != "") { $post["text"] = trim($b["title"] . "\n\n" . $post["text"]); } elseif ($b["title"] != "") { $post["text"] = trim($b["title"]); } $html = bbcode($post["text"], false, false, $htmlmode); $msg = html2plain($html, 0, true); $msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')); $link = ""; if ($includedlinks) { if ($post["type"] == "link") { $link = $post["url"]; } elseif ($post["type"] == "video") { $link = $post["url"]; } elseif ($post["type"] == "photo") { $link = $post["image"]; } if ($msg == "" and isset($post["title"])) { $msg = trim($post["title"]); } if ($msg == "" and isset($post["description"])) { $msg = trim($post["description"]); } // If the link is already contained in the post, then it neeedn't to be added again // But: if the link is beyond the limit, then it has to be added. if ($link != "" and strstr($msg, $link)) { $pos = strpos($msg, $link); if ($limit == 0 or $pos < $limit) { $link = ""; } } } if ($limit > 0) { // Reduce multiple spaces // When posted to a network with limited space, we try to gain space where possible while (strpos($msg, " ") !== false) { $msg = str_replace(" ", " ", $msg); } // Twitter is using its own limiter, so we always assume that shortened links will have this length if (iconv_strlen($link, "UTF-8") > 0) { $limit = $limit - 23; } if (iconv_strlen($msg, "UTF-8") > $limit) { if (!isset($post["url"])) { $limit = $limit - 23; $post["url"] = $b["plink"]; } elseif (strpos($b["body"], "[share") !== false) { $post["url"] = $b["plink"]; } elseif (get_pconfig($b["uid"], "system", "no_intelligent_shortening")) { $post["url"] = $b["plink"]; } $msg = shortenmsg($msg, $limit); } } $post["text"] = trim($msg); return $post; }