function saveStep3() { if (!empty($_POST)) { if ($_SESSION['bd_type'] === 'sqlite') { $_SESSION['bd_base'] = $_SESSION['default_user']; $_SESSION['bd_host'] = ''; $_SESSION['bd_user'] = ''; $_SESSION['bd_password'] = ''; $_SESSION['bd_prefix'] = ''; $_SESSION['bd_prefix_user'] = ''; //No prefix for SQLite } else { if (empty($_POST['type']) || empty($_POST['host']) || empty($_POST['user']) || empty($_POST['base'])) { $_SESSION['bd_error'] = 'Missing parameters!'; } $_SESSION['bd_base'] = substr($_POST['base'], 0, 64); $_SESSION['bd_host'] = $_POST['host']; $_SESSION['bd_user'] = $_POST['user']; $_SESSION['bd_password'] = $_POST['pass']; $_SESSION['bd_prefix'] = substr($_POST['prefix'], 0, 16); $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'] . '_'); } $config_array = array('environment' => 'production', 'salt' => $_SESSION['salt'], 'title' => $_SESSION['title'], 'default_user' => $_SESSION['default_user'], 'auth_type' => $_SESSION['auth_type'], 'db' => array('type' => $_SESSION['bd_type'], 'host' => $_SESSION['bd_host'], 'user' => $_SESSION['bd_user'], 'password' => $_SESSION['bd_password'], 'base' => $_SESSION['bd_base'], 'prefix' => $_SESSION['bd_prefix'])); @unlink(join_path(DATA_PATH, 'config.php')); //To avoid access-rights problems file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . var_export($config_array, true) . ';'); $res = checkBD(); if ($res) { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } elseif (empty($_SESSION['bd_error'])) { $_SESSION['bd_error'] = 'Unknown error!'; } } invalidateHttpCache(); }
function saveStep3() { if (!empty($_POST)) { if ($_SESSION['bd_type'] === 'sqlite') { $_SESSION['bd_base'] = $_SESSION['default_user']; $_SESSION['bd_host'] = ''; $_SESSION['bd_user'] = ''; $_SESSION['bd_password'] = ''; $_SESSION['bd_prefix'] = ''; $_SESSION['bd_prefix_user'] = ''; //No prefix for SQLite } else { if (empty($_POST['type']) || empty($_POST['host']) || empty($_POST['user']) || empty($_POST['base'])) { $_SESSION['bd_error'] = 'Missing parameters!'; } $_SESSION['bd_base'] = substr($_POST['base'], 0, 64); $_SESSION['bd_host'] = $_POST['host']; $_SESSION['bd_user'] = $_POST['user']; $_SESSION['bd_password'] = $_POST['pass']; $_SESSION['bd_prefix'] = substr($_POST['prefix'], 0, 16); $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'] . '_'); } // We use dirname to remove the /i part $base_url = dirname(Minz_Request::guessBaseUrl()); $config_array = array('salt' => $_SESSION['salt'], 'base_url' => $base_url, 'title' => $_SESSION['title'], 'default_user' => $_SESSION['default_user'], 'auth_type' => $_SESSION['auth_type'], 'db' => array('type' => $_SESSION['bd_type'], 'host' => $_SESSION['bd_host'], 'user' => $_SESSION['bd_user'], 'password' => $_SESSION['bd_password'], 'base' => $_SESSION['bd_base'], 'prefix' => $_SESSION['bd_prefix'], 'pdo_options' => array()), 'pubsubhubbub_enabled' => server_is_public($base_url)); @unlink(join_path(DATA_PATH, 'config.php')); //To avoid access-rights problems file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . var_export($config_array, true) . ';'); $res = checkBD(); if ($res) { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } elseif (empty($_SESSION['bd_error'])) { $_SESSION['bd_error'] = 'Unknown error!'; } } invalidateHttpCache(); }
function saveStep3() { if (!empty($_POST)) { if (empty($_POST['type']) || empty($_POST['host']) || empty($_POST['user']) || empty($_POST['base'])) { $_SESSION['bd_error'] = 'Missing parameters!'; } $_SESSION['bd_type'] = isset($_POST['type']) ? $_POST['type'] : 'mysql'; $_SESSION['bd_host'] = $_POST['host']; $_SESSION['bd_user'] = $_POST['user']; $_SESSION['bd_password'] = $_POST['pass']; $_SESSION['bd_base'] = substr($_POST['base'], 0, 64); $_SESSION['bd_prefix'] = substr($_POST['prefix'], 0, 16); $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'] . '_'); $ini_array = array('general' => array('environment' => empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'], 'use_url_rewriting' => false, 'salt' => $_SESSION['salt'], 'base_url' => '', 'title' => $_SESSION['title'], 'default_user' => $_SESSION['default_user'], 'auth_type' => $_SESSION['auth_type'], 'allow_anonymous' => isset($_SESSION['allow_anonymous']) ? $_SESSION['allow_anonymous'] : false), 'db' => array('type' => $_SESSION['bd_type'], 'host' => $_SESSION['bd_host'], 'user' => $_SESSION['bd_user'], 'password' => $_SESSION['bd_password'], 'base' => $_SESSION['bd_base'], 'prefix' => $_SESSION['bd_prefix'])); @unlink(DATA_PATH . '/config.php'); //To avoid access-rights problems file_put_contents(DATA_PATH . '/config.php', "<?php\n return " . var_export($ini_array, true) . ';'); if (file_exists(DATA_PATH . '/config.php') && file_exists(DATA_PATH . '/application.ini')) { @unlink(DATA_PATH . '/application.ini'); //v0.6 } $res = checkBD(); if ($res) { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } elseif (empty($_SESSION['bd_error'])) { $_SESSION['bd_error'] = 'Unknown error!'; } } invalidateHttpCache(); }