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

$ausdb = "nein";

if (istleer($emailtext))
	{
	 noMagic($emailbetreff);
	 noMagic($emailtext);
	 noMagic($absendername);
	 $fehlertext = ltext("emau3_error1");
	 include("email_autoresponder2.php");
	 exit();
	}

if (istleer($absendername))
	{
	 noMagic($emailbetreff);
	 noMagic($emailtext);
	 noMagic($absendername);
	 $fehlertext = ltext("emau3_error2");
	 include("email_autoresponder2.php");
	 exit();
	}

if (istleer($absenderemail))
	{
	 noMagic($emailbetreff);
	 noMagic($emailtext);
	 noMagic($absendername);
	 $fehlertext = ltext("emau3_error3");
	 include("email_autoresponder2.php");
	 exit();
	}

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

$id = safe_query( "select ident from email where pop3 = ?  and ident = ? ", TRUE, new SQLString( $PHP_AUTH_USER ), new SQLInteger( $ident ) );
$werte = db_fetch_array($id);
$ident = $werte["ident"];

$id = safe_query( "select kunde from pop3 where account = ? ", TRUE, new SQLString( $PHP_AUTH_USER ) );
$werte = db_fetch_array($id);
$kunde = $werte["kunde"];

$absendername = addslashes($absendername);
$absenderemail = addslashes($absenderemail);
$emailtext = addslashes($emailtext);
$emailbetreff = addslashes($emailbetreff);
$ident = addslashes($ident);

if ($bearbeiten == 1)
	{
	 safe_query( "update autoresponder set absenderemail = ? , absendername = ? , emailtext = ? , emailbetreff = ?  where ident = ?  and kunde = ? ", TRUE, new SQLString( $absenderemail ), new SQLString( $absendername ), new SQLString( $emailtext ), new SQLString( $emailbetreff ), new SQLInteger( $ident ), new SQLString( $kunde ) );
	 safe_query( "update allgemein set aliases='1'", TRUE );
	 safe_query( "update email set neu = 1 where ident = ? ", TRUE, new SQLInteger( $ident ) );
	} else
	{
	 $id2 = safe_query( "select maxautoresponder, anbieter from kunden where kunde = ? ", TRUE, new SQLString( $kunde ) );
 	 $id = safe_query( "select count(ident) as autoresponder from autoresponder where kunde = ? ", TRUE, new SQLString( $kunde ) );
	 $werte = db_fetch_array($id2);
	 $maxautoresponder = $werte["maxautoresponder"];
	 $anbieter = $werte["anbieter"];

	 $werte = db_fetch_array($id);
	 $autoresponder = $werte["autoresponder"];
	 if (($autoresponder >= $maxautoresponder) && ($maxautoresponder != "-1"))
		{ 
		 $fehlertext = ltext("emau3_error4");
		 db_close();
		 include("email_autoresponder.php");
		 exit();
		}

	 $id = safe_query( "select ident from email where ident = ?  and pop3 = ? ", TRUE, new SQLInteger( $ident ), new SQLString( $PHP_AUTH_USER ) );
	 if (db_num_rows($id) > 0)
		{
		 safe_query( "insert into autoresponder (ident, negvon, von, link, absenderemail, absendername, emailtext, emailbetreff, rcpt, negrcpt, kunde, anbieter) VALUES (  ? ,  '0',  '.*',  '1',  ? ,  ? ,  ? ,  ? ,  '.*',  '0',  ? ,  ?  )", TRUE, new SQLInteger( $ident ), new SQLString( $absenderemail ), new SQLString( $absendername ), new SQLString( $emailtext ), new SQLString( $emailbetreff ), new SQLString( $kunde ), new SQLString( $anbieter ) );
		 safe_query( "update allgemein set aliases='1'", TRUE );
		 safe_query( "update email set neu = 1 where ident = ? ", TRUE, new SQLInteger( $ident ) );
		}
	}
$fehlertitel = ltext("emau3_errortitle");
$fehlertext = ltext("emau3_error5");
db_close();
include("email_autoresponder.php");
exit();

?>
