3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2009-2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @category Installation
20 * @package Installation
22 * @author Adrian Lang <mail@adrianlang.de>
23 * @author Brenda Wallace <shiny@cpan.org>
24 * @author Brett Taylor <brett@webfroot.co.nz>
25 * @author Brion Vibber <brion@pobox.com>
26 * @author CiaranG <ciaran@ciarang.com>
27 * @author Craig Andrews <candrews@integralblue.com>
28 * @author Eric Helgeson <helfire@Erics-MBP.local>
29 * @author Evan Prodromou <evan@status.net>
30 * @author Robin Millette <millette@controlyourself.ca>
31 * @author Sarven Capadisli <csarven@status.net>
32 * @author Tom Adams <tom@holizz.com>
33 * @author Zach Copley <zach@status.net>
34 * @license GNU Affero General Public License http://www.gnu.org/licenses/
36 * @link http://status.net
39 define('INSTALLDIR', dirname(__FILE__));
41 require INSTALLDIR . '/lib/installer.php';
44 * Helper class for building form
49 if (isset($_POST[$name])) {
50 return htmlspecialchars(strval($_POST[$name]));
58 * Web-based installer: provides a form and such.
60 class WebInstaller extends Installer
63 * the actual installation.
64 * If call libraries are present, then install
70 if (!$this->checkPrereqs()) {
75 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
83 * Web implementation of warning output
85 function warning($message, $submessage='')
87 print "<p class=\"error\">$message</p>\n";
88 if ($submessage != '') {
89 print "<p>$submessage</p>\n";
94 * Web implementation of status output
96 function updateStatus($status, $error=false)
98 echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
107 $post = new Posted();
109 if (isset($_POST['dbtype'])) {
110 $dbtype = $_POST['dbtype'];
114 foreach (self::$dbModules as $type => $info) {
115 if ($this->checkExtension($info['check_module'])) {
116 if ($dbtype == null || $dbtype == $type) {
117 $checked = 'checked="checked" ';
118 $dbtype = $type; // if we didn't have one checked, hit the first
122 $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
127 <form method="post" action="install.php" class="form_settings" id="form_install">
129 <fieldset id="settings_site">
130 <legend>Site settings</legend>
131 <ul class="form_data">
133 <label for="sitename">Site name</label>
134 <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
135 <p class="form_guide">The name of your site</p>
138 <label for="fancy-enable">Fancy URLs</label>
139 <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
140 <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
141 <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
146 <fieldset id="settings_db">
147 <legend>Database settings</legend>
148 <ul class="form_data">
150 <label for="host">Hostname</label>
151 <input type="text" id="host" name="host" value="{$post->value('host')}" />
152 <p class="form_guide">Database hostname</p>
155 <label for="dbtype">Type</label>
157 <p class="form_guide">Database type</p>
160 <label for="database">Name</label>
161 <input type="text" id="database" name="database" value="{$post->value('database')}" />
162 <p class="form_guide">Database name</p>
165 <label for="dbusername">DB username</label>
166 <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
167 <p class="form_guide">Database username</p>
170 <label for="dbpassword">DB password</label>
171 <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
172 <p class="form_guide">Database password (optional)</p>
177 <fieldset id="settings_admin">
178 <legend>Administrator settings</legend>
179 <ul class="form_data">
181 <label for="admin_nickname">Administrator nickname</label>
182 <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
183 <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
186 <label for="admin_password">Administrator password</label>
187 <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
188 <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
191 <label for="admin_password2">Confirm password</label>
192 <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
195 <label for="admin_email">Administrator e-mail</label>
196 <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
197 <p class="form_guide">Optional email address for the initial StatusNet user (administrator)</p>
200 <label for="admin_updates">Subscribe to announcements</label>
201 <input type="checkbox" id="admin_updates" name="admin_updates" value="true" checked="checked" />
202 <p class="form_guide">Release and security feed from <a href="http://update.status.net/">update@status.net</a> (recommended)</p>
206 <input type="submit" name="submit" class="submit" value="Submit" />
214 * Handle a POST submission... if we have valid input, start the install!
215 * Otherwise shows the form along with any error messages.
217 function handlePost()
220 <dl class="system_notice">
225 $this->validated = $this->prepare();
226 if ($this->validated) {
234 if (!$this->validated) {
240 * Read and validate input data.
241 * May output side effects.
243 * @return boolean success
247 $this->host = $_POST['host'];
248 $this->dbtype = $_POST['dbtype'];
249 $this->database = $_POST['database'];
250 $this->username = $_POST['dbusername'];
251 $this->password = $_POST['dbpassword'];
252 $this->sitename = $_POST['sitename'];
253 $this->fancy = !empty($_POST['fancy']);
255 $this->adminNick = strtolower($_POST['admin_nickname']);
256 $this->adminPass = $_POST['admin_password'];
257 $adminPass2 = $_POST['admin_password2'];
258 $this->adminEmail = $_POST['admin_email'];
259 $this->adminUpdates = $_POST['admin_updates'];
261 $this->server = $_SERVER['HTTP_HOST'];
262 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
265 if (!$this->validateDb()) {
269 if (!$this->validateAdmin()) {
273 if ($this->adminPass != $adminPass2) {
274 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
284 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
286 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
287 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
288 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
290 <title>Install StatusNet</title>
291 <link rel="shortcut icon" href="favicon.ico"/>
292 <link rel="stylesheet" type="text/css" href="theme/default/css/display.css" media="screen, projection, tv"/>
293 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
294 <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
295 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/default/css/ie.css" /><![endif]-->
296 <script src="js/jquery.min.js"></script>
297 <script src="js/install.js"></script>
302 <address id="site_contact" class="vcard">
303 <a class="url home bookmark" href=".">
304 <img class="logo photo" src="theme/default/logo.png" alt="StatusNet"/>
305 <span class="fn org">StatusNet</span>
311 <div id="content_inner">
312 <h1>Install StatusNet</h1>
314 $installer = new WebInstaller();