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

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

$check_alias = safe_query( "SELECT * FROM $cnf_db_email WHERE pop3 = ? AND CONCAT(prefix, '@', domain) = ?", TRUE, new SQLString( $PHP_AUTH_USER ),
		new SQLString( $alias ) );
if(!db_num_rows($check_alias)) {
	exit;
}
	
// SIGNATUR:
$query_sign = safe_query( "SELECT * FROM $cnf_db_sign WHERE pop3 = ? AND alias = ?", TRUE, new SQLString( $PHP_AUTH_USER ),
		new SQLString( $alias ) );
$sign = mysql_fetch_array($query_sign);
?>
<HTML>
<HEAD>
<title><? echo $lang_text['wbm_sign_edit'] ?></title>
<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="2" leftMargin="2" topMargin="2" MARGINHEIGHT="2" MARGINWIDTH="0">
<script language="JavaScript" src="email_webmail.js" type="text/javascript"></script>
<?
if(!$setsign) {
?>
<FORM name="sign_form" method="post" action="email_signatur.php">
<input TYPE="hidden" NAME="edit_sign_id" VALUE="<? echo $sign['ident'] ?>">
<input TYPE="hidden" NAME="alias" VALUE="<? echo $alias ?>">
<input TYPE="hidden" NAME="setsign" VALUE="1">
<table class="tblbgcolor" align="center" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr><td colspan="2" class="titel-3" background="<?=$strSkinName?>/pics/bg_tbl_header.jpg"><? echo $lang_text['wbm_sign_alias'] ?>:</td></tr>
<td colspan="2">
<TEXTAREA rows="10" cols="35" wrap="virtual" name="sign_text">
<? echo $sign['signatur'] ?>
</TEXTAREA>
</td></tr>
<tr>
<td><? echo std_button(ltext("wbm_form_reset"), 'javascript:document.forms[0].reset()'); ?></td>
<td><? echo std_button(ltext("wbm_form_submit"), 'javascript:document.forms[0].submit()'); ?></td>
</tr>
</table>
<table align="center"><tr><td>(<a class="data" href="javascript:window.self.close()"><? echo $lang_text["wbm_winclose"] ?></a>)</td><tr></table>
</FORM>
<?
} else {
  if ($sign['ident']) $edit_sign_id = $sign['ident'];
  if($edit_sign_id == "") {
  	safe_query( "INSERT INTO $cnf_db_sign ( alias, pop3, signatur ) VALUES ( ?, ?, ? )", TRUE, new SQLString($alias),
		  	new SQLString($PHP_AUTH_USER), new SQLString($sign_text) );	 
  } else {
	  safe_query( "UPDATE $cnf_db_sign SET signatur = ? WHERE ident = ? AND pop3 = ?", TRUE, new SQLString($sign_text),
			  new SQLInteger($edit_sign_id), new SQLString($PHP_AUTH_USER) );
  }
?>
<table class="tblbgcolor" align="center" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr><td colspan="2" class="titel-3" background="<?=$strSkinName?>/pics/bg_tbl_header.jpg"><? echo $lang_text["wbm_sign_change"] ?>:</td></tr>
<td colspan="2">
<hr noshade size="1">
<? echo nl2br($sign_text) ?>
<hr noshade size="1">
</td></tr>
</table>
<table align="center"><tr><td>(<a class="data" href="javascript:window.self.close()"><? echo $lang_text["wbm_winclose"] ?></a>)</td><tr></table>
<?
}
?>

</body>
</html>
