aboutsummaryrefslogtreecommitdiffstats
path: root/mod/authtest.php
blob: 2c8d7b4b4813c9bb83650c12e7691921a8944881 (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
<?php

require_once('include/zot.php');
require_once('mod/magic.php');

function authtest_content(&$a) {



	$o .= '<h3>Magic-Auth Diagnostic</h3>';

	if(! local_user()) {
		notice( t('Permission denied.') . EOL);
		return $o;
	}

	$o .= '<form action="authtest" method="get">';
	$o .= 'Target URL: <input type="text" style="width: 250px;" name="dest" value="' . $_GET['dest'] .'" />';
	$o .= '<input type="submit" name="submit" value="Submit" /></form>'; 

	$o .= '<br /><br />';

	if(x($_GET,'dest')) {
		$_REQUEST['test'] = 1;
		$x = magic_init($a);
		$o .= 'Local Setup returns: ' . print_r($x,true);



		if($x['url']) {
			$z = z_fetch_url($x['url'] . '&test=1');
			if($z['success']) {
				$j = json_decode($z['body'],true);
				if(! $j)
					$o .= 'json_decode failure from remote site. ' . print_r($z['body'],true);
				$o .= 'Remote site responded: ' . print_r($j,true);
			}
			else {
				$o .= 'fetch url failure.' . print_r($z,true);
			}
		}
	}

	return str_replace("\n",'<br />',$o);
}