]> git.mxchange.org Git - friendica.git/blob - mod/display.php
a759d037e5474e734ed6cbb95a2faaea099d339a
[friendica.git] / mod / display.php
1 <?php
2
3 function display_init(&$a) {
4
5         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
6                 return;
7         }
8
9         $nick = (($a->argc > 1) ? $a->argv[1] : '');
10         $profiledata = array();
11
12         // If there is only one parameter, then check if this parameter could be a guid
13         if ($a->argc == 2) {
14                 $nick = "";
15                 $itemuid = 0;
16
17                 // Does the local user have this item?
18                 if (local_user()) {
19                         $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
20                                 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
21                                         AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
22                         if (count($r)) {
23                                 $nick = $a->user["nickname"];
24                                 $itemuid = local_user();
25                         }
26                 }
27
28                 // Or is it anywhere on the server?
29                 if ($nick == "") {
30                         $r = q("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`,
31                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`owner-link`, `item`.`body`
32                                 FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
33                                 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
34                                         AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
35                                         AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
36                                         AND NOT `item`.`private` AND NOT `user`.`hidewall`
37                                         AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
38                                 //      AND NOT `item`.`private` AND `item`.`wall`
39                         if (count($r)) {
40                                 $nick = $r[0]["nickname"];
41                                 $itemuid = $r[0]["uid"];
42                         }
43                 }
44
45                 // Is it an item with uid=0?
46                 if ($nick == "") {
47                         $r = q("SELECT `item`.`id`, `item`.`parent`, `item`.`author-name`, `item`.`author-link`,
48                                 `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`owner-link`, `item`.`body`
49                                 FROM `item` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
50                                         AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
51                                         AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
52                                         AND NOT `item`.`private` AND `item`.`uid` = 0
53                                         AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
54                                 //      AND NOT `item`.`private` AND `item`.`wall`
55                 }
56                 if (count($r)) {
57                         if ($r[0]["id"] != $r[0]["parent"])
58                                 $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
59                                         WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
60                                                 AND `id` = %d", $r[0]["parent"]);
61
62                         if (($itemuid != local_user()) AND local_user()) {
63                                 // Do we know this contact but we haven't got this item?
64                                 // Copy it to our local storage.
65                                 $contactid = get_contact($r[0]['owner-link'], local_user());
66                                 if ($contactid) {
67                                         $item = q("SELECT * FROM `item` WHERE `id` = %d", intval($r[0]["id"]));
68                                         unset($item[0]['id']);
69                                         $item[0]['uid'] = local_user();
70                                         $item[0]['origin'] = 0;
71                                         $item[0]['contact-id'] = $contactid;
72                                         $local_copy = item_store($item[0], false, false, true);
73                                         logger("Stored local copy for post ".$item[0]['id']." under id ".$local_copy, LOGGER_DEBUG);
74                                 }
75                         }
76
77                         $profiledata = display_fetchauthor($a, $r[0]);
78
79                         if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
80                                 $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
81
82                                 if (($nickname != $a->user["nickname"])) {
83                                         $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
84                                                 INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
85                                                 WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
86                                                 dbesc($nickname)
87                                         );
88                                         if (count($r))
89                                                 $profiledata = $r[0];
90
91                                         $profiledata["network"] = NETWORK_DFRN;
92                                 } else
93                                         $profiledata = array();
94                         }
95                 } else {
96                         $a->error = 404;
97                         notice( t('Item not found.') . EOL);
98                         return;
99                 }
100         }
101
102         profile_load($a, $nick, 0, $profiledata);
103
104 }
105
106 function display_fetchauthor($a, $item) {
107
108         $profiledata = array();
109         $profiledata["uid"] = -1;
110         $profiledata["nickname"] = $item["author-name"];
111         $profiledata["name"] = $item["author-name"];
112         $profiledata["picdate"] = "";
113         $profiledata["photo"] = $item["author-avatar"];
114         $profiledata["url"] = $item["author-link"];
115         $profiledata["network"] = $item["network"];
116
117         // Check for a repeated message
118         $skip = false;
119         $body = trim($item["body"]);
120
121         // Skip if it isn't a pure repeated messages
122         // Does it start with a share?
123         if (!$skip AND strpos($body, "[share") > 0)
124                 $skip = true;
125
126         // Does it end with a share?
127         if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8)))
128                 $skip = true;
129
130         if (!$skip) {
131                 $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
132                 // Skip if there is no shared message in there
133                 if ($body == $attributes)
134                         $skip = true;
135         }
136
137         if (!$skip) {
138                 $author = "";
139                 preg_match("/author='(.*?)'/ism", $attributes, $matches);
140                 if ($matches[1] != "")
141                         $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
142
143                 preg_match('/author="(.*?)"/ism', $attributes, $matches);
144                 if ($matches[1] != "")
145                         $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
146
147                 $profile = "";
148                 preg_match("/profile='(.*?)'/ism", $attributes, $matches);
149                 if ($matches[1] != "")
150                         $profiledata["url"] = $matches[1];
151
152                 preg_match('/profile="(.*?)"/ism', $attributes, $matches);
153                 if ($matches[1] != "")
154                         $profiledata["url"] = $matches[1];
155
156                 $avatar = "";
157                 preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
158                 if ($matches[1] != "")
159                         $profiledata["photo"] = $matches[1];
160
161                 preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
162                 if ($matches[1] != "")
163                         $profiledata["photo"] = $matches[1];
164
165                 $profiledata["nickname"] = $profiledata["name"];
166                 $profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
167
168                 $profiledata["address"] = "";
169                 $profiledata["about"] = "";
170         }
171
172         // Don't show details from Diaspora contacts if you don't follow the contact
173         $showdetails = ($profiledata["network"] != NETWORK_DIASPORA);
174
175         // Fetching further contact data from the contact table
176         $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
177                 FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
178                 dbesc(normalise_link($profiledata["url"])), intval(local_user()), dbesc($item["network"]),
179                 intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
180         if (!count($r))
181                 $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
182                         FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `rel` IN (%d, %d)",
183                         dbesc(normalise_link($profiledata["url"])), intval(local_user()),
184                         intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
185
186         if (count($r)) {
187                 $profiledata["name"] = $r[0]["name"];
188                 $profiledata["photo"] = $r[0]["photo"];
189                 $profiledata["nickname"] = $r[0]["nick"];
190                 $profiledata["addr"] = $r[0]["addr"];
191                 $profiledata["keywords"] = $r[0]["keywords"];
192                 $profiledata["network"] = $r[0]["network"];
193
194                 if (local_user() OR $showdetails) {
195                         $showdetails = true;
196                         $profiledata["address"] = $r[0]["location"];
197                         $profiledata["about"] = $r[0]["about"];
198                         $profiledata["gender"] = $r[0]["gender"];
199                 }
200         }
201
202         // Fetching profile data from global contacts
203         if ($profiledata["network"] != NETWORK_FEED) {
204                 $r = q("SELECT `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`, `network` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"])));
205                 if (count($r)) {
206                         $profiledata["name"] = $r[0]["name"];
207                         $profiledata["photo"] = $r[0]["photo"];
208                         $profiledata["nickname"] = $r[0]["nick"];
209                         $profiledata["addr"] = $r[0]["addr"];
210                         $profiledata["network"] = $r[0]["network"];
211
212                         if ($r[0]["keywords"])
213                                 $profiledata["keywords"] = $r[0]["keywords"];
214
215                         if ($showdetails) {
216                                 if ($r[0]["location"])
217                                         $profiledata["address"] = $r[0]["location"];
218
219                                 if ($r[0]["about"])
220                                         $profiledata["about"] = $r[0]["about"];
221
222                                 if ($r[0]["gender"])
223                                         $profiledata["gender"] = $r[0]["gender"];
224                         }
225                 }
226         }
227
228         if (local_user()) {
229                 if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
230                         $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
231         } elseif ($profiledata["network"] == NETWORK_DFRN) {
232                 $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
233                 $profiledata["remoteconnect"] = $connect;
234         }
235
236         return($profiledata);
237 }
238
239 function display_content(&$a, $update = 0) {
240
241         if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
242                 notice( t('Public access denied.') . EOL);
243                 return;
244         }
245
246         require_once('include/security.php');
247         require_once('include/conversation.php');
248         require_once('include/acl_selectors.php');
249
250
251         $o = '';
252
253         $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
254
255
256         if($update) {
257                 $nick = $_REQUEST['nick'];
258         }
259         else {
260                 $nick = (($a->argc > 1) ? $a->argv[1] : '');
261         }
262
263         if($update) {
264                 $item_id = $_REQUEST['item_id'];
265                 $a->profile = array('uid' => intval($update), 'profile_uid' => intval($update));
266         }
267         else {
268                 $item_id = (($a->argc > 2) ? $a->argv[2] : 0);
269
270                 if ($a->argc == 2) {
271                         $nick = "";
272
273                         if (local_user()) {
274                                 $r = q("SELECT `id` FROM `item`
275                                         WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
276                                                 AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
277                                 if (count($r)) {
278                                         $item_id = $r[0]["id"];
279                                         $nick = $a->user["nickname"];
280                                 }
281                         }
282
283                         if ($nick == "") {
284                                 $r = q("SELECT `user`.`nickname`, `item`.`id` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
285                                         WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
286                                                 AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
287                                                 AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
288                                                 AND NOT `item`.`private` AND NOT `user`.`hidewall`
289                                                 AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
290                                         //      AND NOT `item`.`private` AND `item`.`wall`
291                                 if (count($r)) {
292                                         $item_id = $r[0]["id"];
293                                         $nick = $r[0]["nickname"];
294                                 }
295                         }
296                         if ($nick == "") {
297                                 $r = q("SELECT `item`.`id` FROM `item`
298                                         WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
299                                                 AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
300                                                 AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
301                                                 AND NOT `item`.`private` AND `item`.`uid` = 0
302                                                 AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
303                                         //      AND NOT `item`.`private` AND `item`.`wall`
304                                 if (count($r)) {
305                                         $item_id = $r[0]["id"];
306                                 }
307                         }
308                 }
309         }
310
311         if ($item_id AND !is_numeric($item_id)) {
312                 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
313                         dbesc($item_id), intval($a->profile['uid']));
314                 if ($r)
315                         $item_id = $r[0]["id"];
316                 else
317                         $item_id = false;
318         }
319
320         if (!$item_id) {
321                 $a->error = 404;
322                 notice(t('Item not found.').EOL);
323                 return;
324         }
325
326
327         $groups = array();
328
329         $contact = null;
330         $remote_contact = false;
331
332         $contact_id = 0;
333
334         if(is_array($_SESSION['remote'])) {
335                 foreach($_SESSION['remote'] as $v) {
336                         if($v['uid'] == $a->profile['uid']) {
337                                 $contact_id = $v['cid'];
338                                 break;
339                         }
340                 }
341         }
342
343         if($contact_id) {
344                 $groups = init_groups_visitor($contact_id);
345                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
346                         intval($contact_id),
347                         intval($a->profile['uid'])
348                 );
349                 if(count($r)) {
350                         $contact = $r[0];
351                         $remote_contact = true;
352                 }
353         }
354
355         if(! $remote_contact) {
356                 if(local_user()) {
357                         $contact_id = $_SESSION['cid'];
358                         $contact = $a->contact;
359                 }
360         }
361
362         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
363                 intval($a->profile['uid'])
364         );
365         if(count($r))
366                 $a->page_contact = $r[0];
367
368         $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
369
370         if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
371                 notice( t('Access to this profile has been restricted.') . EOL);
372                 return;
373         }
374
375         // We need the editor here to be able to reshare an item.
376
377         if ($is_owner) {
378                 $x = array(
379                         'is_owner' => true,
380                         'allow_location' => $a->user['allow_location'],
381                         'default_location' => $a->user['default-location'],
382                         'nickname' => $a->user['nickname'],
383                         'lockstate' => ( (is_array($a->user)) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'),
384                         'acl' => populate_acl($a->user, true),
385                         'bang' => '',
386                         'visitor' => 'block',
387                         'profile_uid' => local_user(),
388                         'acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
389                 );
390                 $o .= status_editor($a,$x,0,true);
391         }
392
393         $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
394
395         if($update) {
396
397                 $r = q("SELECT `id` FROM `item` WHERE `item`.`uid` = %d
398                         AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
399                         $sql_extra AND `unseen`",
400                         intval($a->profile['uid']),
401                         intval($item_id)
402                 );
403
404                 if(!$r)
405                         return '';
406         }
407
408         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,  `item`.`network` AS `item_network`,
409                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
410                 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
411                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
412                 FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
413                 AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
414                 WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
415                 AND NOT `item`.`moderated`
416                 AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
417                 $sql_extra
418                 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
419                 intval($a->profile['uid']),
420                 intval($item_id)
421         );
422
423         if(!$r && local_user()) {
424                 // Check if this is another person's link to a post that we have
425                 $r = q("SELECT `item`.uri FROM `item`
426                         WHERE (`item`.`id` = %d OR `item`.`uri` = '%s')
427                         LIMIT 1",
428                         intval($item_id),
429                         dbesc($item_id)
430                 );
431                 if($r) {
432                         $item_uri = $r[0]['uri'];
433
434                         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,  `item`.`network` AS `item_network`,
435                                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
436                                 `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
437                                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
438                                 FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
439                                 AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
440                                 WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
441                                 AND NOT `item`.`moderated`
442                                 AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
443                                 ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
444                                 intval(local_user()),
445                                 dbesc($item_uri),
446                                 intval(local_user())
447                         );
448                 }
449         }
450
451
452         if($r) {
453
454                 if((local_user()) && (local_user() == $a->profile['uid'])) {
455                         $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `parent` = %d",
456                                         intval($r[0]['parent']));
457
458                         if ($unseen)
459                                 q("UPDATE `item` SET `unseen` = 0
460                                         WHERE `parent` = %d AND `unseen`",
461                                         intval($r[0]['parent'])
462                                 );
463                 }
464
465                 $items = conv_sort($r,"`commented`");
466
467                 if(!$update)
468                         $o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
469                 $o .= conversation($a,$items,'display', $update);
470
471                 // Preparing the meta header
472                 require_once('include/bbcode.php');
473                 require_once("include/html2plain.php");
474                 $description = trim(html2plain(bbcode($r[0]["body"], false, false), 0, true));
475                 $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
476                 $author_name = $r[0]["author-name"];
477
478                 $image = "";
479                 if ($image == "")
480                         $image = $r[0]["thumb"];
481
482                 if ($title == "")
483                         $title = $author_name;
484
485                 $description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
486                 $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
487                 $author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
488
489                 //<meta name="keywords" content="">
490                 $a->page['htmlhead'] .= '<meta name="author" content="'.$author_name.'" />'."\n";
491                 $a->page['htmlhead'] .= '<meta name="title" content="'.$title.'" />'."\n";
492                 $a->page['htmlhead'] .= '<meta name="fulltitle" content="'.$title.'" />'."\n";
493                 $a->page['htmlhead'] .= '<meta name="description" content="'.$description.'" />'."\n";
494
495                 // Schema.org microdata
496                 $a->page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n";
497                 $a->page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n";
498                 $a->page['htmlhead'] .= '<meta itemprop="image" content="'.$image.'" />'."\n";
499                 $a->page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n";
500
501                 // Twitter cards
502                 $a->page['htmlhead'] .= '<meta name="twitter:card" content="summary" />'."\n";
503                 $a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
504                 $a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
505                 $a->page['htmlhead'] .= '<meta name="twitter:image" content="'.$image.'" />'."\n";
506                 $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$r[0]["plink"].'" />'."\n";
507
508                 // Dublin Core
509                 $a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
510                 $a->page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n";
511
512                 // Open Graph
513                 $a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
514                 $a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
515                 $a->page['htmlhead'] .= '<meta property="og:image" content="'.$image.'" />'."\n";
516                 $a->page['htmlhead'] .= '<meta property="og:url" content="'.$r[0]["plink"].'" />'."\n";
517                 $a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
518                 $a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
519                 // article:tag
520
521                 return $o;
522         }
523
524         $r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
525                 dbesc($item_id),
526                 dbesc($item_id)
527         );
528         if($r) {
529                 if($r[0]['deleted']) {
530                         notice( t('Item has been removed.') . EOL );
531                 }
532                 else {
533                         notice( t('Permission denied.') . EOL );
534                 }
535         }
536         else {
537                 notice( t('Item not found.') . EOL );
538         }
539
540         return $o;
541 }
542