aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php5
-rw-r--r--include/attach.php2
-rw-r--r--include/channel.php13
-rw-r--r--include/connections.php54
-rw-r--r--include/dba/dba_driver.php14
-rw-r--r--include/event.php2
-rw-r--r--include/feedutils.php16
-rw-r--r--include/items.php100
-rw-r--r--include/photo/photo_driver.php2
-rw-r--r--include/photos.php1
-rw-r--r--include/text.php119
11 files changed, 195 insertions, 133 deletions
diff --git a/include/account.php b/include/account.php
index 98d7f00a8..a1fb0f159 100644
--- a/include/account.php
+++ b/include/account.php
@@ -1117,6 +1117,7 @@ function account_service_class_allows($aid, $property, $usage = false) {
*/
function service_class_fetch($uid, $property) {
+ $service_class = null;
if($uid == local_channel()) {
$service_class = App::$account['account_service_class'];
@@ -1127,7 +1128,7 @@ function service_class_fetch($uid, $property) {
where c.channel_account_id=a.account_id and c.channel_id= %d limit 1",
intval($uid)
);
- if($r !== false and count($r)) {
+ if($r) {
$service_class = $r[0]['service_class'];
}
}
@@ -1161,7 +1162,7 @@ function account_service_class_fetch($aid, $property) {
$r = q("select account_service_class as service_class from account where account_id = %d limit 1",
intval($aid)
);
- if($r !== false && count($r)) {
+ if($r) {
$service_class = $r[0]['service_class'];
}
diff --git a/include/attach.php b/include/attach.php
index fc146d008..b7fb17f38 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -220,7 +220,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
$sql_extra .= protect_sprintf(" and filetype like '%" . dbesc($filetype) . "%' ");
if($entries)
- $limit = " limit " . intval($start) . ", " . intval($entries) . " ";
+ $limit = " LIMIT " . intval($entries) . " OFFSET " . intval($start) . " ";
if(! $since)
$since = NULL_DATE;
diff --git a/include/channel.php b/include/channel.php
index c36e50f19..01302a1b9 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1583,6 +1583,10 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details =
$reddress = true;
$connect_url = '';
$connect = '';
+ $default_cover = get_config('system', 'default_cover_photo', 'hubzilla');
+ $default_cover_url = z_root() . '/images/default_cover_photos/' . $default_cover . '/425.png';
+
+
if(! perm_is_allowed($profile['uid'], $observer_hash, 'view_profile')) {
$block = true;
@@ -1681,9 +1685,11 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $details =
'$homepage' => $homepage,
'$chanmenu' => $channel_menu,
'$reddress' => $reddress,
+ '$no_pdesc' => t('This channel has not added a profile description yet'),
'$contact_block' => $contact_block,
'$change_photo' => t('Change your profile photo'),
- '$editmenu' => profile_edit_menu($profile['uid'])
+ '$editmenu' => profile_edit_menu($profile['uid']),
+ '$cover' => get_cover_photo($profile['uid'], 'array', PHOTO_RES_COVER_425) ?: ['url' => $default_cover_url]
));
$arr = [
@@ -2404,7 +2410,7 @@ function get_zcard($channel, $observer_hash = '', $args = array()) {
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
} else {
- $default_cover = get_config('system','default_cover_photo','bggenerator');
+ $default_cover = get_config('system', 'default_cover_photo', 'hubzilla');
$cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.png' ];
}
@@ -2478,7 +2484,7 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) {
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
}
else {
- $default_cover = get_config('system','default_cover_photo','bggenerator');
+ $default_cover = get_config('system', 'default_cover_photo', 'hubzilla');
$cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.png' ];
}
@@ -2855,7 +2861,6 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
q("DELETE FROM app WHERE app_channel = %d", intval($channel_id));
q("DELETE FROM atoken WHERE atoken_uid = %d", intval($channel_id));
q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id));
- q("DELETE FROM conv WHERE uid = %d", intval($channel_id));
q("DELETE FROM pgrp WHERE uid = %d", intval($channel_id));
q("DELETE FROM pgrp_member WHERE uid = %d", intval($channel_id));
diff --git a/include/connections.php b/include/connections.php
index 2a186192d..e8415bb25 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -270,8 +270,6 @@ function mark_orphan_hubsxchans() {
}
-
-
function remove_all_xchan_resources($xchan, $channel_id = 0) {
if(!$xchan)
@@ -279,18 +277,27 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
if(intval($channel_id)) {
-
+ // reserved for future use
}
else {
- $dirmode = intval(get_config('system','directory_mode'));
+ // This function is only to be executed on remote servers where only the xchan exists
+ // and there is no associated channel.
+
+ $c = q("select channel_id from channel where channel_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if ($c) {
+ return;
+ }
$r = q("delete from photo where xchan = '%s'",
dbesc($xchan)
);
- $r = q("select resource_id, resource_type, uid, id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ",
+ $r = q("select id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ",
dbesc($xchan),
dbesc($xchan)
);
@@ -309,37 +316,30 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
dbesc($xchan)
);
- $r = q("delete from xlink where ( xlink_xchan = '%s' or xlink_link = '%s' )",
- dbesc($xchan),
+ $r = q("delete from abook where abook_xchan = '%s'",
dbesc($xchan)
);
- $r = q("delete from abook where abook_xchan = '%s'",
+ $r = q("delete from abconfig where xchan = '%s'",
dbesc($xchan)
);
- if($dirmode === false || $dirmode == DIRECTORY_MODE_NORMAL) {
-
- $r = q("delete from xchan where xchan_hash = '%s'",
- dbesc($xchan)
- );
- $r = q("delete from hubloc where hubloc_hash = '%s'",
- dbesc($xchan)
- );
-
- }
- else {
+ $r = q("delete from xlink where (xlink_xchan = '%s' or xlink_link = '%s')",
+ dbesc($xchan),
+ dbesc($xchan)
+ );
- // directory servers need to keep the record around for sync purposes - mark it deleted
+ $r = q("delete from xprof where xprof_hash = '%s'",
+ dbesc($xchan)
+ );
- $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
- dbesc($xchan)
- );
+ $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
+ dbesc($xchan)
+ );
- $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'",
- dbesc($xchan)
- );
- }
+ $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
}
}
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 152be7f88..631513819 100644
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -67,9 +67,17 @@ class DBA {
require_once('include/dba/dba_pdo.php');
self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$db_charset,$install);
- define('NULL_DATE', self::$null_date);
- define('ACTIVE_DBTYPE', self::$dbtype);
- define('TQUOT', self::$tquot);
+ if (!defined('NULL_DATE')) {
+ define('NULL_DATE', self::$null_date);
+ }
+
+ if (!defined('ACTIVE_DBTYPE')) {
+ define('ACTIVE_DBTYPE', self::$dbtype);
+ }
+
+ if (!defined('TQUOT')) {
+ define('TQUOT', self::$tquot);
+ }
return self::$dba;
}
diff --git a/include/event.php b/include/event.php
index 6273279c2..894a1e4f7 100644
--- a/include/event.php
+++ b/include/event.php
@@ -713,7 +713,7 @@ function event_addtocal($item_id, $uid) {
intval($channel['channel_id'])
);
- if((! $r) || ($r[0]['obj_type'] !== ACTIVITY_OBJ_EVENT))
+ if(!$r || !in_array($r[0]['obj_type'], ['Event', ACTIVITY_OBJ_EVENT]))
return false;
$item = $r[0];
diff --git a/include/feedutils.php b/include/feedutils.php
index 43b95b966..a2d52c698 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -598,12 +598,13 @@ function get_atom_elements($feed, $item) {
// uses the OStatus stack. We need a more generalised way for the calling
// function to specify this behaviour or for plugins to alter it.
+ $terms = [];
+
if($ostatus_protocol) {
$res['title'] = '';
}
elseif($res['plink'] && $res['title']) {
$res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
- $terms = array();
$terms[] = array(
'otype' => TERM_OBJ_POST,
'ttype' => TERM_BOOKMARK,
@@ -613,7 +614,6 @@ function get_atom_elements($feed, $item) {
}
elseif($res['plink']) {
$res['body'] = '#^[url]' . $res['plink'] . '[/url]' . "\n\n" . $res['body'];
- $terms = array();
$terms[] = array(
'otype' => TERM_OBJ_POST,
'ttype' => TERM_BOOKMARK,
@@ -698,7 +698,7 @@ function get_atom_elements($feed, $item) {
}
}
- if(! is_null($terms))
+ if($terms)
$res['term'] = $terms;
$attach = $item->get_enclosures();
@@ -1829,11 +1829,11 @@ function atom_author($tag, $nick, $name, $uri, $h, $w, $type, $photo) {
*/
function atom_render_author($tag, $xchan) {
- $nick = xmlify(substr($xchan['xchan_addr'], 0, strpos($xchan['xchan_addr'], '@')));
- $id = xmlify($xchan['xchan_url']);
- $name = xmlify($xchan['xchan_name']);
- $photo = xmlify($xchan['xchan_photo_l']);
- $type = xmlify($xchan['xchan_photo_mimetype']);
+ $nick = ((!empty($xchan['xchan_addr'])) ? xmlify(substr($xchan['xchan_addr'], 0, strpos($xchan['xchan_addr'], '@'))) : '');
+ $id = ((!empty($xchan['xchan_url'])) ? xmlify($xchan['xchan_url']) : '');
+ $name = ((!empty($xchan['xchan_name'])) ? xmlify($xchan['xchan_name']) : '');
+ $photo = ((!empty($xchan['xchan_photo_l'])) ? xmlify($xchan['xchan_photo_l']) : '');
+ $type = ((!empty($xchan['xchan_photo_mimetype'])) ? xmlify($xchan['xchan_photo_mimetype']) : '');
$w = $h = 300;
$o = "<$tag>\r\n";
diff --git a/include/items.php b/include/items.php
index a9930470c..f6a93cc2c 100644
--- a/include/items.php
+++ b/include/items.php
@@ -719,12 +719,12 @@ function get_item_elements($x,$allow_code = false) {
$arr['comment_policy'] = (($x['comment_scope']) ? htmlspecialchars($x['comment_scope'], ENT_COMPAT,'UTF-8',false) : 'contacts');
- $arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['obj'] = activity_sanitise($x['object']);
- $arr['target'] = activity_sanitise($x['target']);
- $arr['attach'] = activity_sanitise($x['attach']);
- $arr['term'] = decode_tags($x['tags']);
- $arr['iconfig'] = decode_item_meta($x['meta']);
+ $arr['sig'] = ((!empty($x['signature'])) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['obj'] = ((!empty($x['object'])) ? activity_sanitise($x['object']) : '');
+ $arr['target'] = ((!empty($x['target'])) ? activity_sanitise($x['target']) : '');
+ $arr['attach'] = ((!empty($x['attach'])) ? activity_sanitise($x['attach']) : '');
+ $arr['term'] = ((!empty($x['tags'])) ? decode_tags($x['tags']) : '');
+ $arr['iconfig'] = ((!empty($x['meta'])) ? decode_item_meta($x['meta']) : '');
$arr['item_flags'] = 0;
if(array_key_exists('flags',$x)) {
@@ -1539,6 +1539,39 @@ function item_sign(&$item) {
$item['item_verified'] = 1;
}
+/**
+ * @brief packs json data for storage.
+ * if it is a string, check if it is already json encoded.
+ * Otherwise, json encode it
+ * If it is an array, sanitise it and then json_encode it.
+ *
+ * @param array $arr
+ * @param string | intval $k
+ *
+ * @return string | null
+ */
+
+function item_json_encapsulate($arr, $k) {
+ $retval = null;
+
+ if (isset($arr[$k])) {
+ if (is_string($arr[$k])) {
+ // determine if it is json encoded already
+ $test = json_decode($arr[$k]);
+ // assume it is json encoded already
+ $retval = $arr[$k];
+ if ($test === NULL) {
+ $retval = json_encode($arr[$k], JSON_UNESCAPED_SLASHES);
+ }
+ }
+ else {
+ activity_sanitise($arr[$k]);
+ $retval = json_encode($arr[$k], JSON_UNESCAPED_SLASHES);
+ }
+ }
+
+ return $retval;
+}
/**
* @brief Stores an item type record.
@@ -3755,45 +3788,34 @@ function item_expire($uid,$days,$comment_days = 7) {
$sql_extra = ((intval($expire_network_only)) ? " AND item_wall = 0 " : "");
- $expire_limit = get_config('system','expire_limit');
- if(! intval($expire_limit))
- $expire_limit = 5000;
+ $expire_limit = get_config('system','expire_limit', 1000);
$item_normal = item_normal();
- $r = q("SELECT id FROM item
- WHERE uid = %d
- AND created < %s - INTERVAL %s
- AND commented < %s - INTERVAL %s
- AND item_retained = 0
- AND item_thread_top = 1
- AND resource_type = ''
- AND item_starred = 0
- $sql_extra $item_normal LIMIT $expire_limit ",
- intval($uid),
- db_utcnow(),
- db_quoteinterval(intval($days) . ' DAY'),
- db_utcnow(),
- db_quoteinterval(intval($comment_days) . ' DAY')
- );
-
- if(! $r)
- return;
-
- $r = fetch_post_tags($r,true);
-
- foreach($r as $item) {
-
- // don't expire filed items
+ do {
+ $r = q("SELECT id FROM item
+ WHERE uid = %d
+ AND created < %s - INTERVAL %s
+ AND commented < %s - INTERVAL %s
+ AND item_retained = 0
+ AND item_thread_top = 1
+ AND resource_type = ''
+ AND item_starred = 0
+ $sql_extra $item_normal LIMIT $expire_limit",
+ intval($uid),
+ db_utcnow(),
+ db_quoteinterval(intval($days) . ' DAY'),
+ db_utcnow(),
+ db_quoteinterval(intval($comment_days) . ' DAY')
+ );
- if (isset($item['term']) && get_terms_oftype($item['term'], TERM_FILE)) {
- retain_item($item['id']);
- continue;
+ if ($r) {
+ foreach ($r as $item) {
+ drop_item($item['id'], false);
+ }
}
- drop_item($item['id'],false);
- }
-
+ } while ($r);
}
function retain_item($id) {
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 0b691b457..522e638de 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -142,7 +142,7 @@ function guess_image_type($filename, $data = '') {
if(is_null($type) && strpos($filename, 'http') === 0) {
$size = getimagesize($filename);
- if (array_key_exists($size['mime'], $types))
+ if ($size && array_key_exists($size['mime'], $types))
$type = $size['mime'];
}
diff --git a/include/photos.php b/include/photos.php
index 6e00ffbf0..8d83b8475 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -64,7 +64,6 @@ function photo_upload($channel, $observer, $args) {
}
$ac = $acl->get();
-hz_syslog(print_r($ac,true));
$width = $height = 0;
if ($args['getimagesize']) {
diff --git a/include/text.php b/include/text.php
index f1a7f5fbf..aadca80e1 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1794,7 +1794,8 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$s = $poll;
}
- $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : []);
+ $event = (in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT]) ? format_event_obj($item['obj']) : []);
+
$prep_arr = [
'item' => $item,
'html' => $event ? $event['content'] : $s,
@@ -1929,18 +1930,18 @@ function format_poll($item,$s,$opts) {
$output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
- $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
- $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
+ $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
}
else {
//$output .= '[ ] ' . $text . ' (' . $total . ')' . EOL;
$output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '" disabled="disabled">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
- $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
- $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
+ $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
}
}
@@ -1965,18 +1966,18 @@ function format_poll($item,$s,$opts) {
if ($activated && $commentable) {
$output .= '<input type="radio" name="answer" value="' . htmlspecialchars($text) . '">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
- $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
- $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
+ $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
}
else {
$output .= '<input type="radio" name="answer" value="' . htmlspecialchars($text) . '" disabled="disabled">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
- $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
- $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
+ $output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
}
}
@@ -3300,61 +3301,87 @@ function json_url_replace($old,$new,&$s) {
return $replaced;
}
+function item_url_replace($channel, &$item, $old, $new, $oldnick = '') {
-function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
-
- if($item['attach']) {
- json_url_replace($old,$new,$item['attach']);
- if($oldnick && ($oldnick !== $channel['channel_address']))
- json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['attach']);
- }
- if($item['object']) {
- json_url_replace($old,$new,$item['object']);
- if($oldnick && ($oldnick !== $channel['channel_address']))
- json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['object']);
+ if (!empty($item['attach'])) {
+ $converted = false;
+ if (is_array($item['attach'])) {
+ $item['attach'] = item_json_encapsulate($item,'attach');
+ $converted = true;
+ }
+ json_url_replace($old, $new, $item['attach']);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['attach']);
+ }
+ if ($converted) {
+ $item['attach'] = json_decode($item['attach'],true);
+ }
}
- if($item['target']) {
- json_url_replace($old,$new,$item['target']);
- if($oldnick && ($oldnick !== $channel['channel_address']))
- json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']);
+
+ if (!empty($item['obj'])) {
+ $converted = false;
+ if (is_array($item['obj'])) {
+ $item['obj'] = item_json_encapsulate($item,'obj');
+ $converted = true;
+ }
+ json_url_replace($old, $new, $item['obj']);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['obj']);
+ }
+ if ($converted) {
+ $item['obj'] = json_decode($item['obj'],true);
+ }
}
- $root_replaced = null;
- $nick_replaced = null;
+ if (!empty($item['target'])) {
+ $converted = false;
+ if (is_array($item['target'])) {
+ $item['target'] = item_json_encapsulate($item,'target');
+ $converted = true;
+ }
+ json_url_replace($old, $new, $item['target']);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['target']);
+ }
+ if ($converted) {
+ $item['target'] = json_decode($item['target'],true);
+ }
+ }
// FIXME: ignore anything in a share tag
+ $item['body'] = str_replace($old, $new, $item['body']);
- $item['body'] = str_replace($old, $new, $item['body'], $root_replaced);
-
- if($oldnick && ($oldnick !== $channel['channel_address'])) {
- $item['body'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['body'], $nick_replaced);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ $item['body'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['body']);
}
- if ($root_replaced || $nick_replaced) {
- $item['sig'] = Libzot::sign($item['body'], $channel['channel_prvkey']);
- $item['item_verified'] = 1;
- }
+ $item['sig'] = Libzot::sign($item['body'], $channel['channel_prvkey']);
+ $item['item_verified'] = 1;
- $item['plink'] = str_replace($old,$new,$item['plink']);
- if($oldnick && ($oldnick !== $channel['channel_address']))
- $item['plink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['plink']);
+ if (isset($item['plink'])) {
+ $item['plink'] = str_replace($old, $new, $item['plink']);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ $item['plink'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['plink']);
+ }
+ }
- $item['llink'] = str_replace($old,$new,$item['llink']);
- if($oldnick && ($oldnick !== $channel['channel_address']))
- $item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']);
+ if (isset($item['llink'])) {
+ $item['llink'] = str_replace($old, $new, $item['llink']);
+ if ($oldnick && ($oldnick !== $channel['channel_address'])) {
+ $item['llink'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['llink']);
+ }
+ }
- if($item['term']) {
- for($x = 0; $x < count($item['term']); $x ++) {
- $item['term'][$x]['url'] = str_replace($old,$new,$item['term'][$x]['url']);
+ if (isset($item['term']) && is_array($item['term'])) {
+ for ($x = 0; $x < count($item['term']); $x++) {
+ $item['term'][$x]['url'] = str_replace($old, $new, $item['term'][$x]['url']);
if ($oldnick && ($oldnick !== $channel['channel_address'])) {
- $item['term'][$x]['url'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['term'][$x]['url']);
+ $item['term'][$x]['url'] = str_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['term'][$x]['url']);
}
}
}
-
}
-
/**
* @brief Used to wrap ACL elements in angle brackets for storage.
*