Index: trunk/admin/install.php
===================================================================
diff -u -r77 -r78
--- trunk/admin/install.php (.../install.php) (revision 77)
+++ trunk/admin/install.php (.../install.php) (revision 78)
@@ -69,6 +69,15 @@
$pathtoroot = ".".$pathchar;
}
}
+
+if( file_exists($pathtoroot.'debug.php') ) include_once($pathtoroot.'debug.php');
+if( defined('DEBUG_MODE') )
+{
+ error_reporting(E_ALL & E_NOTICE);
+}
+else
+ error_reporting(0);
+
$path_char = GetPathChar();
//phpinfo(INFO_VARIABLES);
@@ -141,7 +150,8 @@
//echo "RU: $rootURL
";
// simulate rootURL variable: end
-if(strlen($g_DBType)>0 && strlen($state)>0 && $state !="dbinfo" && $state !="db_config_save")
+$db_savings = Array('dbinfo', 'db_config_save', 'db_reconfig_save', 'reinstall_process');
+if(strlen($g_DBType)>0 && strlen($state)>0 && !in_array($state, $db_savings) )
{
require_once($pathtoroot."kernel/startup.php");
$localURL=$rootURL."kernel/";
@@ -570,34 +580,7 @@
}
}
unset($ado);
- $ado = inst_GetADODBConnection();
- if($ado->ErrorNo()!=0)
- {
- $db_error = "Connection Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
- $state = "db_reconfig";
-
- }
- else
- {
- if(!TableExists($ado,"ConfigurationAdmin,Category,Permissions"))
- {
- $state="db_reconfig";
- $db_error = "An In-Portal Database was not found at this location";
- }
- else {
- set_ini_value("Database", "DBType",$_POST["ServerType"]);
- set_ini_value("Database", "DBHost",$_POST["ServerHost"]);
- set_ini_value("Database", "DBName",$_POST["ServerDB"]);
- set_ini_value("Database", "DBUser",$_POST["ServerUser"]);
- set_ini_value("Database", "DBUserPassword",$_POST["ServerPass"]);
- set_ini_value("Database","TablePrefix",$_POST["TablePrefix"]);
-
- save_values();
-
- $state = "finish";
- $include_file = "install/install_finish.php";
- }
- }
+ $ado = VerifyDB('db_reconfig', 'finish', 'SaveDBConfig', true);
}
@@ -708,52 +691,7 @@
}
}
unset($ado);
- $ado = inst_GetADODBConnection();
- if($ado->ErrorNo()!=0)
- {
- $db_error = "Connection Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
- $state = "dbinfo";
-
- }
- elseif( $ado->ErrorNo() == 0 )
- {
- // check if all sql statements work
- $sql_tests[] = 'DROP TABLE IF EXISTS test_table';
- $sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
- $sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
- $sql_tests[] = 'UPDATE test_table SET test_col = 12';
- $sql_tests[] = 'ALTER TABLE test_table ADD COLUMN new_col varchar(10)';
- $sql_tests[] = 'SELECT * FROM test_table';
- $sql_tests[] = 'DELETE FROM test_table';
- $sql_tests[] = 'DROP TABLE test_table';
- $test_result = 1;
- foreach($sql_tests as $sql_test)
- {
- $ado->Execute($sql_test);
- if( $ado->ErrorNo()!=0 )
- {
- $test_result = 0;
- break;
- }
- }
-
-
- if($test_result == 1)
- {
- if(TableExists($ado,"ConfigurationAdmin,Category,Permissions"))
- {
- $state="dbinfo";
- $db_error = "An In-Portal Database already exists at this location";
- }
- else
- $state = "license";
- }
- else // mysql user has insufficient permissions
- {
- $db_error = "Permission Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
- $state = "dbinfo";
- }
- }
+ $ado = VerifyDB('dbinfo', 'license');
}
if($state=="dbinfo")
Index: trunk/admin/install/install_lib.php
===================================================================
diff -u -r41 -r78
--- trunk/admin/install/install_lib.php (.../install_lib.php) (revision 41)
+++ trunk/admin/install/install_lib.php (.../install_lib.php) (revision 78)
@@ -501,4 +501,90 @@
echo $ret;
}
+function &VerifyDB($error_state, $next_state, $success_func = null, $db_must_exist = false)
+{
+ // perform various check type to database specified
+ // 1. user is allowed to connect to database
+ // 2. user has all types of permissions in database
+ global $state, $db_error;
+
+ // enshure we use data from post & not from config
+ $GLOBALS['g_DBType'] = $_POST["ServerType"];
+ $GLOBALS['g_DBHost'] = $_POST["ServerHost"];
+ $GLOBALS['g_DBName'] = $_POST["ServerDB"];
+ $GLOBALS['g_DBUser'] = $_POST["ServerUser"];
+ $GLOBALS['g_DBUserPassword'] = $_POST["ServerPass"];
+
+ // connect to database
+ $ado = inst_GetADODBConnection();
+ if($ado->ErrorNo() != 0)
+ {
+ // was error while connecting
+ $db_error = "Connection Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
+ $state = $error_state;
+
+ }
+ elseif( $ado->ErrorNo() == 0 )
+ {
+ // if connected, then check if all sql statements work
+ $test_result = 1;
+
+ $sql_tests[] = 'DROP TABLE IF EXISTS test_table';
+ $sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
+ $sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
+ $sql_tests[] = 'UPDATE test_table SET test_col = 12';
+ $sql_tests[] = 'ALTER TABLE test_table ADD COLUMN new_col varchar(10)';
+ $sql_tests[] = 'SELECT * FROM test_table';
+ $sql_tests[] = 'DELETE FROM test_table';
+ $sql_tests[] = 'DROP TABLE test_table';
+
+ foreach($sql_tests as $sql_test)
+ {
+ $ado->Execute($sql_test);
+ if( $ado->ErrorNo()!=0 )
+ {
+ $test_result = 0;
+ break;
+ }
+ }
+
+ if($test_result == 1)
+ {
+ // if statements work & connection made, then check table existance
+ $db_exists = TableExists($ado,"ConfigurationAdmin,Category,Permissions");
+ if($db_exists != $db_must_exist)
+ {
+ $state = $error_state;
+ $db_error = $db_must_exist ? 'An In-Portal Database already exists at this location' : 'An In-Portal Database was not found at this location';
+ }
+ else
+ {
+ $state = $next_state;
+ if( isset($success_func) ) $success_func();
+ }
+ }
+ else
+ {
+ // user has insufficient permissions in database specified
+ $db_error = "Permission Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
+ $state = $error_state;
+ }
+ }
+ return $ado;
+}
+
+function SaveDBConfig()
+{
+ // save new database configuration
+ echo "in_ere";
+ set_ini_value("Database", "DBType",$_POST["ServerType"]);
+ set_ini_value("Database", "DBHost",$_POST["ServerHost"]);
+ set_ini_value("Database", "DBName",$_POST["ServerDB"]);
+ set_ini_value("Database", "DBUser",$_POST["ServerUser"]);
+ set_ini_value("Database", "DBUserPassword",$_POST["ServerPass"]);
+ set_ini_value("Database","TablePrefix",$_POST["TablePrefix"]);
+ save_values();
+ $GLOBALS['include_file'] = 'install/install_finish.php';
+}
+
?>
Index: trunk/globals.php
===================================================================
diff -u -r25 -r78
--- trunk/globals.php (.../globals.php) (revision 25)
+++ trunk/globals.php (.../globals.php) (revision 78)
@@ -36,7 +36,7 @@
{
global $g_adodbConnection, $g_DBType, $g_DBHost,$g_DBUser,$g_DBUserPassword,$g_DBName,$g_DebugMode;
global $ADODB_FETCH_MODE,$ADODB_COUNTRECS,$ADODB_CACHE_DIR,$pathtoroot;
-
+ //echo '
'.print_r( debug_backtrace() , true).''; if(!isset($g_adodbConnection) && strlen($g_DBType)>0) { $g_adodbConnection = ADONewConnection($g_DBType); Index: trunk/admin/install/reinstall.php =================================================================== diff -u -r41 -r78 --- trunk/admin/install/reinstall.php (.../reinstall.php) (revision 41) +++ trunk/admin/install/reinstall.php (.../reinstall.php) (revision 78) @@ -30,28 +30,28 @@
![]() |
+ ![]() |