2011-10-30 23:28:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
function viewsrc_content(&$a) {
|
|
|
|
|
2012-11-13 22:37:02 +00:00
|
|
|
$o = '';
|
|
|
|
|
2014-09-23 04:37:19 +00:00
|
|
|
$sys = get_sys_channel();
|
|
|
|
|
2012-11-13 22:37:02 +00:00
|
|
|
$item_id = ((argc() > 1) ? intval(argv(1)) : 0);
|
2012-11-13 23:04:25 +00:00
|
|
|
$json = ((argc() > 2 && argv(2) === 'json') ? true : false);
|
2012-11-13 22:37:02 +00:00
|
|
|
|
2015-01-29 04:56:04 +00:00
|
|
|
if(! local_channel()) {
|
2012-11-13 22:37:02 +00:00
|
|
|
notice( t('Permission denied.') . EOL);
|
2011-10-30 23:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(! $item_id) {
|
|
|
|
$a->error = 404;
|
|
|
|
notice( t('Item not found.') . EOL);
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:59:04 +00:00
|
|
|
$item_normal = item_normal();
|
2015-01-29 23:09:35 +00:00
|
|
|
|
2015-01-29 04:56:04 +00:00
|
|
|
if(local_channel() && $item_id) {
|
2015-06-10 23:59:04 +00:00
|
|
|
$r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1",
|
2015-01-29 04:56:04 +00:00
|
|
|
intval(local_channel()),
|
2014-09-23 04:37:19 +00:00
|
|
|
intval($sys['channel_id']),
|
2012-11-13 22:37:02 +00:00
|
|
|
intval($item_id)
|
|
|
|
);
|
|
|
|
|
2014-08-24 04:12:33 +00:00
|
|
|
if($r) {
|
2015-01-23 02:41:10 +00:00
|
|
|
if(intval($r[0]['item_obscured']))
|
2014-08-24 04:12:33 +00:00
|
|
|
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey'));
|
2012-11-13 22:49:03 +00:00
|
|
|
$o = (($json) ? json_encode($r[0]['body']) : str_replace("\n",'<br />',$r[0]['body']));
|
2014-08-24 04:12:33 +00:00
|
|
|
}
|
2012-08-31 01:17:38 +00:00
|
|
|
}
|
2012-11-13 22:37:02 +00:00
|
|
|
|
|
|
|
if(is_ajax()) {
|
2015-04-15 10:26:03 +00:00
|
|
|
print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>';
|
2012-11-13 22:37:02 +00:00
|
|
|
echo $o;
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
2011-10-30 23:28:07 +00:00
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|