From 8a40c718fb9f9272ea99094a760f399e323cd66c Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Fri, 11 Mar 2011 00:18:29 +0100 Subject: Move translation functions. Add tt() for plural cases. --- include/pgettext.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/pgettext.php (limited to 'include') diff --git a/include/pgettext.php b/include/pgettext.php new file mode 100644 index 000000000..2ffee70bc --- /dev/null +++ b/include/pgettext.php @@ -0,0 +1,46 @@ +strings,$s)) { + $t = $a->strings[$s]; + return is_array($t)?$t[0]:$t; + } + return $s; +}} + +if(! function_exists('tt')){ +function tt($singular, $plural, $count){ + + $a = get_app(); + + if(x($a->strings,$singular)) { + $t = $a->strings[$singular]; + $k = string_plural_select($count); + return is_array($t)?$t[$k]:$t; + } + + if ($count!=1){ + return $plural; + } else { + return $singular; + } +}} \ No newline at end of file -- cgit v1.2.3 From 0cf647bf6f199586bad2e13973fe034bf5676eea Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 16:47:41 -0700 Subject: don't let somebody install with a bogus db hostname as this seems to lead to spectacular failure modes --- include/dba.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/dba.php b/include/dba.php index d75ed560a..1fdddb8a2 100644 --- a/include/dba.php +++ b/include/dba.php @@ -19,6 +19,22 @@ class dba { public $connected = false; function __construct($server,$user,$pass,$db,$install = false) { + $server = trim($server); + $user = trim($user); + $pass = trim($pass); + $db = trim($db); + + if($install) { + if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) { + if(! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) { + notice( sprintf( t('Cannot locate DNS info for database server \'%s\'',$server))); + $this->connected = false; + $this->db = null; + return; + } + } + } + $this->db = @new mysqli($server,$user,$pass,$db); if(! mysqli_connect_errno()) { $this->connected = true; -- cgit v1.2.3 From aebf9bb4d6bf2cf3e86378a369f2d51996f4f6a6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 19:12:46 -0700 Subject: non-code change --- include/dba.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/dba.php b/include/dba.php index 1fdddb8a2..e2f369f19 100644 --- a/include/dba.php +++ b/include/dba.php @@ -19,6 +19,7 @@ class dba { public $connected = false; function __construct($server,$user,$pass,$db,$install = false) { + $server = trim($server); $user = trim($user); $pass = trim($pass); @@ -77,7 +78,7 @@ class dba { } else { - /* + /** * If dbfail.out exists, we will write any failed calls directly to it, * regardless of any logging that may or may nor be in effect. * These usually indicate SQL syntax errors that need to be resolved. -- cgit v1.2.3 From f2734681e537031926a1e9c142403048b420deee Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 13 Mar 2011 22:07:56 -0700 Subject: friend finder support functions --- include/fcontact.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/fcontact.php (limited to 'include') diff --git a/include/fcontact.php b/include/fcontact.php new file mode 100644 index 000000000..8821a985f --- /dev/null +++ b/include/fcontact.php @@ -0,0 +1,41 @@ + Date: Mon, 14 Mar 2011 18:34:58 -0700 Subject: force last-child on foster children, disallow time travel --- include/items.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index e930ab5d2..2294fe294 100644 --- a/include/items.php +++ b/include/items.php @@ -401,6 +401,17 @@ function get_atom_elements($feed,$item) { $res['edited'] = $item->get_date('c'); + // Disallow time travelling posts + + $d1 = strtotime($res['created']); + $d2 = strtotime($res['edited']); + $d3 = strtotime('now'); + + if($d1 > $d3) + $res['created'] = datetime_convert(); + if($d2 > $d3) + $res['edited'] = datetime_convert(); + $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); @@ -702,6 +713,18 @@ function item_store($arr,$force_parent = false) { intval($current_post) ); + /** + * If this is now the last-child, force all _other_ children of this parent to *not* be last-child + */ + + if($arr['last-child']) { + $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", + dbesc($arr['uri']), + intval($arr['uid']), + intval($current_post) + ); + } + return $current_post; } -- cgit v1.2.3 From 4cc20f1288a59d6ff48a62da62ec056ebd543e14 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 00:56:25 -0700 Subject: fix youtube videos that use https:// urls --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 978b4af69..4caf18766 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -90,7 +90,7 @@ function bbcode($Text) { $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); // Youtube extensions - $Text = preg_replace("/\[youtube\]http:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text); // oembed tag -- cgit v1.2.3 From f01538a54f68c172e09aabed90e2651ca2305675 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 17:31:49 -0700 Subject: content expiration --- include/expire.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/items.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/notifier.php | 34 +++++++++++++++++++++++----------- include/poller.php | 11 +++++++++++ 4 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 include/expire.php (limited to 'include') diff --git a/include/expire.php b/include/expire.php new file mode 100644 index 000000000..3c30e01c1 --- /dev/null +++ b/include/expire.php @@ -0,0 +1,44 @@ +set_baseurl(get_config('system','url')); + + + logger('expire: start'); + + $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); + if(count($r)) { + foreach($r as $rr) { + logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); + item_expire($rr['uid'],$rr['expire']); + } + } + + return; +} + +if (array_search(__file__,get_included_files())===0){ + expire_run($argv,$argc); + killme(); +} diff --git a/include/items.php b/include/items.php index 2294fe294..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -1507,3 +1507,49 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } +function item_expire($uid,$days) { + + if((! $uid) || (! $days)) + return; + + $r = q("SELECT * FROM `item` + WHERE `uid` = %d + AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY + AND `id` = `parent` + AND `deleted` = 0", + intval($uid), + intval($days) + ); + + if(! count($r)) + return; + + logger('expire: # items=' . count($r) ); + + foreach($r as $item) { + + // Only expire posts, not photos and photo comments + + if(strlen($item['resource-id'])) + continue; + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + + // kill the kids + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + + } + + proc_run('php',"include/notifier.php","expire","$uid"); + +} \ No newline at end of file diff --git a/include/notifier.php b/include/notifier.php index 648a07062..ca2304845 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -40,6 +40,7 @@ function notifier_run($argv, $argc){ break; } + $expire = false; $top_level = false; $recipients = array(); $url_recipients = array(); @@ -57,6 +58,17 @@ function notifier_run($argv, $argc){ $item = $message[0]; } + elseif($cmd === 'expire') { + $expire = true; + $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 + AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP - INTERVAL 10 MINUTE", + intval($item_id) + ); + $uid = $item_id; + $item_id = 0; + if(! count($items)) + return; + } else { // find ancestors @@ -76,11 +88,10 @@ function notifier_run($argv, $argc){ intval($parent_id) ); - if(! count($items)){ + if(! count($items)) { return; } - // avoid race condition with deleting entries if($items[0]['deleted']) { @@ -98,11 +109,11 @@ function notifier_run($argv, $argc){ intval($uid) ); - if(count($r)) - $owner = $r[0]; - else { + if(! count($r)) return; - } + + $owner = $r[0]; + $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -117,7 +128,7 @@ function notifier_run($argv, $argc){ $parent = $items[0]; - if($parent['type'] === 'remote') { + if($parent['type'] === 'remote' && (! $expire)) { // local followup to remote post $followup = true; $notify_hub = false; // not public @@ -235,6 +246,7 @@ function notifier_run($argv, $argc){ } else { foreach($items as $item) { + if(! $item['parent']) continue; @@ -242,9 +254,9 @@ function notifier_run($argv, $argc){ if(! $contact) continue; - $atom .= atom_entry($item,'text',$contact,$owner,true); + $atom .= atom_entry($item,'text',$contact,$owner,true); - if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link'])) + if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link']) && (! $expire)) $slaps[] = atom_entry($item,'html',$contact,$owner,true); } } @@ -319,7 +331,7 @@ function notifier_run($argv, $argc){ // only send salmon if public - e.g. if it's ok to notify // a public hub, it's ok to send a salmon - if(count($slaps) && $notify_hub) { + if((count($slaps)) && ($notify_hub) && (! $expire)) { logger('notifier: slapdelivery: ' . $contact['name']); foreach($slaps as $slappy) { if($contact['notify']) { @@ -350,7 +362,7 @@ function notifier_run($argv, $argc){ // send additional slaps to mentioned remote tags (@foo@example.com) - if($slap && count($url_recipients) && $followup && $notify_hub) { + if($slap && count($url_recipients) && $followup && $notify_hub && (! $expire)) { foreach($url_recipients as $url) { if($url) { logger('notifier: urldelivery: ' . $url); diff --git a/include/poller.php b/include/poller.php index a093190a6..8619697d9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -29,6 +29,17 @@ function poller_run($argv, $argc){ proc_run('php',"include/queue.php"); + // once daily run expire in background + + $d1 = get_config('system','last_expire_day'); + $d2 = intval(datetime_convert('UTC','UTC','now','d')); + + if($d2 != intval($d1)) { + set_config('system','last_expire_day',$d2); + proc_run('php','include/expire.php'); + } + + // clear old cache q("DELETE FROM `cache` WHERE `updated` < '%s'", dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); -- cgit v1.2.3 From ea03d9fa86827cbc7e86885bbe2493d8a9739546 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 17 Mar 2011 21:15:27 -0700 Subject: more thorough cleanup on account/contact removal --- include/Contact.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 7cac3c0e0..4ca77d065 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -14,11 +14,13 @@ function user_remove($uid) { q("DELETE FROM `group` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid)); + q("DELETE FROM `event` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `item` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid)); + q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `user` WHERE `uid` = %d", intval($uid)); if($uid == local_user()) { unset($_SESSION['authenticated']); @@ -41,6 +43,9 @@ function contact_remove($id) { q("DELETE FROM `mail` WHERE `contact-id` = %d ", intval($id) ); + q("DELETE FROM `event` WHERE `cid` = %d ", + intval($id) + ); } -- cgit v1.2.3 From 7e33c1072a4a948941e2522afe0123899b0abddd Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 19 Mar 2011 01:19:11 -0700 Subject: stuff to make connecting to diaspora profiles easier --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 051659321..6900c5920 100644 --- a/include/items.php +++ b/include/items.php @@ -905,6 +905,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { require_once('simplepie/simplepie.inc'); + if(! $contact) + logger('consume feed: anonymous'); $feed = new SimplePie(); $feed->set_raw_data($xml); if($datedir) -- cgit v1.2.3 From be67cf663bc645d9825c7d6c6059663fead06645 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 19 Mar 2011 05:10:05 -0700 Subject: minor edits --- include/items.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 6900c5920..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -905,8 +905,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { require_once('simplepie/simplepie.inc'); - if(! $contact) - logger('consume feed: anonymous'); $feed = new SimplePie(); $feed->set_raw_data($xml); if($datedir) -- cgit v1.2.3 From b7292bc673bc7983b1fd933070bc9d6a0a155dbb Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 20 Mar 2011 17:54:50 -0700 Subject: user pref -> block remote wall posting --- include/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 5e79e1edd..c74a9b4a3 100644 --- a/include/security.php +++ b/include/security.php @@ -25,7 +25,7 @@ function can_write_wall(&$a,$owner) { else { $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", + AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", intval($owner), intval(remote_user()), intval(REL_VIP), -- cgit v1.2.3 From 82bd1ce3cb0097ad6be9650e4a1414e819cf8b0c Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 21 Mar 2011 03:33:58 -0700 Subject: installation issues --- include/dba.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dba.php b/include/dba.php index e2f369f19..49b325cf7 100644 --- a/include/dba.php +++ b/include/dba.php @@ -28,7 +28,7 @@ class dba { if($install) { if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) { if(! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) { - notice( sprintf( t('Cannot locate DNS info for database server \'%s\'',$server))); + notice( sprintf( t('Cannot locate DNS info for database server \'%s\''), $server)); $this->connected = false; $this->db = null; return; -- cgit v1.2.3 From ca113bfaa05fdf90a904c3a286a4e69b3a2d2082 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 24 Mar 2011 21:10:51 -0700 Subject: change link to project website --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 4104cf3cf..db3b909af 100644 --- a/include/nav.php +++ b/include/nav.php @@ -124,7 +124,7 @@ function nav(&$a) { $banner = get_config('system','banner'); if($banner === false) - $banner .= 'logoFriendika'; + $banner .= 'logoFriendika'; $a->page['nav'] .= ''; -- cgit v1.2.3 From 8f547283c07483123901ae41c9f70881113cb35d Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 29 Mar 2011 18:20:52 -0700 Subject: update comment count as new comments come in --- include/main.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/main.js b/include/main.js index 824f2dfdf..750cce74c 100644 --- a/include/main.js +++ b/include/main.js @@ -113,12 +113,18 @@ $.get(update_url,function(data) { in_progress = false; + $('.ccollapse-wrapper',data).each(function() { + var ident = $(this).attr('id'); + if($('#' + ident).length) { + $('#' + ident).replaceWith($(this)); + } + }); $('.wall-item-outside-wrapper',data).each(function() { var ident = $(this).attr('id'); if($('#' + ident).length == 0) { - $('img',this).each(function() { - $(this).attr('src',$(this).attr('dst')); - }); + $('img',this).each(function() { + $(this).attr('src',$(this).attr('dst')); + }); $('#' + prev).after($(this)); } else { @@ -127,11 +133,9 @@ $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper')); $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like')); $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike')); - $('#' + ident + ' ' + '.my-comment-photo').each(function() { - $(this).attr('src',$(this).attr('dst')); - }); - - + $('#' + ident + ' ' + '.my-comment-photo').each(function() { + $(this).attr('src',$(this).attr('dst')); + }); } prev = ident; }); -- cgit v1.2.3 From f198c5cff8932bc1d42c34869afecec6dcab2f46 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 04:07:47 -0700 Subject: secure profile failure --- 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 051659321..58fad9927 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); -- cgit v1.2.3 From 04cd865cc94c1c3647beb567baf1bb64af269c4e Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 04:20:40 -0700 Subject: placeholder arg in dfrn conversations --- include/items.php | 2 +- include/poller.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 58fad9927..4a740e55b 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '?f=&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); diff --git a/include/poller.php b/include/poller.php index 8619697d9..98c55a2a9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -167,7 +167,7 @@ function poller_run($argv, $argc){ if(intval($contact['duplex']) && $contact['issued-id']) $idtosend = '1:' . $orig_id; - $url = $contact['poll'] . '?dfrn_id=' . $idtosend + $url = $contact['poll'] . '?f=&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=data&last_update=' . $last_update ; -- cgit v1.2.3 From 0fe997490df7fbd3d108c8da931e4823b0a4b2d9 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 15:04:18 -0700 Subject: dfrn remote profile protocol revision --- include/items.php | 2 +- include/poller.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4a740e55b..58fad9927 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '?f=&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); diff --git a/include/poller.php b/include/poller.php index 98c55a2a9..8619697d9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -167,7 +167,7 @@ function poller_run($argv, $argc){ if(intval($contact['duplex']) && $contact['issued-id']) $idtosend = '1:' . $orig_id; - $url = $contact['poll'] . '?f=&dfrn_id=' . $idtosend + $url = $contact['poll'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=data&last_update=' . $last_update ; -- cgit v1.2.3 From 89e81862ec316ae41e616dd8b9ddeb6ab18193c7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 16:18:59 -0700 Subject: bug #29 - commas not linkified --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 4caf18766..44f571450 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -22,7 +22,7 @@ function bbcode($Text) { // Perform URL Search - $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]+)/", ' $2', $Text); + $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+\,]+)/", ' $2', $Text); $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1', $Text); $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text); -- cgit v1.2.3 From 08032e04536e67dbf488654a0142350690154c57 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 31 Mar 2011 04:57:31 -0700 Subject: change language dynamically - bound to F8 key --- include/main.js | 13 +++++++++++++ include/nav.php | 1 + 2 files changed, 14 insertions(+) (limited to 'include') diff --git a/include/main.js b/include/main.js index 750cce74c..18e884b31 100644 --- a/include/main.js +++ b/include/main.js @@ -26,6 +26,7 @@ var pr = 0; var liking = 0; var in_progress = false; + var langSelect = false; $(document).ready(function() { $.ajaxSetup({cache: false}); @@ -45,6 +46,18 @@ $('#pause').html(''); } } + // F8 - show/hide language selector + if(event.keyCode == '119') { + if(langSelect) { + langSelect = false; + $('#language-selector').hide(); + } + else { + langSelect = true; + $('#language-selector').show(); + } + } + // this is shift-home on FF, but $ on IE, disabling until I figure out why the diff. // update: incompatible usage of onKeyDown vs onKeyPress // if(event.keyCode == '36' && event.shiftKey == true) { diff --git a/include/nav.php b/include/nav.php index db3b909af..b8b65f84d 100644 --- a/include/nav.php +++ b/include/nav.php @@ -16,6 +16,7 @@ function nav(&$a) { */ $a->page['nav'] .= '' ; + $a->page['nav'] .= lang_selector(); /** * -- cgit v1.2.3 From 9b50b0e16f2046b91cb4c734c56024524d8b178b Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 3 Apr 2011 20:41:40 -0700 Subject: Public exposure warning on affected network group pages. config-able so a plugin can shut it up. --- include/group.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/group.php b/include/group.php index 793e854be..07cd45f19 100644 --- a/include/group.php +++ b/include/group.php @@ -110,7 +110,7 @@ function group_get_members($gid) { LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` WHERE `gid` = %d AND `group_member`.`uid` = %d", intval($gid), - intval($_SESSION['uid']) + intval(local_user()) ); if(count($r)) $ret = $r; @@ -118,6 +118,21 @@ function group_get_members($gid) { return $ret; } +function group_public_members($gid) { + $ret = 0; + if(intval($gid)) { + $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` + LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d AND `contact`.`network` != 'dfrn' ", + intval($gid), + intval(local_user()) + ); + if(count($r)) + $ret = count($r); + } + return $ret; +} + function group_side($every="contacts",$each="group") { -- cgit v1.2.3 From b5bcf44354410e2c37d5ec143c7050c3903200ed Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 4 Apr 2011 01:18:28 -0700 Subject: profile not set --- include/items.php | 2 +- include/poller.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 58fad9927..1dd39d2ba 100644 --- a/include/items.php +++ b/include/items.php @@ -901,7 +901,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { * */ -function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { +function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_feed = false) { require_once('simplepie/simplepie.inc'); diff --git a/include/poller.php b/include/poller.php index 8619697d9..3b80c1c04 100644 --- a/include/poller.php +++ b/include/poller.php @@ -278,7 +278,8 @@ function poller_run($argv, $argc){ continue; } - consume_feed($xml,$importer,$contact,$hub,1); + + consume_feed($xml,$importer,$contact,$hub,1, true); // do it twice. Ensures that children of parents which may be later in the stream aren't tossed -- cgit v1.2.3 From 793967a1d3c23fcf1f3b00a2832f51e6f473f4bd Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 4 Apr 2011 19:36:18 -0700 Subject: better handling of troublesome feeds. --- include/Scrape.php | 2 +- include/items.php | 23 +++++++++++++++-------- include/poller.php | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index ff9899252..21820ddaf 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -216,7 +216,7 @@ function scrape_feed($url) { } if(stristr($line,'application/rss+xml') || stristr($s,'type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -206,7 +206,7 @@ function construct_activity_target($item) { if($item['target']) { $o = '' . "\r\n"; - $r = @simplexml_load_string($item['target']); + $r = parse_xml_string($item['target']); if($r->type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -241,8 +241,14 @@ function get_atom_elements($feed,$item) { $res = array(); $author = $item->get_author(); - $res['author-name'] = unxmlify($author->get_name()); - $res['author-link'] = unxmlify($author->get_link()); + if($author) { + $res['author-name'] = unxmlify($author->get_name()); + $res['author-link'] = unxmlify($author->get_link()); + } + else { + $res['author-name'] = unxmlify($feed->get_title()); + $res['author-link'] = unxmlify($feed->get_permalink()); + } $res['uri'] = unxmlify($item->get_id()); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); @@ -343,7 +349,6 @@ function get_atom_elements($feed,$item) { // the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining // html. - if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { $res['body'] = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', @@ -783,7 +788,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { return 3; } - $res = simplexml_load_string($xml); + $res = parse_xml_string($xml); if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) return (($res->status) ? $res->status : 3); @@ -878,7 +883,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { return 3; } - $res = simplexml_load_string($xml); + $res = parse_xml_string($xml); return $res->status; @@ -916,6 +921,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee if($feed->error()) logger('consume_feed: Error parsing XML: ' . $feed->error()); + $permalink = $feed->get_permalink(); // Check at the feed level for updated contact name and/or photo @@ -1230,6 +1236,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); + $datarray = get_atom_elements($feed,$item); $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -1275,7 +1282,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee if(! is_array($contact)) return; - if($contact['network'] === 'stat') { + if($contact['network'] === 'stat' || stristr($permalink,'twitter.com')) { if(strlen($datarray['title'])) unset($datarray['title']); $datarray['last-child'] = 1; diff --git a/include/poller.php b/include/poller.php index 3b80c1c04..9362c28b3 100644 --- a/include/poller.php +++ b/include/poller.php @@ -203,7 +203,7 @@ function poller_run($argv, $argc){ } - $res = simplexml_load_string($xml); + $res = parse_xml_string($xml); if(intval($res->status) == 1) { logger("poller: $url replied status 1 - marking for death "); -- cgit v1.2.3 From 4c5e091b784574337c7124b7763bbd19f4bc810f Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 4 Apr 2011 20:40:31 -0700 Subject: better twitter follow support --- include/Scrape.php | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index 21820ddaf..002fdfb35 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -227,16 +227,36 @@ function scrape_feed($url) { if(! $dom) return $ret; + + $items = $dom->getElementsByTagName('img'); + + // get img elements (twitter) + + if($items) { + foreach($items as $item) { + $x = $item->getAttribute('id'); + if($x === 'profile-image') { + $ret['photo'] = $item->getAttribute('src'); + } + } + } + $items = $dom->getElementsByTagName('link'); - // get Atom link elements + // get Atom/RSS link elements, take the first one of either. - foreach($items as $item) { - $x = $item->getAttribute('rel'); - if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml')) - $ret['feed_atom'] = $item->getAttribute('href'); - if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml')) - $ret['feed_rss'] = $item->getAttribute('href'); + if($items) { + foreach($items as $item) { + $x = $item->getAttribute('rel'); + if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml')) { + if(! x($ret,'feed_atom')) + $ret['feed_atom'] = $item->getAttribute('href'); + } + if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml')) { + if(! x($ret,'feed_rss')) + $ret['feed_rss'] = $item->getAttribute('href'); + } + } } return $ret; -- cgit v1.2.3 From 438473529c667f151aefcede1d7fa6b8b22f2d91 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 5 Apr 2011 17:41:02 -0700 Subject: atom categories and tag import --- include/items.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a9ac85969..b17eadba2 100644 --- a/include/items.php +++ b/include/items.php @@ -456,7 +456,22 @@ function get_atom_elements($feed,$item) { if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow')) $res['verb'] = ACTIVITY_UNFOLLOW; - + + $cats = $item->get_categories(); + if($cats) { + $tag_arr = array(); + foreach($cats as $cat) { + $term = $cat->get_term(); + if(! $term) + $term = $cat->get_label(); + $scheme = $cat->get_scheme(); + if($scheme && $term && stristr($scheme,'X-DFRN:')) + $tag_arr[] = substr($scheme,7,1) . '[url=' . unxmlify(substr($scheme,9)) . ']' . unxmlify($term) . '[/url]'; + elseif($term) + $tag_arr[] = $term; + } + $res['tag'] = implode(',', $tag_arr); + } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); @@ -614,6 +629,7 @@ function item_store($arr,$force_parent = false) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); + $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; @@ -1503,6 +1519,13 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if(strlen($actarg)) $o .= $actarg; + $tags = item_getfeedtags($item); + if(count($tags)) { + foreach($tags as $t) { + $o .= '' . "\r\n"; + } + } + $mentioned = get_mentions($item); if($mentioned) $o .= $mentioned; @@ -1513,6 +1536,29 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } + +function item_getfeedtags($item) { + $ret = array(); + $matches = false; + $cnt = preg_match_all('|\#\[url\=(.+?)\](.+?)\[\/url\]|',$item['tag'],$matches); + if($cnt) { + for($x = 0; $x < count($matches); $x ++) { + if($matches[1][$x]) + $ret[] = array('#',$matches[1][$x], $matches[2][$x]); + } + } + $matches = false; + $cnt = preg_match_all('|\@\[url\=(.+?)\](.+?)\[\/url\]|',$item['tag'],$matches); + if($cnt) { + for($x = 0; $x < count($matches); $x ++) { + if($matches[1][$x]) + $ret[] = array('#',$matches[1][$x], $matches[2][$x]); + } + } + return $ret; +} + + function item_expire($uid,$days) { -- cgit v1.2.3 From 6728a11ee38e890a0ce9b8b6d96dba98a7238129 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 6 Apr 2011 19:41:16 -0700 Subject: support feed attachments/enclosures, and fix for bug #30 --- include/items.php | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index b17eadba2..501f2f944 100644 --- a/include/items.php +++ b/include/items.php @@ -468,11 +468,34 @@ function get_atom_elements($feed,$item) { if($scheme && $term && stristr($scheme,'X-DFRN:')) $tag_arr[] = substr($scheme,7,1) . '[url=' . unxmlify(substr($scheme,9)) . ']' . unxmlify($term) . '[/url]'; elseif($term) - $tag_arr[] = $term; + $tag_arr[] = notags(trim($term)); } $res['tag'] = implode(',', $tag_arr); } + $attach = $item->get_enclosures(); + if($attach) { + $att_arr = array(); + foreach($attach as $att) { + $len = intval($att->get_length()); + $link = str_replace(',','%2D', notags(trim($att->get_link()))); + $title = str_replace(',','%2D',notags(trim($att->get_title()))); + $type = notags(trim($att->get_type())); + if((! $link) || (strpos($link,'http') !== 0)) + continue; + + if(! $title) + $title = ' '; + if(! $type) + $type = 'application/octet-stream'; + + // this isn't legal html - there is no size in an 'a' tag, remember to strip it before display + + $att_arr[] = '' . $title . ''; + } + $res['attach'] = implode(',', $att_arr); + } + $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); if($rawobj) { @@ -1526,6 +1549,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { } } + $o .= item_getfeedattach($item); + $mentioned = get_mentions($item); if($mentioned) $o .= $mentioned; @@ -1558,6 +1583,26 @@ function item_getfeedtags($item) { return $ret; } +function item_getfeedattach($item) { + $ret = array(); + $arr = explode(',',$item['attach']); + if(count($arr)) { + foreach($arr as $r) { + $matches = false; + $cnt = preg_match('|\(.+?)|',$item['attach'],$matches); + if($cnt) { + $ret .= ' Date: Wed, 6 Apr 2011 20:03:06 -0700 Subject: some fixes to attachment output in feed --- include/items.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 501f2f944..9eaee4573 100644 --- a/include/items.php +++ b/include/items.php @@ -1584,14 +1584,14 @@ function item_getfeedtags($item) { } function item_getfeedattach($item) { - $ret = array(); + $ret = ''; $arr = explode(',',$item['attach']); if(count($arr)) { foreach($arr as $r) { $matches = false; - $cnt = preg_match('|\(.+?)|',$item['attach'],$matches); + $cnt = preg_match('|\(.+?)|',$r,$matches); if($cnt) { - $ret .= ' Date: Wed, 6 Apr 2011 20:36:24 -0700 Subject: xmlify enclosure items --- 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 9eaee4573..c617f13cb 100644 --- a/include/items.php +++ b/include/items.php @@ -1591,11 +1591,11 @@ function item_getfeedattach($item) { $matches = false; $cnt = preg_match('|\(.+?)|',$r,$matches); if($cnt) { - $ret .= ' Date: Wed, 6 Apr 2011 21:59:07 -0700 Subject: attachment storage --- include/items.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index c617f13cb..596946681 100644 --- a/include/items.php +++ b/include/items.php @@ -653,6 +653,7 @@ function item_store($arr,$force_parent = false) { $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); + $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : ''); if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; -- cgit v1.2.3 From e35a5bac55e0e259c7c587adfaf546484b032c92 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 7 Apr 2011 23:10:43 -0700 Subject: the rest of the english html templates except for htconfig --- include/profile_advanced.php | 258 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 include/profile_advanced.php (limited to 'include') diff --git a/include/profile_advanced.php b/include/profile_advanced.php new file mode 100644 index 000000000..8c4ba7698 --- /dev/null +++ b/include/profile_advanced.php @@ -0,0 +1,258 @@ +' . t('Profile') . ''; + +if($a->profile['name']) { + $lbl_fullname = t('Full Name:'); + $fullname = $a->profile['name']; + +$o .= <<< EOT +
+
$lbl_fullname
+
$fullname
+
+
+EOT; +} + +if($a->profile['gender']) { + $lbl_gender = t('Gender:'); + $gender = $a->profile['gender']; + +$o .= <<< EOT +
+
$lbl_gender
+
$gender
+
+
+EOT; +} + +if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) { + $lbl_birthday = t('Birthday:'); + +$o .= <<< EOT +
+
$lbl_birthday
+EOT; + +// If no year, add an arbitrary one so just we can parse the month and day. + +$year_bd_format = t('j F, Y'); +$short_bd_format = t('j F'); + +$o .= '
' + . ((intval($a->profile['dob'])) + ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format)) + : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],6) . ' 00:00 +00:00',$short_bd_format))) + . "
\r\n
"; + +$o .= '
'; + +} + +if($age = age($a->profile['dob'],$a->profile['timezone'],'')) { + $lbl_age = t('Age:'); +$o .= <<< EOT +
+
$lbl_age
+
$age
+
+
+EOT; +} + +if($a->profile['marital']) { + $lbl_marital = t(' Status:'); + $marital = $a->profile['marital']; + +$o .= <<< EOT +
+
$lbl_marital
+
$marital
+EOT; + +if($a->profile['with']) { + $with = $a->profile['with']; + $o .= "
($with)
"; +} +$o .= <<< EOT +
+
+EOT; +} + +if($a->profile['sexual']) { + $lbl_sexual = t('Sexual Preference:'); + $sexual = $a->profile['sexual']; + +$o .= <<< EOT +
+
$lbl_sexual
+
$sexual
+
+
+EOT; +} + +if($a->profile['homepage']) { + $lbl_homepage = t('Homepage:'); + $homepage = linkify($a->profile['homepage']); +$o .= <<< EOT +
+
$lbl_homepage
+
$homepage
+
+
+EOT; +} + +if($a->profile['politic']) { + $lbl_politic = t('Policial Views:'); + $politic = $a->profile['politic']; +$o .= <<< EOT +
+
$lbl_politic
+
$politic
+
+
+EOT; +} + +if($a->profile['religion']) { + $lbl_religion = t('Religion:'); + $religion = $a->profile['religion']; +$o .= <<< EOT +
+
$lbl_religion
+
$religion
+
+
+EOT; +} +if($txt = prepare_text($a->profile['about'])) { + $lbl_about = t('About:'); +$o .= <<< EOT +
+
$lbl_about
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['interest'])) { + $lbl_interests = t('Hobbies/Interests:'); +$o .= <<< EOT +
+
$lbl_interests
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['contact'])) { + $lbl_contact = t('Contact information and Social Networks:'); +$o .= <<< EOT +
+
$lbl_contact
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['music'])) { + $lbl_music = t('Musical interests:'); +$o .= <<< EOT +
+
$lbl_music
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['book'])) { + $lbl_book = t('Books, literature:'); +$o .= <<< EOT +
+
$lbl_book
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['tv'])) { + $lbl_tv = t('Television:'); +$o .= <<< EOT +
+
$lbl_tv
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['film'])) { + $lbl_film = t('Film/dance/culture/entertainment:'); +$o .= <<< EOT +
+
$lbl_film
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['romance'])) { + $lbl_romance = t('Love/Romance:'); +$o .= <<< EOT +
+
$lbl_romance
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['work'])) { + $lbl_work = t('Work/employment:'); +$o .= <<< EOT +
+
$lbl_work
+
+
$txt
+
+
+EOT; +} + +if($txt = prepare_text($a->profile['education'])) { + $lbl_education = t('School/education:'); +$o .= <<< EOT +
+
$lbl_education
+
+
$txt
+
+
+EOT; +} + +return $o; +} -- cgit v1.2.3 From 969cc6996a18290d234101fb9b245d27d4a6314a Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 8 Apr 2011 12:35:42 +0200 Subject: Fix a typo, updated IT strings --- include/profile_advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/profile_advanced.php b/include/profile_advanced.php index 8c4ba7698..c1dfad66f 100644 --- a/include/profile_advanced.php +++ b/include/profile_advanced.php @@ -112,7 +112,7 @@ EOT; } if($a->profile['politic']) { - $lbl_politic = t('Policial Views:'); + $lbl_politic = t('Political Views:'); $politic = $a->profile['politic']; $o .= <<< EOT
-- cgit v1.2.3 From bf865f0210aee4c6742b10bb63cd05f0de9b9d12 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 03:00:29 -0700 Subject: bug #34, line breaks double in retweet/share --- include/bbcode.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 44f571450..6fadbaf7e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,7 +3,7 @@ require_once("include/oembed.php"); // BBcode 2 HTML was written by WAY2WEB.net // extended to work with Mistpark/Friendika - Mike Macgirvin -function bbcode($Text) { +function bbcode($Text,$preserve_nl = false) { // Replace any html brackets with HTML Entities to prevent executing HTML or script // Don't use strip_tags here because it breaks [url] search by replacing & with amp @@ -12,7 +12,10 @@ function bbcode($Text) { $Text = str_replace(">", ">", $Text); // Convert new line chars to html
tags + $Text = nl2br($Text); + if($preserve_nl) + $Text = str_replace(array("\n","\r"), array('',''),$Text); // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; -- cgit v1.2.3 From 58508201a5fe1f4c3bd6bb93e626c46739afda46 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 03:36:12 -0700 Subject: bug #37, ampersand + everything following in url is stripped when using link icon to share link --- include/main.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/main.js b/include/main.js index 18e884b31..8779f8413 100644 --- a/include/main.js +++ b/include/main.js @@ -255,3 +255,26 @@ return false; } + + function bin2hex(s){ + // Converts the binary representation of data to hex + // + // version: 812.316 + // discuss at: http://phpjs.org/functions/bin2hex + // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Onno Marsman + // + bugfixed by: Linuxworld + // * example 1: bin2hex('Kev'); + // * returns 1: '4b6576' + // * example 2: bin2hex(String.fromCharCode(0x00)); + // * returns 2: '00' + var v,i, f = 0, a = []; + s += ''; + f = s.length; + + for (i = 0; i Date: Sun, 10 Apr 2011 05:55:45 -0700 Subject: nav link to help & documentation --- include/nav.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index b8b65f84d..703d8da40 100644 --- a/include/nav.php +++ b/include/nav.php @@ -61,6 +61,12 @@ function nav(&$a) { $a->page['nav'] .= '' . t('Register') . "\r\n"; + $help_url = get_config('system','help_url'); + if(! $help_url) + $help_url = 'http://github.com/friendika/friendika/wiki'; + + $a->page['nav'] .= '' . t('Help') . "\r\n"; + if(strlen($a->apps)) { $a->page['nav'] .= '' . t('Apps') . "\r\n"; } -- cgit v1.2.3 From 940d216395406744f23fe4144f2a503688624b45 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 18:38:55 -0700 Subject: initial dfrn update to pass perms --- include/items.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 596946681..d7644fb42 100644 --- a/include/items.php +++ b/include/items.php @@ -867,14 +867,14 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if($dissolve) $postvars['dissolve'] = '1'; - if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) { - $postvars['data'] = $atom; - } - elseif($owner['page-flags'] == PAGE_COMMUNITY) { + + if((($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { $postvars['data'] = $atom; + $postvars['perm'] = 'rw'; } else { $postvars['data'] = str_replace('1','0',$atom); + $postvars['perm'] = 'r'; } if($rino && $rino_allowed && (! $dissolve)) { @@ -916,7 +916,6 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if((! $curl_stat) || (! strlen($xml))) return(-1); // timed out - if(strpos($xml,'status; - + return $res->status; } -- cgit v1.2.3 From 3d51518a13fd44da3fa9a01b9ae1f1baa5d41848 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 19:29:21 -0700 Subject: set writable flag on dfrn_poll --- include/poller.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index 9362c28b3..cb2461584 100644 --- a/include/poller.php +++ b/include/poller.php @@ -165,11 +165,15 @@ function poller_run($argv, $argc){ if(intval($contact['duplex']) && $contact['dfrn-id']) $idtosend = '0:' . $orig_id; if(intval($contact['duplex']) && $contact['issued-id']) - $idtosend = '1:' . $orig_id; + $idtosend = '1:' . $orig_id; + + // they have permission to write to us. We already filtered this in the contact query. + $perm = 'rw'; $url = $contact['poll'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION - . '&type=data&last_update=' . $last_update ; + . '&type=data&last_update=' . $last_update + . '&perm=' . $perm ; $xml = fetch_url($url); @@ -250,13 +254,14 @@ function poller_run($argv, $argc){ $final_dfrn_id = substr($final_dfrn_id,2); if($final_dfrn_id != $orig_id) { - + logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); // did not decode properly - cannot trust this site continue; } $postvars['dfrn_id'] = $idtosend; $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION; + $postvars['perm'] = 'rw'; $xml = post_url($contact['poll'],$postvars); } -- cgit v1.2.3 From a65c595b169eec63b9a9dddac14b72e88ba34a04 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 21:21:16 -0700 Subject: "display list of status items" moved to include/conversation.php, currently network module has been updated to use it for display, other modules to follow with whatever special case code they require. --- include/conversation.php | 350 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100644 include/conversation.php (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php new file mode 100644 index 000000000..a45befe5b --- /dev/null +++ b/include/conversation.php @@ -0,0 +1,350 @@ +get_baseurl() . '/redir/' . $item['cid'] ; + + if(strlen($item['author-link'])) { + if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) { + $profile_link = $redirect_url; + $sparkle = ' sparkle'; + } + elseif(isset($author_contacts[$item['author-link']])) { + $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']]; + $sparkle = ' sparkle'; + } + } + + $location = (($item['location']) ? '' . $item['location'] . '' : ''); + $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); + if($coord) { + if($location) + $location .= '
(' . $coord . ')'; + else + $location = '' . $coord . ''; + } + + $drop = replace_macros($droptpl,array('$id' => $item['id'])); + $lock = '
'; + + $o .= replace_macros($tpl,array( + '$id' => $item['item_id'], + '$linktitle' => sprintf( t('View %s\s profile'), $profile_name), + '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), + '$name' => $profile_name, + '$sparkle' => $sparkle, + '$lock' => $lock, + '$thumb' => $profile_avatar, + '$title' => $item['title'], + '$body' => smilies(bbcode($item['body'])), + '$ago' => relative_date($item['created']), + '$location' => $location, + '$indent' => '', + '$owner_url' => $owner_url, + '$owner_photo' => $owner_photo, + '$owner_name' => $owner_name, + '$drop' => $drop, + '$conv' => '' . t('View in context') . '' + )); + + } + + return $o; + } + + + + + // Normal View + + + // Figure out how many comments each parent has + // (Comments all have gravity of 6) + // Store the result in the $comments array + + $comments = array(); + foreach($r as $rr) { + if(intval($rr['gravity']) == 6) { + if(! x($comments,$rr['parent'])) + $comments[$rr['parent']] = 1; + else + $comments[$rr['parent']] += 1; + } + } + + // map all the like/dislike activities for each parent item + // Store these in the $alike and $dlike arrays + + foreach($r as $item) { + like_puller($a,$item,$alike,'like'); + like_puller($a,$item,$dlike,'dislike'); + } + + $comments_collapsed = false; + $blowhard = 0; + $blowhard_count = 0; + + foreach($r as $item) { + + $comment = ''; + $template = $tpl; + $commentww = ''; + $sparkle = ''; + $owner_url = $owner_photo = $owner_name = ''; + + + // We've already parsed out like/dislike for special treatment. We can ignore them now + + if(((activity_match($item['verb'],ACTIVITY_LIKE)) + || (activity_match($item['verb'],ACTIVITY_DISLIKE))) + && ($item['id'] != $item['parent'])) + continue; + + // Take care of author collapsing and comment collapsing + // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. + // If there are more than two comments, squash all but the last 2. + + if($item['id'] == $item['parent']) { + if($blowhard == $item['cid'] && (! $item['self'])) { + $blowhard_count ++; + if($blowhard_count == 3) { + $o .= '' . ''; + $blowhard_count = 0; + } + + $comments_seen = 0; + $comments_collapsed = false; + } + else + $comments_seen ++; + + + if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { + if(! $comments_collapsed) { + $o .= ''; + $o .= ''; + } + + + + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + + $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) + ? '
' . t('Private Message') . '
' + : '
'); + + + // Top-level wall post not written by the wall owner (wall-to-wall) + // First figure out who owns it. + + $osparkle = ''; + + if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + + if($item['type'] === 'wall') { + // I do. Put me on the left of the wall-to-wall notice. + $owner_url = $a->contact['url']; + $owner_photo = $a->contact['thumb']; + $owner_name = $a->contact['name']; + $template = $wallwall; + $commentww = 'ww'; + } + if(($item['type'] === 'remote') && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) { + // Could be anybody. + $owner_url = $item['owner-link']; + $owner_photo = $item['owner-avatar']; + $owner_name = $item['owner-name']; + $template = $wallwall; + $commentww = 'ww'; + // If it is our contact, use a friendly redirect link + if((link_compare($item['owner-link'],$item['url'])) + && ($item['network'] === 'dfrn')) { + $owner_url = $redirect_url; + $osparkle = ' sparkle'; + } + } + } + + if($update) + $return_url = $_SESSION['return_url']; + else + $return_url = $_SESSION['return_url'] = $a->cmd; + + $likebuttons = ''; + if($item['id'] == $item['parent']) { + $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array( + '$id' => $item['id'], + '$likethis' => t("I like this \x28toggle\x29"), + '$nolike' => t("I don't like this \x28toggle\x29"), + '$share' => t('Share'), + '$wait' => t('Please wait') + )); + } + + if($item['last-child']) { + $comment = replace_macros($cmnt_tpl,array( + '$return_path' => '', + '$jsreload' => '', // $_SESSION['return_url'], + '$type' => 'net-comment', + '$id' => $item['item_id'], + '$parent' => $item['parent'], + '$profile_uid' => $_SESSION['uid'], + '$mylink' => $a->contact['url'], + '$mytitle' => t('This is you'), + '$myphoto' => $a->contact['thumb'], + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$ww' => $commentww + )); + } + + $edpost = ''; + if(($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = ''; + $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete'))); + + $photo = $item['photo']; + $thumb = $item['thumb']; + + // Post was remotely authored. + + $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); + + $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); + $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb); + + if(strlen($item['author-link'])) { + $profile_link = $item['author-link']; + if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) { + $profile_link = $redirect_url; + $sparkle = ' sparkle'; + } + elseif(isset($author_contacts[$item['author-link']])) { + $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']]; + $sparkle = ' sparkle'; + } + } + else + $profile_link = $item['url']; + + $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : ''); + $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : ''); + + $location = (($item['location']) ? '' . $item['location'] . '' : ''); + $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); + if($coord) { + if($location) + $location .= '
(' . $coord . ')'; + else + $location = '' . $coord . ''; + } + + $indent = (($item['parent'] != $item['item_id']) ? ' comment' : ''); + + if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + $indent .= ' shiny'; + + + + // Build the HTML + + $tmp_item = replace_macros($template,array( + '$id' => $item['item_id'], + '$linktitle' => t('View $name\'s profile'), + '$olinktitle' => t('View $owner_name\'s profile'), + '$to' => t('to'), + '$wall' => t('Wall-to-Wall'), + '$vwall' => t('via Wall-To-Wall:'), + '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), + '$name' => $profile_name, + '$thumb' => $profile_avatar, + '$osparkle' => $osparkle, + '$sparkle' => $sparkle, + '$title' => $item['title'], + '$body' => smilies(bbcode($item['body'])), + '$ago' => relative_date($item['created']), + '$lock' => $lock, + '$location' => $location, + '$indent' => $indent, + '$owner_url' => $owner_url, + '$owner_photo' => $owner_photo, + '$owner_name' => $owner_name, + '$plink' => get_plink($item), + '$edpost' => $edpost, + '$drop' => $drop, + '$vote' => $likebuttons, + '$like' => $like, + '$dislike' => $dislike, + '$comment' => $comment + )); + + $arr = array('item' => $item, 'output' => $tmp_item); + call_hooks('display_item', $arr); + + $o .= $arr['output']; + + } + } + + + // if author collapsing is in force but didn't get closed, close it off now. + + if($blowhard_count >= 3) + $o .= '
'; + + return $o; +} \ No newline at end of file -- cgit v1.2.3 From 7192299ff14b9754aad2a7b85bff837dc2594bc6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 21:43:44 -0700 Subject: first cut at profile page conversation --- 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 a45befe5b..943ebfeba 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -146,7 +146,7 @@ function conversation(&$a,$r, $mode, $update) { // If there are more than two comments, squash all but the last 2. if($item['id'] == $item['parent']) { - if($blowhard == $item['cid'] && (! $item['self'])) { + if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile')) { $blowhard_count ++; if($blowhard_count == 3) { $o .= '' . '