I wasn't satisfied with it not logging you out until your cookie timed out so I made another small change and to my surprise it worked.. This is working off my install of the whos chatting hack of Dom's to work with this hack..
I went back and changed the chat_index.php and added a simple pop up java script to it:
<html>
<head>
<title>Site Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function leave() {
window.open('http://www.your-site.com/chat_logout.php','','toolbar=no,menubar=no,locatio n=no,height=1,width=1');
}
// End -->
</SCRIPT>
</head>
<frameset onUnload="leave()" rows="1,*" frameborder="NO" border="0" framespacing="0">
<frame name="topFrame" scrolling="NO" noresize src="mainchat_top.php" >
<frame name="mainFrame" src="main_chat.php">
</frameset>
<noframes><body bgcolor="#FFFFFF" text="#000000">
</body></noframes>
</html>
Then I created chat_logout.php and inserted this:
<?php
require("global.php");
if( $bbuserid ) {
$DB_site->query("UPDATE user SET inchat='0' WHERE userid='$bbuserinfo[userid]'");
$DB_site->query("UPDATE user SET lastchatactivity=$ourtimenow WHERE userid='$bbuserinfo[userid]'");
} else {
} // end if
?>
echo <script>self.close();</script>
<head>
</head>
</body>
</html>
That was it.. Now it will log you out as soon as you leave the chat..
You may decide to change the time of the pop up window and incude html if you like with some text... No more waiting on the cookie to clear..
|