Merge pull request #293 from MicMee/master
more progress in admin to maintain hubloc with ping
This commit is contained in:
commit
70de97fca1
@ -78,7 +78,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
|||||||
@curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
@curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
||||||
|
|
||||||
|
|
||||||
// don't let curl abort the entire application
|
// don't let curl abort the entire application'
|
||||||
// if it throws any errors.
|
// if it throws any errors.
|
||||||
|
|
||||||
$s = @curl_exec($ch);
|
$s = @curl_exec($ch);
|
||||||
@ -86,7 +86,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
|||||||
$base = $s;
|
$base = $s;
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
$http_code = $curl_info['http_code'];
|
$http_code = $curl_info['http_code'];
|
||||||
// logger('fetch_url:' . $http_code . ' data: ' . $s);
|
//logger('fetch_url:' . $http_code . ' data: ' . $s);
|
||||||
$header = '';
|
$header = '';
|
||||||
|
|
||||||
// Pull out multiple headers, e.g. proxy and continuation headers
|
// Pull out multiple headers, e.g. proxy and continuation headers
|
||||||
|
@ -19,7 +19,7 @@ $a = new App;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Load the configuration file which contains our DB credentials.
|
* Load the configuration file which contains our DB credentials.
|
||||||
* Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
|
* Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -182,7 +182,6 @@ if(strlen($a->module)) {
|
|||||||
* Otherwise, look for the standard program module in the 'mod' directory
|
* Otherwise, look for the standard program module in the 'mod' directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if(! $a->module_loaded) {
|
if(! $a->module_loaded) {
|
||||||
if(file_exists("custom/{$a->module}.php")) {
|
if(file_exists("custom/{$a->module}.php")) {
|
||||||
include_once("custom/{$a->module}.php");
|
include_once("custom/{$a->module}.php");
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @param App $a
|
* @param App $a
|
||||||
*/
|
*/
|
||||||
function admin_post(&$a){
|
function admin_post(&$a){
|
||||||
|
logger('admin_post', LOGGER_DEBUG);
|
||||||
|
|
||||||
if(!is_site_admin()) {
|
if(!is_site_admin()) {
|
||||||
return;
|
return;
|
||||||
@ -74,6 +74,7 @@ function admin_post(&$a){
|
|||||||
*/
|
*/
|
||||||
function admin_content(&$a) {
|
function admin_content(&$a) {
|
||||||
|
|
||||||
|
logger('admin_content', LOGGER_DEBUG);
|
||||||
if(!is_site_admin()) {
|
if(!is_site_admin()) {
|
||||||
return login(false);
|
return login(false);
|
||||||
}
|
}
|
||||||
@ -468,6 +469,7 @@ function admin_page_site(&$a) {
|
|||||||
}
|
}
|
||||||
function admin_page_hubloc_post(&$a){
|
function admin_page_hubloc_post(&$a){
|
||||||
check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc');
|
check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc');
|
||||||
|
require_once('include/zot.php');
|
||||||
|
|
||||||
//prepare for ping
|
//prepare for ping
|
||||||
|
|
||||||
@ -477,19 +479,34 @@ function admin_page_hubloc_post(&$a){
|
|||||||
intval($hublocid)
|
intval($hublocid)
|
||||||
);
|
);
|
||||||
$hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post';
|
$hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post';
|
||||||
logger('hubloc_url : ' . $hublocurl , LOGGER_DEBUG);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if ( $_POST'' == "check" ) {
|
|
||||||
// //todo
|
|
||||||
//}
|
|
||||||
|
|
||||||
//perform ping
|
//perform ping
|
||||||
|
$m = zot_build_packet($a->get_channel(),'ping');
|
||||||
|
$r = zot_zot($hublocurl,$m);
|
||||||
//handle results and set the hubloc flags in db to make results visible
|
//handle results and set the hubloc flags in db to make results visible
|
||||||
|
$r2 = $r[body];
|
||||||
|
$r3 = $r2[success];
|
||||||
|
if ( $r3[success] == True ){
|
||||||
|
//set HUBLOC_OFFLINE to 0
|
||||||
|
logger(' success = true ',LOGGER_DEBUG);
|
||||||
|
} else {
|
||||||
|
//set HUBLOC_OFFLINE to 1
|
||||||
|
logger(' success = false ', LOGGER_DEBUG);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//unfotunatly zping wont work, I guess return format is not correct
|
||||||
|
//require_once('mod/zping.php');
|
||||||
|
//$r = zping_content($hublocurl);
|
||||||
|
//logger('zping answer: ' . $r, LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
||||||
//in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db
|
//in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db
|
||||||
//after repair set hubloc flags to 0
|
//after repair set hubloc flags to 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
goaway($a->get_baseurl(true) . '/admin/hubloc' );
|
goaway($a->get_baseurl(true) . '/admin/hubloc' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +255,11 @@ function post_init(&$a) {
|
|||||||
$a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
|
$a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
|
||||||
info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name']));
|
info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name']));
|
||||||
logger('mod_zot: auth success from ' . $x[0]['xchan_addr']);
|
logger('mod_zot: auth success from ' . $x[0]['xchan_addr']);
|
||||||
|
q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ",
|
||||||
|
intval(HUBLOC_WORKS),
|
||||||
|
intval($x[0]['hubloc_id'])
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if($test) {
|
if($test) {
|
||||||
@ -445,14 +450,12 @@ function post_init(&$a) {
|
|||||||
|
|
||||||
function post_post(&$a) {
|
function post_post(&$a) {
|
||||||
|
|
||||||
logger('mod_zot: ' . print_r($_REQUEST,true), LOGGER_DEBUG);
|
|
||||||
|
|
||||||
$encrypted_packet = false;
|
$encrypted_packet = false;
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
|
||||||
$data = json_decode($_REQUEST['data'],true);
|
$data = json_decode($_REQUEST['data'],true);
|
||||||
|
|
||||||
logger('mod_zot: data: ' . print_r($data,true), LOGGER_DATA);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Many message packets will arrive encrypted. The existence of an 'iv' element
|
* Many message packets will arrive encrypted. The existence of an 'iv' element
|
||||||
@ -481,7 +484,6 @@ function post_post(&$a) {
|
|||||||
$data = array('type' => 'bogus');
|
$data = array('type' => 'bogus');
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('mod_zot: decoded data: ' . print_r($data,true), LOGGER_DATA);
|
|
||||||
|
|
||||||
$msgtype = ((array_key_exists('type',$data)) ? $data['type'] : '');
|
$msgtype = ((array_key_exists('type',$data)) ? $data['type'] : '');
|
||||||
|
|
||||||
@ -490,6 +492,7 @@ function post_post(&$a) {
|
|||||||
// Useful to get a health check on a remote site.
|
// Useful to get a health check on a remote site.
|
||||||
// This will let us know if any important communication details
|
// This will let us know if any important communication details
|
||||||
// that we may have stored are no longer valid, regardless of xchan details.
|
// that we may have stored are no longer valid, regardless of xchan details.
|
||||||
|
logger('POST: got ping send pong now back: ' . z_root() , LOGGER_DEBUG );
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
$ret['site'] = array();
|
$ret['site'] = array();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<form action="{{$baseurl}}/admin/hubloc" method="post">
|
<form action="{{$baseurl}}/admin/hubloc" method="post">
|
||||||
<input type="hidden" name="hublocid" value="{{$hub.hubloc_id}}">
|
<input type="hidden" name="hublocid" value="{{$hub.hubloc_id}}">
|
||||||
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
|
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
|
||||||
|
<input type='hidden' name='url' value='{{$hub.hubloc_host}}'>
|
||||||
<input type="submit" name="check" value="check" >
|
<input type="submit" name="check" value="check" >
|
||||||
<input type="submit" name="repair" value="repair" ></td>
|
<input type="submit" name="repair" value="repair" ></td>
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user