diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bb2diaspora.php | 15 | ||||
-rw-r--r-- | include/deliver.php | 4 | ||||
-rwxr-xr-x | include/items.php | 12 | ||||
-rw-r--r-- | include/network.php | 18 |
4 files changed, 26 insertions, 23 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index f9ecc564f..41001d216 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -72,11 +72,8 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { // So we'll use that to convert to HTML, then convert the HTML back to bbcode, // and then clean up a few Diaspora specific constructs. -function diaspora2bb($s) { +function diaspora2bb($s,$use_zrl = false) { - // for testing purposes: Collect raw markdown articles - // $file = tempnam("/tmp/friendica/", "markdown"); - // file_put_contents($file, $s); $s = html_entity_decode($s,ENT_COMPAT,'UTF-8'); @@ -87,6 +84,7 @@ function diaspora2bb($s) { // <br/> is invalid. Replace it with the valid expression $s = str_replace("<br/>","<br />",$s); + $s = str_replace("\n","<br />",$s); $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); @@ -108,7 +106,14 @@ function diaspora2bb($s) { $s = str_replace('♲',html_entity_decode('♲',ENT_QUOTES,'UTF-8'),$s); // Convert everything that looks like a link to a link - $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s); + if($use_zrl) { + $s = str_replace(array('[img','/img]'),array('[zmg','/zmg]'),$s); + $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]',$s); + } + else { + $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s); + + } //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s); $s = bb_tag_preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]','url',$s); diff --git a/include/deliver.php b/include/deliver.php index b0d15e1ef..0ad008c23 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -13,7 +13,7 @@ function deliver_run($argv, $argc) { if($argc < 2) return; - logger('deliver: invoked: ' . print_r($argv,true), LOGGER_DEBUG); + logger('deliver: invoked: ' . print_r($argv,true), LOGGER_DATA); for($x = 1; $x < $argc; $x ++) { $r = q("select * from outq where outq_hash = '%s' limit 1", @@ -21,6 +21,7 @@ function deliver_run($argv, $argc) { ); if($r) { if($r[0]['outq_posturl'] === z_root() . '/post') { + logger('deliver: local delivery', LOGGER_DEBUG); // local delivery // we should probably batch these and save a few delivery processes // If there is no outq_msg, this is a refresh_all message which does not require local handling @@ -34,6 +35,7 @@ function deliver_run($argv, $argc) { } } else { + logger('deliver: dest: ' . $r[0]['outq_posturl'], LOGGER_DEBUG); $result = zot_zot($r[0]['outq_posturl'],$r[0]['outq_notify']); if($result['success']) { zot_process_response($r[0]['outq_posturl'],$result, $r[0]); diff --git a/include/items.php b/include/items.php index 7fcb382b7..7bb47a284 100755 --- a/include/items.php +++ b/include/items.php @@ -32,11 +32,9 @@ function collect_recipients($item,&$private) { // as that would allow the denied person to see the post by logging out. if((! $item['allow_cid']) && (! $item['allow_gid'])) { - $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)", + $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) ", intval($item['uid']), - intval(ABOOK_FLAG_SELF), - intval(ABOOK_FLAG_PENDING), - intval(ABOOK_FLAG_ARCHIVED) + intval(ABOOK_FLAG_SELF|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED) ); if($r) { @@ -55,11 +53,9 @@ function collect_recipients($item,&$private) { } else { if(! $private) { - $r = q("select abook_xchan from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)", + $r = q("select abook_xchan from abook where abook_channel = %d and not (abook_flags & %d) ", intval($item['uid']), - intval(ABOOK_FLAG_SELF), - intval(ABOOK_FLAG_PENDING), - intval(ABOOK_FLAG_ARCHIVED) + intval(ABOOK_FLAG_SELF|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED) ); if($r) { foreach($r as $rr) { diff --git a/include/network.php b/include/network.php index 03faf9957..66bba5b38 100644 --- a/include/network.php +++ b/include/network.php @@ -597,21 +597,21 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) $s = htmlspecialchars_decode($s, ENT_COMPAT); $matches = null; - $c = preg_match_all('/\[img(.*?)\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER); + $c = preg_match_all('/\[([zi])mg(.*?)\](.*?)\[\/[zi]mg\]/ism',$s,$matches,PREG_SET_ORDER); if($c) { require_once('include/photo/photo_driver.php'); foreach($matches as $mtch) { - logger('scale_external_image: ' . $mtch[1] . ' ' . $mtch[2]); + logger('scale_external_image: ' . $mtch[2] . ' ' . $mtch[3]); if(substr($mtch[1],0,1) == '=') { - $owidth = intval(substr($mtch[1],1)); + $owidth = intval(substr($mtch[2],1)); if(intval($owidth) > 0 && intval($owidth) < 640) continue; } $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3)); - if(stristr($mtch[2],$hostname)) + if(stristr($mtch[3],$hostname)) continue; // $scale_replace, if passed, is an array of two elements. The @@ -620,9 +620,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) // This allows Friendica to display the smaller remote image if // one exists, while still linking to the full-size image if($scale_replace) - $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[2]); + $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[3]); else - $scaled = $mtch[2]; + $scaled = $mtch[3]; $i = z_fetch_url($scaled); @@ -633,7 +633,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) } // guess mimetype from headers or filename - $type = guess_image_type($mtch[2],$i['header']); + $type = guess_image_type($mtch[3],$i['header']); if($i['success']) { $ph = photo_factory($i['body'], $type); @@ -642,12 +642,12 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) $orig_height = $ph->getHeight(); if($orig_width > 640 || $orig_height > 640) { - + $tag = (($match[1] == 'z') ? 'zmg' : 'img'); $ph->scaleImage(640); $new_width = $ph->getWidth(); $new_height = $ph->getHeight(); logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG); - $s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]' + $s = str_replace($mtch[0],'[' . $tag . '=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/' . $tag . ']' . "\n" . (($include_link) ? '[zrl=' . $mtch[2] . ']' . t('view full size') . '[/zrl]' . "\n" : ''),$s); |