aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2011-12-22 15:42:01 -0800
committerfriendica <info@friendica.com>2011-12-22 15:42:01 -0800
commit95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa (patch)
treeced1f9a8bc579f85e0b74f76239de76ea95cedc0 /include
parented725df5f1c1ea2484c689283e93f8f825591384 (diff)
parentb602203e6c9ae4b380fa615450e1a573f47cb756 (diff)
downloadvolse-hubzilla-95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa.tar.gz
volse-hubzilla-95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa.tar.bz2
volse-hubzilla-95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa.zip
Merge branch 'master' into notify
Diffstat (limited to 'include')
-rw-r--r--include/bb2diaspora.php4
-rw-r--r--include/bbcode.php23
-rw-r--r--include/conversation.php2
-rw-r--r--include/diaspora.php27
-rw-r--r--include/socgraph.php55
-rw-r--r--include/text.php2
6 files changed, 78 insertions, 35 deletions
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\]/", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
+ $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '$1', $Text);
-// $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
+ $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '$1', $Text);
// $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
diff --git a/include/bbcode.php b/include/bbcode.php
index 15b2ebb0a..5218a06e8 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", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $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", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
- //}
+ $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $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);
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'];
}
diff --git a/include/diaspora.php b/include/diaspora.php
index 7f1e4a8e3..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);
@@ -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);
@@ -1562,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));
@@ -1593,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));
@@ -1601,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.
@@ -1621,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)) {
@@ -1633,6 +1644,8 @@ function diaspora_signed_retraction($importer,$xml) {
}
}
}
+ else
+ logger('diaspora_signed_retraction: unknown type: ' . $type);
return 202;
// NOTREACHED
@@ -1672,6 +1685,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()),
diff --git a/include/socgraph.php b/include/socgraph.php
index 07dafe7f8..79d7340a4 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -40,17 +40,34 @@ 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') ;
- $s = fetch_url($url . '/@me/@all?fields=displayName,urls,photos');
+ logger('poco_load: ' . $url, LOGGER_DEBUG);
+
+ $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);
+
+ if(! isset($j->entry))
+ return;
+
+ $total = 0;
foreach($j->entry as $entry) {
+ $total ++;
$profile_url = '';
$profile_photo = '';
+ $connect_url = '';
$name = '';
$name = $entry->displayName;
@@ -58,13 +75,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;
}
}
@@ -79,21 +101,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))
@@ -127,6 +151,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),
@@ -222,20 +247,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);
}
diff --git a/include/text.php b/include/text.php
index 04d5dfced..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;
}}