<?php
	$quittype=$_REQUEST["quittype"];
	$db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
	mysql_select_db(get_cfg_var("SIPDB"),$db);
	$userIP = $_SERVER["REMOTE_ADDR"];			//读取该用户当前使用电脑IP地址
	$rs = mysql_query("select ipaddr from logout where ipaddr='".$userIP."'",$db);		//查找该IP是否已经登出
	if ( ($row = mysql_fetch_array($rs))==FALSE ) {			//还没有登出
		mysql_free_result($rs); 
		//向logout表中插入当前用户上网IP地址，以通知监控计费器取消该IP地址连接
		mysql_query( "insert into logout(ipaddr) values('".$userIP."')",$db );
		mysql_query( "delete from contact where ipaddr='".$userIP."'",$db );
	}
	else {
		mysql_free_result($rs); 
	}
	mysql_close($db);
?>

<html>

<head>
<title>Logout</title>
</head>

<body background="../bkg.bmp">

<p align="center"><font size="5"><b>Logout Response</b></font></p>
<hr color="#999966">
<p align="center">
<b>You logout! Thank you!</b>
</p>
<p align="center"><b>If you want to connect to internet,please <a href=login.php>login</a>.</b></p>
<hr>
<p align="center">SIPMonitor System</p>
</body>

</html>
