modernise zot_probe

This commit is contained in:
nobody 2020-10-20 21:42:26 -07:00
parent c817e925f8
commit 000ed1d779
2 changed files with 26 additions and 16 deletions

View file

@ -11,30 +11,30 @@ class Zot_probe extends \Zotlabs\Web\Controller {
function get() {
$o .= '<h3>Zot6 Probe Diagnostic</h3>';
$o = replace_macros(get_markup_template('zot_probe.tpl'), [
'$page_title' => t('Zot6 Probe Diagnostic'),
'$resource' => [ 'resource', t('Object URL') , $_REQUEST['resource'], EMPTY_STR ],
'$authf' => [ 'authf', t('Authenticated fetch'), $_REQUEST['authf'], EMPTY_STR, [ t('No'), t('Yes') ] ],
'$submit' => t('Submit')
]);
$o .= '<form action="zot_probe" method="get">';
$o .= 'Lookup URI: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" /><br>';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br><br>';
if(x($_GET,'resource')) {
$resource = $_GET['resource'];
$channel = (($_GET['authf']) ? \App::get_channel() : null);
if(x($_GET,'addr')) {
$addr = $_GET['addr'];
$channel = (($_GET['auth']) ? \App::get_channel() : null);
if(strpos($addr,'x-zot:') === 0) {
$x = ZotURL::fetch($addr,$channel);
if(strpos($resource,'x-zot:') === 0) {
$x = ZotURL::fetch($resource,$channel);
}
else {
$x = Zotfinger::exec($addr,$channel);
$x = Zotfinger::exec($resource,$channel);
$o .= '<pre>' . htmlspecialchars(print_array($x)) . '</pre>';
$headers = 'Accept: application/x-zot+json, application/jrd+json, application/json';
$redirects = 0;
$x = z_fetch_url($addr,true,$redirects, [ 'headers' => [ $headers ]]);
$x = z_fetch_url($resource,true,$redirects, [ 'headers' => [ $headers ]]);
}
if($x['success']) {

10
view/tpl/zot_probe.tpl Normal file
View file

@ -0,0 +1,10 @@
<h3>{{$page_title}}</h3>
<form action="zot_probe" method="get">
{{include file="field_input.tpl" field=$resource}}
{{include file="field_checkbox.tpl" field=$authf}}
<input type="submit" name="submit" value="{{$submit}}" >
</form>
<br>
<br>