<?
########## 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");

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

$id = safe_query( "select standardip from admin", TRUE );
$werte = db_fetch_array($id);
$oldstandardip = $werte["standardip"];
$standardip = trim($standardip);
$usestd = !$usestd;

## domain checken
if ((!ereg("\.", $standarddomain)) || (ereg("[^a-z0-9.-]", $standarddomain)) || (ereg("^-", $standarddomain)))
	{
	 $fehlertext = ltext("eisd2_error1");
	 db_close();
	 include("einstellungen_stddomain.php");
	 exit();
	}

## ip checken
if (!ereg("([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})", $standardip))
	{
	 $fehlertext = ltext("eisd2_error3");
	 db_close();
	 include("einstellungen_stddomain.php");
	 exit();
	}

$id = safe_query( "select * from ipadressen where ip = ? ", TRUE, new SQLString( $standardip ) );
if (db_num_rows($id) != 0)
	{
	 $fehlertext = ltext("eisd2_error4");
	 db_close();
	 include("einstellungen_stddomain.php");
	 exit();
	}	 

safe_query( "update admin set standarddomain = ? , standardip = ? , stddomain = ? ", TRUE, new SQLString( $standarddomain ), new SQLString( $standardip ), new SQLInteger( $usestd ) );
if ($all == 1)
	{
	 $id = safe_query( "select * from domains where richtigedomain = 3", TRUE );
	 while ($werte = db_fetch_array($id))
		{
		 $kunde = $werte["kunde"];
		 $anbieter = $werte["anbieter"];
		 $olddomain = $werte["domain"];
		 $newdomain = $kunde.".".$standarddomain;
	 	 domain_aendern($olddomain, "loeschen", $kunde);
		 fpalias_aendern($olddomain, "loeschen", $kunde);
		 safe_query( "update domains set domain = ? , lastchange = ?  where domain = ?  and richtigedomain = 3 and kunde = ? ", TRUE, new SQLString( $newdomain ), new SQLInteger( $time ), new SQLString( $olddomain ), new SQLString( $kunde ) );
	 	 domain_aendern($newdomain, "anlegen", $kunde);
		 fpalias_aendern($newdomain, "anlegen", $kunde);
		}
	}
safe_query( "update anbieter set standardip = ?  where standardip = ? ", TRUE, new SQLString( $standardip ), new SQLString( $oldstandardip ) );	 
safe_query( "update kunden set ip = ?  where ip = ? ", TRUE, new SQLString( $standardip ), new SQLString( $oldstandardip ) );	 
safe_query( "update allgemein set httpd = 1", TRUE );

$fehlertitel = ltext("eisd2_errortitle");
$fehlertext = ltext("eisd2_error2");
db_close();
include("einstellungen_stddomain.php");
exit();

?>
