| Author |
Message |
wildboy

Joined: Jan 23, 2008
Posts: 3
|
Posted:
Thu Jan 24, 2008 1:16 pm |
|
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

Joined: Jan 20, 2008
Posts: 5
|
Posted:
Thu Jan 24, 2008 2:42 pm |
|
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.
| php: |
// 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: 756
|
Posted:
Sat Jan 26, 2008 12:21 pm |
|
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:
| php: |
private function getMessages($id = 0, $deny = false)
{
$id = intval($id);
|
AFTER, add:
| php: |
// 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

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

Joined: Sep 01, 2008
Posts: 2
|
Posted:
Tue Sep 02, 2008 11: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: 756
|
Posted:
Wed Sep 03, 2008 7:37 pm |
|
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

Joined: Sep 01, 2008
Posts: 2
|
Posted:
Thu Sep 04, 2008 3:20 pm |
|
| 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

Joined: Sep 13, 2008
Posts: 3
|
Posted:
Sat Sep 13, 2008 3:07 pm |
|
got a problem w/ the live chat. got a mes Error accessing the server! . reloaded twice. any ideas? |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 249
|
Posted:
Sat Sep 13, 2008 4:10 pm |
|
|
|
 |
darkthrone

Joined: Sep 28, 2008
Posts: 2
|
Posted:
Sun Sep 28, 2008 7:40 pm |
|
I Instal Live Chat In My Phpnuk8.0 All Is Fine Only The Chat Box Dont Apears !!! Anyhelp ?? |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 249
|
Posted:
Mon Sep 29, 2008 8:04 am |
|
| 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

Joined: Sep 28, 2008
Posts: 2
|
Posted:
Mon Sep 29, 2008 1:11 pm |
|
No Bro, Just I Instal PhpNuke 8.0.2 After THat I Instal Live Chat. |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 249
|
Posted:
Mon Sep 29, 2008 3:26 pm |
|
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

Joined: Oct 04, 2008
Posts: 5
|
Posted:
Mon Oct 06, 2008 12:51 am |
|
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

Joined: Oct 04, 2008
Posts: 5
|
Posted:
Mon Oct 06, 2008 12:55 am |
|
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 |
| |
|
|
 |
|
|