diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php
index dcbfb411..1521dcfd 100755
--- a/rendertime/rendertime.php
+++ b/rendertime/rendertime.php
@@ -26,6 +26,9 @@ function rendertime_page_end(&$a, &$o) {
$duration = microtime(true)-$a->performance["start"];
+ if (!is_site_admin())
+ return
+
$o = $o.'
'.sprintf(t("Performance: Database: %s, Network: %s, Rendering: %s, Parser: %s, I/O: %s, Other: %s, Total: %s"),
round($a->performance["database"], 3),
round($a->performance["network"], 3),
diff --git a/twitter/twitter.php b/twitter/twitter.php
index e140b1b2..6468bba4 100755
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -230,11 +230,11 @@ function twitter_settings(&$a,&$s) {
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
$s .= '';
$s .= '
';
$s .= '';
- $s .= ''. t('Twitter Posting Settings') .'
';
+ $s .= ''. t('Twitter Settings') .'
';
$s .= '';
if ( (!$ckey) && (!$csecret) ) {
@@ -942,6 +942,8 @@ function twitter_fetchtimeline($a, $uid) {
if ($application_name == "")
$application_name = $a->get_hostname();
+ $has_picture = false;
+
require_once('mod/item.php');
require_once('library/twitteroauth.php');
@@ -993,12 +995,13 @@ function twitter_fetchtimeline($a, $uid) {
switch($media->type) {
case 'photo':
$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
+ $has_picture = true;
break;
}
}
}
- $converted = twitter_convertmsg($a, $_REQUEST['body'], true);
+ $converted = twitter_convertmsg($a, $_REQUEST['body'], true, $has_picture);
$_REQUEST['body'] = $converted["body"];
$_REQUEST['body'] = "[share author='".$post->retweeted_status->user->name.
@@ -1015,12 +1018,13 @@ function twitter_fetchtimeline($a, $uid) {
switch($media->type) {
case 'photo':
$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
+ $has_picture = true;
break;
}
}
}
- $converted = twitter_convertmsg($a, $_REQUEST["body"], true);
+ $converted = twitter_convertmsg($a, $_REQUEST["body"], true, $has_picture);
$_REQUEST['body'] = $converted["body"];
}
@@ -1274,6 +1278,9 @@ function twitter_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
}
function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing_contact) {
+
+ $has_picture = false;
+
$postarray = array();
$postarray['gravity'] = 0;
$postarray['uid'] = $uid;
@@ -1369,6 +1376,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
switch($media->type) {
case 'photo':
$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
+ $has_picture = true;
break;
default:
$postarray['body'] .= print_r($media, true);
@@ -1376,7 +1384,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
}
}
- $converted = twitter_convertmsg($a, $postarray['body']);
+ $converted = twitter_convertmsg($a, $postarray['body'], false, $has_picture);
$postarray['body'] = $converted["body"];
$postarray['tag'] = $converted["tags"];
@@ -1405,6 +1413,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
switch($media->type) {
case 'photo':
$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
+ $has_picture = true;
break;
default:
$postarray['body'] .= print_r($media, true);
@@ -1412,7 +1421,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
}
}
- $converted = twitter_convertmsg($a, $postarray['body']);
+ $converted = twitter_convertmsg($a, $postarray['body'], false, $has_picture);
$postarray['body'] = $converted["body"];
$postarray['tag'] = $converted["tags"];
@@ -1727,10 +1736,14 @@ function twitter_original_url($url, $depth=1, $fetchbody = false) {
return($url);
}
-function twitter_siteinfo($url) {
+function twitter_siteinfo($url, $dontincludemedia) {
require_once("mod/parse_url.php");
- $data = parseurl_getsiteinfo($url);
+ // Fetch site infos - but only from the meta data
+ $data = parseurl_getsiteinfo($url, true);
+
+ if ($dontincludemedia)
+ unset($data["images"]);
if (!is_string($data["text"]) AND (sizeof($data["images"]) == 0) AND ($data["title"] == $url))
return("");
@@ -1738,6 +1751,10 @@ function twitter_siteinfo($url) {
if (is_string($data["title"]))
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]\n";
+ // Add a spoiler to the extra information
+ //if ((sizeof($data["images"]) > 0) OR is_string($data["text"]))
+ // $text .= "[spoiler]";
+
if (sizeof($data["images"]) > 0) {
$imagedata = $data["images"][0];
$text .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
@@ -1746,15 +1763,19 @@ function twitter_siteinfo($url) {
if (is_string($data["text"]))
$text .= "[quote]".$data["text"]."[/quote]";
+ //if ((sizeof($data["images"]) > 0) OR is_string($data["text"]))
+ // $text .= "[/spoiler]";
+
return($text);
}
-function twitter_convertmsg($a, $body, $no_tags = false) {
+function twitter_convertmsg($a, $body, $no_tags = false, $dontincludemedia) {
$links = preg_match_all("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", $body,$matches,PREG_SET_ORDER);
$footer = "";
+ $footerurl = "";
if ($links) {
foreach ($matches AS $match) {
@@ -1767,7 +1788,9 @@ function twitter_convertmsg($a, $body, $no_tags = false) {
$body = str_replace($match[2], "\n[youtube]".$expanded_url."[/youtube]\n", $body);
elseif (strstr($expanded_url, "//player.vimeo.com/"))
$body = str_replace($match[2], "\n[vimeo]".$expanded_url."[/vimeo]\n", $body);
- elseif (strstr($expanded_url, "//instagram.com"))
+ elseif (strstr($expanded_url, "//twitpic.com/")) // Test
+ $body = str_replace($match[2], "\n[url]".$expanded_url."[/url]\n", $body);
+ elseif (strstr($expanded_url, "//instagram.com/"))
$body = str_replace($match[2], "\n[url]".$expanded_url."[/url]\n", $body);
else {
$img_str = fetch_url($expanded_url, true, $redirects, 4);
@@ -1777,12 +1800,11 @@ function twitter_convertmsg($a, $body, $no_tags = false) {
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
unlink($tempfile);
- if (substr($mime, 0, 6) == "image/")
+ if (substr($mime, 0, 6) == "image/") {
$body = str_replace($match[2], "[img]".$expanded_url."[/img]", $body);
- else {
-
- //if ($footer == "")
- $footer = "\n\n".twitter_siteinfo($expanded_url);
+ $dontincludemedia = true;
+ } else {
+ $footerurl = $expanded_url;
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
$body = str_replace($match[2], $footerlink, $body);
@@ -1790,6 +1812,9 @@ function twitter_convertmsg($a, $body, $no_tags = false) {
}
}
+ if ($footerurl != "")
+ $footer = "\n\n".twitter_siteinfo($footerurl, $dontincludemedia);
+
if (($footerlink != "") AND (trim($footer) != "")) {
$removedlink = trim(str_replace($footerlink, "", $body));