Google

NukeCoder


View next topic
View previous topic
Post new topic   Reply to topic
Author Message
wildboy
Newbie
Newbie



Joined: Jan 23, 2008
Posts: 3

PostPosted: Fri Jan 25, 2008 4:16 am Reply with quote

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.
View user's profile Send private message
nimis
Newbie
Newbie



Joined: Jan 20, 2008
Posts: 5

PostPosted: Fri Jan 25, 2008 5:42 am Reply with quote

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 />'
;
      }
    } 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 722

PostPosted: Sun Jan 27, 2008 3:21 am Reply with quote

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(0100) == 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.
View user's profile Send private message Visit poster's website
agentorange
Newbie
Newbie



Joined: Feb 28, 2008
Posts: 3

PostPosted: Thu May 22, 2008 2:22 am Reply with quote

Had no issue's with this code set to 450 = 7 mins clear out. Thanks for the code Wink
View user's profile Send private message
huntergreen
Newbie
Newbie



Joined: Sep 01, 2008
Posts: 2

PostPosted: Wed Sep 03, 2008 2:56 am Reply with quote

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
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 722

PostPosted: Thu Sep 04, 2008 10:37 am Reply with quote

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.
View user's profile Send private message Visit poster's website
huntergreen
Newbie
Newbie



Joined: Sep 01, 2008
Posts: 2

PostPosted: Fri Sep 05, 2008 6:20 am Reply with quote

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...
View user's profile Send private message
inc_izrael
Newbie
Newbie



Joined: Sep 13, 2008
Posts: 3

PostPosted: Sun Sep 14, 2008 6:07 am Reply with quote

got a problem w/ the live chat. got a mes Error accessing the server! . reloaded twice. any ideas?
View user's profile Send private message
Guardian
Mr. Awesome



Joined: Dec 09, 2006
Posts: 234

PostPosted: Sun Sep 14, 2008 7:10 am Reply with quote

Is your server using PHP 5?

_________________
Code Authors Nuke Reviews
View user's profile Send private message
darkthrone
Newbie
Newbie



Joined: Sep 28, 2008
Posts: 2

PostPosted: Mon Sep 29, 2008 10:40 am Reply with quote

I Instal Live Chat In My Phpnuk8.0 All Is Fine Only The Chat Box Dont Apears !!! Anyhelp ??
View user's profile Send private message
Guardian
Mr. Awesome



Joined: Dec 09, 2006
Posts: 234

PostPosted: Mon Sep 29, 2008 11:04 pm Reply with quote

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
View user's profile Send private message
darkthrone
Newbie
Newbie



Joined: Sep 28, 2008
Posts: 2

PostPosted: Tue Sep 30, 2008 4:11 am Reply with quote

No Bro, Just I Instal PhpNuke 8.0.2 After THat I Instal Live Chat.
View user's profile Send private message
Guardian
Mr. Awesome



Joined: Dec 09, 2006
Posts: 234

PostPosted: Tue Sep 30, 2008 6:26 am Reply with quote

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
View user's profile Send private message
adi
Newbie
Newbie



Joined: Oct 04, 2008
Posts: 5

PostPosted: Mon Oct 06, 2008 3:51 pm Reply with quote

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 ?
View user's profile Send private message
adi
Newbie
Newbie



Joined: Oct 04, 2008
Posts: 5

PostPosted: Mon Oct 06, 2008 3:55 pm Reply with quote

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
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT + 10 Hours
Forums ©