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
49 * HTML-friendly escaped string for the POST param of given name, or empty.
55 return htmlspecialchars($this->string($name));
59 * The given POST parameter value, forced to a string.
60 * Missing value will give ''.
65 function string($name)
67 return strval($this->raw($name));
71 * The given POST parameter value, in its original form.
72 * Magic quotes are stripped, if provided.
73 * Missing value will give null.
80 if (isset($_POST[$name])) {
81 return $this->dequote($_POST[$name]);
88 * If necessary, strip magic quotes from the given value.
93 function dequote($val)
95 if (get_magic_quotes_gpc()) {
96 if (is_string($val)) {
97 return stripslashes($val);
98 } else if (is_array($val)) {
99 return array_map(array($this, 'dequote'), $val);
107 * Web-based installer: provides a form and such.
109 class WebInstaller extends Installer
112 * the actual installation.
113 * If call libraries are present, then install
119 if (!$this->checkPrereqs()) {
124 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
132 * Web implementation of warning output
134 function warning($message, $submessage='')
136 print "<p class=\"error\">$message</p>\n";
137 if ($submessage != '') {
138 print "<p>$submessage</p>\n";
143 * Web implementation of status output
145 function updateStatus($status, $error=false)
147 echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
156 $post = new Posted();
158 $dbtype = $post->raw('dbtype');
159 foreach (self::$dbModules as $type => $info) {
160 if ($this->checkExtension($info['check_module'])) {
161 if ($dbtype == null || $dbtype == $type) {
162 $checked = 'checked="checked" ';
163 $dbtype = $type; // if we didn't have one checked, hit the first
167 $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
172 <form method="post" action="install.php" class="form_settings" id="form_install">
174 <fieldset id="settings_site">
175 <legend>Site settings</legend>
176 <ul class="form_data">
178 <label for="sitename">Site name</label>
179 <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
180 <p class="form_guide">The name of your site</p>
183 <label for="fancy-enable">Fancy URLs</label>
184 <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
185 <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
186 <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
191 <fieldset id="settings_db">
192 <legend>Database settings</legend>
193 <ul class="form_data">
195 <label for="host">Hostname</label>
196 <input type="text" id="host" name="host" value="{$post->value('host')}" />
197 <p class="form_guide">Database hostname</p>
200 <label for="dbtype">Type</label>
202 <p class="form_guide">Database type</p>
205 <label for="database">Name</label>
206 <input type="text" id="database" name="database" value="{$post->value('database')}" />
207 <p class="form_guide">Database name</p>
210 <label for="dbusername">DB username</label>
211 <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
212 <p class="form_guide">Database username</p>
215 <label for="dbpassword">DB password</label>
216 <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
217 <p class="form_guide">Database password (optional)</p>
222 <fieldset id="settings_admin">
223 <legend>Administrator settings</legend>
224 <ul class="form_data">
226 <label for="admin_nickname">Administrator nickname</label>
227 <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
228 <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
231 <label for="admin_password">Administrator password</label>
232 <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
233 <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
236 <label for="admin_password2">Confirm password</label>
237 <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
240 <label for="admin_email">Administrator e-mail</label>
241 <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
242 <p class="form_guide">Optional email address for the initial StatusNet user (administrator)</p>
245 <label for="admin_updates">Subscribe to announcements</label>
246 <input type="checkbox" id="admin_updates" name="admin_updates" value="true" checked="checked" />
247 <p class="form_guide">Release and security feed from <a href="http://update.status.net/">update@status.net</a> (recommended)</p>
251 <input type="submit" name="submit" class="submit" value="Submit" />
259 * Handle a POST submission... if we have valid input, start the install!
260 * Otherwise shows the form along with any error messages.
262 function handlePost()
265 <dl class="system_notice">
270 $this->validated = $this->prepare();
271 if ($this->validated) {
279 if (!$this->validated) {
285 * Read and validate input data.
286 * May output side effects.
288 * @return boolean success
292 $post = new Posted();
293 $this->host = $post->string('host');
294 $this->dbtype = $post->string('dbtype');
295 $this->database = $post->string('database');
296 $this->username = $post->string('dbusername');
297 $this->password = $post->string('dbpassword');
298 $this->sitename = $post->string('sitename');
299 $this->fancy = (bool)$post->string('fancy');
301 $this->adminNick = strtolower($post->string('admin_nickname'));
302 $this->adminPass = $post->string('admin_password');
303 $adminPass2 = $post->string('admin_password2');
304 $this->adminEmail = $post->string('admin_email');
305 $this->adminUpdates = $post->string('admin_updates');
307 $this->server = $_SERVER['HTTP_HOST'];
308 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
311 if (!$this->validateDb()) {
315 if (!$this->validateAdmin()) {
319 if ($this->adminPass != $adminPass2) {
320 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
330 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
332 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
333 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
334 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
336 <title>Install StatusNet</title>
337 <link rel="shortcut icon" href="favicon.ico"/>
338 <link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
339 <link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
340 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
341 <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
342 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/neo/css/ie.css" /><![endif]-->
343 <script src="js/jquery.min.js"></script>
344 <script src="js/install.js"></script>
349 <address id="site_contact" class="vcard">
350 <a class="url home bookmark" href=".">
351 <img class="logo photo" src="theme/neo/logo.png" alt="StatusNet"/>
352 <span class="fn org">StatusNet</span>
355 <div id="site_nav_global_primary"></div>
358 <div id="aside_primary_wrapper">
359 <div id="content_wrapper">
360 <div id="site_nav_local_views_wrapper">
361 <div id="site_nav_local_views"></div>
364 <div id="content_inner">
365 <h1>Install StatusNet</h1>
367 $installer = new WebInstaller();
373 <div id="aside_primary" class="aside"></div>
378 <div id="footer"></div>