function install_post(&$a) { global $db; $urlpath = $a->get_path(); $dbhost = notags(trim($_POST['dbhost'])); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $timezone = notags(trim($_POST['timezone'])); $phpath = notags(trim($_POST['phpath'])); $adminmail = notags(trim($_POST['adminmail'])); require_once "dba.php"; unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); if (get_db_errno()) { unset($db); $db = new dba($dbhost, $dbuser, $dbpass, '', true); if (!get_db_errno()) { $r = q("CREATE DATABASE '%s'", dbesc($dbdata)); if ($r) { unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); } } if (get_db_errno()) { notice(t('Could not create/connect to database.') . EOL); return; } } info(t('Connected to database.') . EOL); $tpl = get_intltext_template('htconfig.tpl'); $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$timezone' => $timezone, '$urlpath' => $urlpath, '$phpath' => $phpath, '$adminmail' => $adminmail)); $result = file_put_contents('.htconfig.php', $txt); if (!$result) { $a->data['txt'] = $txt; } $errors = load_database($db); if ($errors) { $a->data['db_failed'] = true; } else { $a->data['db_installed'] = true; } return; }
function install_post(&$a) { global $install_wizard_pass, $db; switch ($install_wizard_pass) { case 1: case 2: return; break; // just in case return don't return :) // just in case return don't return :) case 3: $urlpath = $a->get_path(); $dbhost = notags(trim($_POST['dbhost'])); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $phpath = notags(trim($_POST['phpath'])); require_once "include/dba.php"; unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); /*if(get_db_errno()) { unset($db); $db = new dba($dbhost, $dbuser, $dbpass, '', true); if(! get_db_errno()) { $r = q("CREATE DATABASE '%s'", dbesc($dbdata) ); if($r) { unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); } else { $a->data['db_create_failed']=true; } } else { $a->data['db_conn_failed']=true; return; } }*/ if (get_db_errno()) { $a->data['db_conn_failed'] = true; } return; break; case 4: $urlpath = $a->get_path(); $dbhost = notags(trim($_POST['dbhost'])); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); $dbdata = notags(trim($_POST['dbdata'])); $phpath = notags(trim($_POST['phpath'])); $timezone = notags(trim($_POST['timezone'])); $adminmail = notags(trim($_POST['adminmail'])); // connect to db $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); $tpl = get_intltext_template('htconfig.tpl'); $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$timezone' => $timezone, '$urlpath' => $urlpath, '$phpath' => $phpath, '$adminmail' => $adminmail)); $result = file_put_contents('.htconfig.php', $txt); if (!$result) { $a->data['txt'] = $txt; } $errors = load_database($db); if ($errors) { $a->data['db_failed'] = $errors; } else { $a->data['db_installed'] = true; } return; break; } }
function setup_post(&$a) { global $install_wizard_pass, $db; switch ($install_wizard_pass) { case 1: case 2: return; break; // just in case return don't return :) // just in case return don't return :) case 3: $urlpath = $a->get_path(); $dbhost = trim($_POST['dbhost']); $dbport = intval(trim($_POST['dbport'])); $dbuser = trim($_POST['dbuser']); $dbpass = trim($_POST['dbpass']); $dbdata = trim($_POST['dbdata']); $phpath = trim($_POST['phpath']); $adminmail = trim($_POST['adminmail']); $siteurl = trim($_POST['siteurl']); require_once 'include/dba/dba_driver.php'; unset($db); $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true); if (!$db->connected) { echo "Database Connect failed: " . $db->error; killme(); } /*if(get_db_errno()) { unset($db); $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, '', true); if(! get_db_errno()) { $r = q("CREATE DATABASE '%s'", dbesc($dbdata) ); if($r) { unset($db); $db = new dba($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true); } else { $a->data['db_create_failed']=true; } } else { $a->data['db_conn_failed']=true; return; } }*/ if (get_db_errno()) { $a->data['db_conn_failed'] = true; } return; break; case 4: $urlpath = $a->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'])); $phpath = notags(trim($_POST['phpath'])); $timezone = notags(trim($_POST['timezone'])); $adminmail = notags(trim($_POST['adminmail'])); $siteurl = notags(trim($_POST['siteurl'])); if ($siteurl != z_root()) { $test = z_fetch_url($siteurl . "/setup/testrewrite"); if (!$test['success'] || $test['body'] != 'ok') { $a->data['url_fail'] = true; $a->data['url_error'] = $test['error']; return; } } // connect to db $db = dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, true); if (!$db->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, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), '$phpath' => $phpath, '$adminmail' => $adminmail)); $result = file_put_contents('.htconfig.php', $txt); if (!$result) { $a->data['txt'] = $txt; } $errors = load_database($db); if ($errors) { $a->data['db_failed'] = $errors; } else { $a->data['db_installed'] = true; } return; break; } }