]> git.wh0rd.org Git - tt-rss.git/commitdiff
actually check for DB_PORT in installer, add better hints and use mysqli if available
authorAndrew Dolgov <fox@fakecake.org>
Thu, 18 Apr 2013 12:06:03 +0000 (16:06 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Thu, 18 Apr 2013 12:06:03 +0000 (16:06 +0400)
config.php-dist
install/index.php
utility.css

index 4df299786f422779ec54157744c4bc398b0b174b..7cb9d9397d3b7f665945dc7537d8f4918a81188e 100644 (file)
@@ -8,7 +8,7 @@
        define('DB_USER', "fox");
        define('DB_NAME', "fox");
        define('DB_PASS', "XXXXXX");
-       //define('DB_PORT', '5432'); // when neeeded, PG-only
+       define('DB_PORT', ''); // usually 5432 for PostgreSQL, 3306 for MySQL
 
        define('MYSQL_CHARSET', 'UTF8');
        // Connection charset for MySQL. If you have a legacy database and/or experience
index 99339aca24ff48ee50648f55bd1299d1c89bea56..9cbab20f1fc7dda9298f56d1209ffb07c4cca673 100644 (file)
@@ -88,7 +88,7 @@
                        <img src=\"../images/sign_info.svg\">$msg</div>";
        }
 
-       function db_connect($host, $user, $pass, $db, $type) {
+       function db_connect($host, $user, $pass, $db, $type, $port) {
                if ($type == "pgsql") {
 
                        $string = "dbname=$db user=$user";
                                $string .= " host=$host";
                        }
 
-                       if (defined('DB_PORT')) {
-                               $string = "$string port=" . DB_PORT;
+                       if ($port) {
+                               $string = "$string port=" . $port;
                        }
 
                        $link = pg_connect($string);
                        return $link;
 
                } else if ($type == "mysql") {
-                       $link = mysql_connect($host, $user, $pass);
-                       if ($link) {
-                               $result = mysql_select_db($db, $link);
-                               if ($result) return $link;
+                       if (function_exists("mysqli_connect")) {
+                               return mysqli_connect($host, $user, $pass, $db, $port);
+
+                       } else {
+                               $link = mysql_connect($host, $user, $pass);
+                               if ($link) {
+                                       $result = mysql_select_db($db, $link);
+                                       if ($result) return $link;
+                               }
                        }
                }
        }
                        }
                        return $result;
                } else if ($type == "mysql") {
-                       $result = mysql_query($query, $link);
+
+                       if (function_exists("mysqli_connect")) {
+                               $result = mysqli_query($link, $query);
+                       } else {
+                               $result = mysql_query($query, $link);
+                       }
                        if (!$result) {
                                $query = htmlspecialchars($query);
                                if ($die_on_error) {
 
 <fieldset>
        <label>Database name</label>
-       <input name="DB_NAME" size="20" value="<?php echo $DB_NAME ?>"/>
+       <input required name="DB_NAME" size="20" value="<?php echo $DB_NAME ?>"/>
 </fieldset>
 
 <fieldset>
        <label>Host name</label>
-       <input  name="DB_HOST" placeholder="if needed" size="20" value="<?php echo $DB_HOST ?>"/>
+       <input name="DB_HOST" size="20" value="<?php echo $DB_HOST ?>"/>
+       <span class="hint">If needed</span>
 </fieldset>
 
 <fieldset>
        <label>Port</label>
-       <input name="DB_PORT" type="number" placeholder="if needed, PgSQL only" size="20" value="<?php echo $DB_PORT ?>"/>
+       <input name="DB_PORT" type="number" size="20" value="<?php echo $DB_PORT ?>"/>
+       <span class="hint">Usually 3306 for MySQL or 5432 for PostgreSQL</span>
 </fieldset>
 
 <h2>Other settings</h2>
        <h2>Checking database</h2>
 
        <?php
-               $link = db_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE);
+               $link = db_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT);
 
                if (!$link) {
                        print_error("Unable to connect to database using specified parameters.");
index 074589f9e9d34f5e7b84046b494415844a8f803c..65dc20b1e935f4fabd529e9634efabe8ea2298db 100644 (file)
@@ -240,3 +240,8 @@ body.otp div.content {
        display : inline-block;
        width : auto;
 }
+
+span.hint {
+       font-size : 10px;
+       color : gray;
+}