aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/message.php54
-rw-r--r--include/text.php48
2 files changed, 69 insertions, 33 deletions
diff --git a/include/message.php b/include/message.php
index 95d8d9720..bde07afd8 100644
--- a/include/message.php
+++ b/include/message.php
@@ -16,6 +16,28 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$a = get_app();
$observer_hash = get_observer_hash();
+
+ if($uid) {
+ $r = q("select * from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+ if($r)
+ $channel = $r[0];
+ }
+ else {
+ $channel = App::get_channel();
+ }
+
+ if(! $channel) {
+ $ret['message'] = t('Unable to determine sender.');
+ return $ret;
+ }
+
+
+ $body = cleanup_bbcode($body);
+ $results = linkify_tags($a, $body, $uid);
+
+
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$match))
$attaches = $match[1];
@@ -43,22 +65,6 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$jattach = (($attachments) ? json_encode($attachments) : '');
- if($preview) {
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
if(! $recipient) {
$ret['message'] = t('No recipient provided.');
return $ret;
@@ -67,22 +73,6 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
if(! strlen($subject))
$subject = t('[no subject]');
- if($uid) {
- $r = q("select * from channel where channel_id = %d limit 1",
- intval($uid)
- );
- if($r)
- $channel = $r[0];
- }
- else {
- $channel = App::get_channel();
- }
-
- if(! $channel) {
- $ret['message'] = t('Unable to determine sender.');
- return $ret;
- }
-
// look for any existing conversation structure
diff --git a/include/text.php b/include/text.php
index b25eb8e46..e014024c2 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3061,4 +3061,50 @@ function create_table_from_array($table, $arr) {
}
return $r;
-} \ No newline at end of file
+}
+
+
+
+function cleanup_bbcode($body) {
+
+
+ /**
+ * fix naked links by passing through a callback to see if this is a hubzilla site
+ * (already known to us) which will get a zrl, otherwise link with url, add bookmark tag to both.
+ * First protect any url inside certain bbcode tags so we don't double link it.
+ */
+
+ $body = preg_replace_callback('/\[code(.*?)\[\/(code)\]/ism','\red_escape_codeblock',$body);
+ $body = preg_replace_callback('/\[url(.*?)\[\/(url)\]/ism','\red_escape_codeblock',$body);
+ $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body);
+
+
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\
++\,\(\)]+)/ism", 'nakedoembed', $body);
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\
++\,\(\)]+)/ism", '\red_zrl_callback', $body);
+
+ $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body);
+ $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','\red_unescape_codeblock',$body);
+ $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','\red_unescape_codeblock',$body);
+
+
+ // fix any img tags that should be zmg
+
+ $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','\red_zrlify_img_callback',$body);
+
+
+ $body = bb_translate_video($body);
+
+ /**
+ * Fold multi-line [code] sequences
+ */
+
+ $body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
+
+ $body = scale_external_images($body,false);
+
+
+ return $body;
+
+}