From 904db593df914d2932d9c2f018b00987052461d7 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Mon, 27 Jan 2014 12:01:53 +0100 Subject: add a temporary logger command at remote server side --- mod/post.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/post.php b/mod/post.php index 965ba09a3..d01f61a5c 100644 --- a/mod/post.php +++ b/mod/post.php @@ -490,6 +490,7 @@ function post_post(&$a) { // Useful to get a health check on a remote site. // This will let us know if any important communication 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['site'] = array(); -- cgit v1.2.3 From aa285b83c1c8f674be8f200d4feae6299eafc436 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Tue, 28 Jan 2014 10:58:31 +0100 Subject: to make visible what I try, ping still won't work, but I'm confused about get_channel --- mod/admin.php | 8 +++++++- mod/post.php | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mod/admin.php b/mod/admin.php index 950c7e5ce..e59f15c74 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -468,6 +468,7 @@ function admin_page_site(&$a) { } function admin_page_hubloc_post(&$a){ check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc'); + require_once('include/zot.php'); //prepare for ping @@ -477,7 +478,12 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - logger('hubloc_url : ' . $hublocurl , LOGGER_DEBUG); + logger('ping hubloc_url : ' . $hublocurl , LOGGER_DEBUG); + logger('ping get_channel : ' . print_r($a->get_channel(),true), LOGGER_DEBUG); + $m = zot_build_packet($a->get_channel(),'ping'); + $r = zot_zot($hubloc_url,$m); + logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); + } //if ( $_POST'' == "check" ) { diff --git a/mod/post.php b/mod/post.php index d01f61a5c..cce183e46 100644 --- a/mod/post.php +++ b/mod/post.php @@ -9,6 +9,8 @@ require_once('include/zot.php'); function post_init(&$a) { + logger('POST inside',LOGGER_DEBUG); + logger('POST given parameter: ' . print_r($_REQUEST,true), LOGGER_DEBUG); // Most access to this endpoint is via the post method. // Here we will pick out the magic auth params which arrive -- cgit v1.2.3 From ef97a454bbccbd9f7e0e63180c365ed3227fe42c Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Wed, 29 Jan 2014 15:45:35 +0100 Subject: ping gives us now a reply. But the reply doesnt contains useful data, requires still some investigations --- mod/admin.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index e59f15c74..1a284c42f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -478,23 +478,25 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - logger('ping hubloc_url : ' . $hublocurl , LOGGER_DEBUG); - logger('ping get_channel : ' . print_r($a->get_channel(),true), LOGGER_DEBUG); + + //perform ping $m = zot_build_packet($a->get_channel(),'ping'); + logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); $r = zot_zot($hubloc_url,$m); logger('ping answer: ' . print_r($r,true), 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); + + //handle results and set the hubloc flags in db to make results visible - } - - //if ( $_POST'' == "check" ) { - // //todo - //} + //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 - //perform ping - //handle results and set the hubloc flags in db to make results visible + } - //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 goaway($a->get_baseurl(true) . '/admin/hubloc' ); return; -- cgit v1.2.3 From 0a2b2a139080b41c10bbc7fc0f3b24129f2c3c38 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 10:39:09 +0100 Subject: attempt with fix URL for testing works --- include/network.php | 12 +++++++++--- include/zot.php | 1 + index.php | 5 +++-- mod/admin.php | 7 +++++-- view/tpl/admin_hubloc.tpl | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/network.php b/include/network.php index 3fe7f5400..ca6fa1bfc 100644 --- a/include/network.php +++ b/include/network.php @@ -78,7 +78,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { @curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); - // don't let curl abort the entire application + // dont let curl abort the entire application // if it throws any errors. $s = @curl_exec($ch); @@ -86,7 +86,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { $base = $s; $curl_info = @curl_getinfo($ch); $http_code = $curl_info['http_code']; -// logger('fetch_url:' . $http_code . ' data: ' . $s); + logger('fetch_url:' . $http_code . ' data: ' . $s); $header = ''; // Pull out multiple headers, e.g. proxy and continuation headers @@ -129,7 +129,11 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { function z_post_url($url,$params, $redirects = 0, $opts = array()) { - + + logger('z_post_url',LOGGER_DEBUG); + logger('z_post_url url ' . $url ,LOGGER_DEBUG); + logger('z_post_url params' . $params ,LOGGER_DEBUG); + logger('z_post_url redirects ' . $redirects ,LOGGER_DEBUG); $ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => ""); $ch = curl_init($url); @@ -181,10 +185,12 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) { // if it throws any errors. $s = @curl_exec($ch); + logger('z_post_url s ' . $s ,LOGGER_DEBUG); $base = $s; $curl_info = curl_getinfo($ch); $http_code = $curl_info['http_code']; + logger('z_post_url http_code ' . $http_code ,LOGGER_DEBUG); $header = ''; diff --git a/include/zot.php b/include/zot.php index 7c2cfe019..de2fb4202 100644 --- a/include/zot.php +++ b/include/zot.php @@ -134,6 +134,7 @@ function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_ function zot_zot($url,$data) { + logger('zot_zot ',LOGGER_DEBUG); return z_post_url($url,array('data' => $data)); } diff --git a/index.php b/index.php index 6ffef19cb..15fa264bd 100755 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ $a = new App; /** * * 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 doesnt exist or is empty, we are running in installation mode. * */ @@ -181,7 +181,8 @@ if(strlen($a->module)) { * If the site has a custom module to over-ride the standard module, use it. * Otherwise, look for the standard program module in the 'mod' directory */ - + logger('Index.php', LOGGER_DEBUG); + //logger('Index.php array ' . print_r($a,true), LOGGER_DEBUG); if(! $a->module_loaded) { if(file_exists("custom/{$a->module}.php")) { diff --git a/mod/admin.php b/mod/admin.php index 1a284c42f..360eddd2a 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -9,7 +9,7 @@ * @param App $a */ function admin_post(&$a){ - + logger('admin_post', LOGGER_DEBUG); if(!is_site_admin()) { return; @@ -74,6 +74,7 @@ function admin_post(&$a){ */ function admin_content(&$a) { + logger('admin_content', LOGGER_DEBUG); if(!is_site_admin()) { return login(false); } @@ -478,11 +479,13 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; + $hublocurl = "http://fred-dev.michameer.dyndns.org/post"; //perform ping $m = zot_build_packet($a->get_channel(),'ping'); logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); - $r = zot_zot($hubloc_url,$m); + logger('ping _REQUEST ' . print_r($_REQUEST,true), LOGGER_DEBUG); + $r = zot_zot($hublocurl,$m); logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); //unfotunatly zping wont work, I guess return format is not correct diff --git a/view/tpl/admin_hubloc.tpl b/view/tpl/admin_hubloc.tpl index ea840e1b3..06a8cdf6a 100755 --- a/view/tpl/admin_hubloc.tpl +++ b/view/tpl/admin_hubloc.tpl @@ -15,6 +15,7 @@
+
-- cgit v1.2.3 From c5ac5544cb02aa3194c5cab2b3ab736a2e19e6eb Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 11:04:20 +0100 Subject: clean up logger commands. Placed apostrophs at the end from some comments to keep the syntax highlighting in vi working --- include/network.php | 10 ++-------- include/zot.php | 1 - index.php | 4 +--- mod/admin.php | 3 --- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/include/network.php b/include/network.php index ca6fa1bfc..1fb4beaa7 100644 --- a/include/network.php +++ b/include/network.php @@ -78,7 +78,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { @curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); - // dont let curl abort the entire application + // don't let curl abort the entire application' // if it throws any errors. $s = @curl_exec($ch); @@ -86,7 +86,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { $base = $s; $curl_info = @curl_getinfo($ch); $http_code = $curl_info['http_code']; - logger('fetch_url:' . $http_code . ' data: ' . $s); + //logger('fetch_url:' . $http_code . ' data: ' . $s); $header = ''; // Pull out multiple headers, e.g. proxy and continuation headers @@ -130,10 +130,6 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { function z_post_url($url,$params, $redirects = 0, $opts = array()) { - logger('z_post_url',LOGGER_DEBUG); - logger('z_post_url url ' . $url ,LOGGER_DEBUG); - logger('z_post_url params' . $params ,LOGGER_DEBUG); - logger('z_post_url redirects ' . $redirects ,LOGGER_DEBUG); $ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => ""); $ch = curl_init($url); @@ -185,12 +181,10 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) { // if it throws any errors. $s = @curl_exec($ch); - logger('z_post_url s ' . $s ,LOGGER_DEBUG); $base = $s; $curl_info = curl_getinfo($ch); $http_code = $curl_info['http_code']; - logger('z_post_url http_code ' . $http_code ,LOGGER_DEBUG); $header = ''; diff --git a/include/zot.php b/include/zot.php index de2fb4202..7c2cfe019 100644 --- a/include/zot.php +++ b/include/zot.php @@ -134,7 +134,6 @@ function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_ function zot_zot($url,$data) { - logger('zot_zot ',LOGGER_DEBUG); return z_post_url($url,array('data' => $data)); } diff --git a/index.php b/index.php index 15fa264bd..c2421bc0e 100755 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ $a = new App; /** * * Load the configuration file which contains our DB credentials. - * Ignore errors. If the file doesnt 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.' * */ @@ -181,8 +181,6 @@ if(strlen($a->module)) { * If the site has a custom module to over-ride the standard module, use it. * Otherwise, look for the standard program module in the 'mod' directory */ - logger('Index.php', LOGGER_DEBUG); - //logger('Index.php array ' . print_r($a,true), LOGGER_DEBUG); if(! $a->module_loaded) { if(file_exists("custom/{$a->module}.php")) { diff --git a/mod/admin.php b/mod/admin.php index 360eddd2a..12b847b03 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -479,12 +479,9 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - $hublocurl = "http://fred-dev.michameer.dyndns.org/post"; //perform ping $m = zot_build_packet($a->get_channel(),'ping'); - logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); - logger('ping _REQUEST ' . print_r($_REQUEST,true), LOGGER_DEBUG); $r = zot_zot($hublocurl,$m); logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); -- cgit v1.2.3 From 3bdbdbab53e76ef86b2ff4df6db708b16d216f77 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 30 Jan 2014 19:44:50 +0100 Subject: dont show an empty link to profile creation if multi_profile is not enabled --- view/tpl/profile_vcard.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/view/tpl/profile_vcard.tpl b/view/tpl/profile_vcard.tpl index 7a857fd67..187c3039d 100755 --- a/view/tpl/profile_vcard.tpl +++ b/view/tpl/profile_vcard.tpl @@ -10,8 +10,7 @@ {{/foreach}}
  • {{$profile.menu.chg_photo}}
  • -
  • {{$profile.menu.cr_new}}
  • - + {{if $profile.menu.cr_new}}
  • {{$profile.menu.cr_new}}
  • {{/if}} {{/if}} -- cgit v1.2.3 From c0f02d774a0af0f0959a7690dadb30586ee0b6b1 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 20:41:40 +0100 Subject: started analysis of ping response and clean up more logger --- mod/admin.php | 13 +++++++++++-- mod/post.php | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index 12b847b03..76decae09 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -483,14 +483,23 @@ function admin_page_hubloc_post(&$a){ //perform ping $m = zot_build_packet($a->get_channel(),'ping'); $r = zot_zot($hublocurl,$m); - logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); + //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); - //handle results and set the hubloc flags in db to make results visible //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 diff --git a/mod/post.php b/mod/post.php index cce183e46..cb0dc8302 100644 --- a/mod/post.php +++ b/mod/post.php @@ -9,8 +9,6 @@ require_once('include/zot.php'); function post_init(&$a) { - logger('POST inside',LOGGER_DEBUG); - logger('POST given parameter: ' . print_r($_REQUEST,true), LOGGER_DEBUG); // Most access to this endpoint is via the post method. // Here we will pick out the magic auth params which arrive @@ -257,6 +255,11 @@ function post_init(&$a) { $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name'])); 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 { if($test) { @@ -447,14 +450,12 @@ function post_init(&$a) { function post_post(&$a) { - logger('mod_zot: ' . print_r($_REQUEST,true), LOGGER_DEBUG); $encrypted_packet = false; $ret = array('success' => false); $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 @@ -483,7 +484,6 @@ function post_post(&$a) { $data = array('type' => 'bogus'); } - logger('mod_zot: decoded data: ' . print_r($data,true), LOGGER_DATA); $msgtype = ((array_key_exists('type',$data)) ? $data['type'] : ''); -- cgit v1.2.3