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'); } }
/** * @brief Handle the actions of the different setup steps. * */ function post() { switch ($this->install_wizard_pass) { case 1: case 2: return; // implied break; // implied break; case 3: $urlpath = \App::get_path(); $dbhost = trim($_POST['dbhost']); $dbport = intval(trim($_POST['dbport'])); $dbuser = trim($_POST['dbuser']); $dbpass = trim($_POST['dbpass']); $dbdata = trim($_POST['dbdata']); $dbtype = intval(trim($_POST['dbtype'])); $phpath = trim($_POST['phpath']); $adminmail = trim($_POST['adminmail']); $siteurl = trim($_POST['siteurl']); $advanced = intval($_POST['advanced']) ? 1 : 0; // $siteurl should not have a trailing slash $siteurl = rtrim($siteurl, '/'); require_once 'include/dba/dba_driver.php'; $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); if (!\DBA::$dba->connected) { echo 'Database Connect failed: ' . DBA::$dba->error; killme(); } return; // implied break; // implied break; case 4: $urlpath = \App::get_path(); $dbhost = notags(trim($_POST['dbhost'])); $dbport = intval(notags(trim($_POST['dbport']))); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $dbtype = intval(notags(trim($_POST['dbtype']))); $phpath = notags(trim($_POST['phpath'])); $timezone = notags(trim($_POST['timezone'])); $adminmail = notags(trim($_POST['adminmail'])); $siteurl = notags(trim($_POST['siteurl'])); $advanced = intval($_POST['advanced']) ? 1 : 0; if ($siteurl != z_root()) { $test = z_fetch_url($siteurl . "/setup/testrewrite"); if (!$test['success'] || $test['body'] != 'ok') { \App::$data['url_fail'] = true; \App::$data['url_error'] = $test['error']; return; } } if (!\DBA::$dba->connected) { // connect to db $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true); } if (!\DBA::$dba->connected) { echo 'CRITICAL: DB not connected.'; killme(); } $tpl = get_intltext_template('htconfig.tpl'); $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbport' => $dbport, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, '$uno' => 1 - $advanced, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), '$phpath' => $phpath, '$adminmail' => $adminmail)); $result = file_put_contents('.htconfig.php', $txt); if (!$result) { \App::$data['txt'] = $txt; } $errors = $this->load_database($db); if ($errors) { \App::$data['db_failed'] = $errors; } else { \App::$data['db_installed'] = true; } return; // implied break; // implied break; default: break; } }