From cd7f05801a10ff9ffb47285db5541447673e89f1 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 10 Jul 2014 23:12:07 +0200 Subject: [PATCH 1/3] bbcode: Changed the format of repeated messages once more. --- include/bbcode.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index cea1dbdccc..84969dab9f 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -488,10 +488,10 @@ function bb_ShareAttributes($share, $simplehtml) { $text = $preshare.">> @".$userid_compact.":
".$share[3]; break; case 7: - $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')." @".$userid_compact." ".$share[3]; + $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')." @".$userid_compact.": ".$share[3]; break; case 8: - $text = $preshare."RT @".$userid_compact." ".$share[3]; + $text = $preshare."RT @".$userid_compact.": ".$share[3]; break; default: $headline = trim($share[1]).'
'; @@ -525,8 +525,12 @@ function GetProfileUsername($profile, $username, $compact = false) { } $gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile); - if ($gplus != $profile) - return($username." (".$gplus.")"); + if ($gplus != $profile) { + if ($compact) + return($gplususername." (".$username.")"); + else + return($username." (".$gplus.")"); + } $friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile); if ($friendica != $profile) { From 6f5bc8d9a79204b81109bad208d48305cc592e81 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 10 Jul 2014 23:13:07 +0200 Subject: [PATCH 2/3] Setting the user agent to "Mozilla/5.0 (compatible; Friendica)" --- include/network.php | 6 +++--- mod/parse_url.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/network.php b/include/network.php index 166f911680..f032e712c8 100644 --- a/include/network.php +++ b/include/network.php @@ -35,7 +35,6 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_ } @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - //@curl_setopt($ch, CURLOPT_USERAGENT, "Friendica"); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); @@ -135,7 +134,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$params); - curl_setopt($ch, CURLOPT_USERAGENT, "Friendica"); + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); if(intval($timeout)) { curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); @@ -1164,7 +1163,8 @@ function original_url($url, $depth=1, $fetchbody = false) { curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); + //curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); $header = curl_exec($ch); $curl_info = @curl_getinfo($ch); diff --git a/mod/parse_url.php b/mod/parse_url.php index 481b26533d..7e17b189f8 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -66,7 +66,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true) { curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($ch,CURLOPT_USERAGENT,' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); + //curl_setopt($ch,CURLOPT_USERAGENT,' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); + curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); $header = curl_exec($ch); $curl_info = @curl_getinfo($ch); From 58c3ac09a35e02c2ebb35b2122fcd8241f1472fc Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 10 Jul 2014 23:13:50 +0200 Subject: [PATCH 3/3] Improved option to suppress message flooding by some users. --- mod/community.php | 67 +++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/mod/community.php b/mod/community.php index 8a2c64ad8c..8d23c4af28 100644 --- a/mod/community.php +++ b/mod/community.php @@ -65,25 +65,7 @@ function community_content(&$a, $update = 0) { } - $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, - `user`.`nickname`, `user`.`hidewall` - FROM `thread` FORCE INDEX (`wall_private_received`) - INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0 - INNER JOIN `item` ON `item`.`id` = `thread`.`iid` - AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' - AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' - INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` - WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0 - AND `thread`.`private` = 0 AND `thread`.`wall` = 1 - ORDER BY `thread`.`received` DESC LIMIT %d, %d ", - intval($a->pager['start']), - intval($a->pager['itemspage']) - - ); + $r = community_getitems($a->pager['start'], $a->pager['itemspage']); if(! count($r)) { info( t('No results.') . EOL); @@ -93,21 +75,27 @@ function community_content(&$a, $update = 0) { $maxpostperauthor = get_config('system','max_author_posts_community_page'); if ($maxpostperauthor != 0) { + $count = 1; $previousauthor = ""; $numposts = 0; $s = array(); - foreach ($r AS $row=>$item) { - if ($previousauthor == $item["author-link"]) - ++$numposts; - else - $numposts = 0; + do { + foreach ($r AS $row=>$item) { + if ($previousauthor == $item["author-link"]) + ++$numposts; + else + $numposts = 0; - $previousauthor = $item["author-link"]; + $previousauthor = $item["author-link"]; - if ($numposts < $maxpostperauthor) - $s[] = $item; - } + if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage'])) + $s[] = $item; + } + if ((sizeof($s) < $a->pager['itemspage'])) + $r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']); + + } while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0)); } else $s = $r; @@ -125,3 +113,26 @@ function community_content(&$a, $update = 0) { return $o; } +function community_getitems($start, $itemspage) { + $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, + `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, + `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, + `user`.`nickname`, `user`.`hidewall` + FROM `thread` FORCE INDEX (`wall_private_received`) + INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0 + INNER JOIN `item` ON `item`.`id` = `thread`.`iid` + AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' + AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' + INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` + WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0 + AND `thread`.`private` = 0 AND `thread`.`wall` = 1 + ORDER BY `thread`.`received` DESC LIMIT %d, %d ", + intval($start), + intval($itemspage) + ); + + return($r); + +}