]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - install.php
Misses this file to merge. I like the comments.
[quix0rs-gnu-social.git] / install.php
index 08555d19b9515ea2773a774e3403a0287e74fbdd..2752c967677cddc4dc07e68d43537893fbe4413e 100644 (file)
  * @author   Craig Andrews <candrews@integralblue.com>
  * @author   Eric Helgeson <helfire@Erics-MBP.local>
  * @author   Evan Prodromou <evan@status.net>
+ * @author   Mikael Nordfeldth <mmn@hethane.se>
  * @author   Robin Millette <millette@controlyourself.ca>
  * @author   Sarven Capadisli <csarven@status.net>
  * @author   Tom Adams <tom@holizz.com>
  * @author   Zach Copley <zach@status.net>
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
  * @version  0.9.x
  * @link     http://status.net
@@ -44,13 +46,61 @@ require INSTALLDIR . '/lib/installer.php';
  * Helper class for building form
  */
 class Posted {
+    /**
+     * HTML-friendly escaped string for the POST param of given name, or empty.
+     * @param string $name
+     * @return string
+     */
     function value($name)
+    {
+        return htmlspecialchars($this->string($name));
+    }
+
+    /**
+     * The given POST parameter value, forced to a string.
+     * Missing value will give ''.
+     *
+     * @param string $name
+     * @return string
+     */
+    function string($name)
+    {
+        return strval($this->raw($name));
+    }
+
+    /**
+     * The given POST parameter value, in its original form.
+     * Magic quotes are stripped, if provided.
+     * Missing value will give null.
+     *
+     * @param string $name
+     * @return mixed
+     */
+    function raw($name)
     {
         if (isset($_POST[$name])) {
-            return htmlspecialchars(strval($_POST[$name]));
+            return $this->dequote($_POST[$name]);
         } else {
-            return '';
+            return null;
+        }
+    }
+
+    /**
+     * If necessary, strip magic quotes from the given value.
+     *
+     * @param mixed $val
+     * @return mixed
+     */
+    function dequote($val)
+    {
+        if (get_magic_quotes_gpc()) {
+            if (is_string($val)) {
+                return stripslashes($val);
+            } else if (is_array($val)) {
+                return array_map(array($this, 'dequote'), $val);
+            }
         }
+        return $val;
     }
 }
 
