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 Mikael Nordfeldth <mmn@hethane.se>
31 * @author Robin Millette <millette@controlyourself.ca>
32 * @author Sarven Capadisli <csarven@status.net>
33 * @author Tom Adams <tom@holizz.com>
34 * @author Zach Copley <zach@status.net>
35 * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
36 * @license GNU Affero General Public License http://www.gnu.org/licenses/
38 * @link http://status.net
41 define('INSTALLDIR', dirname(__FILE__));
43 require INSTALLDIR . '/lib/installer.php';
46 * Helper class for building form
50 * HTML-friendly escaped string for the POST param of given name, or empty.
56 return htmlspecialchars($this->string($name));
60 * The given POST parameter value, forced to a string.
61 * Missing value will give ''.
66 function string($name)
68 return strval($this->raw($name));
72 * The given POST parameter value, in its original form.
73 * Magic quotes are stripped, if provided.
74 * Missing value will give null.
81 if (isset($_POST[$name])) {
82 return $this->dequote($_POST[$name]);
89 * If necessary, strip magic quotes from the given value.
94 function dequote($val)
96 if (get_magic_quotes_gpc()) {
97 if (is_string($val)) {
98 return stripslashes($val);
99 } else if (is_array($val)) {
100 return array_map(array($this, 'dequote'), $val);
108 * Web-based installer: provides a form and such.
110 class WebInstaller extends Installer
113 * the actual installation.
114 * If call libraries are present, then install
120 if (!$this->checkPrereqs()) {
121 $this->warning(_('Please fix the above stated problems and refresh this page to continue installing.'));
125 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
133 * Web implementation of warning output
135 function warning($message, $submessage='')
137 print "<p class=\"error\">$message</p>\n";
138 if ($submessage != '') {
139 print "<p>$submessage</p>\n";
144 * Web implementation of status output
146 function updateStatus($status, $error=false)
148 echo '<li' . ($error ? ' class="error"': '' ) . ">$status</li>";
157 $post = new Posted();
159 $dbtype = $post->raw('dbtype');
160 foreach (self::$dbModules as $type => $info) {
161 if ($this->checkExtension($info['check_module'])) {
162 if ($dbtype == null || $dbtype == $type) {
163 $checked = 'checked="checked" ';
164 $dbtype = $type; // if we didn't have one checked, hit the first
168 $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
172 $ssl = array('always'=>null, 'never'=>null);
173 if (!empty($_SERVER['HTTPS'])) {
174 $ssl['always'] = 'checked="checked"';
176 $ssl['never'] = 'checked="checked"';
180 <form method="post" action="install.php" class="form_settings" id="form_install">
182 <fieldset id="settings_site">
183 <legend>Site settings</legend>
184 <ul class="form_data">
186 <label for="sitename">Site name</label>
187 <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
188 <p class="form_guide">The name of your site</p>
191 <label for="fancy-enable">Fancy URLs</label>
192 <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
193 <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
194 <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
197 <label for="ssl">Server SSL</label>
198 <input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']} /> enable<br />
199 <input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']} /> disable<br />
200 <p class="form_guide" id="ssl-form_guide">Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.</p>
205 <fieldset id="settings_db">
206 <legend>Database settings</legend>
207 <ul class="form_data">
209 <label for="host">Hostname</label>
210 <input type="text" id="host" name="host" value="{$post->value('host')}" />
211 <p class="form_guide">Database hostname</p>
214 <label for="dbtype">Type</label>
216 <p class="form_guide">Database type</p>
219 <label for="database">Name</label>
220 <input type="text" id="database" name="database" value="{$post->value('database')}" />
221 <p class="form_guide">Database name</p>
224 <label for="dbusername">DB username</label>
225 <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
226 <p class="form_guide">Database username</p>
229 <label for="dbpassword">DB password</label>
230 <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
231 <p class="form_guide">Database password (optional)</p>
236 <fieldset id="settings_admin">
237 <legend>Administrator settings</legend>
238 <ul class="form_data">
240 <label for="admin_nickname">Administrator nickname</label>
241 <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
242 <p class="form_guide">Nickname for the initial user (administrator)</p>
245 <label for="admin_password">Administrator password</label>
246 <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
247 <p class="form_guide">Password for the initial user (administrator)</p>
250 <label for="admin_password2">Confirm password</label>
251 <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
254 <label for="admin_email">Administrator e-mail</label>
255 <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
256 <p class="form_guide">Optional email address for the initial user (administrator)</p>
259 <label for="admin_updates">Subscribe to announcements</label>
260 <input type="checkbox" id="admin_updates" name="admin_updates" value="true" checked="checked" />
261 <p class="form_guide">Release and security feed from <a href="http://update.status.net/">update@status.net</a> (recommended)</p>
265 <fieldset id="settings_profile">
266 <legend>Site profile</legend>
267 <ul class="form_data">
269 <label for="site_profile">Type of site</label>
270 <select id="site_profile" name="site_profile">
271 <option value="private">Private</option>
272 <option value="community">Community</option>
273 <option value ="public">Public</option>
274 <option value ="singleuser">Single User</option>
276 <p class="form_guide">Initial access settings for your site</p>
280 <input type="submit" name="submit" class="submit" value="Submit" />
288 * Handle a POST submission... if we have valid input, start the install!
289 * Otherwise shows the form along with any error messages.
291 function handlePost()
294 <dl class="system_notice">
299 $this->validated = $this->prepare();
300 if ($this->validated) {
308 if (!$this->validated) {
314 * Read and validate input data.
315 * May output side effects.
317 * @return boolean success
321 $post = new Posted();
322 $this->host = $post->string('host');
323 $this->dbtype = $post->string('dbtype');
324 $this->database = $post->string('database');
325 $this->username = $post->string('dbusername');
326 $this->password = $post->string('dbpassword');
327 $this->sitename = $post->string('sitename');
328 $this->fancy = (bool)$post->string('fancy');
330 $this->adminNick = strtolower($post->string('admin_nickname'));
331 $this->adminPass = $post->string('admin_password');
332 $adminPass2 = $post->string('admin_password2');
333 $this->adminEmail = $post->string('admin_email');
334 $this->adminUpdates = $post->string('admin_updates');
336 $this->siteProfile = $post->string('site_profile');
338 $this->ssl = $post->string('ssl');
340 $this->server = $_SERVER['HTTP_HOST'];
341 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
344 if (!$this->validateDb()) {
348 if (!$this->validateAdmin()) {
352 if ($this->adminPass != $adminPass2) {
353 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
357 if (!in_array($this->ssl, array('never', 'sometimes', 'always'))) {
358 $this->updateStatus("Bad value for server SSL enabling.");
362 if (!$this->validateSiteProfile()) {
372 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
374 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
375 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
376 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
378 <title>Install GNU social</title>
379 <link rel="shortcut icon" href="favicon.ico"/>
380 <link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
381 <link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
382 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
383 <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
384 <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
385 <!--[if lte IE 7]><link rel="stylesheet" type="text/css" theme/base/css/ie7.css" /><![endif]-->
386 <script src="js/extlib/jquery.js"></script>
387 <script src="js/install.js"></script>
392 <address id="site_contact" class="vcard">
393 <a class="url home bookmark" href=".">
394 <img class="logo photo" src="theme/neo/logo.png" alt="GNU social"/>
395 <span class="fn org">GNU social</span>
398 <div id="site_nav_global_primary"></div>
401 <div id="aside_primary_wrapper">
402 <div id="content_wrapper">
403 <div id="site_nav_local_views_wrapper">
404 <div id="site_nav_local_views"></div>
407 <div id="content_inner">
408 <h1>Install GNU social</h1>
410 $installer = new WebInstaller();
416 <div id="aside_primary" class="aside"></div>
421 <div id="footer"></div>