From afa88154114d5632cb13e7c3f56143cccdfd7daa Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 05:28:08 -0700 Subject: bug #447 - make followed feeds private --- include/items.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index ccc11d5be..95a885a1b 100755 --- a/include/items.php +++ b/include/items.php @@ -693,6 +693,8 @@ function encode_rel_links($links) { return xmlify($o); } + + function item_store($arr,$force_parent = false) { // If a Diaspora signature structure was passed in, pull it out of the @@ -806,6 +808,14 @@ function item_store($arr,$force_parent = false) { $deny_cid = $r[0]['deny_cid']; $deny_gid = $r[0]['deny_gid']; $arr['wall'] = $r[0]['wall']; + + // if the parent is private, force privacy for the entire conversation + // This differs from the above settings as it subtly allows comments from + // email correspondents to be private even if the overall thread is not. + + if($r[0]['private']) + $arr['private'] = 1; + } else { @@ -1835,9 +1845,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['last-child'] = 1; } - if(($contact['network'] === NETWORK_FEED) || (! strlen($contact['notify']))) { - // one way feed - no remote comment ability - $datarray['last-child'] = 0; + if($contact['network'] === NETWORK_FEED) { + if(! strlen($contact['notify'])) { + // one way feed - no remote comment ability + $datarray['last-child'] = 0; + } + $datarray['private'] = 1; } // This is my contact on another system, but it's really me. -- cgit v1.2.3 From 3b9c3d886d0c5fcc289950a2c4aeff8457a24217 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 16:21:27 -0700 Subject: sheesh --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a9c6287a9..68693bb9f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -546,7 +546,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $likebuttons = ''; - $shareable = ((($profile_owner == local_user()) && (! $item['private'])) ? true : false); //($mode != 'display') && + $shareable = ((($profile_owner == local_user()) && ((! $item['private']) || $item['network'] === NETWORK_FEED)) ? true : false); if($page_writeable) { if($toplevelpost) { -- cgit v1.2.3 From 09f74be14c94c722a63371cacd7e99a2e8bd7733 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 17:24:16 -0700 Subject: variable confusion in poller, don't allow negative page offsets --- include/onepoll.php | 4 ++-- include/poller.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/onepoll.php b/include/onepoll.php index ba7d5ebaf..02763cf4b 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -94,8 +94,8 @@ function onepoll_run($argv, $argc){ $t = $contact['last-update']; if($contact['subhub']) { - $interval = get_config('system','pushpoll_frequency'); - $contact['priority'] = (($interval !== false) ? intval($interval) : 3); + $poll_interval = get_config('system','pushpoll_frequency'); + $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3); $hub_update = false; if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) diff --git a/include/poller.php b/include/poller.php index 6b12445d1..fefc9b381 100644 --- a/include/poller.php +++ b/include/poller.php @@ -201,8 +201,8 @@ function poller_run($argv, $argc){ if($contact['subhub']) { - $interval = get_config('system','pushpoll_frequency'); - $contact['priority'] = (($interval !== false) ? intval($interval) : 3); + $poll_interval = get_config('system','pushpoll_frequency'); + $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3); $hub_update = false; if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force) -- cgit v1.2.3 From 75104416e07499316444041adfa51ba3c967fd59 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 18:14:49 -0700 Subject: reduce reverted edits due to edit arriving before original --- include/items.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 95a885a1b..638a8212c 100755 --- a/include/items.php +++ b/include/items.php @@ -22,8 +22,6 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) if($a->argv[$x] === 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1])) $category = $a->argv[$x+1]; } - - } @@ -1645,6 +1643,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + + // do not accept (ignore) an earlier edit than one we currently have. + if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + continue; + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), @@ -1791,6 +1794,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + + // do not accept (ignore) an earlier edit than one we currently have. + if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + continue; + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), @@ -2277,7 +2285,12 @@ function local_delivery($importer,$data) { if(count($r)) { $iid = $r[0]['id']; - if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + + // do not accept (ignore) an earlier edit than one we currently have. + if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + continue; + logger('received updated comment' , LOGGER_DEBUG); $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), @@ -2456,6 +2469,11 @@ function local_delivery($importer,$data) { if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + + // do not accept (ignore) an earlier edit than one we currently have. + if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + continue; + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), @@ -2622,6 +2640,11 @@ function local_delivery($importer,$data) { if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + + // do not accept (ignore) an earlier edit than one we currently have. + if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + continue; + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), -- cgit v1.2.3 From 24e85c95b66dac2bd046ebec5c90bb7f2e2de0b8 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 19:36:04 -0700 Subject: date based profile wall filter - backend --- include/text.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index d4a4d5580..f408e0df6 100644 --- a/include/text.php +++ b/include/text.php @@ -1541,3 +1541,16 @@ function protect_sprintf($s) { return(str_replace('%','%%',$s)); } + +function is_a_date_arg($s) { + $i = intval($s); + if($i > 1900) { + $y = date('Y'); + if($i <= $y+1 && strpos($s,'-') == 4) { + $m = intval(substr($s,5)); + if($m > 0 && $m <= 12) + return true; + } + } + return false; +} -- cgit v1.2.3 From b7e2f802d8eec883276a3a7b30aa418aee1fb2a4 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 11 Jun 2012 21:50:10 -0700 Subject: revert an optimisation that was wrong --- include/items.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 638a8212c..38bdf31c0 100755 --- a/include/items.php +++ b/include/items.php @@ -1853,13 +1853,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['last-child'] = 1; } - if($contact['network'] === NETWORK_FEED) { - if(! strlen($contact['notify'])) { + if(($contact['network'] === NETWORK_FEED) || (! strlen($contact['notify']))) { // one way feed - no remote comment ability $datarray['last-child'] = 0; - } - $datarray['private'] = 1; } + if($contact['network'] === NETWORK_FEED) + $datarray['private'] = 1; // This is my contact on another system, but it's really me. // Turn this into a wall post. -- cgit v1.2.3 From 33a4e45f6bdaa249f6aa0b569b704c74a1bd7141 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Tue, 12 Jun 2012 07:09:50 +0200 Subject: Add a hook for post-processing remote items after they've been stored in the database and have an ID --- include/items.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 66e219ddf..037de35eb 100755 --- a/include/items.php +++ b/include/items.php @@ -900,6 +900,16 @@ function item_store($arr,$force_parent = false) { intval($current_post) ); + $arr['id'] = $current_post; + $arr['parent'] = $parent_id; + $arr['allow_cid'] = $allow_cid; + $arr['allow_gid'] = $allow_gid; + $arr['deny_cid'] = $deny_cid; + $arr['deny_gid'] = $deny_gid; + $arr['private'] = $private; + $arr['deleted'] = $parent_deleted; + call_hooks('post_remote_end',$arr); + // update the commented timestamp on the parent q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", -- cgit v1.2.3 From b6ff71acaab74169aeef575cd20cb7cba0756c42 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 02:06:29 -0700 Subject: survive bad/un-parseable input to datetime_convert --- include/datetime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index 3b1491e4d..f6bf1041e 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -87,7 +87,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d $from = 'UTC'; if($to === '') $to = 'UTC'; - if($s === '') + if($s === '' || (! is_string($s))) $s = 'now'; // Slight hackish adjustment so that 'zero' datetime actually returns what is intended -- cgit v1.2.3 From a1c407e017b89634ac48b0c14d7f10816d1c1204 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 12 Jun 2012 12:39:28 +0300 Subject: Removed "oauth/authorize" from the list of not implemented functions since it is implemented in "mod/api.php" --- include/api.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 9925b5766..9f2a5fb3b 100644 --- a/include/api.php +++ b/include/api.php @@ -1654,7 +1654,6 @@ account/update_profile_background_image account/update_profile_image blocks/create blocks/destroy -oauth/authorize Not implemented in status.net: statuses/retweeted_to_me -- cgit v1.2.3 From 1dd52c20cf0e9affc49c2dbbe364f102e9f23e53 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 02:47:05 -0700 Subject: move parens to proper place --- include/items.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d543dcab0..bb81d1a45 100755 --- a/include/items.php +++ b/include/items.php @@ -1655,7 +1655,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. - if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -1806,7 +1806,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. - if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -2297,7 +2297,7 @@ function local_delivery($importer,$data) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. - if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; logger('received updated comment' , LOGGER_DEBUG); @@ -2480,7 +2480,7 @@ function local_delivery($importer,$data) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. - if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -2651,7 +2651,7 @@ function local_delivery($importer,$data) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. - if(datetime_convert('UTC','UTC',$datarray['edited'] < $r[0]['edited'])) + if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) continue; $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", -- cgit v1.2.3 From 832d9eeaaf7c439f3f8802d35e0e4a40509bddf5 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 16:17:34 -0700 Subject: more fixes --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index f408e0df6..8948bf8c4 100644 --- a/include/text.php +++ b/include/text.php @@ -1059,7 +1059,7 @@ function feed_salmonlinks($nick) { if(! function_exists('get_plink')) { function get_plink($item) { $a = get_app(); - if (x($item,'plink') && (! $item['private'])){ + if (x($item,'plink') && ((! $item['private']) || ($item['network'] === NETWORK_FEED))){ return array( 'href' => $item['plink'], 'title' => t('link to source'), -- cgit v1.2.3 From 920ea2e1c759b96bbcad246422b33d7f2c8fc552 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 20:46:30 -0700 Subject: archive widget --- include/items.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index bb81d1a45..8a655594e 100755 --- a/include/items.php +++ b/include/items.php @@ -3390,3 +3390,50 @@ function drop_item($id,$interactive = true) { } } + + +function first_post_date($uid,$wall = false) { + $r = q("select created from item + where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0 + order by created asc limit 1", + intval($uid), + intval($wall ? 1 : 0) + ); + if(count($r)) + return substr($r[0]['created'],0,10); + return false; +} + +function posted_dates($uid,$wall) { + $dnow = datetime_convert('','','now','Y-m-d'); + + $dthen = first_post_date($uid,$wall); + if(! $dthen) + return array(); + + $ret = array(); + while($dnow >= $dthen) { + $start_month = datetime_convert('','','first day of ' . $dnow,'Y-m-d'); + $end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d'); + $str = day_translate(datetime_convert('','',$dnow,'F Y')); + $ret[] = array($str,$end_month,$start_month); + $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d'); + } + return $ret; +} + + +function posted_date_widget($url,$uid,$wall) { + $o = ''; + $ret = posted_dates($uid,$wall); + if(! count($ret)) + return $o; + + $o = replace_macros(get_markup_template('posted_date_widget.tpl'),array( + '$title' => t('Archives'), + '$size' => ((count($ret) > 6) ? 6 : count($ret)), + '$url' => $url, + '$dates' => $ret + )); + return $o; +} \ No newline at end of file -- cgit v1.2.3 From 08af43f3964860f17019fdc42e378a8a0904fe74 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 21:30:17 -0700 Subject: edge case --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 8a655594e..f2dde23a7 100755 --- a/include/items.php +++ b/include/items.php @@ -3417,6 +3417,8 @@ function posted_dates($uid,$wall) { $end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d'); $str = day_translate(datetime_convert('','',$dnow,'F Y')); $ret[] = array($str,$end_month,$start_month); + if($start_month < $dthen) + break; $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d'); } return $ret; -- cgit v1.2.3 From d955813f22d5151046733fc55349112c44a16277 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 21:34:28 -0700 Subject: tracking another edge case --- include/items.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index f2dde23a7..5d9c36d94 100755 --- a/include/items.php +++ b/include/items.php @@ -3393,14 +3393,16 @@ function drop_item($id,$interactive = true) { function first_post_date($uid,$wall = false) { - $r = q("select created from item + $r = q("select id, created from item where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0 order by created asc limit 1", intval($uid), intval($wall ? 1 : 0) ); - if(count($r)) + if(count($r)) { + logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); return substr($r[0]['created'],0,10); + } return false; } -- cgit v1.2.3 From 82ad881c853a96b540ca8eebc16b68661a2bbdef Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 21:38:10 -0700 Subject: think this will fix it --- include/items.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 5d9c36d94..6f2e19f6a 100755 --- a/include/items.php +++ b/include/items.php @@ -3395,6 +3395,7 @@ function drop_item($id,$interactive = true) { function first_post_date($uid,$wall = false) { $r = q("select id, created from item where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0 + and id = parent order by created asc limit 1", intval($uid), intval($wall ? 1 : 0) -- cgit v1.2.3 From bbdb8751e5c17db3ebdfb67dd363a65150df1e62 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 21:39:39 -0700 Subject: that was it --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 6f2e19f6a..2a0a9a426 100755 --- a/include/items.php +++ b/include/items.php @@ -3401,7 +3401,7 @@ function first_post_date($uid,$wall = false) { intval($wall ? 1 : 0) ); if(count($r)) { - logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); +// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); return substr($r[0]['created'],0,10); } return false; -- cgit v1.2.3 From a424fecdae3b54b47778ed7a52452ff80c2bf631 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Jun 2012 22:52:34 -0700 Subject: this should catch any weirdness caused by being in different timezones and making your first post on the 31st of March --- include/items.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2a0a9a426..35a4396dc 100755 --- a/include/items.php +++ b/include/items.php @@ -3402,26 +3402,32 @@ function first_post_date($uid,$wall = false) { ); if(count($r)) { // logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); - return substr($r[0]['created'],0,10); + return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10); } return false; } function posted_dates($uid,$wall) { - $dnow = datetime_convert('','','now','Y-m-d'); + $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d'); $dthen = first_post_date($uid,$wall); if(! $dthen) return array(); + // If it's near the end of a long month, backup to the 28th so that in + // consecutive loops we'll always get a whole month difference. + + if(intval(substr($dnow,8)) > 28) + $dnow = substr($dnow,0,8) . '28'; + if(intval(substr($dthen,8)) > 28) + $dnow = substr($dthen,0,8) . '28'; + $ret = array(); while($dnow >= $dthen) { $start_month = datetime_convert('','','first day of ' . $dnow,'Y-m-d'); $end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d'); $str = day_translate(datetime_convert('','',$dnow,'F Y')); $ret[] = array($str,$end_month,$start_month); - if($start_month < $dthen) - break; $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d'); } return $ret; -- cgit v1.2.3 From 46cb8174fa2f0633caa179b10d6e1776d853f4ea Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 13 Jun 2012 11:55:21 -0400 Subject: enotify: rework strings to more easy to translate --- include/enotify.php | 62 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index fe0f128b6..89ecc3703 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -41,8 +41,8 @@ function notification($params) { $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename); - $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename); - $epreamble = sprintf( t('%s sent you %s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]'); + $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename); + $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to your private messages.'); $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); @@ -66,27 +66,38 @@ function notification($params) { ); } - $possess_desc = str_replace('',item_post_type($p[0]),$possess_desc); + $item_post_type = item_post_type($p[0]); + //$possess_desc = str_replace('',$possess_desc); // "a post" - $dest_str = sprintf($possess_desc,'a'); + $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'), + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $itemlink, + $item_post_type); // "George Bull's post" if($p) - $dest_str = sprintf($possess_desc,sprintf( t("%s's"),$p[0]['author-name'])); + $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'), + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $itemlink, + $p[0]['author-name'] + $item_post_type); // "your post" if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) - $dest_str = sprintf($possess_desc, t('your') ); + $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'), + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $itemlink, + $item_post_type); // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%d by %s'), $parent_id, $params['source_name']); + $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %1$s'), $parent_id, $params['source_name']); $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); - $epreamble = sprintf( t('%s commented on %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . $dest_str . '[/url]'); + $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -97,9 +108,11 @@ function notification($params) { if($params['type'] == NOTIFY_WALL) { $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']); - $preamble = sprintf( t('%s posted to your profile wall at %s') , $params['source_name'], $sitename); + $preamble = sprintf( t('%1$s posted to your profile wall at %1$s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%s posted to %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your profile wall.') . '[/url]'); + $epreamble = sprintf( t('%1$s posted to [url=%2s]your wall[/url]') , + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $itemlink); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -109,8 +122,10 @@ function notification($params) { if($params['type'] == NOTIFY_TAGSELF) { $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']); - $preamble = sprintf( t('%s tagged you at %s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%s %s.') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('tagged you') . '[/url]'); + $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename); + $epreamble = sprintf( t('%1$s [url=%2s]tagged you[/url].') , + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $params['link']); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -120,8 +135,10 @@ function notification($params) { if($params['type'] == NOTIFY_TAGSHARE) { $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']); - $preamble = sprintf( t('%s tagged your post at %s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%s tagged %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your post') . '[/url]' ); + $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename); + $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') , + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', + $itemlink); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -131,8 +148,10 @@ function notification($params) { if($params['type'] == NOTIFY_INTRO) { $subject = sprintf( t('[Friendica:Notify] Introduction received')); - $preamble = sprintf( t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename); - $epreamble = sprintf( t('You\'ve received %s from %s.'), '[url=$itemlink]' . t('an introduction') . '[/url]' , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename); + $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'), + $itemlink, + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = sprintf( t('You may visit their profile at %s'),$params['source_link']); $sitelink = t('Please visit %s to approve or reject the introduction.'); @@ -143,11 +162,12 @@ function notification($params) { if($params['type'] == NOTIFY_SUGGEST) { $subject = sprintf( t('[Friendica:Notify] Friend suggestion received')); - $preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename); - $epreamble = sprintf( t('You\'ve received %s for %s from %s.'), - '[url=$itemlink]' . t('a friend suggestion') . '[/url]', - '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]', - '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename); + $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'), + $itemlink, + '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]', + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + $body = t('Name:') . ' ' . $params['item']['name'] . "\n"; $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n"; $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']); -- cgit v1.2.3 From feab17bfea374fd753b18157eeb8bf5cd61954cf Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 13 Jun 2012 12:08:34 -0400 Subject: enotify: fix stupid typo --- include/enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index 89ecc3703..aba2f8516 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -80,7 +80,7 @@ function notification($params) { $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, - $p[0]['author-name'] + $p[0]['author-name'], $item_post_type); // "your post" -- cgit v1.2.3 From e8e1de36031fcd1adb569f66dcaedecaa8284bd6 Mon Sep 17 00:00:00 2001 From: Erkan Yilmaz Date: Wed, 13 Jun 2012 20:41:53 +0200 Subject: add missing bracket --- include/datetime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index f6bf1041e..58a618610 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -87,7 +87,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d $from = 'UTC'; if($to === '') $to = 'UTC'; - if($s === '' || (! is_string($s))) + if( ($s === '') || (! is_string($s)) ) $s = 'now'; // Slight hackish adjustment so that 'zero' datetime actually returns what is intended -- cgit v1.2.3 From d908c9dd7196276e1364f77abb053aba3dce77af Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 13 Jun 2012 16:17:45 -0700 Subject: disable archive widget for PHP < 5.3 --- include/items.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 35a4396dc..5c797424b 100755 --- a/include/items.php +++ b/include/items.php @@ -3436,6 +3436,18 @@ function posted_dates($uid,$wall) { function posted_date_widget($url,$uid,$wall) { $o = ''; + + // "first day of " constructs were added in php 5.3 + // TODO: emulate posted_dates() logic for prior releases + + if(version_compare(PHP_VERSION, '5.3.0') < 0) + return $o; + + // For former Facebook folks that left because of "timeline" + + if($wall && intval(get_pconfig($uid,'system','no_wall_archive_widget'))) + return $o; + $ret = posted_dates($uid,$wall); if(! count($ret)) return $o; -- cgit v1.2.3 From 7d8b087f4a90dfa8b69bb7660cf68a2b021a31a2 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 13 Jun 2012 19:59:20 -0700 Subject: fix to imported youtube videos, updating of contact profile photos, do not remove "dead" contacts but archive them. --- include/Contact.php | 13 +++++- include/Photo.php | 113 +++++++++++++++++++++++++++++++++++++-------------- include/queue_fn.php | 7 ++++ include/text.php | 6 +-- 4 files changed, 105 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 675d1c81e..3b255a072 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -146,12 +146,23 @@ function mark_for_death($contact) { ); } else { + + // TODO: We really should send a notification to the owner after 2-3 weeks + // so they won't be surprised when the contact vanishes and can take + // remedial action if this was a serious mistake or glitch + $expiry = $contact['term-date'] . ' + 32 days '; if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) { // relationship is really truly dead. + // archive them rather than delete + // though if the owner tries to unarchive them we'll start the whole process over again + + q("update contact set `archive` = 1 where id = %d limit 1", + intval($contact['id']) + ); - contact_remove($contact['id']); + //contact_remove($contact['id']); } } diff --git a/include/Photo.php b/include/Photo.php index f769a70a6..da7c49622 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -256,35 +256,81 @@ class Photo { else $guid = get_guid(); - $r = q("INSERT INTO `photo` - ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )", - intval($uid), - intval($cid), - dbesc($guid), - dbesc($rid), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(basename($filename)), - dbesc($this->type), - dbesc($album), - intval($this->height), - intval($this->width), - dbesc($this->imageString()), - intval($scale), - intval($profile), - dbesc($allow_cid), - dbesc($allow_gid), - dbesc($deny_cid), - dbesc($deny_gid) + $x = q("select id from photo where `resource-id` = '%s' and uid = %d and `contact-id` = %d and `scale` = %d limit 1", + dbesc($rid), + intval($uid), + intval($cid), + intval($scale) ); + if(count($x)) { + $r = q("UPDATE `photo` + set `uid` = %d, + `contact-id` = %d, + `guid` = '%s', + `resource-id` = '%s', + `created` = '%s', + `edited` = '%s', + `filename` = '%s', + `type` = '%s', + `album` = '%s', + `height` = %d, + `width` = %d, + `data` = '%s', + `scale` = %d, + `profile` = %d, + `allow_cid` = '%s', + `allow_gid` = '%s', + `deny_cid` = '%s', + `deny_gid` = '%s', + where id = %d limit 1", + + intval($uid), + intval($cid), + dbesc($guid), + dbesc($rid), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(basename($filename)), + dbesc($this->type), + dbesc($album), + intval($this->height), + intval($this->width), + dbesc($this->imageString()), + intval($scale), + intval($profile), + dbesc($allow_cid), + dbesc($allow_gid), + dbesc($deny_cid), + dbesc($deny_gid), + intval($x[0]['id']) + ); + } + else { + $r = q("INSERT INTO `photo` + ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )", + intval($uid), + intval($cid), + dbesc($guid), + dbesc($rid), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(basename($filename)), + dbesc($this->type), + dbesc($album), + intval($this->height), + intval($this->width), + dbesc($this->imageString()), + intval($scale), + intval($profile), + dbesc($allow_cid), + dbesc($allow_gid), + dbesc($deny_cid), + dbesc($deny_gid) + ); + } return $r; } - - - - - }} @@ -326,6 +372,17 @@ function import_profile_photo($photo,$uid,$cid) { $a = get_app(); + $r = q("select `resource-id` from photo where `uid` = %d and `contact-id` = %d and `scale` = 4 and `album` = 'Contact Photos' limit 1", + intval($uid), + intval($cid) + ); + if(count($r)) { + $hash = $r[0]['resource-id']; + } + else { + $hash = photo_new_resource(); + } + $photo_failure = false; $filename = basename($photo); @@ -340,8 +397,6 @@ function import_profile_photo($photo,$uid,$cid) { $img->scaleImageSquare(175); - $hash = photo_new_resource(); - $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 ); if($r === false) @@ -361,8 +416,6 @@ function import_profile_photo($photo,$uid,$cid) { if($r === false) $photo_failure = true; - - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt(); $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt(); $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt(); diff --git a/include/queue_fn.php b/include/queue_fn.php index 2aca338f5..e43912431 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -23,6 +23,13 @@ function was_recently_delayed($cid) { ); if(count($r)) return true; + + $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1", + intval($cid) + ); + if(count($r)) + return true; + return false; } diff --git a/include/text.php b/include/text.php index 8948bf8c4..cc4bee268 100644 --- a/include/text.php +++ b/include/text.php @@ -1255,13 +1255,13 @@ function bb_translate_video($s) { function html2bb_video($s) { - $s = preg_replace('#]+>(.*?)https+://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)#ism', + $s = preg_replace('#]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)#ism', '[youtube]$2[/youtube]', $s); - $s = preg_replace('#](.*?)https+://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)#ism', + $s = preg_replace('#](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)#ism', '[youtube]$2[/youtube]', $s); - $s = preg_replace('#](.*?)https+://player.vimeo.com/video/([0-9]+)(.*?)#ism', + $s = preg_replace('#](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)#ism', '[vimeo]$2[/vimeo]', $s); return $s; -- cgit v1.2.3 From b0a0c1ef4da159293236253e16eb0ba46a590d21 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 13 Jun 2012 20:03:18 -0700 Subject: couple of little fixes to enotify positional params --- include/enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index aba2f8516..81f3e11eb 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -95,7 +95,7 @@ function notification($params) { // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %1$s'), $parent_id, $params['source_name']); + $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']); $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); $epreamble = $dest_str; @@ -108,7 +108,7 @@ function notification($params) { if($params['type'] == NOTIFY_WALL) { $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']); - $preamble = sprintf( t('%1$s posted to your profile wall at %1$s') , $params['source_name'], $sitename); + $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename); $epreamble = sprintf( t('%1$s posted to [url=%2s]your wall[/url]') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', -- cgit v1.2.3 From edeca6d815a8830d92a42a18199087fc6b1798cd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 13 Jun 2012 20:59:19 -0700 Subject: remove php version restriction on archive widget --- include/items.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 5c797424b..3db1a2802 100755 --- a/include/items.php +++ b/include/items.php @@ -3424,8 +3424,10 @@ function posted_dates($uid,$wall) { $ret = array(); while($dnow >= $dthen) { - $start_month = datetime_convert('','','first day of ' . $dnow,'Y-m-d'); - $end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d'); + $dstart = substr($dnow,0,8) . '01'; + $dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5))); + $start_month = datetime_convert('','',$dstart,'Y-m-d'); + $end_month = datetime_convert('','',$dend,'Y-m-d'); $str = day_translate(datetime_convert('','',$dnow,'F Y')); $ret[] = array($str,$end_month,$start_month); $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d'); @@ -3437,12 +3439,6 @@ function posted_dates($uid,$wall) { function posted_date_widget($url,$uid,$wall) { $o = ''; - // "first day of " constructs were added in php 5.3 - // TODO: emulate posted_dates() logic for prior releases - - if(version_compare(PHP_VERSION, '5.3.0') < 0) - return $o; - // For former Facebook folks that left because of "timeline" if($wall && intval(get_pconfig($uid,'system','no_wall_archive_widget'))) -- cgit v1.2.3 From 79e2ae3791ec092f5be4f5b0b635247df2535089 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 13 Jun 2012 22:34:48 -0700 Subject: syntax on sql --- include/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Photo.php b/include/Photo.php index da7c49622..aa6f5f113 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -281,7 +281,7 @@ class Photo { `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', - `deny_gid` = '%s', + `deny_gid` = '%s' where id = %d limit 1", intval($uid), -- cgit v1.2.3 From be090cc8513504edcfaf368915e45308711f7e7c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 14 Jun 2012 16:56:46 -0700 Subject: better handling of dead contacts --- include/Contact.php | 4 ++++ include/onepoll.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 3b255a072..14e1a52cd 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -139,6 +139,10 @@ function terminate_friendship($user,$self,$contact) { if(! function_exists('mark_for_death')) { function mark_for_death($contact) { + + if($contact['archive']) + return; + if($contact['term-date'] == '0000-00-00 00:00:00') { q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), diff --git a/include/onepoll.php b/include/onepoll.php index 02763cf4b..447881ab7 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -139,15 +139,18 @@ function onepoll_run($argv, $argc){ . '&perm=' . $perm ; $handshake_xml = fetch_url($url); + $html_code = $a->get_curl_code(); logger('onepoll: handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA); - if(! $handshake_xml) { + if((! strlen($handshake_xml)) || ($html_code >= 400) || (! $html_code)) { logger("poller: $url appears to be dead - marking for death "); + // dead connection - might be a transient event, or this might // mean the software was uninstalled or the domain expired. // Will keep trying for one month. + mark_for_death($contact); // set the last-update so we don't keep polling -- cgit v1.2.3 From 267681844d81364afce37c86f92b803c3d8e4c48 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 14 Jun 2012 17:27:07 -0700 Subject: poll even if contact hasn't responded recently, so we can update the termination status --- include/conversation.php | 2 +- include/onepoll.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 68693bb9f..1d5a92284 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -173,8 +173,8 @@ function localize_item(&$item){ $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']); } } + // add zrl's to public images if(preg_match_all('/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is',$item['body'],$matches,PREG_SET_ORDER)) { -logger('matched'); foreach($matches as $mtch) { $item['body'] = str_replace($mtch[0],'[url=' . zrl($mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3] ,true) . '][img' . $mtch[4] . ']h' . $mtch[5] . '[/img][/url]',$item['body']); } diff --git a/include/onepoll.php b/include/onepoll.php index 447881ab7..804a166c8 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -54,9 +54,7 @@ function onepoll_run($argv, $argc){ logger('onepoll: no contact'); return; } - - if(was_recently_delayed($contact_id)) - return; + $d = datetime_convert(); @@ -87,7 +85,7 @@ function onepoll_run($argv, $argc){ } $contact = $contacts[0]; - + logger('onepoll: ' . $contact['id'] . ' ' . $contact['name'], LOGGER_DEBUG); $xml = false; -- cgit v1.2.3 From 2efee75557bafc32b20be1cceac047fdeea3bb71 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 14 Jun 2012 17:38:39 -0700 Subject: also mark for death if there isn't any xml to be found --- include/onepoll.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/onepoll.php b/include/onepoll.php index 804a166c8..22f29deb2 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -162,6 +162,9 @@ function onepoll_run($argv, $argc){ if(! strstr($handshake_xml,' Date: Thu, 14 Jun 2012 17:55:30 -0700 Subject: redundant log entry --- include/onepoll.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/onepoll.php b/include/onepoll.php index 22f29deb2..700498efc 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -85,7 +85,6 @@ function onepoll_run($argv, $argc){ } $contact = $contacts[0]; - logger('onepoll: ' . $contact['id'] . ' ' . $contact['name'], LOGGER_DEBUG); $xml = false; -- cgit v1.2.3 From 4faf0e609fe03095069c7a4bcdfc3496e4a28627 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 16 Jun 2012 03:35:45 -0700 Subject: rev update --- include/onepoll.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include') diff --git a/include/onepoll.php b/include/onepoll.php index 700498efc..d68f26883 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -36,11 +36,6 @@ function onepoll_run($argv, $argc){ logger('onepoll: start'); - $abandon_days = intval(get_config('system','account_abandon_days')); - if($abandon_days < 1) - $abandon_days = 0; - - $manual_id = 0; $generation = 0; $hub_update = false; @@ -62,11 +57,6 @@ function onepoll_run($argv, $argc){ // and which have a polling address and ignore Diaspora since // we are unable to match those posts with a Diaspora GUID and prevent duplicates. - $abandon_sql = (($abandon_days) - ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days)) - : '' - ); - $contacts = q("SELECT `contact`.* FROM `contact` WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != '' AND NOT `network` IN ( '%s', '%s' ) -- cgit v1.2.3