X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdiaspora.php;h=5069c1127526d11f7dc89f0959c1ed168c018095;hb=912e008ded3d439f7779310eb422e4b871a9b63d;hp=19bba52168367c8e07789749469f7615e8957612;hpb=be1bd9ff4e725f7e60b05acd415aee892e97f956;p=friendica.git diff --git a/include/diaspora.php b/include/diaspora.php old mode 100755 new mode 100644 index 19bba52168..5069c11275 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -9,6 +9,12 @@ require_once('include/queue_fn.php'); function diaspora_dispatch_public($msg) { + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + logger('mod-diaspora: disabled'); + return; + } + $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ", dbesc(NETWORK_DIASPORA), dbesc($msg['author']) @@ -29,6 +35,12 @@ function diaspora_dispatch($importer,$msg) { $ret = 0; + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + logger('mod-diaspora: disabled'); + return; + } + // php doesn't like dashes in variable names $msg['message'] = str_replace( @@ -688,16 +700,16 @@ function diaspora_post($importer,$xml) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; $basetag = str_replace('_',' ',substr($tag,1)); - $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); + $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); if(strlen($str_tags)) $str_tags .= ','; - $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; continue; } } @@ -853,17 +865,17 @@ function diaspora_reshare($importer,$xml) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; $basetag = str_replace('_',' ',substr($tag,1)); - $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); + $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); if(strlen($str_tags)) $str_tags .= ','; - $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; continue; } } @@ -1094,17 +1106,17 @@ function diaspora_comment($importer,$xml,$msg) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; $basetag = str_replace('_',' ',substr($tag,1)); - $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); + $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body); if(strlen($str_tags)) $str_tags .= ','; - $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; continue; } } @@ -1160,7 +1172,7 @@ function diaspora_comment($importer,$xml,$msg) { proc_run('php','include/notifier.php','comment',$message_id); } - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ", + $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0 ", dbesc($parent_item['uri']), intval($importer['uid']) ); @@ -1187,7 +1199,7 @@ function diaspora_comment($importer,$xml,$msg) { 'to_email' => $importer['email'], 'uid' => $importer['uid'], 'item' => $datarray, - 'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id, + 'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id, 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], @@ -1737,7 +1749,7 @@ function diaspora_retraction($importer,$xml) { contact_remove($contact['id']); } elseif($type === 'Post') { - $r = q("select * from item where guid = '%s' and uid = %d limit 1", + $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc('guid'), intval($importer['uid']) ); @@ -1785,7 +1797,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) { } if($type === 'StatusMessage') { - $r = q("select * from item where guid = '%s' and uid = %d limit 1", + $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc($guid), intval($importer['uid']) ); @@ -1920,6 +1932,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { $images = array(); + $title = $item['title']; $body = $item['body']; /* @@ -1944,9 +1957,12 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } } */ - $body = xmlify(html_entity_decode(bb2diaspora($body))); + if(strlen($title)) + $body = xmlify('**' . html_entity_decode($title) . '**' . "\n") . $body; + + if($item['attach']) { $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER); if(cnt) { @@ -2267,6 +2283,11 @@ function diaspora_send_mail($item,$owner,$contact) { function diaspora_transmit($owner,$contact,$slap,$public_batch) { + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + return 200; + } + $a = get_app(); $logid = random_string(4); $dest_url = (($public_batch) ? $contact['batch'] : $contact['notify']);