From 1ef2d1c5c405a5c9ab7f41a4fdefd295098b5ac8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 16:52:17 -0800 Subject: updates to put rating info into the local xlink before sending it to known directory servers --- include/notifier.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 06ef7bc94..edb2f1946 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -59,6 +59,7 @@ require_once('include/html2plain.php'); * relay item_id (item was relayed to owner, we will deliver it as owner) * location channel_id * request channel_id xchan_hash message_id + * rating xlink_id * */ @@ -296,6 +297,15 @@ function notifier_run($argv, $argc){ $private = false; $packet_type = 'purge'; } + elseif($cmd === 'rating') { + $r = q("select * from xlink where xlink_id = %d and xlink_static = 1 limit 1", + intval($item_id) + ); + if($r) { + logger('rating message: ' . print_r($r[0],true)); + return; + } + } else { // Normal items -- cgit v1.2.3 From 219fe3a8e7f805eb0898c1931de304c602315eae Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Jan 2015 18:13:14 -0800 Subject: bring back inline images --- include/bbcode.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 5504dce7a..7067fcd39 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -57,7 +57,7 @@ function bb_unspacefy_and_trim($st) { return $unspacefied; } -if(! function_exists('bb_extract_images')) { + function bb_extract_images($body) { $saved_image = array(); @@ -97,24 +97,27 @@ function bb_extract_images($body) { $new_body = $new_body . $orig_body; return array('body' => $new_body, 'images' => $saved_image); -}} +} + -if(! function_exists('bb_replace_images')) { function bb_replace_images($body, $images) { $newbody = $body; $cnt = 0; + if(! $images) + return $newbody; + foreach($images as $image) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } - +// logger('replace_images: ' . $newbody); return $newbody; -}} +} @@ -404,6 +407,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { } + $x = bb_extract_images($Text); + $Text = $x['body']; + $saved_images = $x['images']; + $Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text); @@ -853,6 +860,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\<(.*?)(src|href)=\"[^hfm#](.*?)\>/ism",'<$1$2="">',$Text); + $Text = bb_replace_images($Text,$saved_images); + call_hooks('bbcode',$Text); return $Text; -- cgit v1.2.3 From ab0706521ecc8874f53275d470dfa57a5f457517 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Jan 2015 13:45:28 -0800 Subject: let zot_refresh continue without a primary hub if one cannot be found. also weekly doc updates --- include/zot.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index f3933d030..6057bda52 100644 --- a/include/zot.php +++ b/include/zot.php @@ -298,15 +298,24 @@ function zot_refresh($them,$channel = null, $force = false) { if($channel) logger('zot_refresh: channel: ' . print_r($channel,true), LOGGER_DATA); + $url = null; + if($them['hubloc_url']) $url = $them['hubloc_url']; else { - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) > 0 limit 1", - dbesc($them['xchan_hash']), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'", + dbesc($them['xchan_hash']) ); - if($r) - $url = $r[0]['hubloc_url']; + if($r) { + foreach($r as $rr) { + if($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) { + $url = $rr['hubloc_url']; + break; + } + } + if(! $url) + $url = $r[0]['hubloc_url']; + } } if(! $url) { logger('zot_refresh: no url'); -- cgit v1.2.3 From ef04d21a8f00d2b9623c7fc7f5a5b49f44a7f1d5 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Jan 2015 14:30:37 -0800 Subject: fix random profiles --- include/Contact.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 66062c279..de3a75bb7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -584,12 +584,13 @@ function contact_remove($channel_id, $abook_id) { function random_profile() { $randfunc = db_getfunc('rand'); - + $checkrandom = get_config('randprofile','check'); // False by default $retryrandom = intval(get_config('randprofile','retry')); - if($retryrandom === false) $retryrandom = 5; + if($retryrandom == 0) $retryrandom = 5; for($i = 0; $i < $retryrandom; $i++) { + $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1", db_utcnow(), db_quoteinterval('30 day') ); -- cgit v1.2.3 From 340212d77e246e2f46f0ae1efe5199bf01a858c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Jan 2015 15:01:10 -0800 Subject: sync_locations() toggle DB flag functions were broken - result of postgres changes. Split these into seperate set and reset blocks. --- include/zot.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 6057bda52..04b6806c2 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1988,13 +1988,23 @@ function sync_locations($sender,$arr,$absolute = false) { } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { + if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) { $m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", intval(HUBLOC_FLAGS_PRIMARY), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); + $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; + hubloc_change_primary($r[0]); + $what .= 'primary_hub '; + $changed = true; + } + elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary'])) { + $m = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d", + intval(HUBLOC_FLAGS_PRIMARY), + dbesc(datetime_convert()), + intval($r[0]['hubloc_id']) + ); // make sure hubloc_change_primary() has current data $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; hubloc_change_primary($r[0]); @@ -2009,8 +2019,7 @@ function sync_locations($sender,$arr,$absolute = false) { $changed = true; } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) { + if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) { $n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", intval(HUBLOC_FLAGS_DELETED), dbesc(datetime_convert()), @@ -2019,6 +2028,15 @@ function sync_locations($sender,$arr,$absolute = false) { $what .= 'delete_hub '; $changed = true; } + elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted'])) { + $n = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d", + intval(HUBLOC_FLAGS_DELETED), + dbesc(datetime_convert()), + intval($r[0]['hubloc_id']) + ); + $what .= 'delete_hub '; + $changed = true; + } continue; } -- cgit v1.2.3 From 5d2ab4a4fc60229c923a15e82df62c5ca172459b Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Fri, 30 Jan 2015 16:15:05 -0800 Subject: prevent silly fake null date from causing problems OTW from older builds --- include/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/message.php b/include/message.php index 34fa2cd8d..bfc92cd6d 100644 --- a/include/message.php +++ b/include/message.php @@ -185,7 +185,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' dbesc($mid), dbesc($replyto), dbesc(datetime_convert()), - dbesc($expires) + dbescdate($expires) ); // verify the save -- cgit v1.2.3