]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/installer.php
Merge branch '1.0.x' of git://gitorious.org/statusnet/mainline
[quix0rs-gnu-social.git] / lib / installer.php
index 589a19a66ebc041cc3ca65e12c01e99a794ce688..ff2bed1403adad3508dfe0847afe5b4e7aa8f923 100644 (file)
@@ -32,6 +32,7 @@
  * @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
@@ -81,13 +82,16 @@ abstract class Installer
     {
         $pass = true;
 
-        if (file_exists(INSTALLDIR.'/config.php')) {
-            $this->warning('Config file "config.php" already exists.');
-            $pass = false;
+        $config = INSTALLDIR.'/config.php';
+        if (file_exists($config)) {
+            if (!is_writable($config) || filesize($config) > 0) {
+                $this->warning('Config file "config.php" already exists.');
+                $pass = false;
+            }
         }
 
         if (version_compare(PHP_VERSION, '5.2.3', '<')) {
-            $errors[] = 'Require PHP version 5.2.3 or greater.';
+            $this->warning('Require PHP version 5.2.3 or greater.');
             $pass = false;
         }
 
@@ -128,6 +132,7 @@ abstract class Installer
             $pass = false;
         }
 
+        // @fixme this check seems to be insufficient with Windows ACLs
         if (!is_writable(INSTALLDIR)) {
             $this->warning(sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
                            sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR));
@@ -409,6 +414,10 @@ abstract class Installer
                 "\$config['db']['database'] = '{$this->db['database']}';\n\n".
                 ($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
                 "\$config['db']['type'] = '{$this->db['type']}';\n\n";
+
+        // Normalize line endings for Windows servers
+        $cfg = str_replace("\n", PHP_EOL, $cfg);
+
         // write configuration file out to install directory
         $res = file_put_contents(INSTALLDIR.'/config.php', $cfg);
 
@@ -438,7 +447,7 @@ abstract class Installer
             case 'mysqli':
                 $res = $conn->query($stmt);
                 if ($res === false) {
-                    $error = $conn->error();
+                    $error = $conn->error;
                 }
                 break;
             case 'pgsql':