From f8da48a880f8b01e2284610e74fe3b2b6ec2dc39 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 30 Aug 2011 18:46:34 -0700 Subject: unsafe chars in admin, add img to diaspora markdown processor --- include/bb2diaspora.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 7f7b8748d..066d7bfff 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -17,6 +17,7 @@ function diaspora2bb($s) { $s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s); $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s); $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); + $s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s); $s = escape_tags($s); return $s; -- cgit v1.2.3 From b11a0efff120508a2059afe372f50144dcc8b977 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 30 Aug 2011 20:20:17 -0700 Subject: This *might* fix Diaspora @ tags - or it might not. --- include/bb2diaspora.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 066d7bfff..ec41ce139 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -18,6 +18,8 @@ function diaspora2bb($s) { $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s); $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); $s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s); + $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); + $s = escape_tags($s); return $s; -- cgit v1.2.3 From c60d45752db65a10b491f3a69ab63dc202f61533 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 30 Aug 2011 23:24:45 -0700 Subject: translate D* images (markdown) before links, they overlap and conflict --- include/bb2diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index ec41ce139..92f492116 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -16,8 +16,8 @@ function diaspora2bb($s) { $s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s); $s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s); $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s); - $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); $s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s); + $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); -- cgit v1.2.3 From 93b9d713776bd18e9a3126f025a0c63c8589c201 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 2 Sep 2011 05:13:38 -0700 Subject: completely enclose ~f hashtags so they don't get hijacked by D* --- include/bb2diaspora.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 92f492116..2eeea32cd 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -58,7 +58,8 @@ function bb2diaspora($Text,$preserve_nl = false) { $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text); - $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '[$2]($1)', $Text); + $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/", '[#$2]($1)', $Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/", '[$2]($1)', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text); -- cgit v1.2.3 From 59a6a04e26bf6baec4b7ad62419e9d335db249df Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 3 Sep 2011 07:13:12 -0700 Subject: format events for diaspora --- include/bb2diaspora.php | 58 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 2eeea32cd..c779b6aaf 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -43,6 +43,11 @@ function bb2diaspora($Text,$preserve_nl = false) { $Text = str_replace("<", "<", $Text); $Text = str_replace(">", ">", $Text); + // If we find any event code, turn it into an event. + // After we're finished processing the bbcode we'll + // replace all of the event code with a reformatted version. + + $ev = bbtoevent($Text); if($preserve_nl) $Text = str_replace(array("\n","\r"), array('',''),$Text); @@ -164,15 +169,16 @@ function bb2diaspora($Text,$preserve_nl = false) { // If we found an event earlier, strip out all the event code and replace with a reformatted version. -// if(x($ev,'desc') && x($ev,'start')) { -// $sub = format_event_html($ev); + if(x($ev,'desc') && x($ev,'start')) { - // $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text); - //$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text); -// $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text); -// $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text); -// $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text); -// } + $sub = format_event_diaspora($ev); + + $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text); + $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text); + $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text); + $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text); + $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text); + } @@ -180,3 +186,39 @@ function bb2diaspora($Text,$preserve_nl = false) { return $Text; } + +function format_event_diaspora($ev) { + +// require_once('include/bbcode.php'); + + if(! ((is_array($ev)) && count($ev))) + return ''; + + $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM + + $o = 'Friendika event notification:' . "\n"; + + $o .= '**' . bb2diaspora($ev['desc']) . '**' . "\n"; + + $o .= t('Starts:') . ' ' + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + $ev['start'] , $bd_format )) + : day_translate(datetime_convert('UTC', 'UTC', + $ev['start'] , $bd_format))) + . "\n"; + + if(! $ev['nofinish']) + $o .= t('Finishes:') . ' ' + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + $ev['finish'] , $bd_format )) + : day_translate(datetime_convert('UTC', 'UTC', + $ev['finish'] , $bd_format ))) + . "\n"; + + if(strlen($ev['location'])) + $o .= t('Location:') . bb2diaspora($ev['location']) + . "\n"; + + $o .= "\n"; + return $o; +} -- cgit v1.2.3 From c0a2cc3e98868b3b10472dee00a4590bb11f45c1 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 3 Sep 2011 07:40:05 -0700 Subject: diaspora has no timezone - use UTC for events --- include/bb2diaspora.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index c779b6aaf..65ccc750f 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -201,7 +201,7 @@ function format_event_diaspora($ev) { $o .= '**' . bb2diaspora($ev['desc']) . '**' . "\n"; $o .= t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format))) @@ -209,7 +209,7 @@ function format_event_diaspora($ev) { if(! $ev['nofinish']) $o .= t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format ))) -- cgit v1.2.3 From 9ff1a3444e9029c94541a7c84f0ed5ba764adef3 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 4 Sep 2011 00:48:45 -0700 Subject: add timezone convert module, several other minor or in progress fixes --- include/bb2diaspora.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index c779b6aaf..f9e3b3f28 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -62,9 +62,9 @@ function bb2diaspora($Text,$preserve_nl = false) { // [img]pathtoimage[/img] - $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text); - $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/", '[#$2]($1)', $Text); - $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/", '[$2]($1)', $Text); + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '[$1]($1)', $Text); + $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[#$2]($1)', $Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[$2]($1)', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text); @@ -165,7 +165,7 @@ function bb2diaspora($Text,$preserve_nl = false) { // oembed tag -// $Text = oembed_bbcode2html($Text); + // $Text = oembed_bbcode2html($Text); // If we found an event earlier, strip out all the event code and replace with a reformatted version. @@ -189,8 +189,6 @@ function bb2diaspora($Text,$preserve_nl = false) { function format_event_diaspora($ev) { -// require_once('include/bbcode.php'); - if(! ((is_array($ev)) && count($ev))) return ''; -- cgit v1.2.3