Location: PHPKode > projects > WebDebEx > webdebex/html/user_alias.php
<?php
require_once("functions.php");
DBOpen();
LoginReq();
MyHeader();



$_POST[edit] = CheckInt($_POST[edit]);

$res = DBQuery("SELECT * FROM users WHERE user_id = $_POST[edit] AND user_domain = $_REQUEST[db_session_dom]");
$user = mysql_fetch_assoc($res);

$res = DBQuery("SELECT * FROM domains WHERE dom_id = $user[user_domain]");
$domain = mysql_fetch_assoc($res);



if($user[user_id] > 0) {









if(isset($_POST[delete])) {
	$_POST[delete]=CheckString($_POST[delete],128);

	$res = DBQuery("SELECT count(*) as alias_count FROM aliases WHERE alias_email = '$_POST[delete]' AND alias_type = 'site'");
	$row = mysql_fetch_assoc($res);
	if($row[alias_count]==1) {
		DBQuery("DELETE FROM aliases WHERE alias_email = '$_POST[delete]' AND alias_type = 'site'");
		echo "<BR><B><FONT COLOR=GREEN>Alias '$_POST[delete]' deleted!</FONT></B><BR>";
	} else echo "<BR><B><FONT COLOR=RED>Unknown Alias!</FONT></B><BR>";
}













if(isset($_POST[alias])) {
	$_POST[alias]=CheckString($_POST[alias] . "@$domain[dom_name]",128);

	$status = true;
	echo "<BR>";

	if(!strlen($_POST[alias])>0) {
		echo "<B><FONT COLOR=RED>Empty Alias!</FONT></B><BR>";
		$status = false;
	}



	$res = DBQuery("SELECT count(*) as alias_count FROM aliases WHERE alias_email = '$_POST[alias]' AND alias_type = 'site'");
	$row = mysql_fetch_assoc($res);
	if($row[alias_count]!=0) {
		echo "<B><FONT COLOR=RED>Alias already in use!</FONT></B><BR>";
		$status = false;
	}


	if($status===true) {
		DBQuery("INSERT INTO aliases (alias_type,alias_email,alias_destination,alias_sys_createdate) VALUES ('site','$_POST[alias]','$user[user_name]',NOW())");
		echo "<B><FONT COLOR=GREEN>Alias '$_POST[alias]' added!</FONT></B><BR>";
	}
}





echo "<BR>";
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3>";
	echo "<TR STYLE='background-color: #E0E0E0;'>";
	echo "<TH>&nbsp;Alias&nbsp;</TH>";
	echo "<TH>&nbsp;Destination&nbsp;</TH>";
	echo "<TH>&nbsp;Created&nbsp;</TH>";
	echo "<TH>&nbsp;</TH>";
	echo "</TR>";

	$res = DBQuery("SELECT alias_email, alias_destination, alias_sys_createdate FROM aliases WHERE alias_type = 'site' AND alias_destination = '$user[user_name]' ORDER BY alias_email");
	while($row = mysql_fetch_assoc($res)) {
		if($tmp_color!="#FFFFFF") $tmp_color = "#FFFFFF";
		else $tmp_color = "#E0E0E0";
		echo "<TR STYLE='background-color: $tmp_color;'>";
		echo "<TD STYLE='text-align:left;'>$row[alias_email]</TD>";
		echo "<TD STYLE='text-align:center;'>$row[alias_destination]</TD>";
		echo "<TD STYLE='text-align:center;'>$row[alias_sys_createdate]</TD>";
		echo "<TD STYLE='text-align:center;'><FORM METHOD=POST STYLE='display:inline;' ACTION=user_alias.php><input type='hidden' NAME=delete VALUE=$row[alias_email]><INPUT TYPE=HIDDEN NAME=edit VALUE='$_POST[edit]'><INPUT TYPE=image SRC='icons/delete.gif' STYLE='border:0px;background-color:transparent;' ALT='Delete this Alias'></FORM></TD>";
		echo "</TR>";
	}
echo "</TABLE>";








echo "<BR>";
echo "<FORM METHOD=POST STYLE='display:inline;' ACTION=user_alias.php>";
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3>";
	echo "<TR STYLE='background-color: #E0E0E0;'>";
	echo "<TH>&nbsp;Alias&nbsp;</TH>";
	echo "<TH>&nbsp;</TH>";
	echo "</TR>";

	echo "<TR STYLE='background-color: #FFFFFF;'>";
	echo "<TD><INPUT TYPE=TEXT NAME=alias><INPUT TYPE=HIDDEN NAME=edit VALUE='$_POST[edit]'></TD>";

	echo "<TD><INPUT TYPE=image NAME=create VALUE=1 SRC='icons/add.gif' STYLE='border:0px;background-color:transparent;' ALT='Create new Alias'></TD>";

	echo "</TR>";
echo "</TABLE>";
echo "</FORM>";












} else echo "<BR><B><FONT COLOR=RED>Unknown Destination!</FONT></B><BR>";




DBClose();
MyFooter();
MyEnd();
?>
Return current item: WebDebEx