Merge branch 'develop' into release-3.3.2

This commit is contained in:
fabrixxm 2014-12-10 13:33:44 +01:00
commit 999ea5a79f
10 changed files with 113 additions and 11 deletions

View File

@ -169,7 +169,7 @@
$json = json_encode($rr); $json = json_encode($rr);
if ($_GET['callback']) if ($_GET['callback'])
$json = $_GET['callback']."(".$json.")"; $json = $_GET['callback']."(".$json.")";
return $json; return $json;
break; break;
case "rss": case "rss":
header ("Content-Type: application/rss+xml"); header ("Content-Type: application/rss+xml");
@ -681,6 +681,7 @@
logger('api_statuses_update: no user'); logger('api_statuses_update: no user');
return false; return false;
} }
$user_info = api_get_user($a); $user_info = api_get_user($a);
// convert $_POST array items to the form we use for web posts. // convert $_POST array items to the form we use for web posts.
@ -725,6 +726,64 @@
if($parent) if($parent)
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
else { else {
// Check for throttling (maximum posts per day, week and month)
$throttle_day = get_config('system','throttle_limit_day');
if ($throttle_day > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24*60*60);
$r = q("SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall`
AND `created` > '%s' AND `id` = `parent`",
intval(api_user()), dbesc($datefrom));
if ($r)
$posts_day = $r[0]["posts_day"];
else
$posts_day = 0;
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)));
}
}
$throttle_week = get_config('system','throttle_limit_week');
if ($throttle_week > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24*60*60*7);
$r = q("SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall`
AND `created` > '%s' AND `id` = `parent`",
intval(api_user()), dbesc($datefrom));
if ($r)
$posts_week = $r[0]["posts_week"];
else
$posts_week = 0;
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)));
}
}
$throttle_month = get_config('system','throttle_limit_month');
if ($throttle_month > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24*60*60*30);
$r = q("SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall`
AND `created` > '%s' AND `id` = `parent`",
intval(api_user()), dbesc($datefrom));
if ($r)
$posts_month = $r[0]["posts_month"];
else
$posts_month = 0;
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)));
}
}
$_REQUEST['type'] = 'wall'; $_REQUEST['type'] = 'wall';
if(x($_FILES,'media')) { if(x($_FILES,'media')) {
// upload the image if we have one // upload the image if we have one

View File

@ -56,6 +56,8 @@ function diaspora2bb($s) {
function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
$OriginalText = $Text;
// Since Diaspora is creating a summary for links, this function removes them before posting // Since Diaspora is creating a summary for links, this function removes them before posting
if ($fordiaspora) if ($fordiaspora)
$Text = bb_remove_share_information($Text); $Text = bb_remove_share_information($Text);
@ -73,9 +75,20 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text); $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $Text);
// Convert it to HTML - don't try oembed // Convert it to HTML - don't try oembed
if ($fordiaspora) if ($fordiaspora) {
$Text = bbcode($Text, $preserve_nl, false, 3); $Text = bbcode($Text, $preserve_nl, false, 3);
else {
// Add all tags that maybe were removed
if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",$OriginalText, $tags)) {
$tagline = "";
foreach($tags[2] as $tag)
if (!strpos($Text, "#".$tag))
$tagline .= "#".$tag." ";
$Text = $Text."<br />".$tagline;
}
} else {
$Text = bbcode($Text, $preserve_nl, false, 4); $Text = bbcode($Text, $preserve_nl, false, 4);
// Libertree doesn't convert a harizontal rule if there isn't a linefeed // Libertree doesn't convert a harizontal rule if there isn't a linefeed
$Text = str_replace("<hr />", "<br /><hr />", $Text); $Text = str_replace("<hr />", "<br /><hr />", $Text);

View File

@ -3,10 +3,10 @@ require_once("include/oembed.php");
require_once('include/event.php'); require_once('include/event.php');
function bb_attachment($Text, $plaintext = false, $tryoembed = true) { function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism", $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){ function ($match) use ($plaintext){
$attributes = $match[1]; $attributes = $match[2];
$type = ""; $type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches); preg_match("/type='(.*?)'/ism", $attributes, $matches);
@ -65,6 +65,11 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$preview = $matches[1]; $preview = $matches[1];
} }
if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) {
$preview = $image;
$image = "";
}
if ($plaintext) if ($plaintext)
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title); $text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
else { else {
@ -83,10 +88,10 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$text .= $oembed; $text .= $oembed;
$text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[2])); $text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[3]));
} }
return($text); return($match[1].$text);
},$Text); },$Text);
return($Text); return($Text);

