/** * Affiche une Url formatée * @param $url l'url à formater définie comme un tableau : * $url['c'] = controller * $url['a'] = action * $url['params'] = tableau des paramètres supplémentaires * ou comme une chaîne de caractère * @param $encodage pour indiquer comment encoder les & (& ou & pour html) * @return l'url formatée */ public static function display($url = array(), $encodage = 'html', $absolute = false) { $isArray = is_array($url); if ($isArray) { $url = self::checkUrl($url); } $url_string = ''; if ($absolute) { $url_string = Minz_Request::getBaseUrl(PUBLIC_TO_INDEX_PATH); if ($url_string === PUBLIC_TO_INDEX_PATH) { $url_string = Minz_Request::guessBaseUrl(); } } else { $url_string = $isArray ? '.' : PUBLIC_RELATIVE; } if ($isArray) { $url_string .= self::printUri($url, $encodage); } elseif ($encodage === 'html') { $url_string = Minz_Helper::htmlspecialchars_utf8($url_string . $url); } else { $url_string .= $url; } return $url_string; }
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(); }