aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Zot_probe.php
blob: d0c7e688fb0b8efb9b97d7523e8021666330459e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

namespace Zotlabs\Module;

use Zotlabs\Lib\Zotfinger;
use Zotlabs\Zot6\HTTPSig;

class Zot_probe extends \Zotlabs\Web\Controller {

	function get() {
	
		$o .= '<h3>Zot6 Probe Diagnostic</h3>';
	
		$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,'addr')) {
			$addr = $_GET['addr'];


			$x = Zotfinger::exec($addr);
			
			$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 ]]);

	    	if($x['success']) {

				$o .= '<pre>' . htmlspecialchars($x['header']) . '</pre>' . EOL;

				$o .= 'verify returns: ' . str_replace("\n",EOL,print_r(HTTPSig::verify($x),true)) . EOL;

				$o .= '<pre>' . htmlspecialchars(json_encode(json_decode($x['body']),JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)) . '</pre>' . EOL;

			}				

		}
		return $o;
	}
	
}