]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added SSL option to web and cli installers
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 12 Aug 2013 11:08:14 +0000 (13:08 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 12 Aug 2013 11:08:14 +0000 (13:08 +0200)
install.php
lib/installer.php
scripts/install_cli.php

index f44999285aeddf7758006daf60d8be808452c06f..3fc0a8ab02d90122ba95de6c253ca22172522921 100644 (file)
@@ -27,6 +27,7 @@
  * @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>
@@ -168,6 +169,13 @@ class WebInstaller extends Installer
             }
         }
 
+        $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>
@@ -185,6 +193,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>
 
@@ -321,6 +335,8 @@ STR;
 
         $this->siteProfile = $post->string('site_profile');
 
+        $this->ssl = $post->string('ssl');
+
         $this->server = $_SERVER['HTTP_HOST'];
         $this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
 
@@ -338,6 +354,11 @@ STR;
             $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;
         }
index 2fe83dd9a2e54235dbb65f5ad11ec2292a43f65b..69ad194829b4fac7cea3ddd78ecc395f288db0f7 100644 (file)
@@ -28,6 +28,7 @@
  * @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>
@@ -42,7 +43,7 @@
 abstract class Installer
 {
     /** Web site info */
-    public $sitename, $server, $path, $fancy, $siteProfile;
+    public $sitename, $server, $path, $fancy, $siteProfile, $ssl;
     /** DB info */
     public $host, $database, $dbtype, $username, $password, $db;
     /** Administrator info */
@@ -412,6 +413,9 @@ abstract class Installer
             'sitename' => $this->sitename,
             'server' => $this->server,
             'path' => $this->path,
+            'ssl' => in_array($this->ssl, array('never', 'sometimes', 'always'))
+                     ? $this->ssl
+                     : 'never',
             'db_database' => $this->db['database'],
             'db_type' => $this->db['type']
         ));
@@ -426,6 +430,7 @@ abstract class Installer
                 // site location
                 "\$config['site']['server'] = {$vals['server']};\n".
                 "\$config['site']['path'] = {$vals['path']}; \n\n".
+                "\$config['site']['ssl'] = {$vals['ssl']}; \n\n".
 
                 // checks if fancy URLs are enabled
                 ($this->fancy ? "\$config['site']['fancy'] = true;\n\n":'').
index 3e18f28f3ea1ef3cbaad1b910f1360b7d9747c74..acdc38fabec70259d928ea3d6c03a7d42e1b6862 100755 (executable)
@@ -21,8 +21,9 @@
  * @package  Installation
  *
  * @author   Brion Vibber <brion@status.net>
+ * @author   Mikael Nordfeldth <mmn@hethane.se>
  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
- * @version  0.9.x
+ * @version  1.1.x
  * @link     http://status.net
  */
 
@@ -72,6 +73,7 @@ class CliInstaller extends Installer
             '--path'     => 'path',
             '--sitename' => 'sitename',
             '--fancy'    => 'fancy',
+            '--ssl'      => 'ssl',
 
             '--dbtype'   => 'dbtype',
             '--host'     => 'host',
@@ -106,6 +108,7 @@ class CliInstaller extends Installer
         $this->dbtype = 'mysql';
         $this->adminUpdates = true;
         $this->verbose = true;
+        // ssl is defaulted in lib/installer.php
 
         foreach ($options as $option) {
             $arg = $option[0];
@@ -159,6 +162,8 @@ install_cli.php - StatusNet command-line installer
     -p --path=<path>     Use <path> as path name
        --sitename        User-friendly site name (required)
        --fancy           Whether to use fancy URLs (default no)
+       --ssl             Server SSL enabled (default never), 
+                         [never | sometimes | always]
 
        --dbtype          'mysql' (default) or 'pgsql'
        --host            Database hostname (required)