]> git.mxchange.org Git - friendica.git/blob - mod/viewsrc.php
Merge pull request #4323 from MrPetovan/bug/fix-removeme-auth
[friendica.git] / mod / viewsrc.php
1 <?php
2 /**
3  * @file mod/viewsrc.php
4  */
5 use Friendica\App;
6 use Friendica\Core\L10n;
7 use Friendica\Database\DBM;
8
9 function viewsrc_content(App $a) {
10
11         if (! local_user()) {
12                 notice(L10n::t('Access denied.') . EOL);
13                 return;
14         }
15
16         $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
17
18         if(! $item_id) {
19                 $a->error = 404;
20                 notice(L10n::t('Item not found.') . EOL);
21                 return;
22         }
23
24         $r = q("SELECT `item`.`body` FROM `item`
25                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
26                 and `item`.`moderated` = 0
27                 AND `item`.`id` = '%s' LIMIT 1",
28                 intval(local_user()),
29                 dbesc($item_id)
30         );
31
32         if (DBM::is_result($r))
33                 if(is_ajax()) {
34                         echo str_replace("\n",'<br />',$r[0]['body']);
35                         killme();
36                 } else {
37                         $o .= str_replace("\n",'<br />',$r[0]['body']);
38                 }
39         return $o;
40 }
41