From 96857389ac6a9ab11f0543da5b0af3895dfccfaf Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 23 Jun 2011 01:57:14 -0700 Subject: friendika-z initial implementation --- include/acl_selectors.php | 2 ++ include/notifier.php | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 90fdf9c1c..921a8275b 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -64,6 +64,8 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) "; } + + if($privmail) $o .= "\r\n"; + else + $o .= "\r\n"; + + call_hooks($a->module . '_post_' . $selname, $o); + + return $o; +} + + function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) { @@ -106,6 +204,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p return $o; } + function fixacl(&$item) { $item = intval(str_replace(array('<','>'),array('',''),$item)); } -- cgit v1.2.3 From c9604ef57839e16839e69aa23a21ed8921409343 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 25 Jun 2011 19:40:37 -0700 Subject: allow cross-site xrd/lrdd/webfinger --- include/hostxrd.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hostxrd.php b/include/hostxrd.php index 987175c33..7040f927d 100644 --- a/include/hostxrd.php +++ b/include/hostxrd.php @@ -2,6 +2,7 @@ function hostxrd($baseurl) { + header('Access-Control-Allow-Origin: *'); header("Content-type: text/xml"); $tpl = file_get_contents('view/xrd_host.tpl'); echo str_replace('$domain',$baseurl,$tpl); -- cgit v1.2.3 From 3fe1e197254f62e5377c28a24e4d5a75014e931b Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 26 Jun 2011 19:30:57 -0700 Subject: pass notify endpoint with friend suggestions --- include/notifier.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 842e11080..d9f903853 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -71,6 +71,16 @@ function notifier_run($argv, $argc){ if(! count($items)) return; } + elseif($cmd === 'suggest') { + $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1", + intval($item_id) + ); + if(! count($suggest)) + return; + $uid = $suggest[0]['uid']; + $recipients[] = $suggest[0]['cid']; + $item = $suggest[0]; + } else { // find ancestors @@ -126,7 +136,7 @@ function notifier_run($argv, $argc){ // fill this in with a single salmon slap if applicable $slap = ''; - if($cmd != 'mail') { + if($cmd != 'mail' && $cmd != 'suggest') { require_once('include/group.php'); @@ -236,6 +246,26 @@ function notifier_run($argv, $argc){ '$parent_id' => xmlify($item['parent-uri']) )); } + elseif($cmd === 'suggest') { + $notify_hub = false; // suggestions are not public + + $sugg_template = get_markup_template('atom_suggest.tpl'); + + $atom .= replace_macros($sugg_template, array( + '$name' => xmlify($item['name']), + '$url' => xmlify($item['url']), + '$photo' => xmlify($item['photo']), + '$request' => xmlify($item['request']), + '$note' => xmlify($item['note']) + )); + + // We don't need this any more + + q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", + intval($item['id']) + ); + + } else { if($followup) { foreach($items as $item) { // there is only one item -- cgit v1.2.3 From 06a4c0f703d64cae1e72c2901742e3c101623a7b Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 27 Jun 2011 03:03:58 -0700 Subject: ignore current contact on friend suggestion picker --- include/acl_selectors.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index c19a0f5d3..c3e26082e 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -48,14 +48,22 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $mutual = false; $networks = null; $single = false; + $exclude = false; + $size = 4; + + if(is_array($options)) { + if(x($options,'size')) + $size = $options['size']; - if($is_array($options)) { if(x($options,'mutual_friends')) $mutual = true; if(x($options,'single')) $single = true; if(x($options,'multiple')) $single = false; + if(x($options,'exclude')) + $exclude = $options['exclude']; + if(x($options,'networks')) { switch($options['networks']) { case 'DFRN_ONLY': @@ -79,7 +87,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { } } - $x = array('options' => $options, 'single' => $single, 'mutual' => $mutual, 'networks' => $networks); + $x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks); call_hooks('contact_select_options', $x); @@ -91,6 +99,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD)); } + if(intval($x['exclude'])) + $sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude'])); + if(is_array($x['networks']) && count($x['networks'])) { for($y = 0; $y < count($x['networks']) ; $y ++) $x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'"; @@ -99,9 +110,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { } if($x['single']) - $o .= "\r\n"; else - $o .= "\r\n"; $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' -- cgit v1.2.3 From 390fd8e74a9ed1fd25ac2093c18273769675a7da Mon Sep 17 00:00:00 2001 From: "Abinoam P. Marques Jr." Date: Mon, 27 Jun 2011 20:51:33 -0700 Subject: Fixed: Twitter profiles link. --- include/Scrape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index 505d2bf99..553bd529b 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -423,7 +423,7 @@ function probe_url($url) { $poll = $tapi . '?user_id=' . $tid; else $poll = $tapi . '?screen_name=' . $tid; - $profile = 'http://twitter.com/!#/' . $tid; + $profile = 'http://twitter.com/#!/' . $tid; } if(! x($vcard,'fn')) -- cgit v1.2.3 From 0b221e8945ae785dc706d8ea9a9e8e25532c0096 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 28 Jun 2011 21:11:52 -0700 Subject: bug #96 move libraries to library - better alignment of like rotator --- include/Scrape.php | 2 +- include/expire.php | 6 +++--- include/items.php | 2 +- include/poller.php | 6 +++--- include/salmon.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index 553bd529b..698ec9cf0 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -442,7 +442,7 @@ function probe_url($url) { if(x($feedret,'photo')) $vcard['photo'] = $feedret['photo']; - require_once('simplepie/simplepie.inc'); + require_once('library/simplepie/simplepie.inc'); $feed = new SimplePie(); $xml = fetch_url($poll); diff --git a/include/expire.php b/include/expire.php index 3c30e01c1..cf3b7c8e2 100644 --- a/include/expire.php +++ b/include/expire.php @@ -16,9 +16,9 @@ function expire_run($argv, $argc){ unset($db_host, $db_user, $db_pass, $db_data); }; - require_once('session.php'); - require_once('datetime.php'); - require_once('simplepie/simplepie.inc'); + require_once('include/session.php'); + require_once('include/datetime.php'); + require_once('library/simplepie/simplepie.inc'); require_once('include/items.php'); require_once('include/Contact.php'); diff --git a/include/items.php b/include/items.php index 47a38d5e5..63e180f76 100644 --- a/include/items.php +++ b/include/items.php @@ -995,7 +995,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_feed = false) { - require_once('simplepie/simplepie.inc'); + require_once('library/simplepie/simplepie.inc'); $feed = new SimplePie(); $feed->set_raw_data($xml); diff --git a/include/poller.php b/include/poller.php index 7490bfa81..99517a7ee 100644 --- a/include/poller.php +++ b/include/poller.php @@ -17,9 +17,9 @@ function poller_run($argv, $argc){ }; - require_once('session.php'); - require_once('datetime.php'); - require_once('simplepie/simplepie.inc'); + require_once('include/session.php'); + require_once('include/datetime.php'); + require_once('library/simplepie/simplepie.inc'); require_once('include/items.php'); require_once('include/Contact.php'); require_once('include/email.php'); diff --git a/include/salmon.php b/include/salmon.php index 74da98c93..c1af1a852 100644 --- a/include/salmon.php +++ b/include/salmon.php @@ -145,9 +145,9 @@ EOT; // Setup RSA stuff to PKCS#1 sign the data - set_include_path(get_include_path() . PATH_SEPARATOR . 'phpsec'); + set_include_path(get_include_path() . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'phpsec'); - require_once('phpsec/Crypt/RSA.php'); + require_once('library/phpsec/Crypt/RSA.php'); $rsa = new CRYPT_RSA(); $rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1; -- cgit v1.2.3 From d5855967a7088400e561708428d66c7a8105e8a2 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 28 Jun 2011 22:33:02 -0700 Subject: do not translate hidden photo album 'Contact Photos' as it may become unhidden when different language is used. --- include/Photo.php | 6 +++--- include/items.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/Photo.php b/include/Photo.php index 707b0de5d..de4c3d9e0 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -230,21 +230,21 @@ function import_profile_photo($photo,$uid,$cid) { $hash = photo_new_resource(); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 4 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 ); if($r === false) $photo_failure = true; $img->scaleImage(80); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 5 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5 ); if($r === false) $photo_failure = true; $img->scaleImage(48); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 6 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6 ); if($r === false) $photo_failure = true; diff --git a/include/items.php b/include/items.php index 63e180f76..4f6030e5a 100644 --- a/include/items.php +++ b/include/items.php @@ -1072,13 +1072,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee $img->scaleImageSquare(175); $hash = $resource_id; - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 4); + $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 4); $img->scaleImage(80); - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 5); + $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 5); $img->scaleImage(48); - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 6); + $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 6); $a = get_app(); -- cgit v1.2.3 From 1e307e9869b15cf1f76dcfda8f6fd49d05014d14 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Wed, 29 Jun 2011 12:05:09 +0200 Subject: Fix bug #98, add "never" to relative_date(), fix batch operations --- include/datetime.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index a5b388e76..ade202cad 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -178,6 +178,10 @@ function relative_date($posted_date) { $abs = strtotime($localtime); $etime = time() - $abs; + if ($abs==False) { + return t('never'); + } + if ($etime < 1) { return t('less than a second ago'); } -- cgit v1.2.3 From baead9f4c83564e9b6d8c87f62a377ee1226a149 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 29 Jun 2011 03:54:29 -0700 Subject: very minor nit - if $abs is false, return before trying to use false in a numeric calculation also return 'never' if we have an uninitialised date --- include/datetime.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index ade202cad..8c30cf4b7 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -65,9 +65,9 @@ if(! function_exists('datetime_convert')) { function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") { // Slight hackish adjustment so that 'zero' datetime actually returns what is intended - // otherwise we end up with -0001-11-30 ... + // otherwise we end up with -0001-11-30 ... // add 32 days so that we at least get year 00, and then hack around the fact that - // months and days always start with 1. + // months and days always start with 1. if(substr($s,0,10) == '0000-00-00') { $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); @@ -176,23 +176,24 @@ function relative_date($posted_date) { $localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date); $abs = strtotime($localtime); - $etime = time() - $abs; - if ($abs==False) { + if ($posted_date === '0000-00-00 00:00:00' || $abs === False) { return t('never'); } + + $etime = time() - $abs; if ($etime < 1) { return t('less than a second ago'); } $a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')), - 30 * 24 * 60 * 60 => array( t('month'), t('months')), - 7 * 24 * 60 * 60 => array( t('week'), t('weeks')), - 24 * 60 * 60 => array( t('day'), t('days')), - 60 * 60 => array( t('hour'), t('hours')), - 60 => array( t('minute'), t('minutes')), - 1 => array( t('second'), t('seconds')) + 30 * 24 * 60 * 60 => array( t('month'), t('months')), + 7 * 24 * 60 * 60 => array( t('week'), t('weeks')), + 24 * 60 * 60 => array( t('day'), t('days')), + 60 * 60 => array( t('hour'), t('hours')), + 60 => array( t('minute'), t('minutes')), + 1 => array( t('second'), t('seconds')) ); foreach ($a as $secs => $str) { -- cgit v1.2.3 From f4a1820110e6c85f91c7a3dbdada35f76be83f36 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Wed, 29 Jun 2011 16:06:32 +0200 Subject: re-added last item date in admin user page. relative_date return 'never' if null is passed --- 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 8c30cf4b7..a056eaa60 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -177,7 +177,7 @@ function relative_date($posted_date) { $abs = strtotime($localtime); - if ($posted_date === '0000-00-00 00:00:00' || $abs === False) { + if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) { return t('never'); } -- cgit v1.2.3 From 3eb0b4be2a7e0f4d8f9a518114e1daa49f46b59b Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 29 Jun 2011 22:38:30 -0700 Subject: now that we have admin interface, completely remove register approvals from notifications --- include/main.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include') diff --git a/include/main.js b/include/main.js index 5b9dae461..c2772000d 100644 --- a/include/main.js +++ b/include/main.js @@ -47,11 +47,7 @@ if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() } $('#mail-update').html(mail); var intro = $(data).find('intro').text(); - var register = $(data).find('register').text(); - if(intro == 0) { intro = ''; } - if(register != 0 && intro != '') { intro = intro+'/'+register; } - if(register != 0 && intro == '') { intro = '0/'+register; } - if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() } + if(intro == 0) { intro = ''; $('#notify-update').hide() } else { $('#notify-update').show() } $('#notify-update').html(intro); }); -- cgit v1.2.3 From 994011ddb6cc1097214537160a10bf710aedc553 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 01:15:18 -0700 Subject: load db configs (config,system) for all "executables" --- include/directory.php | 24 ++++++++++++++---------- include/expire.php | 4 ++++ include/notifier.php | 3 +++ include/poller.php | 3 +++ include/queue.php | 3 +++ 5 files changed, 27 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/directory.php b/include/directory.php index 2c9daa5ea..cae78adb4 100644 --- a/include/directory.php +++ b/include/directory.php @@ -2,18 +2,22 @@ require_once("boot.php"); function directory_run($argv, $argc){ - global $a, $db; + global $a, $db; - if(is_null($a)){ - $a = new App; - } + if(is_null($a)) { + $a = new App; + } - if(is_null($db)){ - @include(".htconfig.php"); - require_once("dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; + if(is_null($db)) { + @include(".htconfig.php"); + require_once("dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + }; + + load_config('config'); + load_config('system'); + if($argc != 2) return; diff --git a/include/expire.php b/include/expire.php index cf3b7c8e2..64dbe2536 100644 --- a/include/expire.php +++ b/include/expire.php @@ -22,6 +22,10 @@ function expire_run($argv, $argc){ require_once('include/items.php'); require_once('include/Contact.php'); + load_config('config'); + load_config('system'); + + $a->set_baseurl(get_config('system','url')); diff --git a/include/notifier.php b/include/notifier.php index d9f903853..4b97311f6 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -20,6 +20,9 @@ function notifier_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_config('config'); + load_config('system'); + load_hooks(); if($argc < 3) diff --git a/include/poller.php b/include/poller.php index 99517a7ee..4cab5a3b8 100644 --- a/include/poller.php +++ b/include/poller.php @@ -24,6 +24,9 @@ function poller_run($argv, $argc){ require_once('include/Contact.php'); require_once('include/email.php'); + load_config('config'); + load_config('system'); + $a->set_baseurl(get_config('system','url')); load_hooks(); diff --git a/include/queue.php b/include/queue.php index cbda196da..fb65d5c25 100644 --- a/include/queue.php +++ b/include/queue.php @@ -22,6 +22,9 @@ function queue_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_config('config'); + load_config('system'); + $a->set_baseurl(get_config('system','url')); load_hooks(); -- cgit v1.2.3 From 53653f6a4d6b4c9d348d7e9d8eb1648469b031af Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 17:35:35 -0700 Subject: consolidate perrmisions sql, minor duepuntozero validation fixes --- include/security.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'include') diff --git a/include/security.php b/include/security.php index c74a9b4a3..789e47db2 100644 --- a/include/security.php +++ b/include/security.php @@ -44,3 +44,74 @@ function can_write_wall(&$a,$owner) { return false; } + + +function permissions_sql($owner_id,$remote_verified = false,$groups = null) { + + $local_user = local_user(); + $remote_user = remote_user(); + + /** + * Construct permissions + * + * default permissions - anonymous user + */ + + $sql = " AND allow_cid = '' + AND allow_gid = '' + AND deny_cid = '' + AND deny_gid = '' + "; + + /** + * Profile owner - everything is visible + */ + + if(($local_user) && ($local_user == $owner_id)) { + $sql = ''; + } + + /** + * Authenticated visitor. Unless pre-verified, + * check that the contact belongs to this $owner_id + * and load the groups the visitor belongs to. + * If pre-verified, the caller is expected to have already + * done this and passed the groups into this function. + */ + + elseif($remote_user) { + + if(! $remote_verified) { + $r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1", + intval($remote_user), + intval($owner_id) + ); + if(count($r)) { + $remote_verified = true; + $groups = init_groups_visitor($remote_user); + } + } + if($remote_verified) { + + $gs = '<<>>'; // should be impossible to match + + if(is_array($groups) && count($groups)) { + foreach($groups as $g) + $gs .= '|<' . intval($g) . '>'; + } + + $sql = sprintf( + " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) + AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') + ", + intval($remote_user), + intval($remote_user), + dbesc($gs), + dbesc($gs) + ); + } + } + return $sql; +} \ No newline at end of file -- cgit v1.2.3 From cdddfca0b5971d2437eee09ad6985f3df5ae5bfd Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 19:02:11 -0700 Subject: photos were not working in private mail --- include/notifier.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 4b97311f6..9c194d962 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -238,6 +238,8 @@ function notifier_run($argv, $argc){ if($cmd === 'mail') { $notify_hub = false; // mail is not public + $body = fix_private_photos($item['body'],$owner['uid']); + $atom .= replace_macros($mail_template, array( '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), @@ -245,7 +247,7 @@ function notifier_run($argv, $argc){ '$item_id' => xmlify($item['uri']), '$subject' => xmlify($item['title']), '$created' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)), - '$content' => xmlify($item['body']), + '$content' => xmlify($body), '$parent_id' => xmlify($item['parent-uri']) )); } -- cgit v1.2.3 From 481cd708acfd3291eed7eba6af596c541651963c Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 21:56:07 -0700 Subject: allow polling to mostly survive minor memory shortages. --- include/poller.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index 4cab5a3b8..666748cbc 100644 --- a/include/poller.php +++ b/include/poller.php @@ -2,6 +2,7 @@ require_once("boot.php"); + function poller_run($argv, $argc){ global $a, $db; @@ -47,18 +48,26 @@ function poller_run($argv, $argc){ proc_run('php','include/expire.php'); } - // clear old cache q("DELETE FROM `cache` WHERE `updated` < '%s'", dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); $manual_id = 0; + $generation = 0; $hub_update = false; $force = false; + $restart = false; if(($argc > 1) && ($argv[1] == 'force')) $force = true; + if(($argc > 1) && ($argv[1] == 'restart')) { + $restart = true; + $generation = intval($argv[2]); + if(! $generation) + killme(); + } + if(($argc > 1) && intval($argv[1])) { $manual_id = intval($argv[1]); $force = true; @@ -70,7 +79,8 @@ function poller_run($argv, $argc){ $d = datetime_convert(); - call_hooks('cron', $d); + if(! $restart) + call_hooks('cron', $d); $contacts = q("SELECT `id` FROM `contact` @@ -95,7 +105,7 @@ function poller_run($argv, $argc){ continue; foreach($res as $contact) { - + logger('processing a contact'); $xml = false; if($manual_id) @@ -154,6 +164,22 @@ function poller_run($argv, $argc){ continue; } + // Check to see if we are running out of memory - if so spawn a new process and kill this one + + $avail_memory = return_bytes(ini_get('memory_limit')); + $memused = memory_get_peak_usage(true); + if(intval($avail_memory)) { + if(($memused / $avail_memory) > 0.95) { + if($generation + 1 > 10) { + logger('poller: maximum number of spawns exceeded. Terminating.'); + killme(); + } + logger('poller: memory exceeded. ' . $memused . ' bytes used. Spawning new poll.'); + proc_run('php', 'include/poller.php', 'restart', (string) $generation + 1); + killme(); + } + } + $importer_uid = $contact['uid']; $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", -- cgit v1.2.3 From c08b85777aed76a45b0cfbfa381db419f58d047f Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 22:00:08 -0700 Subject: too much logging --- include/poller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index 666748cbc..5565130e9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -105,7 +105,7 @@ function poller_run($argv, $argc){ continue; foreach($res as $contact) { - logger('processing a contact'); + $xml = false; if($manual_id) -- cgit v1.2.3 From 6e5532149a08b264e958202fa971d35b446fac3b Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 23:27:16 -0700 Subject: missing minutes in event listings --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 1032022b3..aab195d24 100644 --- a/include/event.php +++ b/include/event.php @@ -8,7 +8,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; - $bd_format = t('l F d, Y \@ g A') ; // Friday January 18, 2011 @ 8 AM + $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM $o = '
' . "\r\n"; -- cgit v1.2.3 From b1aa77584f972b8c62fd099fa7fe08c36201b631 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Jul 2011 06:14:15 -0700 Subject: indicate currently selected group in group picker --- include/group.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/group.php b/include/group.php index 804d0c58f..fd3439b85 100644 --- a/include/group.php +++ b/include/group.php @@ -136,7 +136,7 @@ function group_public_members($gid) { -function group_side($every="contacts",$each="group",$edit = false) { +function group_side($every="contacts",$each="group",$edit = false, $group_id = 0) { $o = ''; @@ -145,7 +145,7 @@ function group_side($every="contacts",$each="group",$edit = false) { $createtext = t('Create a new group'); $linktext= t('Everybody'); - + $selected = (($group_id == 0 && $every !== 'contacts') ? ' class="group-selected" ' : ''); $o .= <<< EOT
@@ -157,7 +157,7 @@ $o .= <<< EOT \r\n
"; -- cgit v1.2.3 From f53a2d6da95e88573c4a8e36d40f1c9327490025 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Jul 2011 06:23:09 -0700 Subject: add group highlight to other pages --- include/group.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/group.php b/include/group.php index fd3439b85..30a023d41 100644 --- a/include/group.php +++ b/include/group.php @@ -145,7 +145,7 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0 $createtext = t('Create a new group'); $linktext= t('Everybody'); - $selected = (($group_id == 0 && $every !== 'contacts') ? ' class="group-selected" ' : ''); + $selected = (($group_id == 0) ? ' class="group-selected" ' : ''); $o .= <<< EOT
@@ -166,7 +166,7 @@ EOT; ); if(count($r)) { foreach($r as $rr) - $selected = (($group_id == $rr['id'] && $every !== 'contacts') ? ' class="group-selected" ' : ''); + $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : ''); $o .= ' \r\n"; } $o .= " \r\n
\r\n
"; -- cgit v1.2.3 From 813d6c453ceefe284c8736fa4d8038e9d1eebcb2 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Jul 2011 06:26:46 -0700 Subject: missed block --- include/group.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/group.php b/include/group.php index 30a023d41..da4d41748 100644 --- a/include/group.php +++ b/include/group.php @@ -165,9 +165,10 @@ EOT; intval($_SESSION['uid']) ); if(count($r)) { - foreach($r as $rr) + foreach($r as $rr) { $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : ''); $o .= ' \r\n"; + } } $o .= " \r\n \r\n"; -- cgit v1.2.3 From 9816f14d40a04867b2d96891c297252cc4a7006d Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Jul 2011 17:39:16 -0700 Subject: statusnet improvements --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4f6030e5a..9cafaea62 100644 --- a/include/items.php +++ b/include/items.php @@ -1449,11 +1449,11 @@ function new_follower($importer,$contact,$datarray,$item) { } else { - // create contact record - set to readonly + // create contact record $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `photo`, `network`, `rel`, `blocked`, `readonly`, `pending`, `writable` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 1, 1, 1 ) ", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1 ) ", intval($importer['uid']), dbesc(datetime_convert()), dbesc($url), -- cgit v1.2.3 From d28d2ff440efba47ad65cf28eab4be96e0ea05b2 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Jul 2011 18:18:01 -0700 Subject: better (more consistent) handling of ostatus contacts --- include/poller.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index 5565130e9..569eb59d1 100644 --- a/include/poller.php +++ b/include/poller.php @@ -310,13 +310,22 @@ function poller_run($argv, $argc){ // Upgrading DB fields from an older Friendika version // Will only do this once per notify-enabled OStatus contact + // or if relationship changes - if(($contact['notify']) && (! $contact['writable'])) { - q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d LIMIT 1", + $stat_writeable = ((($contact['notify']) && ($contact['rel'] == REL_VIP || $contact['rel'] == REL_BUD)) ? 1 : 0); + + if($stat_writeable != $contact['writable']) { + q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1", + intval($stat_writeable), intval($contact['id']) ); } + // Are we allowed to import from this person? + + if($contact['rel'] == REL_VIP || $contact['blocked'] || $contact['readonly']) + continue; + $xml = fetch_url($contact['poll']); } elseif($contact['network'] === NETWORK_MAIL) { -- cgit v1.2.3 From 24836f2966842b413ae29f325fbb61b30186a5f7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 2 Jul 2011 02:47:01 -0700 Subject: improvied group highlighting, move new group link down --- include/group.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/group.php b/include/group.php index da4d41748..e16c900d9 100644 --- a/include/group.php +++ b/include/group.php @@ -151,10 +151,6 @@ $o .= <<< EOT

Groups

- - \r\n
"; + $o .= " \r\n "; + + $o .= <<< EOT + + + + +EOT; return $o; } -- cgit v1.2.3 From 5ceeb6752d645036b832077d88b71a8825952322 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 3 Jul 2011 19:41:04 -0700 Subject: starred items --- include/conversation.php | 9 +++++++-- include/main.js | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index ff0a7612b..40981d5f4 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -177,6 +177,7 @@ function conversation(&$a, $items, $mode, $update) { $drop = replace_macros($droptpl,array('$id' => $item['id'])); $lock = '
'; + $star = ''; $body = prepare_body($item,true); @@ -197,6 +198,7 @@ function conversation(&$a, $items, $mode, $update) { '$owner_url' => $owner_url, '$owner_photo' => $owner_photo, '$owner_name' => $owner_name, + '$star' => $star, '$drop' => $drop, '$conv' => '' . t('View in context') . '' )); @@ -381,8 +383,8 @@ function conversation(&$a, $items, $mode, $update) { } $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes')) - ? '' + ? '' : ''); @@ -394,6 +396,8 @@ function conversation(&$a, $items, $mode, $update) { $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$select' => t('Select'), '$delete' => t('Delete'))); + $star = (($profile_owner == local_user() && $toplevelpost) ? '' : ''); + $photo = $item['photo']; $thumb = $item['thumb']; @@ -473,6 +477,7 @@ function conversation(&$a, $items, $mode, $update) { '$owner_name' => $owner_name, '$plink' => get_plink($item), '$edpost' => $edpost, + '$star' => $star, '$drop' => $drop, '$vote' => $likebuttons, '$like' => $like, diff --git a/include/main.js b/include/main.js index c2772000d..26c78b277 100644 --- a/include/main.js +++ b/include/main.js @@ -174,6 +174,21 @@ liking = 1; } + function dostar(ident) { + $('#like-rotator-' + ident.toString()).show(); + $.get('starred/' + ident.toString(), function(data) { + if(data.match(/1/)) { + $('#starred-' + ident.toString()).addClass('starred'); + $('#starred-' + ident.toString()).removeClass('unstarred'); + } + else { + $('#starred-' + ident.toString()).addClass('unstarred'); + $('#starred-' + ident.toString()).removeClass('starred'); + } + $('#like-rotator-' + ident.toString()).hide(); + }); + } + function getPosition(e) { var cursor = {x:0, y:0}; if ( e.pageX || e.pageY ) { -- cgit v1.2.3