aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Linkinfo.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Linkinfo.php')
-rw-r--r--Zotlabs/Module/Linkinfo.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index b9f90deec..76c679cc5 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -2,9 +2,6 @@
namespace Zotlabs\Module;
-
-
-
class Linkinfo extends \Zotlabs\Web\Controller {
function get() {
@@ -48,7 +45,22 @@ class Linkinfo extends \Zotlabs\Web\Controller {
}
logger('linkinfo: ' . $url);
-
+
+ // Replace plink URL with 'share' tag if possible
+ preg_match("/(mid=b64\.|display\/|posts\/)([\w\-]+)(&.+)?$/", $url, $mid);
+
+ if (!empty($mid) && $mid[1] == 'mid=b64.')
+ $mid[2] = base64_decode($mid[2]);
+
+ $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d AND item_private = 0 LIMIT 1",
+ dbesc((empty($mid) ? $url : $mid[2])),
+ intval(local_channel())
+ );
+ if ($r) {
+ echo "[share=" . $r[0]['id'] . "][/share]";
+ killme();
+ }
+
$result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
if($result['success']) {
$hdrs=array();
@@ -275,7 +287,7 @@ class Linkinfo extends \Zotlabs\Web\Controller {
// Check codepage in HTTP headers or HTML if not exist
$cp = (preg_match('/Content-Type: text\/html; charset=(.+)\r\n/i', $header, $o) ? $o[1] : '');
if(empty($cp))
- $cp = (preg_match('/meta.+content=["|\']text\/html; charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'AUTO');
+ $cp = (preg_match('/meta.+content=["\']text\/html; charset=([^"\']+)/i', $body, $o) ? $o[1] : 'AUTO');
$body = mb_convert_encoding($body, 'UTF-8', $cp);
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
@@ -444,8 +456,9 @@ class Linkinfo extends \Zotlabs\Web\Controller {
while (strpos($text, " "))
$text = trim(str_replace(" ", " ", $text));
-
- $siteinfo["text"] = html_entity_decode(substr($text,0,350), ENT_QUOTES, "UTF-8").'...';
+
+ $text = substr(html_entity_decode($text, ENT_QUOTES, "UTF-8"), 0, 350);
+ $siteinfo["text"] = rtrim(substr($text, 0, strrpos($text, " ")), "?.,:;!-") . '...';
}
}