summaryrefslogtreecommitdiff
path: root/install.php
diff options
context:
space:
mode:
Diffstat (limited to 'install.php')
-rw-r--r--install.php189
1 files changed, 117 insertions, 72 deletions
diff --git a/install.php b/install.php
index 41024c901..bb53e2b55 100644
--- a/install.php
+++ b/install.php
@@ -435,82 +435,119 @@ 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 .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
- $checked = '';
}
}
echo<<<E_O_T
</ul>
</dd>
</dl>
-<dl id="page_notice" class="system_notice">
- <dt>Page notice</dt>
- <dd>
- <div class="instructions">
- <p>Enter your database connection information below to initialize the database.</p>
- </div>
- </dd>
-</dl>
<form method="post" action="install.php" class="form_settings" id="form_install">
<fieldset>
- <legend>Connection settings</legend>
- <ul class="form_data">
- <li>
- <label for="sitename">Site name</label>
- <input type="text" id="sitename" name="sitename" />
- <p class="form_guide">The name of your site</p>
- </li>
- <li>
- <label for="fancy-enable">Fancy URLs</label>
- <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
- <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
- <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
- </li>
- <li>
- <label for="host">Hostname</label>
- <input type="text" id="host" name="host" />
- <p class="form_guide">Database hostname</p>
- </li>
- <li>
-
- <label for="dbtype">Type</label>
- $dbRadios
- <p class="form_guide">Database type</p>
- </li>
-
- <li>
- <label for="database">Name</label>
- <input type="text" id="database" name="database" />
- <p class="form_guide">Database name</p>
- </li>
- <li>
- <label for="username">DB username</label>
- <input type="text" id="username" name="username" />
- <p class="form_guide">Database username</p>
- </li>
- <li>
- <label for="password">DB password</label>
- <input type="password" id="password" name="password" />
- <p class="form_guide">Database password (optional)</p>
- </li>
- <li>
- <label for="admin_nickname">Administrator nickname</label>
- <input type="text" id="admin_nickname" name="admin_nickname" />
- <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
- </li>
- <li>
- <label for="initial_user_password">Administrator password</label>
- <input type="password" id="admin_password" name="admin_password" />
- <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
- </li>
- </ul>
+ <fieldset id="settings_site">
+ <legend>Site settings</legend>
+ <ul class="form_data">
+ <li>
+ <label for="sitename">Site name</label>
+ <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
+ <p class="form_guide">The name of your site</p>
+ </li>
+ <li>
+ <label for="fancy-enable">Fancy URLs</label>
+ <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
+ <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
+ <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
+ </li>
+ </ul>
+ </fieldset>
+
+ <fieldset id="settings_db">
+ <legend>Database settings</legend>
+ <ul class="form_data">
+ <li>
+ <label for="host">Hostname</label>
+ <input type="text" id="host" name="host" value="{$post->value('host')}" />
+ <p class="form_guide">Database hostname</p>
+ </li>
+ <li>
+ <label for="dbtype">Type</label>
+ $dbRadios
+ <p class="form_guide">Database type</p>
+ </li>
+ <li>
+ <label for="database">Name</label>
+ <input type="text" id="database" name="database" value="{$post->value('database')}" />
+ <p class="form_guide">Database name</p>
+ </li>
+ <li>
+ <label for="dbusername">DB username</label>
+ <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
+ <p class="form_guide">Database username</p>
+ </li>
+ <li>
+ <label for="dbpassword">DB password</label>
+ <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
+ <p class="form_guide">Database password (optional)</p>
+ </li>
+ </ul>
+ </fieldset>
+
+ <fieldset id="settings_admin">
+ <legend>Administrator settings</legend>
+ <ul class="form_data">
+ <li>
+ <label for="admin_nickname">Administrator nickname</label>
+ <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
+ <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
+ </li>
+ <li>
+ <label for="admin_password">Administrator password</label>
+ <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
+ <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
+ </li>
+ <li>
+ <label for="admin_password2">Confirm password</label>
+ <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
+ </li>
+ <li>
+ <label for="admin_email">Administrator e-mail</label>
+ <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
+ <p class="form_guide">Optional email address for the initial StatusNet user (administrator)</p>
+ </li>
+ </ul>
+ </fieldset>
<input type="submit" name="submit" class="submit" value="Submit" />
</fieldset>
</form>
@@ -528,13 +565,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 +615,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 +644,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."
);
@@ -620,7 +664,7 @@ STR;
updateStatus("StatusNet has been installed at $link");
updateStatus(
- "You can visit your <a href='$link'>new StatusNet site</a> (login as '$adminNick')."
+ "<strong>DONE!</strong> You can visit your <a href='$link'>new StatusNet site</a> (login as '$adminNick'). If this is your first StatusNet install, you may want to poke around our <a href='http://status.net/wiki/Getting_started'>Getting Started guide</a>."
);
}
@@ -797,19 +841,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;