Location: PHPKode > projects > Laikwan WMC > wmc_20070325/imap/login.php
<?

// headers
header("Content-type: text/html; charset=utf-8");
header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

// session
@ini_set("session.use_cookies",	 0);
@ini_set("session.use_trans_sid", 1);					 
session_start();

flush();

$logout = isset($_REQUEST["logout"])?$_REQUEST["logout"]:"";

if ($logout) {
	if(isset($_SESSION['imap']['mbox'])){
		imap_close($_SESSION['imap']['mbox']);
	}
	unset($_SESSION['imap']);
} else {
	$server = isset($_REQUEST["inserver"])?$_REQUEST["inserver"]:"";
	$user = isset($_REQUEST["user"])?$_REQUEST["user"]:"";
	$pass = isset($_REQUEST["pass"])?$_REQUEST["pass"]:"";
	$accindex = isset($_REQUEST["accindex"])?$_REQUEST["accindex"]:"";

	// login
	$mbox = imap_open("{".$server."}", $user, $pass);

	// successful
	if ($mbox){
		$_SESSION['imap']['server'] = $server;
		$_SESSION['imap']['user'] = $user;
		$_SESSION['imap']['pass'] = $pass;
		imap_close($mbox);

?> 
		<div style="display: none">
			<a id="a" href='a'>a</a>
		</div>

		<script>

		var p = document.getElementById('a').href.split('?');
		if(p.length>=2){
			var val = p[1].substr('PHPSESSID='.length);
			top.ACCOUNT.success('<? echo $accindex ?>', '<? echo $user ?>', val);
		}else{
			top.ACCOUNT.failed('<? echo $accindex ?>', '<? echo $user ?>', "Weird error.");
		}
		</script>
<?
	}else{
?> 
<html>
<script>
		top.ACCOUNT.failed('<? echo $accindex ?>', '<? echo $user ?>', 'Login Failure');
</script>
</html>

<?
	}
}

?>

Return current item: Laikwan WMC