]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - install.php
Show HTML for thumbnails instead of redirecting. Remove dead code.
[quix0rs-gnu-social.git] / install.php
index 66e8e8712460ecc007feb79ea3ebf0aa8622f1b5..570b08edf473b13e709ece605656a279d89016de 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Controlez-Vous, Inc.
+ * Copyright (C) 2009, Control Yourself, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -35,15 +35,17 @@ function main()
 
 function checkPrereqs()
 {
+       $pass = true;
+
     if (file_exists(INSTALLDIR.'/config.php')) {
          ?><p class="error">Config file &quot;config.php&quot; already exists.</p>
          <?php
-        return false;
+        $pass = false;
     }
 
     if (version_compare(PHP_VERSION, '5.0.0', '<')) {
             ?><p class="error">Require PHP version 5 or greater.</p><?php
-                   return false;
+                   $pass = false;
     }
 
     $reqs = array('gd', 'mysql', 'curl',
@@ -53,7 +55,7 @@ function checkPrereqs()
     foreach ($reqs as $req) {
         if (!checkExtension($req)) {
             ?><p class="error">Cannot load required extension: <code><?php echo $req; ?></code></p><?php
-                   return false;
+                   $pass = false;
         }
     }
 
@@ -61,17 +63,23 @@ function checkPrereqs()
          ?><p class="error">Cannot write config file to: <code><?php echo INSTALLDIR; ?></code></p>
               <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code>
          <?php
-            return false;
+            $pass = false;
        }
 
        if (!is_writable(INSTALLDIR.'/avatar/')) {
          ?><p class="error">Cannot write avatar directory: <code><?php echo INSTALLDIR; ?>/avatar/</code></p>
               <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?>/avatar/</code></p>
          <?
-            return false;
+            $pass = false;
+       }
+       if (!is_writable(INSTALLDIR.'/background/')) {
+         ?><p class="error">Cannot write background directory: <code><?php echo INSTALLDIR; ?>/background/</code></p>
+              <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?>/background/</code></p>
+         <?
+            $pass = false;
        }
 
-       return true;
+       return $pass;
 }
 
 function checkExtension($name)
@@ -86,7 +94,7 @@ function checkExtension($name)
 
 function showForm()
 {
-?>
+    echo<<<E_O_T
         </ul>
     </dd>
 </dl>
@@ -108,6 +116,11 @@ function showForm()
                 <p class="form_guide">The name of your site</p>
             </li>
             <li>
+                <label for="fancy-enable">Fancy URLs</label>
+                <input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
+                <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="host">Hostname</label>
                 <input type="text" id="host" name="host" />
@@ -132,7 +145,8 @@ function showForm()
         <input type="submit" name="submit" class="submit" value="Submit" />
     </fieldset>
 </form>
-<?php
+
+E_O_T;
 }
 
 function updateStatus($status, $error=false)
@@ -148,47 +162,50 @@ function handlePost()
 ?>
 
 <?php
-    $host = $_POST['host'];
+    $host     = $_POST['host'];
     $database = $_POST['database'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $sitename = $_POST['sitename'];
+    $fancy    = !empty($_POST['fancy']);
 ?>
     <dl class="system_notice">
         <dt>Page notice</dt>
         <dd>
             <ul>
 <?php
+       $fail = false;
+
     if (empty($host)) {
         updateStatus("No hostname specified.", true);
-        showForm();
-        return;
+               $fail = true;
     }
 
     if (empty($database)) {
         updateStatus("No database specified.", true);
-        showForm();
-        return;
+               $fail = true;
     }
 
     if (empty($username)) {
         updateStatus("No username specified.", true);
-        showForm();
-        return;
+               $fail = true;
     }
 
     if (empty($password)) {
         updateStatus("No password specified.", true);
-        showForm();
-        return;
+               $fail = true;
     }
 
     if (empty($sitename)) {
         updateStatus("No sitename specified.", true);
-        showForm();
-        return;
+               $fail = true;
     }
 
+       if($fail){
+               showForm();
+           return;
+       }
+
     updateStatus("Starting installation...");
     updateStatus("Checking database...");
     $conn = mysql_connect($host, $username, $password);
@@ -225,24 +242,29 @@ function handlePost()
     }
     updateStatus("Writing config file...");
     $sqlUrl = "mysqli://$username:$password@$host/$database";
-    $res = writeConf($sitename, $sqlUrl);
+    $res = writeConf($sitename, $sqlUrl, $fancy);
     if (!$res) {
         updateStatus("Can't write config file.", true);
         showForm();
         return;
     }
     updateStatus("Done!");
+    if ($path) $path .= '/';
+    updateStatus("You can visit your <a href='/$path'>new Laconica site</a>.");
 ?>
 
 <?php
 }
 
-function writeConf($sitename, $sqlUrl)
+function writeConf($sitename, $sqlUrl, $fancy)
 {
     $res = file_put_contents(INSTALLDIR.'/config.php',
                              "<?php\n".
+                             "if (!defined('LACONICA')) { exit(1); }\n\n".
                              "\$config['site']['name'] = \"$sitename\";\n\n".
-                             "\$config['db']['database'] = \"$sqlUrl\";\n\n");
+                             ($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
+                             "\$config['db']['database'] = \"$sqlUrl\";\n\n".
+                             "?>");
     return $res;
 }
 
@@ -271,11 +293,13 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
     <head>
         <title>Install Laconica</title>
-        <link rel="stylesheet" type="text/css" href="theme/base/css/display.css?version=0.8" media="screen, projection, tv"/>
+       <link rel="shortcut icon" href="favicon.ico"/>
         <link rel="stylesheet" type="text/css" href="theme/default/css/display.css?version=0.8" media="screen, projection, tv"/>
         <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css?version=0.8" /><![endif]-->
         <!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css?version=0.8" /><![endif]-->
-        <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/earthy/css/ie.css?version=0.8" /><![endif]-->
+        <!--[if IE]><link rel="stylesheet" type="text/css" href="theme/default/css/ie.css?version=0.8" /><![endif]-->
+        <script src="js/jquery.min.js"></script>
+        <script src="js/install.js"></script>
     </head>
     <body id="install">
         <div id="wrap">