| Database-File : | ';
$line .= ' | Persistent Connection :';
$line .= '');
send('');
send('');
send('');
send('');
} elseif (isset($_REQUEST["14"])) { // 14 - Database - test
$type = $_REQUEST["db_type"];
sendHead(" - Database");
send(""._TITLE."");
send("Database - Test - ".$type."");
$paramsOk = true;
if (isset($_REQUEST["db_host"]))
$host = $_REQUEST["db_host"];
else
$paramsOk = false;
if (isset($_REQUEST["db_pcon"]))
$pcon = "true";
else
$pcon = "false";
switch ($type) {
case "mysql":
if (isset($_REQUEST["db_name"]))
$name = $_REQUEST["db_name"];
else
$paramsOk = false;
if (isset($_REQUEST["db_user"]))
$user = $_REQUEST["db_user"];
else
$paramsOk = false;
if (isset($_REQUEST["db_pass"]))
$pass = $_REQUEST["db_pass"];
else
$paramsOk = false;
break;
case "sqlite":
$name = "";
$user = "";
$pass = "";
}
$databaseTestOk = false;
$databaseError = "";
// test
if ($paramsOk) {
$dbCon = getAdoConnection($type, $host, $user, $pass, $name);
if (!$dbCon) {
$databaseTestOk = false;
$databaseError = "cannot connect to database.";
} else {
send('');
$databaseTestCount = 0;
foreach ($queries['test'][$type] as $databaseTypeName => $databaseQuery) {
send('- '.$databaseQuery.' : ');
$dbCon->Execute($databaseQuery);
if ($dbCon->ErrorNo() == 0) {
send('Ok
');
$databaseTestCount++;
} else { // damn there was an error
send('Error');
// close ado-connection
$dbCon->Close();
break;
}
}
if ($databaseTestCount == count($queries['test'][$type])) {
$databaseTestOk = true;
} else {
$databaseTestOk = false;
}
send(' ');
}
} else {
$databaseTestOk = false;
$databaseError = "config error.";
}
// output
if ($databaseTestOk) {
// load path
$tf_settings = loadSettings("tf_settings");
if ($tf_settings !== false) {
$oldpath = $tf_settings["path"];
if (((strlen($oldpath) > 0)) && (substr($oldpath, -1 ) != "/"))
$oldpath .= "/";
} else {
$oldpath = _DEFAULT_PATH;
}
// close ado-connection
$dbCon->Close();
send('Ok ');
send("Next : Write Config File");
send("Please ensure this script can write to the dir "._DIR."inc/config/");
send(' ');
} elseif (isset($_REQUEST["15"])) { // 15 - Database - config-file
sendHead(" - Database");
send(""._TITLE."");
send("Database - Config-File");
$oldpath = $_REQUEST["oldpath"];
$type = $_REQUEST["db_type"];
$host = $_REQUEST["db_host"];
$name = $_REQUEST["db_name"];
$user = $_REQUEST["db_user"];
$pass = $_REQUEST["db_pass"];
$pcon = $_REQUEST["db_pcon"];
// write file
$databaseConfWriteOk = false;
$databaseConfWriteError = "";
$databaseConfContent = "";
writeDatabaseConfig($type, $host, $user, $pass, $name, $pcon);
// output
if ($databaseConfWriteOk) {
send('Ok ');
send('database-config-file '._DIR._FILE_DBCONF.' written.');
} else {
send('Error ');
send($databaseConfWriteError."");
send('to perform this step manual paste the following content to the database-config-file '._DIR._FILE_DBCONF.' : ');
send('');
send(" Note : You must write this file before you can continue !");
}
send(" Next : Create/Alter Tables");
send('');
} elseif (isset($_REQUEST["16"])) { // 16 - Database - table-creation
sendHead(" - Database");
send(""._TITLE."");
send("Database - Create/Alter Tables");
$oldpath = $_REQUEST["oldpath"];
if (is_file(_FILE_DBCONF)) {
require_once(_FILE_DBCONF);
$databaseTableCreationCount = 0;
$databaseTableCreation = false;
$databaseError = "";
$dbCon = getAdoConnection($cfg["db_type"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]);
if (!$dbCon) {
$databaseTableCreation = false;
$databaseError = "cannot connect to database.";
} else {
send('');
foreach ($queries['create'][$cfg["db_type"]] as $databaseTypeName => $databaseQuery) {
send('- '.$databaseQuery.' : ');
$dbCon->Execute($databaseQuery);
if ($dbCon->ErrorNo() == 0) {
send('Ok
');
$databaseTableCreationCount++;
} else { // damn there was an error
send('Error');
$databaseError = "error creating tables.";
// close ado-connection
$dbCon->Close();
break;
}
}
if ($databaseTableCreationCount == count($queries['create'][$cfg["db_type"]])) {
// close ado-connection
$dbCon->Close();
$databaseTableCreation = true;
} else {
$databaseTableCreation = false;
}
send(' ');
}
if ($databaseTableCreation) {
send('Ok ');
send($databaseTableCreationCount.' queries executed.');
send("Next : Data");
send('');
} else {
send('Error ');
send($databaseError."");
}
} else {
send('Error ');
send('database-config-file '._DIR._FILE_DBCONF.' missing. setup cannot continue.');
}
} elseif (isset($_REQUEST["17"])) { // 17 - Database - data
sendHead(" - Database");
send(" "._TITLE."");
send("Database - Data");
$oldpath = $_REQUEST["oldpath"];
if (is_file(_FILE_DBCONF)) {
require_once(_FILE_DBCONF);
$databaseDataCount = 0;
$databaseData = false;
$databaseError = "";
$dbCon = getAdoConnection($cfg["db_type"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]);
if (!$dbCon) {
$databaseData = false;
$databaseError = "cannot connect to database.";
} else {
send('');
// add path
array_unshift($queries['data'][$cfg["db_type"]], "INSERT INTO tf_settings VALUES ('path','".$oldpath."')");
// add delete-state
array_unshift($queries['data'][$cfg["db_type"]], "DELETE FROM tf_settings");
// exec
foreach ($queries['data'][$cfg["db_type"]] as $databaseTypeName => $databaseQuery) {
send('- '.$databaseQuery.' : ');
$dbCon->Execute($databaseQuery);
if ($dbCon->ErrorNo() == 0) {
send('Ok
');
$databaseDataCount++;
} else { // damn there was an error
send('Error');
$databaseError = "error importing data.";
// close ado-connection
$dbCon->Close();
break;
}
}
if ($databaseDataCount == count($queries['data'][$cfg["db_type"]])) {
// close ado-connection
$dbCon->Close();
$databaseData = true;
} else {
$databaseData = false;
}
send(' ');
}
if ($databaseData) {
send('Ok ');
send($databaseDataCount.' queries executed.');
send("Next : Configuration");
sendButton(2);
} else {
send('Error ');
send($databaseError."");
}
} else {
send('Error ');
send('database-config-file '._DIR._FILE_DBCONF.' missing. setup cannot continue.');
}
} elseif (isset($_REQUEST["2"])) { // 2 - Configuration
sendHead(" - Configuration");
send(" "._TITLE."");
send("Configuration");
send("Next : Server Settings");
sendButton(21);
send('');
} elseif (isset($_REQUEST["21"])) { // 21 - Configuration - Server Settings input
sendHead(" - Configuration");
send(""._TITLE."");
send("Configuration - Server Settings");
if (is_file(_FILE_DBCONF)) {
require_once(_FILE_DBCONF);
$dbCon = getAdoConnection($cfg["db_type"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]);
if (!$dbCon) {
send('Error ');
send("cannot connect to database.");
} else {
$tf_settings = loadSettings("tf_settings");
// close ado-connection
$dbCon->Close();
if ($tf_settings !== false) {
send(' |