@@ -68,7 +118,7 @@ class WebInstaller extends Installer
     function main()
     {
         if (!$this->checkPrereqs()) {
-            $this->showForm();
+            $this->warning(_('Please fix the above stated problems and refresh this page to continue installing.'));
             return;
         }
 
@@ -106,11 +156,7 @@ class WebInstaller extends Installer
         global $dbModules;
         $post = new Posted();
         $dbRadios = '';
-        if (isset($_POST['dbtype'])) {
-            $dbtype = $_POST['dbtype'];
-        } else {
-            $dbtype = null;
-        }
+        $dbtype = $post->raw('dbtype');
         foreach (self::$dbModules as $type => $info) {
             if ($this->checkExtension($info['check_module'])) {
                 if ($dbtype == null || $dbtype == $type) {
@@ -119,10 +165,19 @@ class WebInstaller extends Installer
                 } else {
                     $checked = '';
                 }
-                $dbRadios .= "<input type=\"radio\" name=\"dbtype\" id=\"dbtype-$type\" value=\"$type\" $checked/> $info[name]<br />\n";
+                $dbRadios .= sprintf('<input type="radio" name="dbtype" id="dbtype-%1$s" value="%1$s" %2$s/>%3$s<br />',
+                                htmlspecialchars($type), $checked,
+                                htmlspecialchars($info['name']));
             }
         }
 
+        $ssl = array('always'=>null, 'never'=>null);
+        if (!empty($_SERVER['HTTPS'])) {
+            $ssl['always'] = 'checked="checked"';
+        } else {
+            $ssl['never'] = 'checked="checked"';
+        }
+
         echo<<<E_O_T
     <form method="post" action="install.php" class="form_settings" id="form_install">
         <fieldset>
@@ -140,6 +195,12 @@ class WebInstaller extends Installer
                         <input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
                         <p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
                     </li>
+                    <li>
+                        <label for="ssl">Server SSL</label>
+                        <input type="radio" name="ssl" id="ssl-always" value="always" {$ssl['always']} /> enable<br />
+                        <input type="radio" name="ssl" id="ssl-never" value="never" {$ssl['never']} /> disable<br />
+                        <p class="form_guide" id="ssl-form_guide">Enabling SSL (https://) requires extra webserver configuration and certificate generation not offered by this installation.</p>
+                    </li>
                 </ul>
             </fieldset>
 
@@ -153,7 +214,7 @@ class WebInstaller extends Installer
                     </li>
                     <li>
                         <label for="dbtype">Type</label>
-                        $dbRadios
+                        {$dbRadios}
                         <p class="form_guide">Database type</p>
                     </li>
                     <li>
@@ -180,12 +241,12 @@ class WebInstaller extends Installer
                     <li>
                         <label for="admin_nickname">Administrator nickname</label>
                         <input type="text" id="admin_nickname" name="admin_nickname" value="{$post->value('admin_nickname')}" />
-                        <p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
+                        <p class="form_guide">Nickname for the initial user (administrator)</p>
                     </li>
                     <li>
                         <label for="admin_password">Administrator password</label>
                         <input type="password" id="admin_password" name="admin_password" value="{$post->value('admin_password')}" />
-                        <p class="form_guide">Password for the initial StatusNet user (administrator)</p>
+                        <p class="form_guide">Password for the initial user (administrator)</p>
                     </li>
                     <li>
                         <label for="admin_password2">Confirm password</label>
@@ -194,12 +255,22 @@ class WebInstaller extends Installer
                     <li>
                         <label for="admin_email">Administrator e-mail</label>
                         <input id="admin_email" name="admin_email" value="{$post->value('admin_email')}" />
-                        <p class="form_guide">Optional email address for the initial StatusNet user (administrator)</p>
+                        <p class="form_guide">Optional email address for the initial user (administrator)</p>
                     </li>
+                </ul>
+            </fieldset>
+            <fieldset id="settings_profile">
+                <legend>Site profile</legend>
+                <ul class="form_data">
                     <li>
-                        <label for="admin_updates">Subscribe to announcements</label>
-                        <input type="checkbox" id="admin_updates" name="admin_updates" value="true" checked="checked" />
-                        <p class="form_guide">Release and security feed from <a href="http://update.status.net/">update@status.net</a> (recommended)</p>
+                        <label for="site_profile">Type of site</label>
+                        <select id="site_profile" name="site_profile">
+                            <option value="community">Community</option>
+                            <option value="public">Public (open registration)</option>
+                            <option value="singleuser">Single User</option>
+                            <option value="private">Private (no federation)</option>
+                        </select>
+                        <p class="form_guide">Initial access settings for your site</p>
                     </li>
                 </ul>
             </fieldset>
@@ -239,24 +310,28 @@ STR;
     /**
      * Read and validate input data.
      * May output side effects.
-     * 
+     *
      * @return boolean success
      */
     function prepare()
     {
-        $this->host     = $_POST['host'];
-        $this->dbtype   = $_POST['dbtype'];
-        $this->database = $_POST['database'];
-        $this->username = $_POST['dbusername'];
-        $this->password = $_POST['dbpassword'];
-        $this->sitename = $_POST['sitename'];
-        $this->fancy    = !empty($_POST['fancy']);
-
-        $this->adminNick    = strtolower($_POST['admin_nickname']);
-        $this->adminPass    = $_POST['admin_password'];
-        $adminPass2         = $_POST['admin_password2'];
-        $this->adminEmail   = $_POST['admin_email'];
-        $this->adminUpdates = $_POST['admin_updates'];
+        $post = new Posted();
+        $this->host     = $post->string('host');
+        $this->dbtype   = $post->string('dbtype');
+        $this->database = $post->string('database');
+        $this->username = $post->string('dbusername');
+        $this->password = $post->string('dbpassword');
+        $this->sitename = $post->string('sitename');
+        $this->fancy    = (bool)$post->string('fancy');
+
+        $this->adminNick    = strtolower($post->string('admin_nickname'));
+        $this->adminPass    = $post->string('admin_password');
+        $adminPass2         = $post->string('admin_password2');
+        $this->adminEmail   = $post->string('admin_email');
+
+        $this->siteProfile = $post->string('site_profile');
+
+        $this->ssl = $post->string('ssl');
 
         $this->server = $_SERVER['HTTP_HOST'];
         $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
@@ -269,12 +344,21 @@ STR;
         if (!$this->validateAdmin()) {
             $fail = true;
         }
-        
+
         if ($this->adminPass != $adminPass2) {
             $this->updateStatus("Administrator passwords do not match. Did you mistype?", true);
             $fail = true;
         }
-        
+
+        if (!in_array($this->ssl, array('never', 'sometimes', 'always'))) {
+            $this->updateStatus("Bad value for server SSL enabling.");
+            $fail = true;
+        }
+
+        if (!$this->validateSiteProfile()) {
+            $fail = true;
+        }
+
         return !$fail;
     }
 
@@ -287,36 +371,47 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
     <head>
-        <title>Install StatusNet</title>
-       <link rel="shortcut icon" href="favicon.ico"/>
-        <link rel="stylesheet" type="text/css" href="theme/default/css/display.css" media="screen, projection, tv"/>
-        <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css" /><![endif]-->
-        <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css" /><![endif]-->
-        <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/default/css/ie.css" /><![endif]-->
-        <script src="js/jquery.min.js"></script>
+        <title>Install GNU social</title>
+        <link rel="shortcut icon" href="favicon.ico"/>
+        <link rel="stylesheet" type="text/css" href="theme/base/css/display.css" media="screen, projection, tv"/>
+        <link rel="stylesheet" type="text/css" href="theme/neo/css/display.css" media="screen, projection, tv"/>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+        <script src="js/extlib/jquery.js"></script>
         <script src="js/install.js"></script>
     </head>
     <body id="install">
         <div id="wrap">
             <div id="header">
-                <address id="site_contact" class="vcard">
-                    <a class="url home bookmark" href=".">
-                        <img class="logo photo" src="theme/default/logo.png" alt="StatusNet"/>
-                        <span class="fn org">StatusNet</span>
+                <address id="site_contact" class="h-card">
+                    <a class="u-url p-name home bookmark org" href=".">
+                        <img class="logo u-photo" src="theme/neo/logo.png" alt="GNU social"/>
+                        GNU social
                     </a>
                 </address>
+                <div id="site_nav_global_primary"></div>
             </div>
             <div id="core">
+             <div id="aside_primary_wrapper">
+              <div id="content_wrapper">
+               <div id="site_nav_local_views_wrapper">
+                <div id="site_nav_local_views"></div>
+
                 <div id="content">
                      <div id="content_inner">
-                        <h1>Install StatusNet</h1>
-<?php 
+                        <h1>Install GNU social</h1>
+<?php
 $installer = new WebInstaller();
 $installer->main();
 ?>
                    </div>
                 </div>
+
+                <div id="aside_primary" class="aside"></div>
+               </div>
+              </div>
+             </div>
             </div>
+            <div id="footer"></div>
         </div>
     </body>
 </html>