From: <es...@fh...> - 2010-10-17 22:50:30
|
Author: pcvolkmer Date: Mon Oct 18 00:50:20 2010 New Revision: 5695 Log: Fix related to #406: Added JavaScript check for database settings. This check also provides an AJAX call to check if database is reachable with given settings. Added: trunk/web/common/js/setup.js (with props) Modified: trunk/web/common/install.footer.inc.php trunk/web/setup.php Modified: trunk/web/common/install.footer.inc.php ============================================================================== --- trunk/web/common/install.footer.inc.php (original) +++ trunk/web/common/install.footer.inc.php Mon Oct 18 00:50:20 2010 @@ -74,33 +74,6 @@ </div> <script type="text/javascript" src="common/js/jQuery/jquery-latest.pack.js"></script> -<script type="text/javascript"> - - function checkPassword() { - if ($('#INSTALL_ROOT_PASS').val() == $('#INSTALL_ROOT_PASS_CHECK').val()) { - jQuery.post( - 'setup.php', - { - passwordcheck: $('#INSTALL_ROOT_PASS').val() - }, - function(data) { - if (data == 'FALSE') { - $('#INSTALL_ROOT_PASS').css('background-color','red'); - $('#INSTALL_ROOT_PASS_CHECK').css('background-color','red'); - } else { - $('#INSTALL_ROOT_PASS').css('background-color','lightGreen'); - $('#INSTALL_ROOT_PASS_CHECK').css('background-color','lightGreen'); - } - } - ); - } else { - $('#INSTALL_ROOT_PASS').css('background-color','red'); - $('#INSTALL_ROOT_PASS_CHECK').css('background-color','red'); - } - } - - $('#INSTALL_ROOT_PASS').change(checkPassword); - $('#INSTALL_ROOT_PASS_CHECK').change(checkPassword); -</script> +<script type="text/javascript" src="common/js/setup.js"></script> </body> </html> Added: trunk/web/common/js/setup.js ============================================================================== --- trunk/web/common/js/setup.js (added) +++ trunk/web/common/js/setup.js Mon Oct 18 00:50:20 2010 @@ -1,0 +1,77 @@ +var checkDatabaseSettingsOK = false; +var checkPasswordOK = false; + +function enableCompleteButton() { + if (checkDatabaseSettingsOK && checkPasswordOK) { + $('#BUTTON_OK').removeAttr('disabled'); + } +} + +function setDbSettingsColor(color) { + $('#INSTALL_DB_HOST').css('background-color',color), + $('#INSTALL_DB_PORT').css('background-color',color), + $('#INSTALL_DB_USER').css('background-color',color), + $('#INSTALL_DB_PASS').css('background-color',color) + $('#INSTALL_DB_NAME').css('background-color',color), + $('#INSTALL_XPWEBDB_NAME').css('background-color',color) +} + +function checkDatabaseSettings() { + jQuery.post( + 'setup.php', + { + databasecheck: 'databasecheck', + dbHost: $('#INSTALL_DB_HOST').val(), + dbPort: $('#INSTALL_DB_PORT').val(), + dbUser: $('#INSTALL_DB_USER').val(), + dbPassword: $('#INSTALL_DB_PASS').val(), + dbName: $('#INSTALL_DB_NAME').val(), + xpwebdbname: $('#INSTALL_XPWEBDB_NAME').val() + }, + function(data) { + if (data == 'TRUE') { + setDbSettingsColor('lightGreen'); + checkDatabaseSettingsOK = true; + enableCompleteButton(); + } else { + setDbSettingsColor('red'); + } + } + ); +} + +function checkPassword() { + if ($('#INSTALL_ROOT_PASS').val() == $('#INSTALL_ROOT_PASS_CHECK').val()) { + jQuery.post( + 'setup.php', + { + passwordcheck: $('#INSTALL_ROOT_PASS').val() + }, + function(data) { + if (data == 'TRUE') { + $('#INSTALL_ROOT_PASS').css('background-color','lightGreen'); + $('#INSTALL_ROOT_PASS_CHECK').css('background-color','lightGreen'); + checkPasswordOK = true; + enableCompleteButton(); + } else { + $('#INSTALL_ROOT_PASS').css('background-color','red'); + $('#INSTALL_ROOT_PASS_CHECK').css('background-color','red'); + } + + } + ); + } else { + $('#INSTALL_ROOT_PASS').css('background-color','red'); + $('#INSTALL_ROOT_PASS_CHECK').css('background-color','red'); + } +} + +$('#INSTALL_ROOT_PASS').change(checkPassword); +$('#INSTALL_ROOT_PASS_CHECK').change(checkPassword); + +$('#INSTALL_DB_HOST').change(checkDatabaseSettings); +$('#INSTALL_DB_PORT').change(checkDatabaseSettings); +$('#INSTALL_DB_NAME').change(checkDatabaseSettings); +$('#INSTALL_XPWEBDB_NAME').change(checkDatabaseSettings); +$('#INSTALL_DB_USER').change(checkDatabaseSettings); +$('#INSTALL_DB_PASS').change(checkDatabaseSettings); Propchange: trunk/web/common/js/setup.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: trunk/web/setup.php ============================================================================== --- trunk/web/setup.php (original) +++ trunk/web/setup.php Mon Oct 18 00:50:20 2010 @@ -35,16 +35,31 @@ /**Einbinden der Klasse Passwords*/ require_once (PATH_TO_ROOT."common/classes/class.passwords.inc.php"); +date_default_timezone_set("Europe/Berlin"); + // AJAX-Prüfungen für das Setup if (isset($_POST['passwordcheck'])) { $password = $_POST['passwordcheck']; echo Passwords::checkPassword($password) ? 'TRUE' : 'FALSE'; exit(); -} +} + +if (isset($_POST['databasecheck'])) { + global $db; + $settings = $_POST; + require_once (PATH_TO_ROOT."common/ez_sql.inc.php"); + $eStudyDb = $db; + $settings['dbName'] = $settings['xpwebdbname']; + require_once (PATH_TO_ROOT."common/ez_sql.inc.php"); + $xpWebDb = $db; + + echo ($eStudyDb->dbh && $xpWebDb->dbh) ? 'TRUE' : 'FALSE'; + exit(); +} /**Ausgabe des HTML-Kopfes*/ require_once (PATH_TO_ROOT."common/install.header.inc.php"); -date_default_timezone_set("Europe/Berlin"); + // Set unlimited max_execution_time to allow setup.php to run at once. // setup should be edited to execute single steps sont take more than 30seconds! ini_set('max_execution_time', -1); |