mirror of
https://github.com/friendica/friendica
synced 2024-12-24 16:40:15 +00:00
Merge pull request #1044 from annando/master
Better user agent string, suppress flooding of the community page by single users
This commit is contained in:
commit
85fede486e
4 changed files with 52 additions and 36 deletions
|
@ -488,10 +488,10 @@ function bb_ShareAttributes($share, $simplehtml) {
|
||||||
$text = $preshare.">> @".$userid_compact.": <br />".$share[3];
|
$text = $preshare.">> @".$userid_compact.": <br />".$share[3];
|
||||||
break;
|
break;
|
||||||
case 7:
|
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;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$text = $preshare."RT @".$userid_compact." ".$share[3];
|
$text = $preshare."RT @".$userid_compact.": ".$share[3];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$headline = trim($share[1]).'<div class="shared_header">';
|
$headline = trim($share[1]).'<div class="shared_header">';
|
||||||
|
@ -525,8 +525,12 @@ function GetProfileUsername($profile, $username, $compact = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile);
|
$gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile);
|
||||||
if ($gplus != $profile)
|
if ($gplus != $profile) {
|
||||||
return($username." (".$gplus.")");
|
if ($compact)
|
||||||
|
return($gplususername." (".$username.")");
|
||||||
|
else
|
||||||
|
return($username." (".$gplus.")");
|
||||||
|
}
|
||||||
|
|
||||||
$friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile);
|
$friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile);
|
||||||
if ($friendica != $profile) {
|
if ($friendica != $profile) {
|
||||||
|
|
|
@ -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_RETURNTRANSFER,true);
|
||||||
//@curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
|
|
||||||
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; 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_RETURNTRANSFER,true);
|
||||||
curl_setopt($ch, CURLOPT_POST,1);
|
curl_setopt($ch, CURLOPT_POST,1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
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)) {
|
if(intval($timeout)) {
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, $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_TIMEOUT, 10);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
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);
|
$header = curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
|
@ -65,25 +65,7 @@ function community_content(&$a, $update = 0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
$r = community_getitems($a->pager['start'], $a->pager['itemspage']);
|
||||||
`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'])
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
if(! count($r)) {
|
if(! count($r)) {
|
||||||
info( t('No results.') . EOL);
|
info( t('No results.') . EOL);
|
||||||
|
@ -93,21 +75,27 @@ function community_content(&$a, $update = 0) {
|
||||||
$maxpostperauthor = get_config('system','max_author_posts_community_page');
|
$maxpostperauthor = get_config('system','max_author_posts_community_page');
|
||||||
|
|
||||||
if ($maxpostperauthor != 0) {
|
if ($maxpostperauthor != 0) {
|
||||||
|
$count = 1;
|
||||||
$previousauthor = "";
|
$previousauthor = "";
|
||||||
$numposts = 0;
|
$numposts = 0;
|
||||||
$s = array();
|
$s = array();
|
||||||
|
|
||||||
foreach ($r AS $row=>$item) {
|
do {
|
||||||
if ($previousauthor == $item["author-link"])
|
foreach ($r AS $row=>$item) {
|
||||||
++$numposts;
|
if ($previousauthor == $item["author-link"])
|
||||||
else
|
++$numposts;
|
||||||
$numposts = 0;
|
else
|
||||||
|
$numposts = 0;
|
||||||
|
|
||||||
$previousauthor = $item["author-link"];
|
$previousauthor = $item["author-link"];
|
||||||
|
|
||||||
if ($numposts < $maxpostperauthor)
|
if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage']))
|
||||||
$s[] = $item;
|
$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
|
} else
|
||||||
$s = $r;
|
$s = $r;
|
||||||
|
|
||||||
|
@ -125,3 +113,26 @@ function community_content(&$a, $update = 0) {
|
||||||
return $o;
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true) {
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
//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);
|
$header = curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
Loading…
Reference in a new issue