aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVasudev Kamath <kamathvasudev@gmail.com>2012-05-12 12:10:09 +0530
committerVasudev Kamath <kamathvasudev@gmail.com>2012-05-12 12:10:09 +0530
commit10db2f00f9f90cb7ee9fbd94a5c986427de779c2 (patch)
tree9504ad13c592621521f7051fb06b5ca81ce1d757 /include
parentb5e857c0e7ccf4ef3d33e5b6d0a4325b693a8e80 (diff)
parent2454028ef61a3ea1dd8308896c8bbf1f04f97ac9 (diff)
downloadvolse-hubzilla-10db2f00f9f90cb7ee9fbd94a5c986427de779c2.tar.gz
volse-hubzilla-10db2f00f9f90cb7ee9fbd94a5c986427de779c2.tar.bz2
volse-hubzilla-10db2f00f9f90cb7ee9fbd94a5c986427de779c2.zip
Merge branch 'master' of git://github.com/friendica/friendica
Diffstat (limited to 'include')
-rw-r--r--include/contact_widgets.php3
-rw-r--r--include/conversation.php9
-rw-r--r--include/delivery.php11
-rw-r--r--include/diaspora.php18
-rw-r--r--include/expire.php6
-rw-r--r--include/items.php16
-rw-r--r--include/onepoll.php6
-rw-r--r--include/plugin.php11
-rw-r--r--include/poller.php4
-rw-r--r--include/queue_fn.php11
-rw-r--r--include/text.php6
11 files changed, 83 insertions, 18 deletions
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index 42d3afdee..ce1cdbad5 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -183,7 +183,8 @@ function common_friends_visitor_widget($profile_uid) {
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
'$base' => $a->get_baseurl(),
'$uid' => $profile_uid,
- '$cid' => $cid,
+ '$cid' => (($cid) ? $cid : '0'),
+ '$linkmore' => (($t > 5) ? 'true' : ''),
'$more' => t('show more'),
'$items' => $r
));
diff --git a/include/conversation.php b/include/conversation.php
index 521b4623b..6bf673b97 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -278,6 +278,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
else
$nickname = $a->user['nickname'];
+ // prevent private email from leaking.
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ continue;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
if($item['author-link'] && (! $item['author-name']))
@@ -447,8 +450,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
else {
// prevent private email reply to public conversation from leaking.
- if($item['private'] && ! $threads[$threadsid]['private'])
- continue;
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ continue;
$comments_seen ++;
$comment_lastcollapsed = false;
@@ -959,7 +962,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$o .= replace_macros($tpl,array(
- '$return_path' => $a->cmd,
+ '$return_path' => $a->query_string,
'$action' => $a->get_baseurl(true) . '/item',
'$share' => (x($x,'button') ? $x['button'] : t('Share')),
'$upload' => t('Upload photo'),
diff --git a/include/delivery.php b/include/delivery.php
index 28d81226a..5f84a548a 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -347,7 +347,10 @@ function delivery_run($argv, $argc){
}
}
- $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ if(! was_recently_delayed($contact['id']))
+ $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ else
+ $deliver_status = (-1);
logger('notifier: dfrn_delivery returns ' . $deliver_status);
@@ -390,7 +393,11 @@ function delivery_run($argv, $argc){
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
- $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ if(! was_recently_delayed($contact['id']))
+ $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ else
+ $deliver_status = (-1);
+
if($deliver_status == (-1)) {
// queue message for redelivery
add_to_queue($contact['id'],NETWORK_OSTATUS,$slappy);
diff --git a/include/diaspora.php b/include/diaspora.php
index 5069c1127..2051de5fc 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -2298,14 +2298,20 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch) {
logger('diaspora_transmit: ' . $logid . ' ' . $dest_url);
- if(! intval(get_config('system','diaspora_test')))
- post_url($dest_url . '/', $slap);
+ if(was_recently_delayed($contact['id'])) {
+ $return_code = 0;
+ }
else {
- logger('diaspora_transmit: test_mode');
- return 200;
+ if(! intval(get_config('system','diaspora_test'))) {
+ post_url($dest_url . '/', $slap);
+ $return_code = $a->get_curl_code();
+ }
+ else {
+ logger('diaspora_transmit: test_mode');
+ return 200;
+ }
}
-
- $return_code = $a->get_curl_code();
+
logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code);
if((! $return_code) || (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))) {
diff --git a/include/expire.php b/include/expire.php
index 5fa0ec758..755cd2494 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -32,7 +32,11 @@ function expire_run($argv, $argc){
// physically remove anything that has been deleted for more than two months
$r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
- q("optimize table item");
+
+ // make this optional as it could have a performance impact on large sites
+
+ if(intval(get_config('system','optimize_items')))
+ q("optimize table item");
logger('expire: start');
diff --git a/include/items.php b/include/items.php
index e9df9b00c..129499967 100644
--- a/include/items.php
+++ b/include/items.php
@@ -119,7 +119,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`,
+ `contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
@@ -952,7 +952,7 @@ function tag_deliver($uid,$item_id) {
$mention = false;
- $u = q("select uid, nickname, language, username, email, `page-flags`, `notify-flags` from user where uid = %d limit 1",
+ $u = q("select * from user where uid = %d limit 1",
intval($uid)
);
if(! count($u))
@@ -1027,10 +1027,20 @@ function tag_deliver($uid,$item_id) {
if(! count($c))
return;
- q("update item set wall = 1, origin = 1, forum_mode = 1, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s' where id = %d limit 1",
+ // also reset all the privacy bits to the forum default permissions
+
+ $private = ($u[0]['allow_cid'] || $u[0]['allow_gid'] || $u[0]['deny_cid'] || $u[0]['deny_gid']) ? 1 : 0;
+
+ q("update item set wall = 1, origin = 1, forum_mode = 1, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
+ `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d limit 1",
dbesc($c[0]['name']),
dbesc($c[0]['url']),
dbesc($c[0]['thumb']),
+ intval($private),
+ dbesc($u[0]['allow_cid']),
+ dbesc($u[0]['allow_gid']),
+ dbesc($u[0]['deny_cid']),
+ dbesc($u[0]['deny_gid']),
intval($item_id)
);
diff --git a/include/onepoll.php b/include/onepoll.php
index 42bce0f68..a64922aa3 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -25,6 +25,7 @@ function onepoll_run($argv, $argc){
require_once('include/email.php');
require_once('include/socgraph.php');
require_once('include/pidfile.php');
+ require_once('include/queue_fn.php');
load_config('config');
load_config('system');
@@ -54,6 +55,9 @@ function onepoll_run($argv, $argc){
return;
}
+ if(was_recently_delayed($contact_id))
+ return;
+
$d = datetime_convert();
// Only poll from those with suitable relationships,
@@ -452,7 +456,7 @@ function onepoll_run($argv, $argc){
if($xml) {
logger('poller: received xml : ' . $xml, LOGGER_DATA);
- if(! strstr($xml,'<?xml')) {
+ if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) {
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
diff --git a/include/plugin.php b/include/plugin.php
index 4ff78a8b4..ae8eee78a 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -70,8 +70,10 @@ function reload_plugins() {
$installed = array();
$parr = explode(',',$plugins);
+
if(count($parr)) {
foreach($parr as $pl) {
+
$pl = trim($pl);
$fname = 'addon/' . $pl . '/' . $pl . '.php';
@@ -101,6 +103,7 @@ function reload_plugins() {
}
}
}
+
}}
@@ -163,6 +166,14 @@ function call_hooks($name, &$data = null) {
$func = $hook[HOOK_FUNCTION];
$func($a,$data);
}
+ else {
+ // remove orphan hooks
+ q("delete from hook where hook = '%s' and file = '$s' and function = '%s' limit 1",
+ dbesc($hook[HOOK_HOOK]),
+ dbesc($hook[HOOK_FILE]),
+ dbesc($hook[HOOK_FUNCTION])
+ );
+ }
}
}
}
diff --git a/include/poller.php b/include/poller.php
index f6553c846..6b12445d1 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -126,7 +126,9 @@ function poller_run($argv, $argc){
$force = true;
}
- $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
+ $interval = intval(get_config('system','poll_interval'));
+ if(! $interval)
+ $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
$sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3c1087f4e..2aca338f5 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -15,6 +15,17 @@ function remove_queue_item($id) {
);
}
+function was_recently_delayed($cid) {
+
+ $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
+ and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
+ intval($cid)
+ );
+ if(count($r))
+ return true;
+ return false;
+}
+
function add_to_queue($cid,$network,$msg,$batch = false) {
diff --git a/include/text.php b/include/text.php
index 1b5b0afd4..e3c683338 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1524,3 +1524,9 @@ function fix_mce_lf($s) {
$s = str_replace("\n\n","\n",$s);
return $s;
}
+
+
+function protect_sprintf($s) {
+ return(str_replace('%','%%',$s));
+}
+