View File

@ -10,7 +10,7 @@ function gprobe_run(&$argv, &$argc){
if(is_null($a)) { if(is_null($a)) {
$a = new App; $a = new App;
} }
if(is_null($db)) { if(is_null($db)) {
@include(".htconfig.php"); @include(".htconfig.php");
require_once("include/dba.php"); require_once("include/dba.php");
@ -37,6 +37,8 @@ function gprobe_run(&$argv, &$argc){
dbesc(normalise_link($url)) dbesc(normalise_link($url))
); );
logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG);
if(! count($r)) { if(! count($r)) {
$arr = probe_url($url); $arr = probe_url($url);
@ -55,7 +57,8 @@ function gprobe_run(&$argv, &$argc){
} }
if(count($r)) if(count($r))
poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url'])); poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
return; return;
} }

View File

@ -903,6 +903,12 @@ function add_page_info_data($data) {
if ($no_photos AND ($data["type"] == "photo")) if ($no_photos AND ($data["type"] == "photo"))
return(""); 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"])) if (($data["type"] != "photo") AND is_string($data["title"]))
$text .= "[bookmark=".$data["url"]."]".trim($data["title"])."[/bookmark]"; $text .= "[bookmark=".$data["url"]."]".trim($data["title"])."[/bookmark]";

View File

@ -1130,7 +1130,7 @@ function original_url($url, $depth=1, $fetchbody = false) {
if (in_array($param, array("utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign", if (in_array($param, array("utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign",
"wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid", "wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid",
"fb_action_ids", "fb_action_types", "fb_ref", "fb_action_ids", "fb_action_types", "fb_ref",
"awesm", "awesm", "wtrid",
"woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term"))) { "woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term"))) {
$pair = $param."=".urlencode($value); $pair = $param."=".urlencode($value);

View File

@ -62,7 +62,7 @@ ACL.prototype.add_mention = function(id) {
that.element.val( searchText + that.element.val() ); that.element.val( searchText + that.element.val() );
} else { } else {
if ( tinyMCE.activeEditor.getContent({format : 'raw'}).search(searchText) >= 0 ) return; if ( tinyMCE.activeEditor.getContent({format : 'raw'}).search(searchText) >= 0 ) return;
tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(), 'span', {}, searchText); tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(), 'dummy', {}, searchText);
} }
} }

View File

@ -17,6 +17,12 @@ class HTML5_Parser
* @return Parsed HTML as DOMDocument * @return Parsed HTML as DOMDocument
*/ */
static public function parse($text, $builder = null) { static public function parse($text, $builder = null) {
// Cleanup invalid HTML
$doc = new DOMDocument();
@$doc->loadHTML($text);
$text = $doc->saveHTML();
$tokenizer = new HTML5_Tokenizer($text, $builder); $tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse(); $tokenizer->parse();
return $tokenizer->save(); return $tokenizer->save();

View File

@ -187,6 +187,9 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
case "description": case "description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = $attr["content"];
break; break;
case "thumbnail":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:image": case "twitter:image":
$siteinfo["image"] = $attr["content"]; $siteinfo["image"] = $attr["content"];
break; break;
@ -421,6 +424,12 @@ function parse_url_content(&$a) {
$url= $siteinfo["url"]; $url= $siteinfo["url"];
// If the link contains BBCode stuff, make a short link out of this to avoid parsing problems
if (strpos($url, '[') OR strpos($url, ']')) {
require_once("include/network.php");
$url = short_link($url);
}
$sitedata = ""; $sitedata = "";
if($siteinfo["title"] == "") { if($siteinfo["title"] == "") {

View File

@ -3,6 +3,7 @@
body { body {
background-color: #eeeeee !important; background-color: #eeeeee !important;
font-family: "Lucida Sans Unicode","Lucida Sans", sans-serif;
} }
header #banner #logo-text { header #banner #logo-text {