]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/installer.php
Translator documentation updated/added.
[quix0rs-gnu-social.git] / lib / installer.php
index a5588fbed6404fac095b46a1f5a164f896a29830..1add65ba815a654ffaeab6ba39adaea6f988d26a 100644 (file)
@@ -236,7 +236,7 @@ abstract class Installer
         }
         // @fixme hardcoded list; should use User::allowed_nickname()
         // if/when it's safe to have loaded the infrastructure here
-        $blacklist = array('main', 'admin', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'bookmarklet', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook');
+        $blacklist = array('main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'bookmarklet', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook');
         if (in_array($this->adminNick, $blacklist)) {
             $this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
                          '" is reserved.', true);
@@ -341,6 +341,7 @@ abstract class Installer
             }
             $schema->ensureTable($name, $def);
         }
+        return true;
     }
 
     /**
@@ -355,6 +356,30 @@ abstract class Installer
         return $schema;
     }
 
+    /**
+     * Return a parseable PHP literal for the given value.
+     * This will include quotes for strings, etc.
+     *
+     * @param mixed $val
+     * @return string
+     */
+    function phpVal($val)
+    {
+        return var_export($val, true);
+    }
+
+    /**
+     * Return an array of parseable PHP literal for the given values.
+     * These will include quotes for strings, etc.
+     *
+     * @param mixed $val
+     * @return array
+     */
+    function phpVals($map)
+    {
+        return array_map(array($this, 'phpVal'), $map);
+    }
+
     /**
      * Write a stock configuration file.
      *
@@ -364,24 +389,32 @@ abstract class Installer
      */
     function writeConf()
     {
+        $vals = $this->phpVals(array(
+            'sitename' => $this->sitename,
+            'server' => $this->server,
+            'path' => $this->path,
+            'db_database' => $this->db['database'],
+            'db_type' => $this->db['type'],
+        ));
+
         // assemble configuration file in a string
         $cfg =  "<?php\n".
                 "if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }\n\n".
 
                 // site name
-                "\$config['site']['name'] = '{$this->sitename}';\n\n".
+                "\$config['site']['name'] = {$vals['sitename']};\n\n".
 
                 // site location
-                "\$config['site']['server'] = '{$this->server}';\n".
-                "\$config['site']['path'] = '{$this->path}'; \n\n".
+                "\$config['site']['server'] = {$vals['server']};\n".
+                "\$config['site']['path'] = {$vals['path']}; \n\n".
 
                 // checks if fancy URLs are enabled
                 ($this->fancy ? "\$config['site']['fancy'] = true;\n\n":'').
 
                 // database
-                "\$config['db']['database'] = '{$this->db['database']}';\n\n".
+                "\$config['db']['database'] = {$vals['db_database']};\n\n".
                 ($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
-                "\$config['db']['type'] = '{$this->db['type']}';\n\n";
+                "\$config['db']['type'] = {$vals['db_type']};\n\n";
 
         // Normalize line endings for Windows servers
         $cfg = str_replace("\n", PHP_EOL, $cfg);
@@ -409,11 +442,12 @@ abstract class Installer
             if (!mb_strlen($stmt)) {
                 continue;
             }
-            $res = $conn->execute($stmt);
-            if (DB::isError($res)) {
-                $error = $result->getMessage();
+            try {
+                $res = $conn->simpleQuery($stmt);
+            } catch (Exception $e) {
+                $error = $e->getMessage();
                 $this->updateStatus("ERROR ($error) for SQL '$stmt'");
-                return $res;
+                return false;
             }
         }
         return true;
@@ -426,9 +460,6 @@ abstract class Installer
      */
     function registerInitialUser()
     {
-        define('STATUSNET', true);
-        define('LACONICA', true); // compatibility
-
         require_once INSTALLDIR . '/lib/common.php';
 
         $data = array('nickname' => $this->adminNick,