aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
committerfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
commite6a5f7800390e5091743d6a97c6fd8f54c5d1530 (patch)
tree20c49c7d11b411b91530ef43374a208274ebbb57 /include
parent4a243b63f7019a1e56ecf03b138cd7fc396236c2 (diff)
parent3e5226adc70838c784a0b208de25fffde37a6679 (diff)
downloadvolse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.gz
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.bz2
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.zip
Merge branch 'master' into tres
Conflicts: include/zot.php
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php5
-rw-r--r--include/bbcode.php21
-rw-r--r--include/message.php2
-rw-r--r--include/notifier.php10
-rw-r--r--include/zot.php43
5 files changed, 63 insertions, 18 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 5d211ee66..7e7649b94 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -566,12 +566,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')
);
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 . '#$]', '<img class="zrl" src="' . $image .'" alt="' . t('Image/photo') . '" />', $newbody);
+ $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '<img src="' . $image .'" alt="' . 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;
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
diff --git a/include/notifier.php b/include/notifier.php
index 79be25621..303e3485b 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
*
*/
@@ -294,6 +295,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
diff --git a/include/zot.php b/include/zot.php
index 58cb9a8cc..ed8f1e72e 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -296,14 +296,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_primary = 1 limit 1",
+ $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');
@@ -1954,10 +1964,18 @@ function sync_locations($sender,$arr,$absolute = false) {
}
}
- if((intval($r[0]['hubloc_primary']) && (! $location['primary']))
- || ((! intval($r[0]['hubloc_primary'])) && ($location['primary']))) {
- $m = q("update hubloc set hubloc_primary = %d, hubloc_updated = '%s' where hubloc_id = %d",
- intval($location['primary']),
+ if(intval($r[0]['hubloc_primary']) && (! $location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id = %d",
+ 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((! intval($r[0]['hubloc_primary'])) && ($location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
@@ -1977,8 +1995,15 @@ function sync_locations($sender,$arr,$absolute = false) {
}
if((intval($r[0]['hubloc_deleted']) && (! $location['deleted']))
|| ((! (intval($r[0]['hubloc_deleted']))) && ($location['deleted']))) {
- $n = q("update hubloc set hubloc_deleted = %d, hubloc_updated = '%s' where hubloc_id = %d",
- intval($location['deleted']),
+ $n = q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]['hubloc_id'])
+ );
+ $what .= 'delete_hub ';
+ $changed = true;
+ }
+ elseif((! intval($r[0]['hubloc_deleted'])) && ($location['deleted'])) {
+ $n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);