<?
########## 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 prefix, domain, pop3, pop3x from email where kunde = ?  and ident = ? ", TRUE, new SQLString( $PHP_AUTH_USER ), new SQLInteger( $ident ) );
$werte = db_fetch_array($id);
$emailadresse = $werte["prefix"]."@".$werte["domain"];

if ($ausdb != "nein")
	{
	 $pop3x = $werte["pop3x"];
	 $pop3 = $werte["pop3"];
	 if (ereg("@", $pop3)) { $htyp = "1"; } else { $htyp = "0"; }

	 $nebenempfaenger = explode(":", $pop3x);
	 for ($i = 0; $i < $max_emailrcpts; $i++)
		{
		 $varname = "typ".($i + 1);
		 if (ereg("@", $nebenempfaenger[$i])) { $$varname = "1"; } else { $$varname = "0"; }
		 if (istleer($nebenempfaenger[$i])) { $$varname = "1"; }
		}
	} else
	{
 	 for ($i = 0; $i < $max_emailrcpts; $i++)
		{
		 $evarname = "email".($i + 1);
		 $avarname = "acc".($i + 1);
		 $tvarname = "typ".($i + 1);
		 if ($$tvarname == 0) { $nebenempfaenger[$i] = $$avarname; } else { $nebenempfaenger[$i] = $$evarname; }
		}
	}


$id = safe_query( "select account, kommentar from pop3 where kunde = ?  order by number", TRUE, new SQLString( $PHP_AUTH_USER ) );
$allpops[] = "";
$allcomments[] = "";
while ($werte = db_fetch_array($id)) {
	$xpop3 = $werte["account"];
	$comment = $werte["kommentar"];
	$allpops[] = $xpop3;
	$allcomments[] = sub_comment($comment,18);
}

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

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

?>
<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>
<?
echo js_f_call_help('', 'emembe_title');
?>
function doChange()
{
document.forms[0].submit();
}
</script>
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
    <td> 
      <? echo ltext("emembe_title").": $emailadresse"; ?>
      <form action="email_email_bearbeiten2.php" method="post">
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
          <tr >
            <td colspan=2 class="titel-3" ><? echo ltext("emembe_cell_recpt1"); ?></td>
          </tr>
          <tr > 
            <td > 
              <input type="radio" name="htyp" value="1"<? if ($htyp == 1) { echo " checked"; } ?>>
              <? echo ltext("emembe_cell_redirect"); ?> 
            </td>
            <td > 
              <input type="text" name="hemail" value="<? if ($htyp == 1) { echo $pop3; } ?>">
            </td>
          </tr>
          <tr > 
            <td > 
              <input type="radio" name="htyp" value="0"<? if ($htyp == 0) { echo " checked"; } ?>>
              <? echo ltext("emembe_cell_save"); ?> 
            </td>
            <td > 
              <select name="hacc">
                <?
for ($pops = 0; $pops < count($allpops); $pops++) {
	 $account = $allpops[$pops];
	 $comment = $allcomments[$pops];
	 echo '<option value="'.$account.'"'; if ($account == $pop3) { echo " selected"; } echo '>'.$account.$comment.'</option>';
	}
?>
              </select>
            </td>
          </tr>
          <?
for ($i = 1; $i <= $max_emailrcpts; $i++)
	{
	 $typ = "typ".$i;
	 $email = "email".$i;
	 $acc = "acc".$i;
	 $x = $i -1;
?>
          <tr > 
            <td colspan=2 class="titel-3" ><? echo ltext("emembe_cell_recpt2"); ?><? echo $i; ?>
              </td>
          </tr>
          <tr > 
            <td > 
              <input type="radio" name="<? echo $typ; ?>" value="1"<? if ($$typ == 1) { echo " checked"; } ?>>
              <? echo ltext("emembe_cell_redirect"); ?> 
            </td>
            <td > 
              <input type="text" name="<? echo $email; ?>" value="<? if ($$typ == 1) { echo $nebenempfaenger[$x]; } ?>">
            </td>
          </tr>
          <tr > 
            <td > 
              <input type="radio" name="<? echo $typ; ?>" value="0"<? if ($$typ == 0) { echo " checked"; } ?>>
              <? echo ltext("emembe_cell_save"); ?> 
            </td>
            <td > 
              <select name="<? echo $acc; ?>">
                <?
for ($pops = 0; $pops < count($allpops); $pops++)
	{
	 $account = $allpops[$pops];
	 $comment = $allcomments[$pops];
	 echo '<option value="'.$account.'"'; if ($account == $nebenempfaenger[$x]) { echo " selected"; } echo '>'.$account.$comment.'</option>';
	}
?>
              </select>
            </td>
          </tr>
          <?
	}
?>
          <tr > 
            <td >&nbsp;
              <input type="hidden" name="ident" value="<? echo $ident; ?>">
            </td>
            <td><? echo std_button(ltext('emembe_button1'), 'javascript:doChange()') ?></td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
   
</table>
</BODY>
</HTML>
<?
db_close();
?>
