phpBB3 Ajax Chat Archive [Fix]

Chat Archive - August 22nd, 2010

A couple years ago Nicholas Alipaz released an add-on for the popular AJAX Chat MOD for phpBB3. To be honest, the idea was good, but it wasn’t really worth much because after you had built up a significant amount of shouts the script would die from using too much memory which held me back from using it.

I finally decided to delve into fixing it up a bit. I’m going to give you a couple of the code changes that might enhance the archive for you and make it work better. I’ll also take suggestions for anything else you’d like done to it. I should state beforehand, I don’t have the permission of the author nor am I attempting to take over the project.

He or anyone else is welcome to take any of the current code I provide or any that I decide to do in the future to add to his script. The changes are very simple and should make this mod work in just about any environment. You may ask if I think there is a great point to having an archive with hundred of thousands of shouts, that I can’t answer, but my members wanted it.

With over 130,000 accumulated shouts, I downloaded the sql file for the chat table alone, and it was 20mb. That is a very relevant term, depending on who you are. I’m just going to give you the facts, and you can make your decision from there.

If three people or more request that the html be ported from prosilver to subSilver2 template, I’d be glad to do so. Included will be the ability to submit posts and delete shouts with subSilver2.

Find

$rows = $db->sql_fetchrow($result);

Add After

$last_post_id = $rows['total_posts']; // using variable from new query

Find

$sql = 'SELECT * FROM ' . CHAT_TABLE . ' ORDER BY message_id DESC';

Replace With

$sql = 'SELECT COUNT(message_id) as \'total_posts\' FROM ' . CHAT_TABLE;	// This query was changed to count the rows using COUNT function

Find

$sql = 'SELECT * FROM ' . CHAT_TABLE . ' WHERE message_id >= '.(($last_post_id - $pagenumber) - $postlimit).' AND message_id <= '.($last_post_id - $pagenumber).' ORDER BY message_id DESC';

Replace With

//Changed query to use LIMIT instead of checking against the message_id numbers
      $sql = 'SELECT * FROM ' . CHAT_TABLE .' ORDER BY message_id DESC LIMIT '. $pagenumber .', ' . $postlimit;

Find

$sql = 'SELECT * FROM ' . CHAT_TABLE . ' WHERE message_id >= '.($last_post_id - $postlimit).' ORDER BY message_id DESC';

Replace With

// Changed query to use LIMIT instead of checking against the message_id numbers
      $sql = 'SELECT * FROM ' . CHAT_TABLE . ' ORDER BY message_id DESC LIMIT 0,' . $postlimit;

That’s it. If you want to improve the titles a bit and make them slightly more SEO friendly then do the following changes. It might be best for the ranking of your site if you add the file chat_archive.php into robots.txt if you’re strict about what pages you want listed on search engines.

Find

page_header($user->lang['PAGE_TITLE']);

Replace With

page_header($user->lang['PAGE_TITLE']. $title);

Find

$pagenumber = $_REQUEST['start'];

Add After

$title = ($pagenumber > 0) ?  ' - ' . ' Shouts: ' .   ( (($pagenumber. ' of ' . $last_post_id))) : '';;

Handyman, the author of the current chatbox claims that in his next version there will be the ability to log the shouts. Obviously if that comes to fruition, and he has a pretty good track record, then this add-on will be pointless therefore this code can be thrown in the proverbial trash bin.

Posted in Tips & Code
Tags: ,

7 ResponsesComments Feed

  1. Visual

    Thank you. I will test this out when I get home.

    08/22/10, 1:42 am
  2. gogubeb

    I had memory problem with chat_archive.php and i made changes how you said above, but now i can’t see the pages, it shows me only a point.

    01/15/11, 9:14 am
  3. Who cares about pligg anyways?

    02/08/11, 8:51 am
  4. I’d like to take the job 100ree young nymphet
    066577

    09/07/11, 1:09 am
  5. I’m not working at the moment svens place bbs
    %-P

    09/07/11, 5:13 pm
  6. Will I have to work on Saturdays? Real Pedo Bbs =-]

    09/21/11, 12:11 pm
  7. Have you got a telephone directory? http://ehurytoqy.de.tl ukrainian nymphet models i would spend all day sucking and fucking those titties if i was a lesbian or if i had a dick

    05/03/12, 11:16 am

Leave a Reply

Your email address will not be published. Required fields are marked *