hisham
IS-IT--Management
- Nov 6, 2000
- 194
I tried a PHP chat script that has an auto cleaning of old chat text by using:
function ShowAddPosts() {
global $HTTP_SESSION_VARS;
global $chat;
global $nick;
global $timeoutseconds;
global $timestamp;
global $timeout;
global $skin;
$activedir = "./style/";
@chdir($activedir);
$timeoutseconds = 250; // Timeout value in seconds
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
And the following query:
$chat = strip_tags($chat,'<i><b><a>');
if(!empty($chat)) {
$strQuery = "insert into chatScript values(0, '$chat','$nick','$timestamp')";
mysql_query($strQuery);
}
$strQuery = ("DELETE FROM chatScript WHERE timestamp<$timeout" or die("$useronline $base DELETE Error"
mysql_query($strQuery);
This work while the browser is opened, but if the user shutdown the browser, the old chat text will not delete from the Mysql Table.
How can I delete the old chat text when user shut down the browser?
The complete code:
function ShowAddPosts() {
global $HTTP_SESSION_VARS;
global $chat;
global $nick;
global $timeoutseconds;
global $timestamp;
global $timeout;
global $skin;
$activedir = "./style/";
@chdir($activedir);
$timeoutseconds = 250; // Timeout value in seconds
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
And the following query:
$chat = strip_tags($chat,'<i><b><a>');
if(!empty($chat)) {
$strQuery = "insert into chatScript values(0, '$chat','$nick','$timestamp')";
mysql_query($strQuery);
}
$strQuery = ("DELETE FROM chatScript WHERE timestamp<$timeout" or die("$useronline $base DELETE Error"
mysql_query($strQuery);
This work while the browser is opened, but if the user shutdown the browser, the old chat text will not delete from the Mysql Table.
How can I delete the old chat text when user shut down the browser?
The complete code: