From fd708b28b8b985c8cdab096401b23bb42d1c0056 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 13 Sep 2015 22:48:18 -0700 Subject: ping site function (taken from admin/hubloc) --- include/hubloc.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'include/hubloc.php') diff --git a/include/hubloc.php b/include/hubloc.php index 396f4ddfa..8bd6d8d68 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -275,4 +275,29 @@ function xchan_fetch($arr) { $ret[str_replace('xchan_','',$k)] = $v; } return $ret; -} \ No newline at end of file +} + + + +function ping_site($url) { + + $ret = array('success' => false); + + $sys = get_sys_channel(); + + $m = zot_build_packet($sys,'ping'); + $r = zot_zot($url . '/post',$m); + if(! $r['success']) { + $ret['message'] = 'no answer from ' . $url; + return $ret; + } + $packet_result = $r['body']; + if(! $packet_result['success']) { + $ret['message'] = 'packet failure from ' . $url; + return $ret; + } + + $ret['success'] = true; + return $ret; + +} -- cgit v1.2.3 From 97b990c9bf0c08e9088ea8dea54177c044eaa6ad Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 14 Sep 2015 19:16:25 -0700 Subject: site checking stuff --- include/hubloc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/hubloc.php') diff --git a/include/hubloc.php b/include/hubloc.php index 8bd6d8d68..674a3885f 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -291,13 +291,18 @@ function ping_site($url) { $ret['message'] = 'no answer from ' . $url; return $ret; } - $packet_result = $r['body']; + $packet_result = json_decode($r['body'],true); if(! $packet_result['success']) { $ret['message'] = 'packet failure from ' . $url; return $ret; } - $ret['success'] = true; - return $ret; + if($packet_result['success']) { + $ret['success'] = true; + } + else { + $ret['message'] = 'unknown error from ' . $url; + } + return $ret; } -- cgit v1.2.3