2019-04-29 04:17:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zotlabs\Module;
|
|
|
|
|
|
|
|
use App;
|
|
|
|
use Zotlabs\Web\Controller;
|
2020-03-16 22:58:41 +00:00
|
|
|
use Zotlabs\Lib\Activity;
|
2019-04-29 04:17:04 +00:00
|
|
|
|
|
|
|
class Inspect extends Controller {
|
|
|
|
|
|
|
|
function get() {
|
|
|
|
|
|
|
|
$output = EMPTY_STR;
|
|
|
|
|
|
|
|
if (! is_site_admin()) {
|
|
|
|
notice( t('Permission denied.') . EOL);
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sys = get_sys_channel();
|
|
|
|
|
|
|
|
if (argc() > 2) {
|
|
|
|
$item_type = argv(1);
|
|
|
|
$item_id = argv(2);
|
|
|
|
}
|
|
|
|
elseif (argc() > 1) {
|
|
|
|
$item_type = 'item';
|
|
|
|
$item_id = argv(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $item_id) {
|
|
|
|
App::$error = 404;
|
|
|
|
notice( t('Item not found.') . EOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($item_type === 'item') {
|
|
|
|
$r = q("select * from item where uuid = '%s' or id = %d ",
|
|
|
|
dbesc($item_id),
|
|
|
|
intval($item_id)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($r) {
|
|
|
|
xchan_query($r);
|
|
|
|
$items = fetch_post_tags($r,true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! $items) {
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
if ($item['obj']) {
|
|
|
|
$item['obj'] = json_decode($item['obj'],true);
|
|
|
|
}
|
|
|
|
if ($item['target']) {
|
|
|
|
$item['target'] = json_decode($item['target'],true);
|
|
|
|
}
|
|
|
|
if ($item['attach']) {
|
|
|
|
$item['attach'] = json_decode($item['attach'],true);
|
|
|
|
}
|
|
|
|
|
2019-04-29 06:03:48 +00:00
|
|
|
$output .= '<pre>' . print_array($item) . '</pre>' . EOL . EOL;
|
2020-03-16 22:58:41 +00:00
|
|
|
|
|
|
|
$output .= '<pre>' . escape_tags(json_encode(Activity::encode_activity($item,true), JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)) . '</pre>' . EOL . EOL;
|
2019-04-29 04:17:04 +00:00
|
|
|
}
|
2020-03-16 22:58:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-29 04:17:04 +00:00
|
|
|
}
|
|
|
|
|
2019-04-29 06:03:48 +00:00
|
|
|
if ($item_type === 'xchan') {
|
|
|
|
$items = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_hash = '%s' or hubloc_addr = '%s' ",
|
|
|
|
dbesc($item_id),
|
|
|
|
dbesc($item_id)
|
|
|
|
);
|
|
|
|
|
|
|
|
if(! $items) {
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$output .= '<pre>' . print_array($item) . '</pre>' . EOL . EOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-29 04:17:04 +00:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|