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 * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
35 * @license GNU Affero General Public License http://www.gnu.org/licenses/
37 * @link http://status.net
40 define('INSTALLDIR', dirname(__FILE__));
42 require INSTALLDIR . '/lib/installer.php';
45 * Helper class for building form
50 if (isset($_POST[$name])) {
51 return htmlspecialchars(strval($_POST[$name]));
59 * Web-based installer: provides a form and such.
61 class WebInstaller extends Installer
64 * the actual installation.
65 * If call libraries are present, then install
71 if (!$this->checkPrereqs()) {
76 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
84 * Web implementation of warning output
86 function warning($message, $submessage='')
88 print "<p class=\"error\">$message</p>\n";
89 if ($submessage != '') {
90 print "<p>$submessage</p>\n";
95 * Web implementation of status output
97 function updateStatus($status, $error=false)
99 echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
108 $post = new Posted();
110 if (isset($_POST['dbtype'])) {
111 $dbtype = $_POST['dbtype'];
115 foreach (self::$dbModules as $type => $info) {
116 if ($this->checkExtension($info['check_module'])) {
117 if ($dbtype == null || $dbtype == $type) {
118 $checked = 'checked="checked" ';
119 $dbtype = $type; // if we didn't have one checked, hit the first
123 $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
128 <form method="post" action="install.php" class="form_settings" id="form_install">
130 <fieldset id="settings_site">
131 <legend>Site settings</legend>
132 <ul class="form_data">
134 <label for="sitename">Site name</label>
135 <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
136 <p class="form_guide">The name of your site</p>
139 <label for="fancy-enable">Fancy URLs</label>
140 <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
141 <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
142 <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
147 <fieldset id="settings_db">
148 <legend>Database settings</legend>
149 <ul class="form_data">
151 <label for="host">Hostname</label>
152 <input type="text" id="host" name="host" value="{$post->value('host')}" />
153 <p class="form_guide">Database hostname</p>
156 <label for="dbtype">Type</label>
158 <p class="form_guide">Database type</p>
161 <label for="database">Name</label>
162 <input type="text" id="database" name="database" value="{$post->value('database')}" />
163 <p class="form_guide">Database name</p>
166 <label for="dbusername">DB username</label>
167 <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
168 <p class="form_guide">Database username</p>
171 <label for="dbpassword">DB password</label>
172 <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
173 <p class="form_guide">Database password (optional)</p>
178 <fieldset id="settings_admin">
179 <legend>Administrator settings</legend>
180 <ul class="form_data">
182 <label for="admin_nickname">Administrator nickname</label>
183 <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
184 <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
187 <label for="admin_password">Administrator password</label>
188 <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
189 <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
192 <label for="admin_password2">Confirm password</label>
193 <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
196 <label for="admin_email">Administrator e-mail</label>
197 <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
198 <p class="form_guide">Optional email address for the initial StatusNet user (administrator)</p>
201 <label for="admin_updates">Subscribe to announcements</label>
202 <input type="checkbox" id="admin_updates" name="admin_updates" value="true" checked="checked" />
203 <p class="form_guide">Release and security feed from <a href="http://update.status.net/">update@status.net</a> (recommended)</p>
207 <input type="submit" name="submit" class="submit" value="Submit" />
215 * Handle a POST submission... if we have valid input, start the install!
216 * Otherwise shows the form along with any error messages.
218 function handlePost()
221 <dl class="system_notice">
226 $this->validated = $this->prepare();
227 if ($this->validated) {
235 if (!$this->validated) {
241 * Read and validate input data.
242 * May output side effects.
244 * @return boolean success
248 $this->host = $_POST['host'];
249 $this->dbtype = $_POST['dbtype'];
250 $this->database = $_POST['database'];
251 $this->username = $_POST['dbusername'];
252 $this->password = $_POST['dbpassword'];
253 $this->sitename = $_POST['sitename'];
254 $this->fancy = !empty($_POST['fancy']);
256 $this->adminNick = strtolower($_POST['admin_nickname']);
257 $this->adminPass = $_POST['admin_password'];
258 $adminPass2 = $_POST['admin_password2'];
259 $this->adminEmail = $_POST['admin_email'];
260 $this->adminUpdates = $_POST['admin_updates'];
262 $this->server = $_SERVER['HTTP_HOST'];
263 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
266 if (!$this->validateDb()) {
270 if (!$this->validateAdmin()) {
274 if ($this->adminPass != $adminPass2) {
275 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
285 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
287 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
288 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
289 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
291 <title>Install StatusNet</title>
292 <link rel="shortcut icon" href="favicon.ico"/>
293 <link rel="stylesheet" type="text/css" href="theme/default/css/display.css" media="screen, projection, tv"/>
294 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
295 <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
296 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/default/css/ie.css" /><![endif]-->
297 <script src="js/jquery.min.js"></script>
298 <script src="js/install.js"></script>
303 <address id="site_contact" class="vcard">
304 <a class="url home bookmark" href=".">
305 <img class="logo photo" src="theme/default/logo.png" alt="StatusNet"/>
306 <span class="fn org">StatusNet</span>
312 <div id="content_inner">
313 <h1>Install StatusNet</h1>
315 $installer = new WebInstaller();