streams/Zotlabs/Module/Zotfinger.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2019-04-15 06:41:26 +00:00
<?php
2021-12-03 03:01:39 +00:00
2019-04-15 06:41:26 +00:00
namespace Zotlabs\Module;
/*
* Zotfinger
* Diagnostic tool to perform Zot6 channel discovery
* and optionally import the record (if invoked by site admin).
* Also see zot_probe which provides similar functionality
* for all types of Zot6 resources and is not restricted to
* channel discovery.
*/
2021-12-03 03:01:39 +00:00
2019-04-15 06:41:26 +00:00
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Zotfinger as Zfinger;
2021-12-02 23:02:31 +00:00
class Zotfinger extends Controller
{
public function get()
{
$o = replace_macros(get_markup_template('zotfinger.tpl'), [
'$page_title' => t('Zotfinger Diagnostic'),
'$resource' => ['resource', t('Lookup URL'), $_GET['resource'], EMPTY_STR],
'$submit' => t('Submit')
]);
if ($_GET['resource']) {
$channel = App::get_channel();
$resource = trim(escape_tags($_GET['resource']));
$do_import = ((intval($_GET['import']) && is_site_admin()) ? true : false);
$j = Zfinger::exec($resource, $channel);
if ($do_import && $j) {
$x = Libzot::import_xchan($j['data']);
}
$o .= '<pre>' . str_replace("\n", '<br>', print_array($j)) . '</pre>';
}
return $o;
}
2019-04-15 06:41:26 +00:00
}