From cb2e68c88ef6d5b50f3636066d76f5ecfe68cf13 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 Dec 2011 01:08:19 -0800 Subject: home_init hook --- include/bbcode.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 15b2ebb0a..a8e3bed70 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -11,6 +11,7 @@ function stripcode_br_cb($s) { function tryoembed($match){ $url = ((count($match)==2)?$match[1]:$match[2]); + logger('tryoembed: $url'); $o = oembed_fetch_url($url); @@ -180,22 +181,18 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '', $Text); - /*if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){ - // use oembed for youtube links - $Text = preg_replace("/\[youtube\]/",'[embed]',$Text); - $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text); - } else {*/ - // Youtube extensions - $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); - $Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text); + // Youtube extensions + $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); + $Text = preg_replace_callback("/\[youtube\](www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); + $Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text); - $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); - //} + $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); + $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); $Text = preg_replace_callback("/\[vimeo\](https?:\/\/vimeo.com\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); -- cgit v1.2.3 From 193435e9803b29555772f19e45283eb411f91f8b Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 Dec 2011 13:52:52 -0800 Subject: default suggestions not being collected properly --- include/socgraph.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/socgraph.php b/include/socgraph.php index 07dafe7f8..ffd3fd5df 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -42,7 +42,8 @@ function poco_load($cid,$uid = 0,$url = null) { logger('poco_load: ' . $url, LOGGER_DATA); - $s = fetch_url($url . '/@me/@all?fields=displayName,urls,photos'); + + $s = fetch_url($url . ($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos' ); if(($a->get_curl_code() > 299) || (! $s)) return; -- cgit v1.2.3 From 690b3f57b7869a0032993b0b93abe0fa292df44f Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 16 Dec 2011 14:06:50 -0800 Subject: bug 241 - valid emails may contain + on lhs --- 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 04d5dfced..5e9c39336 100644 --- a/include/text.php +++ b/include/text.php @@ -635,7 +635,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { if(! function_exists('valid_email')) { function valid_email($x){ - if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) + if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) return true; return false; }} -- cgit v1.2.3 From 22d59350e958e24cc3b7c49ce8ceae2e3178576e Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 16 Dec 2011 14:31:39 -0800 Subject: improve the email regex a bit more --- 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 5e9c39336..d6b3ceeab 100644 --- a/include/text.php +++ b/include/text.php @@ -635,7 +635,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { if(! function_exists('valid_email')) { function valid_email($x){ - if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) + if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) return true; return false; }} -- cgit v1.2.3 From e6b538c0466fb73bc3bf781266f85f45f8b39ea3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 Dec 2011 00:50:17 -0800 Subject: add webfinger addr to gcontact for friend "connect" links --- include/socgraph.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/socgraph.php b/include/socgraph.php index ffd3fd5df..78a5514a0 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -52,6 +52,7 @@ function poco_load($cid,$uid = 0,$url = null) { $profile_url = ''; $profile_photo = ''; + $connect_url = ''; $name = ''; $name = $entry->displayName; @@ -59,13 +60,18 @@ function poco_load($cid,$uid = 0,$url = null) { foreach($entry->urls as $url) { if($url->type == 'profile') { $profile_url = $url->value; - break; + continue; } + if($url->type == 'webfinger') { + $connect_url = str_replace('acct:' , '', $url->value); + continue; + } + } foreach($entry->photos as $photo) { if($photo->type == 'profile') { $profile_photo = $photo->value; - break; + continue; } } @@ -80,21 +86,23 @@ function poco_load($cid,$uid = 0,$url = null) { $gcid = $x[0]['id']; if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) { - q("update gcontact set `name` = '%s', `photo` = '%s' where - `nurl` = '%s' limit 1", + q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s' + where `nurl` = '%s' limit 1", dbesc($name), dbesc($profile_photo), + dbesc($connect_url), dbesc(normalise_link($profile_url)) ); } } else { - q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`) - values ( '%s', '%s', '%s', '%s') ", + q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`) + values ( '%s', '%s', '%s', '%s','%s') ", dbesc($name), dbesc($profile_url), dbesc(normalise_link($profile_url)), - dbesc($profile_photo) + dbesc($profile_photo), + dbesc($connect_url) ); $x = q("select * from `gcontact` where `nurl` = '%s' limit 1", dbesc(normalise_link($profile_url)) -- cgit v1.2.3 From dc46a01cd467ac8c03acda6abcdb3aa56ef2db77 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 Dec 2011 13:03:20 -0800 Subject: suggest query for no friends messed up --- include/socgraph.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/socgraph.php b/include/socgraph.php index 78a5514a0..5420b06c8 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -231,20 +231,22 @@ function suggestion_query($uid, $start = 0, $limit = 40) { intval($limit) ); - if(count($r)) + if(count($r) && count($r) >= ($limit -1)) return $r; - $r = q("SELECT gcontact.* from gcontact + $r2 = q("SELECT gcontact.* from gcontact left join glink on glink.gcid = gcontact.id - where uid = 0 and cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d) + where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d) and not gcontact.id in ( select gcid from gcign where uid = %d ) - order by rand limit %d, %d ", + order by rand() limit %d, %d ", + intval($uid), intval($uid), intval($start), intval($limit) ); - return $r; + + return array_merge($r,$r2); } -- cgit v1.2.3 From ad54a91d4df0007892f4c801fa1b3a79466b5bf3 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Dec 2011 00:40:00 -0800 Subject: poco_load aborting after debug statement --- include/socgraph.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/socgraph.php b/include/socgraph.php index 5420b06c8..60bf075d3 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -40,16 +40,28 @@ function poco_load($cid,$uid = 0,$url = null) { if(! $url) return; - logger('poco_load: ' . $url, LOGGER_DATA); + $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos') ; + logger('poco_load: ' . $url, LOGGER_DEBUG); - $s = fetch_url($url . ($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos' ); + $s = fetch_url($url); + + logger('poco_load: returns ' . $s, LOGGER_DATA); + + logger('poco_load: return code: ' . $a->get_curl_code(), LOGGER_DEBUG); if(($a->get_curl_code() > 299) || (! $s)) return; + + $j = json_decode($s); + + logger('poco_load: json: ' . print_r($j,true),LOGGER_DATA); + + $total = 0; foreach($j->entry as $entry) { + $total ++; $profile_url = ''; $profile_photo = ''; $connect_url = ''; @@ -136,6 +148,7 @@ function poco_load($cid,$uid = 0,$url = null) { } } + logger("poco_load: loaded $total entries",LOGGER_DEBUG); q("delete from glink where `cid` = %d and `uid` = %d and `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", intval($cid), -- cgit v1.2.3 From 7c6bc5a93d50de8e15d6158aa3dae7936097dbec Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Dec 2011 13:51:55 -0800 Subject: invalid thread-id in "nouveau" mode of conversation, bug 245 --- 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 deced3cb8..fae57c565 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -294,7 +294,7 @@ function conversation(&$a, $items, $mode, $update) { $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); - $threads[$threadsid]['id'] = $arr[$item['item_id']]; + $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['html'] .= $arr['output']; } -- cgit v1.2.3 From 79f3bbbf2b0e41db2653f9d0fd4eb7520ba58a25 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Dec 2011 16:51:57 -0800 Subject: more data checking, cleans up some infrequent php errors --- include/diaspora.php | 7 +++++++ include/socgraph.php | 3 +++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 7f1e4a8e3..3ab454246 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -188,6 +188,13 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey,$public = false) logger('diaspora_msg_build: ' . $msg, LOGGER_DATA); + // without a public key nothing will work + + if(! $pubkey) { + logger('diaspora_msg_build: pubkey missing: contact id: ' . $contact['id']); + return ''; + } + $inner_aes_key = random_string(32); $b_inner_aes_key = base64_encode($inner_aes_key); $inner_iv = random_string(16); diff --git a/include/socgraph.php b/include/socgraph.php index 60bf075d3..79d7340a4 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -58,6 +58,9 @@ function poco_load($cid,$uid = 0,$url = null) { logger('poco_load: json: ' . print_r($j,true),LOGGER_DATA); + if(! isset($j->entry)) + return; + $total = 0; foreach($j->entry as $entry) { -- cgit v1.2.3 From 63f66a5a93661cfc327449561a2150aa8187a228 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Dec 2011 19:06:25 -0800 Subject: bug 244 multiple birthday reminders from Diaspora if profile changed repeatedly --- include/bbcode.php | 2 +- include/diaspora.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index a8e3bed70..5218a06e8 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -11,7 +11,7 @@ function stripcode_br_cb($s) { function tryoembed($match){ $url = ((count($match)==2)?$match[1]:$match[2]); - logger('tryoembed: $url'); + logger("tryoembed: $url"); $o = oembed_fetch_url($url); diff --git a/include/diaspora.php b/include/diaspora.php index 3ab454246..fdf756610 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1679,6 +1679,12 @@ function diaspora_profile($importer,$xml) { $birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d'); + // this is to prevent multiple birthday notifications in a single year + // if we already have a stored birthday and the 'm-d' part hasn't changed, preserve the entry, which will preserve the notify year + + if(substr($birthday,5) === substr($contact['bd'],5)) + $birthday = $contact['bd']; + $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($name), dbesc(datetime_convert()), -- cgit v1.2.3 From 7fbfbdae0700e68a465f70963521b9043fe5de30 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 Dec 2011 17:01:41 -0800 Subject: audio/video bb tags showing up on Diaspora --- include/bb2diaspora.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index eb709e01d..0e001df35 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -173,9 +173,9 @@ function bb2diaspora($Text,$preserve_nl = false) { // html5 video and audio -// $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '', $Text); + $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '$1', $Text); -// $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '', $Text); + $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '$1', $Text); // $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '', $Text); -- cgit v1.2.3 From dacbbfaafbaec739199771062ceb55ecb8246999 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Dec 2011 14:42:12 -0800 Subject: bug #188 diaspora_signed_retraction not removing post --- include/diaspora.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index fdf756610..d1e975a89 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -69,7 +69,7 @@ function diaspora_dispatch($importer,$msg) { $ret = diaspora_retraction($importer,$xmlbase->retraction,$msg); } elseif($xmlbase->signed_retraction) { - $ret = diaspora_signed_retraction($importer,$xmlbase->retraction,$msg); + $ret = diaspora_signed_retraction($importer,$xmlbase->signed_retraction,$msg); } elseif($xmlbase->photo) { $ret = diaspora_photo($importer,$xmlbase->photo,$msg); @@ -1569,6 +1569,7 @@ EOT; function diaspora_retraction($importer,$xml) { + $guid = notags(unxmlify($xml->guid)); $diaspora_handle = notags(unxmlify($xml->diaspora_handle)); $type = notags(unxmlify($xml->type)); @@ -1600,7 +1601,8 @@ function diaspora_retraction($importer,$xml) { // NOTREACHED } -function diaspora_signed_retraction($importer,$xml) { +function diaspora_signed_retraction($importer,$xml,$msg) { + $guid = notags(unxmlify($xml->target_guid)); $diaspora_handle = notags(unxmlify($xml->sender_handle)); @@ -1608,8 +1610,10 @@ function diaspora_signed_retraction($importer,$xml) { $sig = notags(unxmlify($xml->target_author_signature)); $contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle); - if(! $contact) + if(! $contact) { + logger('diaspora_signed_retraction: no contact'); return; + } // this may not yet work for comments. Need to see how the relaying works // and figure out who signs it. @@ -1628,7 +1632,7 @@ function diaspora_signed_retraction($importer,$xml) { if($type === 'StatusMessage') { $r = q("select * from item where guid = '%s' and uid = %d limit 1", - dbesc('guid'), + dbesc($guid), intval($importer['uid']) ); if(count($r)) { @@ -1640,6 +1644,8 @@ function diaspora_signed_retraction($importer,$xml) { } } } + else + logger('diaspora_signed_retraction: unknown type: ' . $type); return 202; // NOTREACHED -- cgit v1.2.3