From 66334374af2a19fb76383028975724b9eda03cf2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 17:30:33 -0700 Subject: zot_site_info - always sign the site block with the site private key --- include/zot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/zot.php b/include/zot.php index 1a9692ae9..a9ec95baa 100644 --- a/include/zot.php +++ b/include/zot.php @@ -4183,7 +4183,7 @@ function zotinfo($arr) { if($x) $ret['locations'] = $x; - $ret['site'] = zot_site_info($e); + $ret['site'] = zot_site_info(); check_zotinfo($e,$x,$ret); @@ -4195,10 +4195,10 @@ function zotinfo($arr) { } -function zot_site_info($channel = null) { +function zot_site_info() { - $signing_key = (($channel) ? $channel['channel_prvkey'] : get_config('system','prvkey')); - $sig_method = get_config('system','signature_algorithm','sha256'); + $signing_key = get_config('system','prvkey'); + $sig_method = get_config('system','signature_algorithm','sha256'); $ret = []; $ret['site'] = []; -- cgit v1.2.3 From d91a82430ad4ea9def4f0c033df4be34cb26d42e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 20:11:21 -0700 Subject: more zot6 basic stuff --- Zotlabs/Lib/System.php | 7 +++++++ boot.php | 2 -- include/zot.php | 14 +++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index a5790fb07..8b4d7258a 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -61,6 +61,13 @@ class System { return 'pro'; } + + static public function get_zot_revision() { + $x = [ 'revision' => ZOT_REVISION ]; + call_hooks('zot_revision',$x) + return $x['revision']; + } + static public function get_std_version() { if(defined('STD_VERSION')) return STD_VERSION; diff --git a/boot.php b/boot.php index df5c77e43..e0ffb050c 100755 --- a/boot.php +++ b/boot.php @@ -72,8 +72,6 @@ define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* prima define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server. -define ( 'ZOT6_COMPLIANT', 0x1000); - // We will look for upstream directories whenever me make contact // with other sites, but if this is a new installation and isn't // a standalone hub, we need to seed the service with a starting diff --git a/include/zot.php b/include/zot.php index a9ec95baa..af7fbf8fd 100644 --- a/include/zot.php +++ b/include/zot.php @@ -124,7 +124,7 @@ function zot_build_packet($channel, $type = 'notify', $recipients = null, $remot 'sitekey' => get_config('system','pubkey') ], 'callback' => '/post', - 'version' => ZOT_REVISION, + 'version' => Zotlabs\Lib\System::get_zot_revision(), 'encryption' => crypto_methods(), 'signing' => signing_methods() ]; @@ -2894,8 +2894,9 @@ function import_site($arr, $pubkey) { $site_flags = $site_directory; - if(array_key_exists('zot',$arr) && ((float) $arr['zot']) >= 6.0) - $site_flags = ($site_flags & ZOT6_COMPLIANT); + if(array_key_exists('zot',$arr)) { + set_sconfig($arr['url'],'system','zot_version',$arr['zot']); + } if($exists) { if(($siterecord['site_flags'] != $site_flags) @@ -4225,12 +4226,7 @@ function zot_site_info() { $ret['site']['encryption'] = crypto_methods(); $ret['site']['signing'] = signing_methods(); - if(function_exists('zotvi_load')) { - $ret['site']['zot'] = '6.0'; - } - else { - $ret['site']['zot'] = ZOT_REVISION; - } + $ret['site']['zot'] = Zotlabs\Lib\System::get_zot_revision(); // hide detailed site information if you're off the grid -- cgit v1.2.3 From be8061b64b47d96ae67e672bf2835e8cec73d979 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 20:12:43 -0700 Subject: typo --- Zotlabs/Lib/System.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 8b4d7258a..c3e11eb6a 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -64,7 +64,7 @@ class System { static public function get_zot_revision() { $x = [ 'revision' => ZOT_REVISION ]; - call_hooks('zot_revision',$x) + call_hooks('zot_revision',$x); return $x['revision']; } -- cgit v1.2.3 From 9d7a88b40dff8ea49e7185d71e7bad4139b1d289 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 23:14:02 -0700 Subject: move the Link header initialisation from Router (where it does not really belong) to Webserver, where we do similar module specific initialisations prior to calling Router->Dispatch() --- Zotlabs/Module/Post.php | 15 +++++---------- Zotlabs/Web/Router.php | 18 ------------------ Zotlabs/Web/WebServer.php | 28 ++++++++++++++++++++++++++++ boot.php | 3 +++ 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Zotlabs/Module/Post.php b/Zotlabs/Module/Post.php index dba26075f..76b74a338 100644 --- a/Zotlabs/Module/Post.php +++ b/Zotlabs/Module/Post.php @@ -24,18 +24,13 @@ class Post extends \Zotlabs\Web\Controller { } function post() { + if(array_key_exists('data',$_REQUEST)) { + $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler()); - - - - - - - - $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler()); + // notreached; + exit; + } - // notreached; - exit; } } diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index b0193652b..9486130cb 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -178,24 +178,6 @@ class Router { */ if(\App::$module_loaded) { - if (( \App::$module === 'channel' ) && argc() > 1) { - \App::$channel_links = [ - [ - 'rel' => 'lrdd', - 'type' => 'application/xrd+xml', - 'url' => z_root() . '/xrd?f=&uri=acct%3A' . argv(1) . '%40' . \App::get_hostname() - ], - [ - 'rel' => 'jrd', - 'type' => 'application/jrd+json', - 'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . \App::get_hostname() - ], - ]; - $x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ]; - call_hooks('channel_links', $x ); - \App::$channel_links = $x['channel_links']; - header('Link: ' . \App::get_channel_links()); - } \App::$page['page_title'] = \App::$module; $placeholder = ''; diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 8431a2e0e..65b772fee 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -107,6 +107,34 @@ class WebServer { $Router = new Router($a); + /* Initialise the Link: response header if this is a channel page. + * This cannot be done inside the channel module because some protocol + * addons over-ride the module functions and these links are common + * to all protocol drivers; thus doing it here avoids duplication. + */ + + if (( \App::$module === 'channel' ) && argc() > 1) { + \App::$channel_links = [ + [ + 'rel' => 'lrdd', + 'type' => 'application/xrd+xml', + 'url' => z_root() . '/xrd?f=&uri=acct%3A' . argv(1) . '%40' . \App::get_hostname() + ], + [ + 'rel' => 'jrd', + 'type' => 'application/jrd+json', + 'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . \App::get_hostname() + ], + ]; + $x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ]; + call_hooks('channel_links', $x ); + \App::$channel_links = $x['channel_links']; + header('Link: ' . \App::get_channel_links()); + } + + + + /* initialise content region */ if(! x(\App::$page, 'content')) diff --git a/boot.php b/boot.php index e0ffb050c..056d7c729 100755 --- a/boot.php +++ b/boot.php @@ -921,6 +921,9 @@ class App { * * There will always be one argument. If provided a naked domain * URL, self::$argv[0] is set to "home". + * + * If $argv[0] has a period in it, for example foo.json; rewrite + * to module = 'foo' and set $_REQUEST['module_format'] = 'json'; */ self::$argv = explode('/', self::$cmd); -- cgit v1.2.3 From 86e888e5ebf4090dbab33a28a68fa67b93566417 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 23:39:48 -0700 Subject: whitespace --- Zotlabs/Module/Post.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Zotlabs/Module/Post.php b/Zotlabs/Module/Post.php index 76b74a338..f67cbf020 100644 --- a/Zotlabs/Module/Post.php +++ b/Zotlabs/Module/Post.php @@ -26,8 +26,6 @@ class Post extends \Zotlabs\Web\Controller { function post() { if(array_key_exists('data',$_REQUEST)) { $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler()); - - // notreached; exit; } -- cgit v1.2.3