X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Finstall.php;h=7a69a731baa7ed34570458fddf345a215277aba2;hb=7c73e8634c954cc2bd0d1138729459d7d5090f62;hp=4596f9a251a552573d31787ff11eeb8016953ece;hpb=a97ad9dc422556d0679ff066fb378570183ed57e;p=friendica.git diff --git a/mod/install.php b/mod/install.php index 4596f9a251..7a69a731ba 100644 --- a/mod/install.php +++ b/mod/install.php @@ -4,10 +4,10 @@ */ use Friendica\App; -use Friendica\Core\L10n; use Friendica\Core\Install; +use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Util\Temporal; $install_wizard_pass = 1; @@ -22,10 +22,9 @@ function install_init(App $a) { // We overwrite current theme css, because during install we could not have a working mod_rewrite // so we could not have a css at all. Here we set a static css file for the install procedure pages - $a->config['system']['theme'] = "../install"; - $a->theme['stylesheet'] = System::baseUrl()."/view/install/style.css"; - Install::setInstallMode(); + $a->setConfigValue('system', 'value', '../install'); + $a->theme['stylesheet'] = System::baseUrl()."/view/install/style.css"; global $install_wizard_pass; if (x($_POST, 'pass')) { @@ -51,7 +50,7 @@ function install_post(App $a) { $phpath = notags(trim($_POST['phpath'])); require_once("include/dba.php"); - if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata)) { + if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { $a->data['db_conn_failed'] = true; } @@ -67,12 +66,24 @@ function install_post(App $a) { $timezone = notags(trim($_POST['timezone'])); $language = notags(trim($_POST['language'])); $adminmail = notags(trim($_POST['adminmail'])); - $rino = 1; // connect to db - dba::connect($dbhost, $dbuser, $dbpass, $dbdata); + DBA::connect($dbhost, $dbuser, $dbpass, $dbdata); + + $errors = Install::createConfig($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail); - Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino); + if ($errors) { + $a->data['db_failed'] = $errors; + return; + } + + $errors = Install::installDatabaseStructure(); + + if ($errors) { + $a->data['db_failed'] = $errors; + } else { + $a->data['db_installed'] = true; + } return; break; @@ -111,16 +122,11 @@ function install_content(App $a) { $db_return_text .= $txt; } - if (dba::$connected) { + if (DBA::$connected) { $r = q("SELECT COUNT(*) as `total` FROM `user`"); - if (DBM::is_result($r) && $r[0]['total']) { - $tpl = get_markup_template('install.tpl'); - return replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => '', - '$status' => L10n::t('Database already in use.'), - '$text' => '', - ]); + if (DBA::isResult($r) && $r[0]['total']) { + $install_wizard_pass = 2; + $wizard_status = L10n::t('Database already in use.'); } } @@ -140,9 +146,7 @@ function install_content(App $a) { switch ($install_wizard_pass) { case 1: { // System check - if (x($_POST, 'phpath')) { - $phpath = notags(trim($_POST['phpath'])); - } + $phpath = defaults($_POST, 'phpath', 'php'); list($checks, $checkspassed) = Install::check($phpath); @@ -163,13 +167,12 @@ function install_content(App $a) { case 2: { // Database config - $dbhost = ((x($_POST, 'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'); - $dbuser = notags(trim($_POST['dbuser'])); - $dbpass = notags(trim($_POST['dbpass'])); - $dbdata = notags(trim($_POST['dbdata'])); - $phpath = notags(trim($_POST['phpath'])); - - $adminmail = notags(trim($_POST['adminmail'])); + $dbhost = notags(trim(defaults($_POST, 'dbhost' , 'localhost'))); + $dbuser = notags(trim(defaults($_POST, 'dbuser' , '' ))); + $dbpass = notags(trim(defaults($_POST, 'dbpass' , '' ))); + $dbdata = notags(trim(defaults($_POST, 'dbdata' , '' ))); + $phpath = notags(trim(defaults($_POST, 'phpath' , '' ))); + $adminmail = notags(trim(defaults($_POST, 'adminmail', '' ))); $tpl = get_markup_template('install_db.tpl'); $o .= replace_macros($tpl, [ @@ -187,8 +190,6 @@ function install_content(App $a) { '$dbdata' => ['dbdata', L10n::t('Database Name'), $dbdata, '', 'required'], '$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'], - - '$lbl_10' => L10n::t('Please select a default timezone for your website'), '$baseurl' => System::baseUrl(), @@ -196,7 +197,6 @@ function install_content(App $a) { '$phpath' => $phpath, '$submit' => L10n::t('Submit'), - ]); return $o; }; break; @@ -245,7 +245,7 @@ function install_content(App $a) { function manual_config(App $a) { $data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8'); - $o = L10n::t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); + $o = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o .= ""; return $o; }