diff options
author | Mario <mario@mariovavti.com> | 2024-07-06 11:05:22 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-07-06 11:05:22 +0000 |
commit | 45275910e606a02b12393714ea3b0409da440d61 (patch) | |
tree | 10b2d173d58cb930f8df28fe75af73dd4974c08c /boot.php | |
parent | 0c1d0f7498661fb34dcca6f3c6566e757af310a7 (diff) | |
parent | c04e781926a78e514cdf211fa24930a331149072 (diff) | |
download | volse-hubzilla-master.tar.gz volse-hubzilla-master.tar.bz2 volse-hubzilla-master.zip |
Merge branch '9.2RC'master
Diffstat (limited to 'boot.php')
-rw-r--r-- | boot.php | 88 |
1 files changed, 51 insertions, 37 deletions
@@ -62,9 +62,11 @@ require_once('include/conversation.php'); require_once('include/acl_selectors.php'); require_once('include/selectors.php'); require_once('include/activities.php'); +require_once('include/security.php'); + define('PLATFORM_NAME', 'hubzilla'); -define('STD_VERSION', '9.0.2'); +define('STD_VERSION', '9.2'); define('ZOT_REVISION', '6.0'); define('DB_UPDATE_VERSION', 1263); @@ -602,8 +604,19 @@ define('DBTYPE_MYSQL', 0); define('DBTYPE_POSTGRES', 1); -function sys_boot() { - +/** + * Boot the app. + * + * Detects if the system is installed, and if it is, reads the basic configuration + * in `.htconfig`, conects to the database, and loads the system configuration stored + * in the db. + * + * As a side effect it also sets the App::$install flag to true if the system is _not_ + * installed yet. + * + * @return True if the system is installed, false otherwise. + */ +function sys_boot(): bool { // our central App object @@ -686,6 +699,8 @@ function sys_boot() { */ call_hooks('init_1'); } + + return !App::$install; } @@ -766,7 +781,6 @@ class App { public static $langsave; public static $rtl = false; public static $plugins_admin; - public static $module_loaded = false; public static $query_string; public static $page; public static $profile; @@ -1249,7 +1263,7 @@ class App { '$metas' => self::$meta->get(), '$plugins' => $x['header'], '$update_interval' => $interval, - '$sse_enabled' => get_config('system', 'sse_enabled', 0), + '$sse_enabled' => Config::Get('system', 'sse_enabled', 0), '$head_css' => head_get_css(), '$head_js' => head_get_js(), '$linkrel' => head_get_links(), @@ -1495,9 +1509,9 @@ function is_ajax() { */ function check_config() { - $saved = get_config('system', 'urlverify'); + $saved = Config::Get('system', 'urlverify'); if (!$saved) - set_config('system', 'urlverify', bin2hex(z_root())); + Config::Set('system', 'urlverify', bin2hex(z_root())); if (($saved) && ($saved != bin2hex(z_root()))) { // our URL changed. Do something. @@ -1513,7 +1527,7 @@ function check_config() { // only change the url to an ip address if it was already an ip and not a dns name if ((!$is_ip_addr) || ($is_ip_addr && $was_ip_addr)) { fix_system_urls($oldurl, z_root()); - set_config('system', 'urlverify', bin2hex(z_root())); + Config::Set('system', 'urlverify', bin2hex(z_root())); } else logger('Attempt to change baseurl from a DNS name to an IP address was refused.'); @@ -1634,7 +1648,7 @@ function fix_system_urls($oldurl, $newurl) { } } - Zotlabs\Daemon\Master::Summon(['Notifier', 'refresh_all', $c[0]['channel_id']]); + Master::Summon(['Notifier', 'refresh_all', $c[0]['channel_id']]); } } @@ -1713,9 +1727,9 @@ function login($register = false, $form_id = 'main_login', $hiddens = false, $lo // your site. - $register_policy = get_config('system', 'register_policy'); + $register_policy = Config::Get('system', 'register_policy'); - $reglink = get_config('system', 'register_link', z_root() . '/' . ((intval($register_policy) === REGISTER_CLOSED) ? 'pubsites' : 'register')); + $reglink = Config::Get('system', 'register_link', z_root() . '/' . ((intval($register_policy) === REGISTER_CLOSED) ? 'pubsites' : 'register')); if ($reglink !== 'none') { $reg = [ @@ -1736,7 +1750,7 @@ function login($register = false, $form_id = 'main_login', $hiddens = false, $lo $_SESSION['login_return_url'] = App::$query_string; } - $email_required = get_config('system', 'verify_email'); + $email_required = Config::Get('system', 'verify_email'); $lname_label = (($email_required) ? t('Email or nickname') : t('Nickname')); $o .= replace_macros($tpl, [ @@ -1746,9 +1760,9 @@ function login($register = false, $form_id = 'main_login', $hiddens = false, $lo '$login' => t('Login'), '$remote_login' => t('Remote Authentication'), '$form_id' => $form_id, - '$lname' => [$form_id . '_username', $lname_label], - '$lpassword' => [$form_id . '_password', t('Password')], - '$remember_me' => [$form_id . '_remember', t('Remember me'), '', '', [t('No'), t('Yes')]], + '$lname' => [$form_id . '_username', $lname_label, null, null, null, null], + '$lpassword' => [$form_id . '_password', t('Password'), null, null, null, null], + '$remember_me' => [$form_id . '_remember', t('Remember me'), '', '', [t('No'), t('Yes')], null, null], '$hiddens' => $hiddens, '$register' => $reg, '$lostpass' => t('Forgot your password?'), @@ -1854,13 +1868,13 @@ function can_view_public_stream() { return false; } - if (!(intval(get_config('system', 'open_pubstream', 1)))) { + if (!(intval(Config::Get('system', 'open_pubstream', 1)))) { if (!get_observer_hash()) { return false; } } - $net_firehose = ((get_config('system', 'disable_discover_tab', 1)) ? false : true); + $net_firehose = ((Config::Get('system', 'disable_discover_tab', 1)) ? false : true); if (!$net_firehose) { return false; @@ -2001,7 +2015,7 @@ function info($s) { * @return int */ function get_max_import_size() { - return (intval(get_config('system', 'max_import_size'))); + return (intval(Config::Get('system', 'max_import_size'))); } @@ -2055,7 +2069,7 @@ function proc_run() { proc_close(proc_open($cmd, [], $foo)); } else { - if (get_config('system', 'use_proc_open')) + if (Config::Get('system', 'use_proc_open')) proc_close(proc_open($cmdline . " &", [], $foo)); else exec($cmdline . ' > /dev/null &'); @@ -2333,7 +2347,7 @@ function construct_page() { $uid = ((App::$profile_uid) ? App::$profile_uid : local_channel()); - $navbar = get_config('system', 'navbar', 'default'); + $navbar = Config::Get('system', 'navbar', 'default'); if ($uid) { $navbar = get_pconfig($uid, 'system', 'navbar', $navbar); } @@ -2533,7 +2547,7 @@ function head_get_icon() { * @return string */ function get_directory_realm() { - if ($x = get_config('system', 'directory_realm')) + if ($x = Config::Get('system', 'directory_realm')) return $x; return DIRECTORY_REALM; @@ -2546,13 +2560,13 @@ function get_directory_realm() { */ function get_directory_primary() { - $dirmode = intval(get_config('system', 'directory_mode')); + $dirmode = intval(Config::Get('system', 'directory_mode')); if ($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_PRIMARY) { return z_root(); } - if ($x = get_config('system', 'directory_primary')) + if ($x = Config::Get('system', 'directory_primary')) return $x; return DIRECTORY_FALLBACK_MASTER; @@ -2565,13 +2579,13 @@ function get_directory_primary() { * @return string relative date of last completed poller execution */ function get_poller_runtime() { - $t = get_config('system', 'lastpoll'); + $t = Config::Get('system', 'lastpoll'); return relative_date($t); } function z_get_upload_dir() { - $upload_dir = get_config('system', 'uploaddir'); + $upload_dir = Config::Get('system', 'uploaddir'); if (!$upload_dir) $upload_dir = ini_get('upload_tmp_dir'); if (!$upload_dir) @@ -2581,7 +2595,7 @@ function z_get_upload_dir() { } function z_get_temp_dir() { - $temp_dir = get_config('system', 'tempdir'); + $temp_dir = Config::Get('system', 'tempdir'); if (!$temp_dir) $temp_dir = sys_get_temp_dir(); @@ -2637,12 +2651,12 @@ function check_for_new_perms() { if (Permissions::version() != PermissionRoles::version()) return; - $pregistered = get_config('system', 'perms'); + $pregistered = Config::Get('system', 'perms'); $pcurrent = array_keys(Permissions::Perms()); if (!$pregistered) { - set_config('system', 'perms', $pcurrent); + Config::Set('system', 'perms', $pcurrent); return; } @@ -2699,7 +2713,7 @@ function check_for_new_perms() { // We should probably call perms_refresh here, but this should get pushed in 24 hours and there is no urgency if ($found_new_perm) - set_config('system', 'perms', $pcurrent); + Config::Set('system', 'perms', $pcurrent); } @@ -2708,17 +2722,17 @@ function check_for_new_perms() { */ function check_cron_broken() { - $d = get_config('system', 'lastcron'); + $d = Config::Get('system', 'lastcron'); if ((!$d) || ($d < datetime_convert('UTC', 'UTC', 'now - 4 hours'))) { - Zotlabs\Daemon\Master::Summon(['Cron']); - set_config('system', 'lastcron', datetime_convert()); + Master::Summon(['Cron']); + Config::Set('system', 'lastcron', datetime_convert()); } - $t = get_config('system', 'lastcroncheck'); + $t = Config::Get('system', 'lastcroncheck'); if (!$t) { // never checked before. Start the timer. - set_config('system', 'lastcroncheck', datetime_convert()); + Config::Set('system', 'lastcroncheck', datetime_convert()); return; } @@ -2727,7 +2741,7 @@ function check_cron_broken() { return; } - set_config('system', 'lastcroncheck', datetime_convert()); + Config::Set('system', 'lastcroncheck', datetime_convert()); if (($d) && ($d > datetime_convert('UTC', 'UTC', 'now - 3 days'))) { // Scheduled tasks have run successfully in the last 3 days. @@ -2759,7 +2773,7 @@ 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 (((Config::Get('system', 'block_public')) && (!get_account_id()) && (!remote_channel())) ? true : false); } - return (((get_config('system', 'block_public')) && (!local_channel()) && (!remote_channel())) ? true : false); + return (((Config::Get('system', 'block_public')) && (!local_channel()) && (!remote_channel())) ? true : false); } |