+ // authenticated visitor - here lie dragons
+ // If $remotecontact is true, we know that not only is this a remotely authenticated
+ // person, but that it is *our* contact, which is important in multi-user mode.
+
+ elseif($remote_contact) {
+ $gs = '<<>>'; // should be impossible to match
+ if(count($groups)) {
+ foreach($groups as $g)
+ $gs .= '|<' . intval($g) . '>';
+ }
+ $sql_extra = sprintf(
+ " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
+ AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
+ AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
+ AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
+
+ intval($_SESSION['visitor_id']),
+ intval($_SESSION['visitor_id']),
+ dbesc($gs),
+ dbesc($gs)
+ );
+ }
+
+ $r = q("SELECT COUNT(*) AS `total`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+ $sql_extra ",
+ intval($a->profile['profile_uid'])
+
+ );
+
+ if(count($r))
+ $a->set_pager_total($r[0]['total']);
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`,
+ `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+ $sql_extra
+ ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ",
+ intval($a->profile['profile_uid']),
+ intval($a->pager['start']),
+ intval($a->pager['itemspage'])
+
+ );
+
+
+ $cmnt_tpl = file_get_contents('view/comment_item.tpl');
+
+ $like_tpl = file_get_contents('view/like.tpl');
+
+ $tpl = file_get_contents('view/wall_item.tpl');
+
+ if($update)
+ $return_url = $_SESSION['return_url'];
+ else
+ $return_url = $_SESSION['return_url'] = $a->cmd;
+
+ $alike = array();
+ $dlike = array();
+
+ if(count($r)) {
+
+ foreach($r as $item) {
+
+ if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) {
+ $url = $item['url'];
+ if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
+ $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
+ if(! is_array($alike[$item['parent'] . '-l']))
+ $alike[$item['parent'] . '-l'] = array();
+ $alike[$item['parent']] ++;
+ $alike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
+ }
+ if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
+ $url = $item['url'];
+ if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
+ $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
+ if(! is_array($dlike[$item['parent'] . '-l']))
+ $dlike[$item['parent'] . '-l'] = array();
+ $dlike[$item['parent']] ++;
+ $dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';