]> git.mxchange.org Git - friendica.git/blob - mod/viewsrc.php
The central item fetch does work now and the API now uses these functions
[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         $o = ''; 
17         $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
18
19         if(! $item_id) {
20                 $a->error = 404;
21                 notice(L10n::t('Item not found.') . EOL);
22                 return;
23         }
24
25         $r = q("SELECT `item`.`body` FROM `item`
26                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
27                 and `item`.`moderated` = 0
28                 AND `item`.`id` = '%s' LIMIT 1",
29                 intval(local_user()),
30                 dbesc($item_id)
31         );
32
33         if (DBM::is_result($r))
34                 if(is_ajax()) {
35                         echo str_replace("\n",'<br />',$r[0]['body']);
36                         killme();
37                 } else {
38                         $o .= str_replace("\n",'<br />',$r[0]['body']);
39                 }
40         return $o;
41 }
42