<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once( "../include/class.SQLInteger.php" );
include_once( "../include/class.SQLString.php" );
include_once("auth.php");

db_connect($db_host, $db_user, $db_pass);

$id = safe_query( "select count(datenbank) as mysql from mysql_datenbanken where kunde = ? ", TRUE, new SQLString( $PHP_AUTH_USER ) );
$werte = db_fetch_array($id);
$mysql = $werte["mysql"];

$id = safe_query( "select dbname from mysql_datenbanken where kunde = ?  and datenbank = ? ", TRUE, new SQLString( $PHP_AUTH_USER ), new SQLInteger( $db ) );
$werte = db_fetch_array($id);
$dblang = $werte["dbname"];
$dblang2 = str_replace("_", "\\_", $dblang);

$loUser = new SQLString($PHP_AUTH_USER);
$loDb = new SQLString( $dblang2 );
if ($mysql > 1)	{
	safe_query( "delete from mysql_datenbanken where datenbank = ?  and kunde = ? ", 
							TRUE, new SQLInteger($db), $loUser );
	db_close();
	
	if ( userdb_connect() ) {
		userdb_query( "DELETE FROM db WHERE Db = ".$loDb->SQL()." AND User = ".$loUser->SQL() );
		userdb_query( "DROP DATABASE $dblang");
		userdb_query( "FLUSH PRIVILEGES" );
		 
		$fehlertitel = ltext("dbmylo2_errortitle");
		$fehlertext = ltext("dbmylo2_error1", array($dblang));
		userdb_close();
		include("db_mysql.php");
		exit();
	}	

} else {
	safe_query( "delete from mysql_datenbanken where datenbank = ?  and kunde = ? ", 
							TRUE, new SQLInteger($db), $loUser );
	db_close();

	if ( userdb_connect() ) {
		userdb_query( "DELETE FROM db WHERE Db = ".$loDb->SQL()." AND User = ".$loUser->SQL() );
		userdb_query( "DROP DATABASE $dblang" );
		userdb_query( "DELETE FROM user WHERE User = ".$loUser->SQL() );
		userdb_query( "FLUSH PRIVILEGES" );

	 $fehlertitel = ltext("dbmylo2_errortitle");
	 $fehlertext = ltext("dbmylo2_error2", array($dblang));
	 userdb_close();
	 include("db_mysql.php");
	 exit();
	}
}
?>
