' . sprintf(__('Path %s is not writable.'), path::real(dirname(DC_RC_PATH))) . '

' . '

' . __('Dotclear installation wizard could not create configuration file for you. ' . 'You must change folder right or create the config.php ' . 'file manually, please refer to ' . '' . 'the documentation to learn how to do this.') . '

'; } $DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : (function_exists('mysqli_connect') ? 'mysqli' : 'mysql'); $DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : ''; $DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : ''; $DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : ''; $DBPASSWORD = !empty($_POST['DBPASSWORD']) ? $_POST['DBPASSWORD'] : ''; $DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'dc_'; $ADMINMAILFROM = !empty($_POST['ADMINMAILFROM']) ? $_POST['ADMINMAILFROM'] : ''; if (!empty($_POST)) { try { if ($DBDRIVER == 'sqlite') { if (strpos($DBNAME, '/') === false) { $sqlite_db_directory = dirname(DC_RC_PATH) . '/../db/'; files::makeDir($sqlite_db_directory, true); # Can we write sqlite_db_directory ? if (!is_writable($sqlite_db_directory)) { throw new Exception(sprintf(__('Cannot write "%s" directory.'), path::real($sqlite_db_directory, false))); } $DBNAME = $sqlite_db_directory . $DBNAME; } } # Tries to connect to database try { $con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, $DBPASSWORD); } catch (Exception $e) { throw new Exception('

' . __($e->getMessage()) . '

'); } # Checks system capabilites require dirname(__FILE__) . '/check.php'; if (!dcSystemCheck($con, $_e)) { $can_install = false; throw new Exception('

' . __('Dotclear cannot be installed.') . '

'); } # Check if dotclear is already installed $schema = dbSchema::init($con); if (in_array($DBPREFIX . 'version', $schema->getTables())) { throw new Exception(__('Dotclear is already installed.')); } # Check master email if (!text::isEmail($ADMINMAILFROM)) { throw new Exception(__('Master email is not valid.')); } # Does config.php.in exist? $config_in = dirname(__FILE__) . '/../../inc/config.php.in'; if (!is_file($config_in)) { throw new Exception(sprintf(__('File %s does not exist.'), $config_in)); } # Can we write config.php if (!is_writable(dirname(DC_RC_PATH))) { throw new Exception(sprintf(__('Cannot write %s file.'), DC_RC_PATH)); } # Creates config.php file $full_conf = file_get_contents($config_in); writeConfigValue('DC_DBDRIVER', $DBDRIVER, $full_conf); writeConfigValue('DC_DBHOST', $DBHOST, $full_conf); writeConfigValue('DC_DBUSER', $DBUSER, $full_conf); writeConfigValue('DC_DBPASSWORD', $DBPASSWORD, $full_conf); writeConfigValue('DC_DBNAME', $DBNAME, $full_conf); writeConfigValue('DC_DBPREFIX', $DBPREFIX, $full_conf); $admin_url = preg_replace('%install/wizard.php$%', '', $_SERVER['REQUEST_URI']); writeConfigValue('DC_ADMIN_URL', http::getHost() . $admin_url, $full_conf); $admin_email = !empty($ADMINMAILFROM) ? $ADMINMAILFROM : 'dotclear@' . $_SERVER['HTTP_HOST']; writeConfigValue('DC_ADMIN_MAILFROM', $admin_email, $full_conf); writeConfigValue('DC_MASTER_KEY', md5(uniqid()), $full_conf); $fp = @fopen(DC_RC_PATH, 'wb'); if ($fp === false) { throw new Exception(sprintf(__('Cannot write %s file.'), DC_RC_PATH)); } fwrite($fp, $full_conf); fclose($fp); chmod(DC_RC_PATH, 0666); $con->close(); http::redirect('index.php?wiz=1'); } catch (Exception $e) { $err = $e->getMessage(); } } function writeConfigValue($name, $val, &$str) { $val = str_replace("'", "\'", $val); $str = preg_replace('/(\'' . $name . '\')(.*?)$/ms', '$1,\'' . $val . '\');', $str); } header('Content-Type: text/html; charset=UTF-8'); // Prevents Clickjacking as far as possible header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ ?> <?php echo __('Dotclear installation wizard'); ?>
' . __('Dotclear installation wizard') . '' . '
'; if (!empty($err)) { echo ''; } else { echo '

' . __('Welcome') . '

' . '

' . __('To complete your Dotclear installation and start writing on your blog, ' . 'we just need to know how to access your database and who you are. ' . 'Just fill this two steps wizard with this information and we will be done.') . '

' . '

' . __('Attention:') . ' ' . __('this wizard may not function on every host. If it does not work for you, ' . 'please refer to ' . 'the documentation to learn how to create the config.php ' . 'file manually.') . '

'; } echo '

' . __('System information') . '

' . '

' . __('Please provide the following information needed to create your configuration file.') . '

' . '
' . '

' . form::combo('DBDRIVER', [ __('MySQL (deprecated)') => 'mysql', __('MySQLi') => 'mysqli', __('MySQLi (full UTF-8)') => 'mysqlimb4', __('PostgreSQL') => 'pgsql', __('SQLite') => 'sqlite'], ['default' => $DBDRIVER, 'extra_html' => 'required placeholder="' . __('Driver') . '"']) . '

' . '

' . form::field('DBHOST', 30, 255, html::escapeHTML($DBHOST)) . '

' . '

' . form::field('DBNAME', 30, 255, html::escapeHTML($DBNAME)) . '

' . '

' . form::field('DBUSER', 30, 255, html::escapeHTML($DBUSER)) . '

' . '

' . form::password('DBPASSWORD', 30, 255) . '

' . '

' . form::field('DBPREFIX', 30, 255, [ 'default' => html::escapeHTML($DBPREFIX), 'extra_html' => 'required placeholder="' . __('Prefix') . '"' ]) . '

' . '

' . form::email('ADMINMAILFROM', [ 'size' => 30, 'default' => html::escapeHTML($ADMINMAILFROM), 'autocomplete' => 'email' ]) . '

' . '

' . '
'; ?>