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

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

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

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

$id = safe_query( "select admin.email as email, kunden.maxemail as maxemail from admin, kunden where kunden.kunde = ? ", TRUE, new SQLString( $kunde ) );
$werte = db_fetch_array($id);
if (($werte["email"] == 0) || ($werte["maxemail"] == 0))
	{
	 $id = safe_query( "select count(kunde) as email from email where kunde = ? ", TRUE, new SQLString( $kunde ) );
	 $werte = db_fetch_array($id);
	 if ($werte["email"] == 0)
		{
		 $id = safe_query( "select count(kunde) as pop3 from pop3 where kunde = ? ", TRUE, new SQLString( $kunde ) );
		 $werte = db_fetch_array($id);
		 if ($werte["pop3"] == 0)
			{
			 db_close();
			 header("Location: ./allgemein_pwaendern.php");
			}
		}
	}

$id2 = safe_query( "select maxautoresponder 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"];
$werte = db_fetch_array($id);
$autoresponder = $werte["autoresponder"];

$id3 = safe_query( "select kunde from email where kunde = ? ", TRUE, new SQLString( $kunde ) );
$anzahlemailadressen = db_num_rows($id3);
?>

<HTML>
<HEAD>
<META content="text/html; charset=<? echo $lang_html_charset; ?>" http-equiv=Content-Type>
<LINK href="<?=$strSkinName?>/style.css" rel=stylesheet type=text/css>
</HEAD>

<BODY bgColor=#ffffff bottomMargin=0 leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<br><? include("../fehler.inc.php"); ?>
<script>
function doChange()
{
document.forms[0].submit();
}
</script>
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
    <td><b><? echo ltext("emau_title"); ?></b><br><br><? echo ltext("emau_desc1"); ?><br><br><? echo ltext("emau_desc2"); ?>
      <? if ($anzahlemailadressen > 0) { ?>
      <form method="post" action="email_autoresponder2.php">
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
          <tr>
            <td><b><? echo ltext("emau_cell_email"); ?></b></td>
            <td><b><? echo ltext("emau_cell_autoresp"); ?></b></td>
          </tr>
          <tr>
            <td>
              <select name="ident">
                <?
$id = safe_query( "select ident from autoresponder where kunde = ? ", TRUE, new SQLString( $kunde ) );
$autoresponderliste = "";
while ($werte = db_fetch_array($id))
	{
	 $autoresponderliste .= "[".$werte["ident"]."]";
	}
$id = safe_query( "select prefix, domain, ident from email where pop3 = ?  order by prefix, domain", TRUE, new SQLString( $PHP_AUTH_USER ) );
while ($werte = db_fetch_array($id))
	{
	 $emailadresse = $werte["prefix"]."@".$werte["domain"];
	 $ident = $werte["ident"];
	 if (ereg("\[".$ident."\]", $autoresponderliste))
		{
		 $emailadresse .= " *";
		}

?>
                <option value="<? echo $ident; ?>">
                <? echo $emailadresse; ?>
                </option>
                <?
	}
?>
              </select>
            </td>
            <td><? echo std_button(ltext("emau_btn_new"), 'javascript:doChange()'); ?></td>
          </tr>
        </table>
      </form>
      <? } else { ?>
      <? echo ltext("emau_desc4"); ?>
      <? } ?>
    </td>
  </tr>
</table>
</BODY>
</HTML>

<?
db_close();
?>
