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

//echo __FILE__ ."<br>";

if( !in_array($returnto, $actions) )
{
	include( $thisdir . "/business_inc/list.php" );
}

$baddb = false;

if( $save )
{
	if( strlen($name) < 1 )
	{
		$alerts[] = ltext("server_anlegen_fehler_name");
	}
		
	
	if( (strlen($ip) < 1) || ereg("[^.0-9A-Za-z]", $ip) )
	{
		$alerts[] = ltext("server_anlegen_fehler_ip");
	}
	
	if (ereg("[^0-9A-Za-z]", $user))
	{
		$alerts[] = ltext("server_anlegen_fehler_user");
	}
	
	if (strlen($user) < 1)
	{
		$alerts[] = ltext("server_anlegen_fehler_user");
	}
	        
	if (strlen($dbname) < 1)
	{
		$alerts[] = ltext("server_anlegen_fehler_dbname");
	}
	
	if (strlen($cpassword) < 1)
	{
		$alerts[] = ltext("server_anlegen_fehler_password");
	}

	if( !count($alerts) && $testconnection )
	{
		if( !$testid = @mysql_connect($ip, $user, $cpassword) )
		{
			$alerts[] = ltext("server_anlegen_fehler_noconnect");
			$baddb = true;
		}
		
		if( $testid && !@mysql_select_db($dbname, $testid) )
		{
			$alerts[] = ltext("server_anlegen_fehler_nodb");
			$baddb = true;
		}
		
		if($testid)
		{
			mysql_close($testid);
		}
	}
}

if( count($alerts) && $editdata != 2 )
{
	if($baddb && !$editdata)
	{
		print_header();
		include( $thisdir . "/business_inc/hiddenform.php" );
		print_footer();
	}
	else 
	{
		include( $thisdir . "/business_inc/" . $returnto . ".php" );
	}
}
else 
{
	$name = str_replace('\'', '\\\'', $name);
	$ip = str_replace('\'', '\\\'', $ip);
	$user = str_replace('\'', '\\\'', $user);
	$cpassword = str_replace('\'', '\\\'', $cpassword);
	$port = str_replace('\'', '\\\'', $port);
	$dbname = str_replace('\'', '\\\'', $dbname);
	
	db_connect($db_host, $db_user, $db_pass);
	if($KeyServer)
	{
		db_query("update bmysql set Servername = '$name', ip ='$ip' , cuser = '$user', cpassword = '$cpassword', port = '$port', dbname = '$dbname' where KeyServer = '$KeyServer'");
	}
	else 
	{
		db_query("insert into bmysql ( Servername, ip, cuser, cpassword, port, dbname ) values ('$name','$ip','$user','$cpassword','$port', '$dbname')");
	}
	include( $thisdir . "/business_inc/list.php" );
}

?>
