Ticket #508 (new defect)

Opened 22 months ago

Last modified 22 months ago

Issues with install.php

Reported by: reporter Owned by: mbonetti
Priority: normal Milestone:
Component: BUGS Version:
Severity: normal Keywords:
Cc:

Description

There seems to be some issues with the install page:

* If MySQL is not installed, the SQLite radio button is selected, but the fields are not updated to reflect this (i.e the fields look like MySQL was selected).

* The field validation code does not work.

The attached patch should fix these issues.

Change History

Changed 22 months ago by reporter

Apparently attachments do not work, so here is the patch inline instead:

Index: install.php =================================================================== --- install.php (revision 1787) +++ install.php (working copy) @@ -58,7 +58,6 @@

$hasSQLite = function_exists('sqlite_open'); $hasSocket = function_exists('fsockopen');

-// $hasSQLite = true;

// If the server is running safe mode, try writing a temp file. if(ini_get('safe_mode')) {

define ('TMPINIT', DBINIT . GREGARIUS_CODENAME . "tmp");

@@ -156,7 +155,7 @@

. "\n" . " function ValidateData?() {\n" . " var ret = false;\n"

- . " if('mysql' == document.getElementById('type').value) {\n" + . " if(document.getElementById('mysql_radio').checked) {\n"

. " if(document.getElementById('server').value.length < 1) {\n" . " alert('A server location is required.');\n" . " document.getElementById('server').focus();\n"

@@ -172,7 +171,7 @@

. " } else {\n" . " ret = true;\n" . " }\n"

- . " } else if('sqlite' == document.getElementById('type').value) {\n" + . " } else if(document.getElementById('sqlite_radio').checked) {\n"

. " if(document.getElementById('server').value.length < 1) {\n" . " alert('A server path is required.');\n" . " document.getElementById('server').focus();\n"

@@ -186,7 +185,7 @@

. "//]]>\n" . "</script>\n" . "</head>\n"

- . "<body>\n" + . "<body onload=\"document.getElementById('" . ($hasMySQL ? "mysql" : "sqlite") . "_radio').onchange()\">\n"

. "<div id=\"nav\" class=\"frame\">" . "<h1>Gregarius Database Setup</h1>\n" . "<fieldset class=\"install\" style=\"text-align:center\">\n"

@@ -210,8 +209,8 @@

. "<legend>Database Settings</legend>\n" . "<p>The settings below are for the database Gregarius will keep its data.</p>\n" . "<p><label for=\"type\">Server Type <a href=\"#\" onclick=\"ToggleHelp?('type_help'); return false; \">[?]</a></label>\n"

- . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"type\" value=\"mysql\" onchange=\"ToggleType?(this); return false;\" " . ($hasMySQL ? "checked=\"checked\"" : "disabled=\"disabled\"") . "/>MySQL" - . "<input type=\"radio\" style=\"display:inline\" name=\"type\" value=\"sqlite\" onchange=\"ToggleType?(this); return false;\" " . ($hasSQLite ? ($hasMySQL ? "" : "checked=\"checked\"") : "disabled=\"disabled\"") . "/>SQLite" + . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"mysql_radio\" value=\"mysql\" onchange=\"ToggleType?(this); return false;\" " . ($hasMySQL ? "checked=\"checked\"" : "disabled=\"disabled\"") . "/>MySQL" + . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"sqlite_radio\" value=\"sqlite\" onchange=\"ToggleType?(this); return false;\" " . ($hasSQLite ? ($hasMySQL ? "" : "checked=\"checked\"") : "disabled=\"disabled\"") . "/>SQLite"

. "<span class=\"help\" id=\"type_help\">" . TYPE_HELP . "</span></p>\n" . "<p><label for=\"server\">Server Location <a href=\"#\" onclick=\"ToggleHelp?('server_help'); return false; \">[?]</a></label>\n" . "<input type=\"text\" name=\"server\" id=\"server\" value=\"" . SQL_SERVER_DEFAULT . "\" />"

@@ -255,11 +254,11 @@

