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 .= sprintf('<input type="radio" name="dbtype" id="dbtype-%1$s" value="%1$s" %2$s/>%3$s<br />',
169 htmlspecialchars($type), $checked,
170 htmlspecialchars($info['name']));
174 $ssl = array('always'=>null, 'never'=>null);
175 if (!empty($_SERVER['HTTPS'])) {
176 $ssl['always'] = 'checked="checked"';
178 $ssl['never'] = 'checked="checked"';
182 <form method="post" action="install.php" class="form_settings" id="form_install">
184 <fieldset id="settings_site">
185 <legend>Site settings</legend>
186 <ul class="form_data">
188 <label for="sitename">Site name</label>
189 <input type="text" id="sitename" name="sitename" value="{$post->value('sitename')}" />
190 <p class="form_guide">The name of your site</p>
193 <label for="fancy-enable">Fancy URLs</label>
194 <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
195 <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
196 <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
199 <label for="ssl">Server SSL</label>
200 <input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']} /> enable<br />
201 <input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']} /> disable<br />
202 <p class="form_guide" id="ssl-form_guide">Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.</p>
207 <fieldset id="settings_db">
208 <legend>Database settings</legend>
209 <ul class="form_data">
211 <label for="host">Hostname</label>
212 <input type="text" id="host" name="host" value="{$post->value('host')}" />
213 <p class="form_guide">Database hostname</p>
216 <label for="dbtype">Type</label>
218 <p class="form_guide">Database type</p>
221 <label for="database">Name</label>
222 <input type="text" id="database" name="database" value="{$post->value('database')}" />
223 <p class="form_guide">Database name</p>
226 <label for="dbusername">DB username</label>
227 <input type="text" id="dbusername" name="dbusername" value="{$post->value('dbusername')}" />
228 <p class="form_guide">Database username</p>
231 <label for="dbpassword">DB password</label>
232 <input type="password" id="dbpassword" name="dbpassword" value="{$post->value('dbpassword')}" />
233 <p class="form_guide">Database password (optional)</p>
238 <fieldset id="settings_admin">
239 <legend>Administrator settings</legend>
240 <ul class="form_data">
242 <label for="admin_nickname">Administrator nickname</label>
243 <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
244 <p class="form_guide">Nickname for the initial user (administrator)</p>
247 <label for="admin_password">Administrator password</label>
248 <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
249 <p class="form_guide">Password for the initial user (administrator)</p>
252 <label for="admin_password2">Confirm password</label>
253 <input type="password" id="admin_password2" name="admin_password2" value="{$post->value('admin_password2')}" />
256 <label for="admin_email">Administrator e-mail</label>
257 <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
258 <p class="form_guide">Optional email address for the initial user (administrator)</p>
262 <fieldset id="settings_profile">
263 <legend>Site profile</legend>
264 <ul class="form_data">
266 <label for="site_profile">Type of site</label>
267 <select id="site_profile" name="site_profile">
268 <option value="community">Community</option>
269 <option value="public">Public (open registration)</option>
270 <option value="singleuser">Single User</option>
271 <option value="private">Private (no federation)</option>
273 <p class="form_guide">Initial access settings for your site</p>
277 <input type="submit" name="submit" class="submit" value="Submit" />
285 * Handle a POST submission... if we have valid input, start the install!
286 * Otherwise shows the form along with any error messages.
288 function handlePost()
291 <dl class="system_notice">
296 $this->validated = $this->prepare();
297 if ($this->validated) {
305 if (!$this->validated) {
311 * Read and validate input data.
312 * May output side effects.
314 * @return boolean success
318 $post = new Posted();
319 $this->host = $post->string('host');
320 $this->dbtype = $post->string('dbtype');
321 $this->database = $post->string('database');
322 $this->username = $post->string('dbusername');
323 $this->password = $post->string('dbpassword');
324 $this->sitename = $post->string('sitename');
325 $this->fancy = (bool)$post->string('fancy');
327 $this->adminNick = strtolower($post->string('admin_nickname'));
328 $this->adminPass = $post->string('admin_password');
329 $adminPass2 = $post->string('admin_password2');
330 $this->adminEmail = $post->string('admin_email');
332 $this->siteProfile = $post->string('site_profile');
334 $this->ssl = $post->string('ssl');
336 $this->server = $_SERVER['HTTP_HOST'];
337 $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
340 if (!$this->validateDb()) {
344 if (!$this->validateAdmin()) {
348 if ($this->adminPass != $adminPass2) {
349 $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
353 if (!in_array($this->ssl, array('never', 'always'))) {
354 $this->updateStatus("Bad value for server SSL enabling.");
358 if (!$this->validateSiteProfile()) {
368 <?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
370 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
371 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
372 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
374 <title>Install GNU social</title>
375 <link rel="shortcut icon" href="favicon.ico"/>
376 <link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
377 <link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
378 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
379 <script src="js/extlib/jquery.js"></script>
380 <script src="js/install.js"></script>
385 <address id="site_contact" class="h-card">
386 <a class="u-url p-name home bookmark org" href=".">
387 <img class="logo u-photo" src="theme/neo/logo.png" alt="GNU social"/>
391 <div id="site_nav_global_primary"></div>
394 <div id="aside_primary_wrapper">
395 <div id="content_wrapper">
396 <div id="site_nav_local_views_wrapper">
397 <div id="site_nav_local_views"></div>
400 <div id="content_inner">
401 <h1>Install GNU social</h1>
403 $installer = new WebInstaller();
409 <div id="aside_primary" class="aside"></div>
414 <div id="footer"></div>