From de006771c7fe92a889d759c2c75c1473c420ad47 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 22 May 2016 16:54:30 -0700 Subject: renamed include files identity.php (channel.php) and Contact.php (connections.php) --- boot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index e7e962b8e..25551346b 100755 --- a/boot.php +++ b/boot.php @@ -39,14 +39,14 @@ require_once('include/permissions.php'); require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('include/features.php'); require_once('include/taxonomy.php'); -require_once('include/identity.php'); -require_once('include/Contact.php'); +require_once('include/channel.php'); +require_once('include/connections.php'); require_once('include/account.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'STD_VERSION', '1.7.1' ); -define ( 'ZOT_REVISION', 1 ); +define ( 'ZOT_REVISION', 1.1 ); define ( 'DB_UPDATE_VERSION', 1168 ); -- cgit v1.2.3 From 5e0698ba8731e7e4659a24c0ab4fa9c4a1aef173 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 22 May 2016 17:52:30 -0700 Subject: turn the oft-repeated block_public ... check into a function observer_prohibited() --- boot.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 25551346b..690a330d8 100755 --- a/boot.php +++ b/boot.php @@ -2400,3 +2400,12 @@ function check_cron_broken() { } + +function observer_prohibited($allow_account = false) { + + if($allow_account) + return (((get_config('system','block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false ); + return (((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) ? true : false ); + +} + -- cgit v1.2.3 From 80f2ba640ec528bd43db243122a69e765703b7c0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 May 2016 20:49:23 -0700 Subject: code cleanup --- boot.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 690a330d8..d4836e61c 100755 --- a/boot.php +++ b/boot.php @@ -1197,7 +1197,6 @@ class App { * @return App */ function get_app() { - global $a; return $a; } @@ -1247,7 +1246,6 @@ function system_unavailable() { function clean_urls() { - global $a; // if(App::$config['system']['clean_urls']) return true; @@ -1255,8 +1253,6 @@ function clean_urls() { } function z_path() { - global $a; - $base = z_root(); if(! clean_urls()) $base .= '/?q='; @@ -1272,7 +1268,6 @@ function z_path() { * @return string */ function z_root() { - global $a; return App::get_baseurl(); } @@ -1604,7 +1599,6 @@ function fix_system_urls($oldurl, $newurl) { // returns the complete html for inserting into the page function login($register = false, $form_id = 'main-login', $hiddens=false) { - $a = get_app(); $o = ''; $reg = false; $reglink = get_config('system', 'register_link'); @@ -1674,9 +1668,7 @@ function goaway($s) { } function shutdown() { - global $db; - if(is_object($db) && $db->connected) - $db->close(); + } /** @@ -1766,7 +1758,6 @@ function remote_user() { * @param string $s Text to display */ function notice($s) { - $a = get_app(); if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array(); // ignore duplicated error messages which haven't yet been displayed @@ -1790,7 +1781,6 @@ function notice($s) { * @param string $s Text to display */ function info($s) { - $a = get_app(); if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array(); if(App::$interactive) $_SESSION['sysmsg_info'][] = $s; @@ -1891,7 +1881,6 @@ function is_windows() { */ function is_site_admin() { - $a = get_app(); if($_SESSION['delegate']) return false; @@ -1912,7 +1901,7 @@ function is_site_admin() { * @return bool true if user is a developer */ function is_developer() { - $a = get_app(); + if((intval($_SESSION['authenticated'])) && (is_array(App::$account)) && (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) @@ -1923,7 +1912,6 @@ function is_developer() { function load_contact_links($uid) { - $a = get_app(); $ret = array(); @@ -2241,7 +2229,6 @@ function appdirpath() { * @param string $icon */ function head_set_icon($icon) { - global $a; App::$data['pageicon'] = $icon; // logger('head_set_icon: ' . $icon); @@ -2253,7 +2240,6 @@ function head_set_icon($icon) { * @return string absolut path to pageicon */ function head_get_icon() { - global $a; $icon = App::$data['pageicon']; if(! strpos($icon, '://')) @@ -2319,7 +2305,7 @@ function z_get_temp_dir() { } function z_check_cert() { - $a = get_app(); + if(strpos(z_root(),'https://') !== false) { $x = z_fetch_url(z_root() . '/siteinfo/json'); if(! $x['success']) { @@ -2340,8 +2326,6 @@ function z_check_cert() { */ function cert_bad_email() { - $a = get_app(); - $email_tpl = get_intltext_template("cert_bad_eml.tpl"); $email_msg = replace_macros($email_tpl, array( '$sitename' => App::$config['system']['sitename'], @@ -2380,8 +2364,6 @@ function check_cron_broken() { return; } - $a = get_app(); - $email_tpl = get_intltext_template("cron_bad_eml.tpl"); $email_msg = replace_macros($email_tpl, array( '$sitename' => App::$config['system']['sitename'], -- cgit v1.2.3 From 4716627453c811bd6be6bf72afd83f43ab1abfc0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 25 May 2016 21:10:13 -0700 Subject: run background/daemon tasks at approximately 4 hour intervals from web accesses if they aren't being run otherwise. This ensures they run, although perhaps a bit infrequently; even if unconfigured. This is not suitable for a production site, but may be acceptable for small single person hubs and test sites. The 'cron warning email' now means that background processes are totally borked; probably due to a fascist hosting provider that has blocked process execution. --- boot.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index d4836e61c..2fa7d8061 100755 --- a/boot.php +++ b/boot.php @@ -2346,21 +2346,27 @@ function cert_bad_email() { */ function check_cron_broken() { - $t = get_config('system','lastpollcheck'); + $d = get_config('system','lastcron'); + + if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) { + Zotlabs\Daemon\Master::Summon(array('Cron')); + } + + $t = get_config('system','lastcroncheck'); if(! $t) { // never checked before. Start the timer. - set_config('system','lastpollcheck',datetime_convert()); + set_config('system','lastcroncheck',datetime_convert()); return; } + if($t > datetime_convert('UTC','UTC','now - 3 days')) { // Wait for 3 days before we do anything so as not to swamp the admin with messages return; } - $d = get_config('system','lastpoll'); if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) { // Scheduled tasks have run successfully in the last 3 days. - set_config('system','lastpollcheck',datetime_convert()); + set_config('system','lastcroncheck',datetime_convert()); return; } @@ -2377,7 +2383,6 @@ function check_cron_broken() { 'From: Administrator' . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); - set_config('system','lastpollcheck',datetime_convert()); return; } -- cgit v1.2.3 From 096fdfc61b5381bd3f7918a7c5f6004461354f32 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 26 May 2016 16:33:01 -0700 Subject: 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. --- boot.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'boot.php') diff --git a/boot.php b/boot.php index 2fa7d8061..b0ef5b3b9 100755 --- a/boot.php +++ b/boot.php @@ -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. -- cgit v1.2.3 From 1bce285eca9bf53044f3949a55fc434db2671b3a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 26 May 2016 17:51:59 -0700 Subject: don't need quite so many backslashes --- boot.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index b0ef5b3b9..1c3938cb4 100755 --- a/boot.php +++ b/boot.php @@ -584,7 +584,7 @@ function sys_boot() { // our central App object - \App::init(); + App::init(); /* * Load the configuration file which contains our DB credentials. @@ -594,10 +594,10 @@ function sys_boot() { // miniApp is a conversion object from old style .htconfig.php files - $a = new \miniApp; + $a = new miniApp; - \App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); + App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true); @include('.htconfig.php'); @@ -605,13 +605,13 @@ function sys_boot() { define('UNO', 0); if(array_key_exists('default_timezone',get_defined_vars())) { - \App::$config['system']['timezone'] = $default_timezone; + 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); + App::$timezone = ((App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC'); + date_default_timezone_set(App::$timezone); /* @@ -620,9 +620,9 @@ function sys_boot() { 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) { + 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(); } @@ -636,8 +636,8 @@ function sys_boot() { load_config('system'); load_config('feature'); - \App::$session = new \Zotlabs\Web\Session(); - \App::$session->init(); + App::$session = new Zotlabs\Web\Session(); + App::$session->init(); load_hooks(); call_hooks('init_1'); } -- cgit v1.2.3