if(file_exists(DBINIT)) {

print("The dbinit.php file already exists in the Gregarius directory! Please remove it if you would like to use this installer.");

} else if(!empty($_POSTprocess?) && 1 == $_POSTprocess?) {

- if(empty($_POSTserver?) - empty($_POSTdatabase?) - empty($_POSTusername?) - empty($_POSTpassword?) - empty($_POSTtype?)) { + print($_POSTdatabase?); + if(empty($_POSTtype?)

+ empty($_POSTserver?)

+ $_POSTtype?=='mysql'

+ && (empty($_POSTusername?) empty($_POSTpassword?) empty($_POSTdatabase?))) {

print("Not all required fields have been filled in!");

} else {

Changed 22 months ago by reporter

Yet another try, since the wiki markup made the last one garbage

Index: install.php
===================================================================
--- install.php (revision 1787)
+++ install.php (working copy)
@@ -58,7 +58,6 @@
     $hasSQLite = function_exists('sqlite_open');
     $hasSocket = function_exists('fsockopen');
 
-//    $hasSQLite = true;
     // If the server is running safe mode, try writing a temp file.
     if(ini_get('safe_mode')) {
         define ('TMPINIT', DBINIT . GREGARIUS_CODENAME . "tmp");
@@ -156,7 +155,7 @@
     . "\n"
     . "  function ValidateData() {\n"
     . "    var ret = false;\n"
-    . "    if('mysql' == document.getElementById('type').value) {\n"
+    . "    if(document.getElementById('mysql_radio').checked) {\n"
     . "      if(document.getElementById('server').value.length < 1) {\n"
     . "        alert('A server location is required.');\n"
     . "        document.getElementById('server').focus();\n"
@@ -172,7 +171,7 @@
     . "      } else {\n"
     . "        ret = true;\n"
     . "      }\n"
-    . "    } else if('sqlite' == document.getElementById('type').value) {\n"
+    . "    } else if(document.getElementById('sqlite_radio').checked) {\n"
     . "      if(document.getElementById('server').value.length < 1) {\n"
     . "        alert('A server path is required.');\n"
     . "        document.getElementById('server').focus();\n"
@@ -186,7 +185,7 @@
     . "//]]>\n"
     . "</script>\n"
     . "</head>\n"
-    . "<body>\n"
+    . "<body onload=\"document.getElementById('" . ($hasMySQL ? "mysql" : "sqlite") . "_radio').onchange()\">\n"
     . "<div id=\"nav\" class=\"frame\">"
     . "<h1>Gregarius Database Setup</h1>\n"
     . "<fieldset class=\"install\" style=\"text-align:center\">\n"
@@ -210,8 +209,8 @@
     . "<legend>Database Settings</legend>\n"
     . "<p>The settings below are for the database Gregarius will keep its data.</p>\n"
     . "<p><label for=\"type\">Server Type <a href=\"#\" onclick=\"ToggleHelp('type_help'); return false; \">[?]</a></label>\n"
-    . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"type\" value=\"mysql\" onchange=\"ToggleType(this); return false;\" " . ($hasMySQL ? "checked=\"checked\"" : "disabled=\"disabled\"") . "/>MySQL"
-    . "<input type=\"radio\" style=\"display:inline\" name=\"type\" value=\"sqlite\" onchange=\"ToggleType(this); return false;\" " . ($hasSQLite ? ($hasMySQL ? "" : "checked=\"checked\"") : "disabled=\"disabled\"") . "/>SQLite"
+    . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"mysql_radio\" value=\"mysql\" onchange=\"ToggleType(this); return false;\" " . ($hasMySQL ? "checked=\"checked\"" : "disabled=\"disabled\"") . "/>MySQL"
+    . "<input type=\"radio\" style=\"display:inline\" name=\"type\" id=\"sqlite_radio\" value=\"sqlite\" onchange=\"ToggleType(this); return false;\" " . ($hasSQLite ? ($hasMySQL ? "" : "checked=\"checked\"") : "disabled=\"disabled\"") . "/>SQLite"
     . "<span class=\"help\" id=\"type_help\">" . TYPE_HELP . "</span></p>\n"
     . "<p><label for=\"server\">Server Location <a href=\"#\" onclick=\"ToggleHelp('server_help'); return false; \">[?]</a></label>\n"
     . "<input type=\"text\" name=\"server\" id=\"server\" value=\"" . SQL_SERVER_DEFAULT . "\" />"
@@ -255,11 +254,11 @@
 if(file_exists(DBINIT)) {
     print("The dbinit.php file already exists in the Gregarius directory! Please remove it if you would like to use this installer.");
 } else if(!empty($_POST['process']) && 1 == $_POST['process']) {
-        if(empty($_POST['server']) ||
-            empty($_POST['database']) ||
-            empty($_POST['username']) ||
-            empty($_POST['password']) ||
-            empty($_POST['type'])) {
+       print($_POST['database']);
+        if(empty($_POST['type'])
+           || empty($_POST['server'])
+           || $_POST['type']=='mysql'
+               && (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['database']))) {
 
             print("Not all required fields have been filled in!");
         } else {
Note: See TracTickets for help on using tickets.