I've seen this issue pop up around here a few times - where the older chat messages will be visible. Last night a created a solution that works for me, so I thought I would share it here.
First, I am using version 1.x and I using the MySQL container, so my messages are stored in a database.
Create a php script - I called mine purge.php
The script uses a function to return the elapsed time from NOW and the timestamp on the data record. You may want to modify this function to suit yourself. A connection is established to the database, and each record is read. If the elapsed time is greater than 20 minutes the the record is deleted. The script ends by Optimizing the table. You can set up the elapsed time interval at this line in the script: if ($result > 20 ) {
I have set mine for 20 minutes
You can run this script interactively, but why? Run it as a cron if possible. Here is the command that I used to run as a cron job. Set a time interval that you like.
/usr/local/bin/php -q /home/domain/public_html/path/to/purge.php
PURGE.PHP
<?php
/**Function when($ts) takes timestamp on input and returns
* human readable time difference. Example output:
* I am running my script in 20 minute intervals to clear the
* database and remove overhead.
**/
function kiedy($ts) {
$ts=time()-$ts;
if ($ts<60)
// <1 minute
return $ts; //." seconds ago";
elseif ($ts<60*60)
// <1 hour
return floor($ts/60); //." minutes ago";
elseif ($ts<60*60*2)
// <2 hour
return "60"; //"1 hour ago";
elseif ($ts<60*60*24)
// <24 hours = 1 day
return floor($ts/60*60); //." hours ago";
elseif ($ts<60*60*24*2)
// <2 days
return "1 day ago";
elseif ($ts<60*60*24*7)
// <7 days = 1 week
return floor($ts/60*60*24); //." days ago";
elseif ($ts<60*60*24*30.5)
// <30.5 days ~ 1 month
return floor($ts/60*60*24*7); //." weeks ago";
elseif ($ts<60*60*24*365)
// <365 days = 1 year
return floor($ts/60*60*24*30.5); //." months ago";
else
// more than 1 year
return floor($ts/60*60*24*365); //." years ago";
};
$link = mysql_connect("localhost", "database", "pwd");
mysql_select_db("database");
$res = mysql_query("SELECT timestamp from chattable ORDER by timestamp DESC");
while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) {
$ts = $line['timestamp'];
$result=kiedy($ts);
if ($result > 20 ) { // ADJUST THIS TO CLEAR X MINUTES
$SQL = "DELETE from chattable WHERE timestamp = '$ts'";
$resultD = mysql_query($SQL);
}
}
$SQL = 'OPTIMIZE TABLE chattable';
$resultO = mysql_query($SQL);
?>
Good Luck