diff --git a/install.php b/install.php index 41024c901f..51c86683a0 100644 --- a/install.php +++ b/install.php @@ -435,15 +435,39 @@ E_O_T; E_O_T; } +/** + * Helper class for building form + */ +class Posted { + function value($name) + { + if (isset($_POST[$name])) { + return htmlspecialchars(strval($_POST[$name])); + } else { + return ''; + } + } +} + function showForm() { global $dbModules; + $post = new Posted(); $dbRadios = ''; - $checked = 'checked="checked" '; // Check the first one which exists + if (isset($_POST['dbtype'])) { + $dbtype = $_POST['dbtype']; + } else { + $dbtype = null; + } foreach ($dbModules as $type => $info) { if (checkExtension($info['check_module'])) { + if ($dbtype == null || $dbtype == $type) { + $checked = 'checked="checked" '; + $dbtype = $type; // if we didn't have one checked, hit the first + } else { + $checked = ''; + } $dbRadios .= " $info[name]
\n"; - $checked = ''; } } echo<<
  • - +

    The name of your site

  • @@ -475,7 +499,7 @@ function showForm()
  • - +

    Database hostname

  • @@ -487,29 +511,38 @@ function showForm()
  • - +

    Database name

  • - - + +

    Database username

  • - - + +

    Database password (optional)

  • - +

    Nickname for the initial StatusNet user (administrator)

  • - - + +

    Password for the initial StatusNet user (administrator)

  • +
  • + + +
  • +
  • + + +

    Optional email address for the initial StatusNet user (administrator)

    +
  • @@ -528,13 +561,15 @@ function handlePost() $host = $_POST['host']; $dbtype = $_POST['dbtype']; $database = $_POST['database']; - $username = $_POST['username']; - $password = $_POST['password']; + $username = $_POST['dbusername']; + $password = $_POST['dbpassword']; $sitename = $_POST['sitename']; $fancy = !empty($_POST['fancy']); $adminNick = $_POST['admin_nickname']; $adminPass = $_POST['admin_password']; + $adminPass2 = $_POST['admin_password2']; + $adminEmail = $_POST['admin_email']; $server = $_SERVER['HTTP_HOST']; $path = substr(dirname($_SERVER['PHP_SELF']), 1); @@ -576,6 +611,11 @@ STR; updateStatus("No initial StatusNet user password specified.", true); $fail = true; } + + if ($adminPass != $adminPass2) { + updateStatus("Administrator passwords do not match. Did you mistype?", true); + $fail = true; + } if ($fail) { showForm(); @@ -600,7 +640,7 @@ STR; } // Okay, cross fingers and try to register an initial user - if (registerInitialUser($adminNick, $adminPass)) { + if (registerInitialUser($adminNick, $adminPass, $adminEmail)) { updateStatus( "An initial user with the administrator role has been created." ); @@ -797,19 +837,20 @@ function runDbScript($filename, $conn, $type = 'mysqli') return true; } -function registerInitialUser($nickname, $password) +function registerInitialUser($nickname, $password, $email) { define('STATUSNET', true); define('LACONICA', true); // compatibility require_once INSTALLDIR . '/lib/common.php'; - $user = User::register( - array('nickname' => $nickname, - 'password' => $password, - 'fullname' => $nickname - ) - ); + $data = array('nickname' => $nickname, + 'password' => $password, + 'fullname' => $nickname); + if ($email) { + $data['email'] = $email; + } + $user = User::register($data); if (empty($user)) { return false;