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 <fieldset id="settings_profile">
252 <legend>Site profile</legend>
253 <ul class="form_data">
255 <label for="site_profile">Type of site</label>
256 <select id="site_profile" name="site_profile">
257 <option value="private">Private</option>
258 <option value="community">Community</option>
259 <option value ="public">Public</option>
260 <option value ="singleuser">Single User</option>
262 <p class="form_guide">Initial access settings for your site</p>
266 <input type="submit" name="submit" class="submit" value="Submit" />
274 * Handle a POST submission... if we have valid input, start the install!
275 * Otherwise shows the form along with any error messages.
277 function handlePost()
280 <dl class="system_notice">
285 $this->validated = $this->prepare();
286 if ($this->validated) {
294 if (!$this->validated) {
300 * Read and validate input data.
301 * May output side effects.
303 * @return boolean success
307 $post = new Posted();
308 $this->host = $post->string('host');
309 $this->dbtype = $post->string('dbtype');
310 $this->database = $post->string('database');
311 $this->username = $post->string('dbusername');
312 $this->password = $post->string('dbpassword');
313 $this->sitename = $post->string('sitename');
314 $this->fancy = (bool)$post->string('fancy');
316 $this->adminNick = strtolower($post->string('admin_nickname'));
317 $this->adminPass = $post->string('admin_password');
318 $adminPass2 = $post->string('admin_password2');
319 $this->adminEmail = $post->string('admin_email');
320 $this->adminUpdates = $post->string('admin_updates');
322 $this->siteProfile = $post->string('site_profile');
324 $this->server = $_SERVER['HTTP_HOST'];
325 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
328 if (!$this->validateDb()) {
332 if (!$this->validateAdmin()) {
336 if ($this->adminPass != $adminPass2) {
337 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
341 if (!$this->validateSiteProfile()) {
351 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
353 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
354 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
355 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
357 <title>Install StatusNet</title>
358 <link rel="shortcut icon" href="favicon.ico"/>
359 <link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
360 <link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
361 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
362 <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
363 <!--[if lte IE 7]><link rel="stylesheet" type="text/css" theme/base/css/ie7.css" /><![endif]-->
364 <script src="js/jquery.min.js"></script>
365 <script src="js/install.js"></script>
370 <address id="site_contact" class="vcard">
371 <a class="url home bookmark" href=".">
372 <img class="logo photo" src="theme/neo/logo.png" alt="StatusNet"/>
373 <span class="fn org">StatusNet</span>
376 <div id="site_nav_global_primary"></div>
379 <div id="aside_primary_wrapper">
380 <div id="content_wrapper">
381 <div id="site_nav_local_views_wrapper">
382 <div id="site_nav_local_views"></div>
385 <div id="content_inner">
386 <h1>Install StatusNet</h1>
388 $installer = new WebInstaller();
394 <div id="aside_primary" class="aside"></div>
399 <div id="footer"></div>