diff options
author | redmatrix <git@macgirvin.com> | 2016-05-26 16:33:01 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-26 16:33:01 -0700 |
commit | 096fdfc61b5381bd3f7918a7c5f6004461354f32 (patch) | |
tree | 7d664358e06fd2228aab13a60b719a50d88b49f9 | |
parent | 8e4889bdf1454b3ddb183c25926286d62faa642a (diff) | |
download | volse-hubzilla-096fdfc61b5381bd3f7918a7c5f6004461354f32.tar.gz volse-hubzilla-096fdfc61b5381bd3f7918a7c5f6004461354f32.tar.bz2 volse-hubzilla-096fdfc61b5381bd3f7918a7c5f6004461354f32.zip |
consolidate all the sys_boot functionality that is common between the web server and the cli daemon manager. Get rid of yet another global variable ($default_timezone) whilst doing so.
-rw-r--r-- | Zotlabs/Web/WebServer.php | 60 | ||||
-rwxr-xr-x | boot.php | 66 | ||||
-rw-r--r-- | include/cli_startup.php | 28 | ||||
-rwxr-xr-x | install/htconfig.sample.php | 4 | ||||
-rw-r--r-- | view/cs/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/de/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/en-au/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/en-gb/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/en/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/eo/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/fr/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/it/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/nb-no/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/pt-br/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/ru/htconfig.tpl | 2 | ||||
-rw-r--r-- | view/sv/htconfig.tpl | 2 |
16 files changed, 82 insertions, 100 deletions
diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 5237bf667..88ab4995b 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -13,65 +13,7 @@ class WebServer { require_once('boot.php'); - if(file_exists('.htsite.php')) - include('.htsite.php'); - - - // miniApp is a conversion object from old style .htconfig.php files - - $a = new \miniApp; - - // our central App object - - \App::init(); - - /* - * 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. - */ - - \App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); - - @include('.htconfig.php'); - - if(! defined('UNO')) - define('UNO', 0); - - $a->convert(); - - \App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); - date_default_timezone_set(\App::$timezone); - - - /* - * Try to open the database; - */ - - require_once('include/dba/dba_driver.php'); - - if(! \App::$install) { - \DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, \App::$install); - if(! \DBA::$dba->connected) { - system_unavailable(); - } - - unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); - - /** - * Load configs from db. Overwrite configs from .htconfig.php - */ - - load_config('config'); - load_config('system'); - load_config('feature'); - - \App::$session = new Session(); - \App::$session->init(); - load_hooks(); - call_hooks('init_1'); - - } + sys_boot(); \App::$language = get_best_language(); @@ -579,6 +579,72 @@ define ( 'ITEM_IS_STICKY', 1000 ); define ( 'DBTYPE_MYSQL', 0 ); define ( 'DBTYPE_POSTGRES', 1 ); + +function sys_boot() { + + // our central App object + + \App::init(); + + /* + * 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. + */ + + // miniApp is a conversion object from old style .htconfig.php files + + $a = new \miniApp; + + + \App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); + + @include('.htconfig.php'); + + if(! defined('UNO')) + define('UNO', 0); + + if(array_key_exists('default_timezone',get_defined_vars())) { + \App::$config['system']['timezone'] = $default_timezone; + } + + $a->convert(); + + \App::$timezone = ((\App::$config['system']['timezone']) ? \App::$config['system']['timezone'] : 'UTC'); + date_default_timezone_set(\App::$timezone); + + + /* + * Try to open the database; + */ + + require_once('include/dba/dba_driver.php'); + + if(! \App::$install) { + \DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, \App::$install); + if(! \DBA::$dba->connected) { + system_unavailable(); + } + + unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); + + /** + * Load configs from db. Overwrite configs from .htconfig.php + */ + + load_config('config'); + load_config('system'); + load_config('feature'); + + \App::$session = new \Zotlabs\Web\Session(); + \App::$session->init(); + load_hooks(); + call_hooks('init_1'); + } + +} + + /** * * Reverse the effect of magic_quotes_gpc if it is enabled. diff --git a/include/cli_startup.php b/include/cli_startup.php index 792598c6c..a4c1f629a 100644 --- a/include/cli_startup.php +++ b/include/cli_startup.php @@ -6,33 +6,7 @@ require_once('boot.php'); function cli_startup() { - global $default_timezone; - - $a = new miniApp; - - App::init(); - - @include(".htconfig.php"); - - $a->convert(); - - if(! defined('UNO')) - define('UNO', 0); - - App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); - date_default_timezone_set(App::$timezone); - - require_once('include/dba/dba_driver.php'); - DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); - unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); - - App::$session = new Zotlabs\Web\Session(); - App::$session->init(); - - load_config('system'); - + sys_boot(); App::set_baseurl(get_config('system','baseurl')); - load_hooks(); - }
\ No newline at end of file diff --git a/install/htconfig.sample.php b/install/htconfig.sample.php index 5e506225e..c46805171 100755 --- a/install/htconfig.sample.php +++ b/install/htconfig.sample.php @@ -37,11 +37,11 @@ define( 'UNO', 0 ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = 'America/Los_Angeles'; +App::$config['system']['timezone'] = 'America/Los_Angeles'; // What is your site name? DO NOT ADD A TRAILING SLASH! -App::$config['system']['baseurl'] = 'https://myredsite.example'; +App::$config['system']['baseurl'] = 'https://mysite.example'; App::$config['system']['sitename'] = "Hubzilla"; App::$config['system']['location_hash'] = 'if the auto install failed, put a unique random string here'; diff --git a/view/cs/htconfig.tpl b/view/cs/htconfig.tpl index d0a799cf6..802b31b49 100644 --- a/view/cs/htconfig.tpl +++ b/view/cs/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/de/htconfig.tpl b/view/de/htconfig.tpl index adbb7ea92..2b71610b6 100644 --- a/view/de/htconfig.tpl +++ b/view/de/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/en-au/htconfig.tpl b/view/en-au/htconfig.tpl index 4dcc3c7c9..896b35bb2 100644 --- a/view/en-au/htconfig.tpl +++ b/view/en-au/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/en-gb/htconfig.tpl b/view/en-gb/htconfig.tpl index ead987fcc..04eb404fc 100644 --- a/view/en-gb/htconfig.tpl +++ b/view/en-gb/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/en/htconfig.tpl b/view/en/htconfig.tpl index 4aa6132a6..47daf3f99 100644 --- a/view/en/htconfig.tpl +++ b/view/en/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? DO NOT ADD A TRAILING SLASH! diff --git a/view/eo/htconfig.tpl b/view/eo/htconfig.tpl index 7a452087b..b90c00d6e 100644 --- a/view/eo/htconfig.tpl +++ b/view/eo/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/fr/htconfig.tpl b/view/fr/htconfig.tpl index 029c472f7..d49448ac2 100644 --- a/view/fr/htconfig.tpl +++ b/view/fr/htconfig.tpl @@ -29,7 +29,7 @@ define( 'UNO', {{$uno}} ); // Choisissez votre emplacement géographique. Si vous n'êtes pas certain, utilisez "America/Los_Angeles". // Vous pourrez le changer plus tard et ce réglage n'affecte que les visiteurs anonymes. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // Quel sera le nom de votre site? diff --git a/view/it/htconfig.tpl b/view/it/htconfig.tpl index d0a799cf6..802b31b49 100644 --- a/view/it/htconfig.tpl +++ b/view/it/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/nb-no/htconfig.tpl b/view/nb-no/htconfig.tpl index d0a799cf6..802b31b49 100644 --- a/view/nb-no/htconfig.tpl +++ b/view/nb-no/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/pt-br/htconfig.tpl b/view/pt-br/htconfig.tpl index d0a799cf6..802b31b49 100644 --- a/view/pt-br/htconfig.tpl +++ b/view/pt-br/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/ru/htconfig.tpl b/view/ru/htconfig.tpl index 97155ea42..5456d12c1 100644 --- a/view/ru/htconfig.tpl +++ b/view/ru/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? diff --git a/view/sv/htconfig.tpl b/view/sv/htconfig.tpl index 97155ea42..5456d12c1 100644 --- a/view/sv/htconfig.tpl +++ b/view/sv/htconfig.tpl @@ -28,7 +28,7 @@ define( 'UNO', {{$uno}} ); // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. -$default_timezone = '{{$timezone}}'; +App::$config['system']['timezone'] = '{{$timezone}}'; // What is your site name? |