4 function display_content(&$a) {
6 require_once("include/bbcode.php");
7 require_once('include/security.php');
8 require_once('include/conversation.php');
11 $o = '<div id="live-display"></div>' . "\r\n";
13 $nick = (($a->argc > 1) ? $a->argv[1] : '');
14 profile_load($a,$nick);
16 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
20 notice( t('Item not found.') . EOL);
29 $remote_contact = false;
32 $contact_id = $_SESSION['visitor_id'];
33 $groups = init_groups_visitor($contact_id);
34 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
36 intval($a->profile['uid'])
40 $remote_contact = true;
44 if(! $remote_contact) {
46 $contact_id = $_SESSION['cid'];
47 $contact = $a->contact;
51 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
52 intval($a->profile['uid'])
55 $a->page_contact = $r[0];
65 // Profile owner - everything is visible
67 if(local_user() && (local_user() == $a->profile['uid'])) {
71 // authenticated visitor - here lie dragons
72 // If $remotecontact is true, we know that not only is this a remotely authenticated
73 // person, but that it is *our* contact, which is important in multi-user mode.
75 elseif($remote_contact) {
76 $gs = '<<>>'; // should be impossible to match
78 foreach($groups as $g)
79 $gs .= '|<' . intval($g) . '>';
82 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
83 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
84 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
85 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
87 intval($_SESSION['visitor_id']),
88 intval($_SESSION['visitor_id']),
94 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
95 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
96 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
97 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
98 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
99 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
100 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
101 AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
103 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
104 intval($a->profile['uid']),
112 if((local_user()) && (local_user() == $a->profile['uid'])) {
113 q("UPDATE `item` SET `unseen` = 0
114 WHERE `parent` = %d AND `unseen` = 1",
115 intval($r[0]['parent'])
120 $o .= conversation($a,$r,'display', false);
124 $r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
129 if($r[0]['deleted']) {
130 notice( t('Item has been removed.') . EOL );
133 notice( t('Permission denied.') . EOL );
137 notice( t('Item not found.') . EOL );
142 $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';