Location: PHPKode > projects > The Invisible Mailer (TiM) > tim/accounts.php
<?php

include "common.php";
include "template.phpinc";
include "popAccount.phpclass";


$title = "TiM Accounts";

$accounts_query = $mailstore->rawQuery("select aid, aname from accounts where atype = 'in'");
$mainbody = "<CENTER><TABLE WIDTH=75%><TR><TD VALIGN=TOP><B>Manage Accounts</B>"
		."<UL>";
		
while ($row = mysql_fetch_array($accounts_query)) {
	$mainbody .= "<LI><A HREF='accounts.php?aid=".$row['aid']."'>".$row['aname']."</A>\n";
}

$mainbody .= "<LI><A HREF='accounts.php'>Add Account</A></UL></TD>";

if (isset($aid)) {

	$aid = addslashes(stripslashes($aid));
	$account_query = $mailstore->rawQuery("select * from accounts where atype = 'in' and aid = '$aid'");

	$account = mysql_fetch_array($account_query);
	
	$accountname = $account['aname'];
	$accountid = $account['aid'];
	$account = unserialize(base64_decode($account['ahash']));
	
	$toadd = "";
	
	$toadd .= "<TABLE BORDER=1 BORDERCOLOR=black CELLSPACING=0 CELLPADDING=4 WIDTH=300>";
	$toadd .= "<TR><FORM ACTION='modaccount.php' METHOD='post'><INPUT TYPE=HIDDEN NAME='aid' VALUE='$accountid'>"
			."<TD COLSPAN=7 BGCOLOR=#BBBBFF><INPUT TYPE=TEXT NAME='name' VALUE='$accountname' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%; background-color: #BBBBFF; border: 0px solid #BBBBFF; font-weight: bold'></TD></TR>"
			."<TR><TD WIDTH=25%>Server</TD><TD><INPUT TYPE=TEXT NAME='server' VALUE='".$account->server."' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Port</TD><TD><INPUT TYPE=TEXT NAME='port' VALUE='".$account->port."' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Username</TD><TD><INPUT TYPE=TEXT NAME='uname' VALUE='".$account->username."' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Password</TD><TD><INPUT TYPE=PASSWORD NAME='pword' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Timeout</TD><TD><INPUT TYPE=TEXT NAME='timeout' VALUE='".$account->timeout."' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Mode</TD><TD><SELECT NAME='mode' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'>";

	if ($account->leave)
		$toadd.= "<OPTION VALUE='leave'>Leave on server</OPTION><OPTION VALUE='take'>Delete from server</OPTION>";
	else
		$toadd.= "<OPTION VALUE='take'>Delete from server</OPTION><OPTION VALUE='leave'>Leave on server</OPTION>";

	$toadd .= "</SELECT></TD></TR><TR><TD BGCOLOR=#DDDDDD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=SUBMIT VALUE='Update' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt;'> <INPUT TYPE=BUTTON VALUE='Delete' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt;' ONCLICK='go2ask(\"rmaccount.php?aid=$aid\")'></TD></FORM></TR></TABLE><P>";

}

else {

// now add an add dialog

	$toadd = "<TABLE BORDER=1 BORDERCOLOR=black CELLSPACING=0 CELLPADDING=4 WIDTH=300>";
	$toadd .= "<TR><FORM ACTION='addaccount.php' METHOD='post'><INPUT TYPE=HIDDEN NAME='aid' VALUE='$accountid'>"
			."<TD WIDTH=25%>Name</TD><TD BGCOLOR=#BBFFBB><INPUT TYPE=TEXT NAME='name' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%; background-color: #BBFFBB; border: 0px solid #BBBBFF; font-weight: bold'></TD></TR>"
			."<TR><TD WIDTH=25%>Server</TD><TD><INPUT TYPE=TEXT NAME='server' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Port</TD><TD><INPUT TYPE=TEXT NAME='port' VALUE='110' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Username</TD><TD><INPUT TYPE=TEXT NAME='uname' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Password</TD><TD><INPUT TYPE=PASSWORD NAME='pword' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Timeout</TD><TD><INPUT TYPE=TEXT NAME='timeout' VALUE='30' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'></TD></TR>"
			."<TR><TD WIDTH=25%>Mode</TD><TD><SELECT NAME='mode' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt; width: 100%'>"
			."<OPTION VALUE='take'>Delete from server</OPTION><OPTION VALUE='leave'>Leave on server</OPTION>"
			."</SELECT></TD></TR><TR><TD BGCOLOR=#DDDDDD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=SUBMIT VALUE='Add' STYLE='font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; font-size: 10pt;'></TD></FORM></TR></TABLE><P>";

	
// end add dialog

}

$mainbody .= "<TD VALIGN=TOP WIDTH=300>".$toadd."</TD></TR></TABLE></CENTER>";

tim_flush();

?>
Return current item: The Invisible Mailer (TiM)