| Author |
Message |
wildboy
Newbie


Joined: Jan 23, 2008
Posts: 3
|
Posted:
Fri Jan 25, 2008 4:16 am |
|
Is there any way to set through the admin page to check every time it refreshes for posts older then a specified time and automatically delete them?
I am using Live Chat as a tool for those who are basically having a two way conversation on my forums to be able to do it more expediently. I do not really need to or want to see any posts over an hour old. I thought that admin setting allowed for this but it seems to be only a one time thing. Is this possible?
By the way your tool is excellent and has been a wonderful addition to my site. |
|
|
|
 |
nimis
Newbie


Joined: Jan 20, 2008
Posts: 5
|
Posted:
Fri Jan 25, 2008 5:42 am |
|
Hi wildboy.. Ive been think in the same lines as you, ['time_value'].
Ive extracted this section from the index.php forom the admin folder and would think that it's here the value should be changed in case 'time_range': case'h' case 'm' case 'd' and case'w'.
gotcha can u suggest what the values should be for cleaning after 1hour if this is the correct place.
// handle deleting messages older than X
case 'time_range':
if (!empty($_POST['time_value']) && !empty($_POST['time_type']))
{
switch($_POST['time_type'])
{
case 'h':
$target = time() - (intval($_POST['time_value']) * 3600);
$out = $_POST['time_value'].' hours';
break;
case 'm':
$target = time() - (intval($_POST['time_value']) * 60);
$out = $_POST['time_value'].' minutes';
break;
case 'd':
$target = time() - (intval($_POST['time_value']) * 86400);
$out = $_POST['time_value'].' days';
break;
case 'w':
$target = time() - (intval($_POST['time_value']) * 604800);
$out = $_POST['time_value'].' weeks';
break;
}
$sql = 'DELETE FROM `'.$prefix.'_live_chat` WHERE timestamp<\''.$target.'\'';
if (!($result = $db->sql_query($sql)))
{
echo '
<table align="center" style="border: 1px solid '.$bgcolor2.'; font-size: 14px;">
<tr>
<td align="center" valign="top" style="padding: 0px 8px 0px 8px;"><img src="modules/'.$module_name.'/images/admin/error.png" alt="" /></td>
<td align="center" valign="top" style="padding: 0px 8px 0px 8px; border-left: 1px solid '.$bgcolor2.';">
Error, could not delete messages older than '.$out.'!
</td>
</tr>
</table><br />';
}
else
{
echo '
<table align="center" style="border: 1px solid '.$bgcolor2.'; font-size: 14px;">
<tr>
<td align="center" valign="top" style="padding: 0px 8px 0px 8px;"><img src="modules/'.$module_name.'/images/admin/info.png" alt="" /></td>
<td align="center" valign="top" style="padding: 0px 8px 0px 8px; border-left: 1px solid '.$bgcolor2.';">
Messages older than '.$out.' deleted!<br /><strong>'.$db->sql_affectedrows().'</strong> messages deleted!
</td>
</tr>
</table><br />';
}
} |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 726
|
Posted:
Sun Jan 27, 2008 3:21 am |
|
Yes that is some code to delete messages, but to do it automatically there are a few things that need to be taken into consideration.
1. You want it to do the deleting right before it checks for new messages.
2. You do not want to run the delete query on every new message check. It refreshes every 1 second by default so that would be alot more strain on the mysql server.
modules/Live_Chat/lib/class.chat.php
find:
private function getMessages($id = 0, $deny = false)
{
$id = intval($id);
AFTER, add:
// keep this query from running every time.
// this makes it run only 1 out of 100 chat refreshes.
// it could probably be set higher for busy chat rooms.
if (rand(0, 100) == 100)
{
// set how old the message should be before it gets deleted
// 3600 = 1 hour in seconds | 1800 = half hour, etc
$target = time() - 3600;// $target = 1 hour ago
$sql = 'DELETE FROM `'.TABLE_CHAT.'` WHERE timestamp<\''.intval($target).'\'';
if (!($result = $this->db->sql_query($sql)))
{
//error
}
}
This is untested code, so let me know if there are any errors. |
|
|
|
 |
agentorange
Newbie


Joined: Feb 28, 2008
Posts: 3
|
Posted:
Thu May 22, 2008 2:22 am |
|
Had no issue's with this code set to 450 = 7 mins clear out. Thanks for the code  |
|
|
|
 |
huntergreen
Newbie


Joined: Sep 01, 2008
Posts: 2
|
Posted:
Wed Sep 03, 2008 2:56 am |
|
Hello,
I have tried implementing your code, but still cant seem to get it to clear out automatically.
Any ideas...
btw.. using Evo....
Thanks for any advice |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 726
|
Posted:
Thu Sep 04, 2008 10:37 am |
|
Hi, my only thought is that the code didn't copy and paste well or maybe you didn't adjust the time to less then the hour. I would say try again on a fresh copy and don't use notepad or wordpad to do the edits. Use a better editor like dreamweaver, notepad++, context, etc. |
|
|
|
 |
huntergreen
Newbie


Joined: Sep 01, 2008
Posts: 2
|
Posted:
Fri Sep 05, 2008 6:20 am |
|
| gotcha wrote: |
| Hi, my only thought is that the code didn't copy and paste well or maybe you didn't adjust the time to less then the hour. I would say try again on a fresh copy and don't use notepad or wordpad to do the edits. Use a better editor like dreamweaver, notepad++, context, etc. |
Less then the hour.... is that adjusted from your code or first posters code?
Thanx for your replies... |
|
|
|
 |
inc_izrael
Newbie


Joined: Sep 13, 2008
Posts: 3
|
Posted:
Sun Sep 14, 2008 6:07 am |
|
got a problem w/ the live chat. got a mes Error accessing the server! . reloaded twice. any ideas? |
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 238
|
Posted:
Sun Sep 14, 2008 7:10 am |
|
|
|
 |
darkthrone
Newbie


Joined: Sep 28, 2008
Posts: 2
|
Posted:
Mon Sep 29, 2008 10:40 am |
|
I Instal Live Chat In My Phpnuk8.0 All Is Fine Only The Chat Box Dont Apears !!! Anyhelp ?? |
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 238
|
Posted:
Mon Sep 29, 2008 11:04 pm |
|
| darkthrone wrote: |
| I Instal Live Chat In My Phpnuk8.0 All Is Fine Only The Chat Box Dont Apears !!! Anyhelp ?? |
Are you using PHP 5? |
_________________ Code Authors Nuke Reviews |
|
|
 |
darkthrone
Newbie


Joined: Sep 28, 2008
Posts: 2
|
Posted:
Tue Sep 30, 2008 4:11 am |
|
No Bro, Just I Instal PhpNuke 8.0.2 After THat I Instal Live Chat. |
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 238
|
Posted:
Tue Sep 30, 2008 6:26 am |
|
Well if your are not using PHP 5, Live Chat will not work as it requires PHP5, you can find more information in the readme. |
_________________ Code Authors Nuke Reviews |
|
|
 |
adi
Newbie


Joined: Oct 04, 2008
Posts: 5
|
Posted:
Mon Oct 06, 2008 3:51 pm |
|
thanks for the code..anks for the code..
i set it to 600 and it worked great !!
any suggestion how to make the live chat worked for html link in the message ? |
|
|
|
 |
adi
Newbie


Joined: Oct 04, 2008
Posts: 5
|
Posted:
Mon Oct 06, 2008 3:55 pm |
|
hi gotcha..
any suggestion for live chat to accept html link
and upload file..? make a 1 on 1 chat room with another user ?
live chat is a great module that im lookin for
would be better if could do those jobs above
regards,
adi
indonesia |
|
|
|
 |
|
|