|
|
@ -7,7 +7,7 @@ require_once("include/acl_selectors.php"); |
|
|
|
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
|
|
|
// is identical to the code in mod/message.php for 'item_extract_images' and
|
|
|
|
// 'item_redir_and_replace_images'
|
|
|
|
if(! function_exists('item_extract_images')) { |
|
|
|
if (! function_exists('item_extract_images')) { |
|
|
|
function item_extract_images($body) { |
|
|
|
|
|
|
|
$saved_image = array(); |
|
|
@ -18,12 +18,12 @@ function item_extract_images($body) { |
|
|
|
$img_start = strpos($orig_body, '[img'); |
|
|
|
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); |
|
|
|
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); |
|
|
|
while(($img_st_close !== false) && ($img_end !== false)) { |
|
|
|
while (($img_st_close !== false) && ($img_end !== false)) { |
|
|
|
|
|
|
|
$img_st_close++; // make it point to AFTER the closing bracket
|
|
|
|
$img_end += $img_start; |
|
|
|
|
|
|
|
if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { |
|
|
|
if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { |
|
|
|
// This is an embedded image
|
|
|
|
|
|
|
|
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close)); |
|
|
@ -36,7 +36,7 @@ function item_extract_images($body) { |
|
|
|
|
|
|
|
$orig_body = substr($orig_body, $img_end + strlen('[/img]')); |
|
|
|
|
|
|
|
if($orig_body === false) // in case the body ends on a closing image tag
|
|
|
|
if ($orig_body === false) // in case the body ends on a closing image tag
|
|
|
|
$orig_body = ''; |
|
|
|
|
|
|
|
$img_start = strpos($orig_body, '[img'); |
|
|
@ -49,7 +49,7 @@ function item_extract_images($body) { |
|
|
|
return array('body' => $new_body, 'images' => $saved_image); |
|
|
|
}} |
|
|
|
|
|
|
|
if(! function_exists('item_redir_and_replace_images')) { |
|
|
|
if (! function_exists('item_redir_and_replace_images')) { |
|
|
|
function item_redir_and_replace_images($body, $images, $cid) { |
|
|
|
|
|
|
|
$origbody = $body; |
|
|
@ -57,7 +57,7 @@ function item_redir_and_replace_images($body, $images, $cid) { |
|
|
|
|
|
|
|
$cnt = 1; |
|
|
|
$pos = get_bb_tag_pos($origbody, 'url', 1); |
|
|
|
while($pos !== false && $cnt < 1000) { |
|
|
|
while ($pos !== false && $cnt < 1000) { |
|
|
|
|
|
|
|
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is'; |
|
|
|
$replace = '[url=' . z_path() . '/redir/' . $cid |
|
|
@ -66,7 +66,7 @@ function item_redir_and_replace_images($body, $images, $cid) { |
|
|
|
$newbody .= substr($origbody, 0, $pos['start']['open']); |
|
|
|
$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']); |
|
|
|
$origbody = substr($origbody, $pos['end']['close']); |
|
|
|
if($origbody === false) |
|
|
|
if ($origbody === false) |
|
|
|
$origbody = ''; |
|
|
|
|
|
|
|
$subject = preg_replace($search, $replace, $subject); |
|
|
@ -96,7 +96,7 @@ function item_redir_and_replace_images($body, $images, $cid) { |
|
|
|
function localize_item(&$item){ |
|
|
|
|
|
|
|
$extracted = item_extract_images($item['body']); |
|
|
|
if($extracted['images']) |
|
|
|
if ($extracted['images']) |
|
|
|
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']); |
|
|
|
|
|
|
|
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; |
|
|
@ -126,7 +126,7 @@ function localize_item(&$item){ |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
if($obj['resource-id']){ |
|
|
|
if ($obj['resource-id']){ |
|
|
|
$post_type = t('photo'); |
|
|
|
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); |
|
|
|
$rr['plink'] = $m[1]; |
|
|
@ -137,19 +137,19 @@ function localize_item(&$item){ |
|
|
|
|
|
|
|
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]'; |
|
|
|
|
|
|
|
if(activity_match($item['verb'],ACTIVITY_LIKE)) { |
|
|
|
if (activity_match($item['verb'],ACTIVITY_LIKE)) { |
|
|
|
$bodyverb = t('%1$s likes %2$s\'s %3$s'); |
|
|
|
} |
|
|
|
elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) { |
|
|
|
elseif (activity_match($item['verb'],ACTIVITY_DISLIKE)) { |
|
|
|
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); |
|
|
|
} |
|
|
|
elseif(activity_match($item['verb'],ACTIVITY_ATTEND)) { |
|
|
|
elseif (activity_match($item['verb'],ACTIVITY_ATTEND)) { |
|
|
|
$bodyverb = t('%1$s attends %2$s\'s %3$s'); |
|
|
|
} |
|
|
|
elseif(activity_match($item['verb'],ACTIVITY_ATTENDNO)) { |
|
|
|
elseif (activity_match($item['verb'],ACTIVITY_ATTENDNO)) { |
|
|
|
$bodyverb = t('%1$s doesn\'t attend %2$s\'s %3$s'); |
|
|
|
} |
|
|
|
elseif(activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) { |
|
|
|
elseif (activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) { |
|
|
|
$bodyverb = t('%1$s attends maybe %2$s\'s %3$s'); |
|
|
|
} |
|
|
|
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink); |
|
|
@ -187,7 +187,7 @@ function localize_item(&$item){ |
|
|
|
} |
|
|
|
if (stristr($item['verb'],ACTIVITY_POKE)) { |
|
|
|
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); |
|
|
|
if(! $verb) |
|
|
|
if (! $verb) |
|
|
|
return; |
|
|
|
if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) return; |
|
|
|
|
|
|
@ -229,7 +229,7 @@ function localize_item(&$item){ |
|
|
|
} |
|
|
|
if (stristr($item['verb'],ACTIVITY_MOOD)) { |
|
|
|
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); |
|
|
|
if(! $verb) |
|
|
|
if (! $verb) |
|
|
|
return; |
|
|
|
|
|
|
|
$Aname = $item['author-name']; |
|
|
@ -262,7 +262,7 @@ function localize_item(&$item){ |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
if($obj['resource-id']){ |
|
|
|
if ($obj['resource-id']){ |
|
|
|
$post_type = t('photo'); |
|
|
|
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); |
|
|
|
$rr['plink'] = $m[1]; |
|
|
@ -289,7 +289,7 @@ function localize_item(&$item){ |
|
|
|
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; |
|
|
|
|
|
|
|
$obj = parse_xml_string($xmlhead.$item['object']); |
|
|
|
if(strlen($obj->id)) { |
|
|
|
if (strlen($obj->id)) { |
|
|
|
$r = q("select * from item where uri = '%s' and uid = %d limit 1", |
|
|
|
dbesc($obj->id), |
|
|
|
intval($item['uid']) |
|
|
@ -307,16 +307,16 @@ function localize_item(&$item){ |
|
|
|
} |
|
|
|
} |
|
|
|
$matches = null; |
|
|
|
if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { |
|
|
|
foreach($matches as $mtch) { |
|
|
|
if(! strpos($mtch[1],'zrl=')) |
|
|
|
if (preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { |
|
|
|
foreach ($matches as $mtch) { |
|
|
|
if (! strpos($mtch[1],'zrl=')) |
|
|
|
$item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// add zrl's to public images
|
|
|
|
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is"; |
|
|
|
if(preg_match($photo_pattern,$item['body'])) { |
|
|
|
if (preg_match($photo_pattern,$item['body'])) { |
|
|
|
$photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]'; |
|
|
|
$item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']); |
|
|
|
} |
|
|
@ -343,9 +343,9 @@ function localize_item(&$item){ |
|
|
|
function count_descendants($item) { |
|
|
|
$total = count($item['children']); |
|
|
|
|
|
|
|
if($total > 0) { |
|
|
|
foreach($item['children'] as $child) { |
|
|
|
if(! visible_activity($child)) |
|
|
|
if ($total > 0) { |
|
|
|
foreach ($item['children'] as $child) { |
|
|
|
if (! visible_activity($child)) |
|
|
|
$total --; |
|
|
|
$total += count_descendants($child); |
|
|
|
} |
|
|
@ -360,14 +360,14 @@ function visible_activity($item) { |
|
|
|
// in which case we handle them specially
|
|
|
|
|
|
|
|
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); |
|
|
|
foreach($hidden_activities as $act) { |
|
|
|
if(activity_match($item['verb'],$act)) { |
|
|
|
foreach ($hidden_activities as $act) { |
|
|
|
if (activity_match($item['verb'],$act)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) { |
|
|
|
if(! (($item['self']) && ($item['uid'] == local_user()))) { |
|
|
|
if (activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) { |
|
|
|
if (! (($item['self']) && ($item['uid'] == local_user()))) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -465,7 +465,7 @@ function item_condition() { |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
if(!function_exists('conversation')) { |
|
|
|
if (!function_exists('conversation')) { |
|
|
|
function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
|
|
|
|
require_once('include/bbcode.php'); |
|
|
@ -480,22 +480,23 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
|
|
|
|
$arr_blocked = null; |
|
|
|
|
|
|
|
if(local_user()) { |
|
|
|
if (local_user()) { |
|
|
|
$str_blocked = get_pconfig(local_user(),'system','blocked'); |
|
|
|
if($str_blocked) { |
|
|
|
if ($str_blocked) { |
|
|
|
$arr_blocked = explode(',',$str_blocked); |
|
|
|
for($x = 0; $x < count($arr_blocked); $x ++) |
|
|
|
for ($x = 0; $x < count($arr_blocked); $x ++) { |
|
|
|
$arr_blocked[$x] = trim($arr_blocked[$x]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$previewing = (($preview) ? ' preview ' : ''); |
|
|
|
|
|
|
|
if($mode === 'network') { |
|
|
|
if ($mode === 'network') { |
|
|
|
$profile_owner = local_user(); |
|
|
|
$page_writeable = true; |
|
|
|
if(!$update) { |
|
|
|
if (!$update) { |
|
|
|
// The special div is needed for liveUpdate to kick in for this page.
|
|
|
|
// We only launch liveUpdate if you aren't filtering in some incompatible
|
|
|
|
// way and also you aren't writing a comment (discovered in javascript).
|
|
|
@ -520,14 +521,14 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if($mode === 'profile') { |
|
|
|
else if ($mode === 'profile') { |
|
|
|
$profile_owner = $a->profile['profile_uid']; |
|
|
|
$page_writeable = can_write_wall($a,$profile_owner); |
|
|
|
|
|
|
|
if(!$update) { |
|
|
|
if (!$update) { |
|
|
|
$tab = notags(trim($_GET['tab'])); |
|
|
|
$tab = ( $tab ? $tab : 'posts' ); |
|
|
|
if($tab === 'posts') { |
|
|
|
if ($tab === 'posts') { |
|
|
|
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
|
|
|
|
// because browser prefetching might change it on us. We have to deliver it with the page.
|
|
|
|
|
|
|
@ -537,40 +538,40 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if($mode === 'notes') { |
|
|
|
else if ($mode === 'notes') { |
|
|
|
$profile_owner = local_user(); |
|
|
|
$page_writeable = true; |
|
|
|
if(!$update) { |
|
|
|
if (!$update) { |
|
|
|
$live_update_div = '<div id="live-notes"></div>' . "\r\n" |
|
|
|
. "<script> var profile_uid = " . local_user() |
|
|
|
. "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if($mode === 'display') { |
|
|
|
else if ($mode === 'display') { |
|
|
|
$profile_owner = $a->profile['uid']; |
|
|
|
$page_writeable = can_write_wall($a,$profile_owner); |
|
|
|
if(!$update) { |
|
|
|
if (!$update) { |
|
|
|
$live_update_div = '<div id="live-display"></div>' . "\r\n" |
|
|
|
. "<script> var profile_uid = " . $_SESSION['uid'] . ";" |
|
|
|
. " var profile_page = 1; </script>"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if($mode === 'community') { |
|
|
|
else if ($mode === 'community') { |
|
|
|
$profile_owner = 0; |
|
|
|
$page_writeable = false; |
|
|
|
if(!$update) { |
|
|
|
if (!$update) { |
|
|
|
$live_update_div = '<div id="live-community"></div>' . "\r\n" |
|
|
|
. "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
else if($mode === 'search') { |
|
|
|
else if ($mode === 'search') { |
|
|
|
$live_update_div = '<div id="live-search"></div>' . "\r\n"; |
|
|
|
} |
|
|
|
|
|
|
|
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false); |
|
|
|
|
|
|
|
|
|
|
|
if($update) |
|
|
|
if ($update) |
|
|
|
$return_url = $_SESSION['return_url']; |
|
|
|
else |
|
|
|
$return_url = $_SESSION['return_url'] = $a->query_string; |
|
|
@ -594,9 +595,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
|
|
|
|
$page_template = get_markup_template("conversation.tpl"); |
|
|
|
|
|
|
|
if($items && count($items)) { |
|
|
|
if ($items && count($items)) { |
|
|
|
|
|
|
|
if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { |
|
|
|
if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { |
|
|
|
|
|
|
|
// "New Item View" on network page or search page results
|
|
|
|
// - just loop through the items and format them minimally for display
|
|
|
@ -604,17 +605,17 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
// $tpl = get_markup_template('search_item.tpl');
|
|
|
|
$tpl = 'search_item.tpl'; |
|
|
|
|
|
|
|
foreach($items as $item) { |
|
|
|
foreach ($items as $item) { |
|
|
|
|
|
|
|
if($arr_blocked) { |
|
|
|
if ($arr_blocked) { |
|
|
|
$blocked = false; |
|
|
|
foreach($arr_blocked as $b) { |
|
|
|
if($b && link_compare($item['author-link'],$b)) { |
|
|
|
foreach ($arr_blocked as $b) { |
|
|
|
if ($b && link_compare($item['author-link'],$b)) { |
|
|
|
$blocked = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if($blocked) |
|
|
|
if ($blocked) |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
@ -626,8 +627,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
$owner_name = ''; |
|
|
|
$sparkle = ''; |
|
|
|
|
|
|
|
if($mode === 'search' || $mode === 'community') { |
|
|
|
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) |
|
|
|
if ($mode === 'search' || $mode === 'community') { |
|
|
|
if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) |
|
|
|
&& ($item['id'] != $item['parent'])) |
|
|
|
continue; |
|
|
|
$nickname = $item['nickname']; |
|
|
@ -636,11 +637,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
$nickname = $a->user['nickname']; |
|
|
|
|
|
|
|
// prevent private email from leaking.
|
|
|
|
if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) |
|
|
|
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) |
|
|
|
continue; |
|
|
|
|
|
|
|
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); |
|
|
|
if($item['author-link'] && (! $item['author-name'])) |
|
|
|
if ($item['author-link'] && (! $item['author-name'])) |
|
|
|
$profile_name = $item['author-link']; |
|
|
|
|
|
|
|
|
|
|
@ -652,7 +653,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
$taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", |
|
|
|
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION)); |
|
|
|
|
|
|
|
foreach($taglist as $tag) { |
|
|
|
foreach ($taglist as $tag) { |
|
|
|
|
|
|
|
if ($tag["url"] == "") |
|
|
|
$tag["url"] = $searchpath.strtolower($tag["term"]); |
|
|
@ -669,9 +670,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
|
|
|
|
$sp = false; |
|
|
|
$profile_link = best_link_url($item,$sp); |
|
|
|
if($profile_link === 'mailbox') |
|
|
|
if ($profile_link === 'mailbox') |
|
|
|
$profile_link = ''; |
|
|
|
if($sp) |
|
|
|
if ($sp) |
|
|
|
$sparkle = ' sparkle'; |
|
|
|
else |
|
|
|
$profile_link = zrl($profile_link); |
|
|
@ -698,7 +699,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); |
|
|
|
|
|
|
|
localize_item($item); |
|
|
|
if($mode === 'network-new') |
|
|
|
if ($mode === 'network-new') |
|
|
|
$dropping = true; |
|
|
|
else |
|
|
|
$dropping = false; |
|
|
@ -723,7 +724,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
|
|
|
|
list($categories, $folders) = get_cats_and_terms($item); |
|
|
|
|
|
|
|
if($a->theme['template_engine'] === 'internal') { |
|
|
|
if ($a->theme['template_engine'] === 'internal') { |
|
|
|
$profile_name_e = template_escape($profile_name); |
|
|
|
$item['title_e'] = template_escape($item['title']); |
|
|
|
$body_e = template_escape($body); |
|
|
@ -818,18 +819,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { |
|
|
|
// But for now, this array respects the old style, just in case
|
|
|
|
|
|
|
|
$threads = array(); |
|
|
|
foreach($items as $item) { |
|
|
|
foreach ($items as $item) { |
|
|
|
|
|
|
|
if($arr_blocked) { |
|
|
|
if ($arr_blocked) { |
|
|
|
$blocked = false; |
|
|
|
foreach($arr_blocked as $b) { |
|
|
|
foreach ($arr_blocked as $b) { |
|
|
|
|
|
|
|
if($b && link_compare($item['author-link'],$b)) { |
|
|
|
if ($b && link_compare($item['author-link'],$b)) { |
|
|
|
$blocked = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|