[Released] Chat Archive for AJAX Chat

MODs and Styles for phpBB3.

To post your MOD or style, go to the STG MOD Manager
Forum rules
Go to http://startrekguide.com/mods to submit your MOD or style

Re: [Released] Chat Archive for AJAX Chat

Postby spaceace » 02 Oct 2011, 06:38

TheKiller wrote:You just have to upload the files. But the MOD Wont work on me.
It gives me
Code: Select all
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 21: Constant CHAT_TABLE already defined
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 22: Constant CHAT_SESSIONS_TABLE already defined
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 57: Undefined variable: tcount
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 58: Undefined index: start
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4610: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4612: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4613: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4614: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 263: Undefined index: page


And there arent any buttons on switching to a other page, in the archive.
I see Amy gave up in the end and switched to mChat :(
Handyman, get your [*donkey*] and update the Chatbox, Pleaseee !! :beg: :beg: :beg:
:lol:


that error is from the chat_archive.php trying to define the tables that are already being defined. open that file and remove the lines that define the CHAT_TABLE and CHAT_SESSIONS_TABLE. they should be lines 21 and 22 as the error indicates. those tables are now getting defined in a different place due to the latest post add-on ;)
User avatar
spaceace
Supporter
Supporter
 
Posts: 263
Joined: 14 Feb 2008, 20:44
Location: Ontario, Canada
Gender: Male
phpBB Knowledge: 5


Re: [Released] Chat Archive for AJAX Chat

Postby Dragosvr92 » 04 Oct 2011, 19:08

Hey Spaceace!
Thanks for your reply, but it doesnt help.

I removed :
Code: Select all
define('CHAT_TABLE', $table_prefix . 'chat');
define('CHAT_SESSIONS_TABLE', $table_prefix . 'chat_sessions');


It now gives:
Code: Select all
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 57: Undefined variable: tcount
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 58: Undefined index: start
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 96: Undefined index: total_posts
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4609: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4611: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4612: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4613: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3726)
[phpBB Debug] PHP Notice: in file /chat_archive.php on line 268: Undefined index: page


I just replaced my chat.php coe and the error still persists.
Error doesnt apear to happen on a fresh phpBB copy. :|


This is my chat_archive.php files, with the updates gaven a while back on here.
Error is showing withthe main file also.

Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id: chat.php 52 2007-11-04 05:56:17Z Handyman $
* @copyright (c) 2007 StarTrekGuide
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('chat');
define('CHAT_TABLE', $table_prefix . 'chat');
define('CHAT_SESSIONS_TABLE', $table_prefix . 'chat_sessions');
/******************************************/
/* EDIT these for custom online settings */
/****************************************/
$session_time = 300;
$default_delay = 50000;
//set status
$times = array(
   'online'   => 10000,
   'idle'      => 300000,
   'offline'   => 1800000,
);
//set delay for each status
$delay = array(
   'online'   => 5000,
   'idle'      => 60000,
   'offline'   => 300000,
);
/*****************************************/
/* DO NOT EDIT ANYTHING BELOW THIS LINE */
/***************************************/
$mode = request_var('mode', '');
$last_id = request_var('last_id', 0);
$last_post = request_var('last_post', 0);
$last_time = request_var('last_time', 0);
$get = $init = false;
$count = 0;
$sql = 'SELECT COUNT(message_id) as \'total_posts\' FROM ' . CHAT_TABLE;    // This query was changed to count the rows using COUNT function
  $result = $db->sql_query($sql);
  $rows = $db->sql_fetchrowset($result);
    $last_post_id = count($rows);


$postlimit = 100;
$data = $db->sql_query("SELECT * FROM ".CHAT_TABLE);
$last = ceil($tcount/$postlimit);
$pagenumber = $_REQUEST['start'];
$title = ($pagenumber > 0) ?  ' - ' . ' Shouts: ' .   ( (($pagenumber. ' of ' . $last_post_id))) : '';;


switch ($mode)
{
   default:
    if(isset($_REQUEST['start'])) {
      //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;
   }
    else {
      // 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;
    
    }
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
            $last_id = $row['message_id'];
         }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ($user->data['user_type'] == USER_FOUNDER || $user->data['user_type'] == USER_NORMAL)
      {
         $sql = 'SELECT * FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_id = {$user->data['user_id']}";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $last_post_id = $rows['total_posts']; // using variable from new query
         $db->sql_freeresult($result);
         if ($row['user_id'] != $user->data['user_id'])
         {
            $sql_ary = array(
               'user_id'         => $user->data['user_id'],
               'username'         => $user->data['username'],
               'user_colour'      => $user->data['user_colour'],
               'user_login'      => time(),
               'user_lastupdate'   => time(),
            );
            $sql = 'INSERT INTO ' . CHAT_SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
         }
         else
         {
            $sql_ary = array(
               'username'         => $user->data['username'],
               'user_colour'      => $user->data['user_colour'],
               'user_login'      => time(),
               'user_lastupdate'   => time(),
            );
            $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
            $db->sql_query($sql);
         }
      }
      whois_online();
      $template->assign_vars(array(
         'TIME'   => time(),
         'DELAY'   => $default_delay,
      ));
   break;
   case 'read':
      $sql = 'SELECT * FROM ' . CHAT_TABLE . " WHERE message_id < ".$_REQUEST['page']." ORDER BY message_id DESC";
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      if (!sizeof($rows) && ((time() - 60) < $last_time))
      {
         exit;
      }
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
            $last_id = $row['message_id'];
                $template->assign_block_vars('soundrow', array(
                'SOUND'   => '<div style="visibility: hidden; position: absolute;"><object data="sound.swf" type="application/x-shockwave-flash"><param name="movie" value="sound.swf" /></object></div>',
                ));
             }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ((time() - 60) > $last_time)
      {
         whois_online();
         $sql_ary = array(
            'username'         => $user->data['username'],
            'user_colour'      => $user->data['user_colour'],
            'user_lastupdate'   => time(),
         );
         $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . '
            SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
            WHERE user_id = {$user->data['user_id']}";
         $result = $db->sql_query($sql);
      }
      $get = true;
   break;
   case 'add':
      if (!$user->data['is_registered'] || $user->data['user_type'] == USER_INACTIVE || $user->data['user_type'] == USER_IGNORE)
      {
         redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'));
      }
      $get = true;
      $read_interval = request_var('read_interval', 0);
      $message = utf8_normalize_nfc(request_var('message', '', true));
      if (!$message)
      {
         break;
      }
      $message = str_replace('---', '- -', $message);
      $uid = $bitfield = $options = '';
      $allow_bbcode = $allow_urls = $allow_smilies = true;
      generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
      $sql_ary = array(
         'chat_id'         => 1,
         'user_id'         => $user->data['user_id'],
         'username'         => $user->data['username'],
         'user_colour'      => $user->data['user_colour'],
         'message'         => $message,
         'bbcode_bitfield'   => $bitfield,
         'bbcode_uid'      => $uid,
         'bbcode_options'   => $options,
         'time'            => time(),
      );
      $sql = 'INSERT INTO ' . CHAT_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
      $db->sql_query($sql);
      $sql_ary = array(
         'username'         => $user->data['username'],
         'user_colour'      => $user->data['user_colour'],
         'user_lastpost'      => time(),
         'user_lastupdate'   => time(),
      );
      $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
      $result = $db->sql_query($sql);
      $sql = 'SELECT * FROM ' . CHAT_TABLE . " WHERE message_id > $last_id ORDER BY message_id DESC";
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      if (!sizeof($rows) && ((time() - 60) < $last_time))
      {
         exit;
      }
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
                $template->assign_block_vars('soundrow', array(
                'SOUND'   => '<div style="visibility: hidden; position: absolute;"><object data="soundout.swf" type="application/x-shockwave-flash"><param name="movie" value="soundout.swf" /></object></div>',
                ));
             $last_id = $row['message_id'];
             }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ($read_interval != $delay['online'])
      {
         whois_online();
      }
   break;
   case 'delete':
      $get = true;
      $chat_id = request_var('chat_id', 0);
      if (!$chat_id)
      {
         break;
      }
      if (!$auth->acl_get('a_') && !$auth->acl_get('m_'))
      {
         break;
      }
      $sql = 'DELETE FROM ' . CHAT_TABLE . " WHERE message_id = $chat_id";
      $db->sql_query($sql);
   break;
}
$mode = strtoupper($mode);
$template->assign_vars(array(
   'FILENAME'      => append_sid("{$phpbb_root_path}chat.$phpEx"),
   'LAST_ID'      => $last_id,
   'S_CHAT'      => (!$get) ? true : false,
   'S_GET_CHAT'   => ($get) ? true : false,
   'S_' . $mode   => true,
));
$template->assign_block_vars('navlinks', array(
   'FORUM_NAME'   => 'Chat Archive',
   'U_VIEW_FORUM'   => append_sid("{$phpbb_root_path}chat.$phpEx"))
);
      
page_header($user->lang['PAGE_TITLE']. $title);
$template->assign_vars(array(
   'MAKE_FORUM_ACTIVE' => ' class="activetab"',
   'SUB_NAV' => 'sub_nav_forum',
  'PAGE'  => $_REQUEST['page'],
  'PAGINATION' => generate_pagination($_SERVER['PHP_SELF'], $last_post_id, $postlimit, $pagenumber, true),
));
$template->set_filenames(array(
   'body' => 'chat_arch_body.html')
);
page_footer();
function whois_online()
{
   global $db, $template, $user;
   global $delay, $last_post, $session_time;
   $check_time = time() - $session_time;
   $sql_ary = array(
      'username'         => $user->data['username'],
      'user_colour'      => $user->data['user_colour'],
      'user_lastupdate'   => time(),
   );
   $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
   $db->sql_query($sql);
   $sql = 'DELETE FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_lastupdate < $check_time";
   $db->sql_query($sql);
   $sql = 'SELECT *
      FROM ' . CHAT_SESSIONS_TABLE . "
      WHERE user_lastupdate > $check_time
      ORDER BY username ASC";
   $result = $db->sql_query($sql);
   $status_time = time();
   while ($row = $db->sql_fetchrow($result))
   {
      if ($row['user_id'] == $user->data['user_id'])
      {
         $last_post = $row['user_lastpost'];
         $login_time = $row['user_login'];
         $status_time = ($last_post > $login_time) ? $last_post : $login_time;
      }
      $status = get_status($row['user_lastpost']);
      $template->assign_block_vars('whoisrow', array(
         'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
         'USER_STATUS'   => $status,
      ));
   }
   $db->sql_freeresult($result);
   $template->assign_vars(array(
      'DELAY'         => ($status_time) ? $delay[get_status($status_time)] : $delay['idle'],
      'LAST_TIME'      => time(),
      'S_WHOISONLINE'   => true,
   ));
   return false;
}
function get_status($last)
{
   global $times;
   $status = 'online';
   if ($last < (time() - $times['offline']))
   {
      $status = 'offline';
   }
   else if ($last < (time() - $times['idle']))
   {
      $status = 'idle';
   }
   return $status;
}
?>

Previous username: TheKiller
Avatar on Memberlist 1.0.3

Image
User avatar
Dragosvr92    
MOD Author
MOD Author
 
Posts: 362
Joined: 26 Sep 2009, 10:32
Location: Romania
Gender: Male
phpBB Knowledge: 3

Re: [Released] Chat Archive for AJAX Chat

Postby spaceace » 10 Oct 2011, 05:55

i was going to download this mod to see if the chat.php and shout.php files have different code from the original mod that could cause the problem, but it seems the page and file no longer exists to download it from :(
User avatar
spaceace
Supporter
Supporter
 
Posts: 263
Joined: 14 Feb 2008, 20:44
Location: Ontario, Canada
Gender: Male
phpBB Knowledge: 5

Re: [Released] Chat Archive for AJAX Chat

Postby Dragosvr92 » 10 Oct 2011, 10:08

The MOD Dosent provide any shout or chat php files. And there is no incompability between the mod and my chat.
The MOD may be found here:
viewtopic.php?f=127&t=8955&start=40#p128364
Previous username: TheKiller
Avatar on Memberlist 1.0.3

Image
User avatar
Dragosvr92    
MOD Author
MOD Author
 
Posts: 362
Joined: 26 Sep 2009, 10:32
Location: Romania
Gender: Male
phpBB Knowledge: 3

Re: [Released] Chat Archive for AJAX Chat

Postby tsouliang » 17 Feb 2012, 11:53

hello :)

Hum, for me the mods display only the first page ... and the link ( page 2, 3, ... 20 and next ) do nothing -.-
I start from a new phpbb 3.0.10. no other mods . only chat_archive.php and chat_arch_body.html.

It must be simple to do that no ?
please help ;)

here my files :
chat_archive.php
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id: chat.php 52 2007-11-04 05:56:17Z Handyman $
* @copyright (c) 2007 StarTrekGuide
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('chat');
define('CHAT_TABLE', $table_prefix . 'chat');
define('CHAT_SESSIONS_TABLE', $table_prefix . 'chat_sessions');
/******************************************/
/* EDIT these for custom online settings */
/****************************************/
$session_time = 300;
$default_delay = 50000;
//set status
$times = array(
   'online'   => 10000,
   'idle'      => 300000,
   'offline'   => 1800000,
);
//set delay for each status
$delay = array(
   'online'   => 5000,
   'idle'      => 60000,
   'offline'   => 300000,
);
/*****************************************/
/* DO NOT EDIT ANYTHING BELOW THIS LINE */
/***************************************/
$mode = request_var('mode', '');
$last_id = request_var('last_id', 0);
$last_post = request_var('last_post', 0);
$last_time = request_var('last_time', 0);
$get = $init = false;
$count = 0;
$sql = 'SELECT * FROM ' . CHAT_TABLE . ' ORDER BY message_id DESC';
  $result = $db->sql_query($sql);
  $rows = $db->sql_fetchrowset($result);
    $last_post_id = count($rows);


$postlimit = 100;
$data = $db->sql_query("SELECT * FROM ".CHAT_TABLE);
$last = ceil($tcount/$postlimit);
$pagenumber = $_REQUEST['start'];


switch ($mode)
{
   default:
    if(isset($_REQUEST['start'])) {
      $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';
    }
    else {
      $sql = 'SELECT * FROM ' . CHAT_TABLE . ' WHERE message_id >= '.($last_post_id - $postlimit).' ORDER BY message_id DESC';
    }
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
            $last_id = $row['message_id'];
         }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ($user->data['user_type'] == USER_FOUNDER || $user->data['user_type'] == USER_NORMAL)
      {
         $sql = 'SELECT * FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_id = {$user->data['user_id']}";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
         if ($row['user_id'] != $user->data['user_id'])
         {
            $sql_ary = array(
               'user_id'         => $user->data['user_id'],
               'username'         => $user->data['username'],
               'user_colour'      => $user->data['user_colour'],
               'user_login'      => time(),
               'user_lastupdate'   => time(),
            );
            $sql = 'INSERT INTO ' . CHAT_SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
         }
         else
         {
            $sql_ary = array(
               'username'         => $user->data['username'],
               'user_colour'      => $user->data['user_colour'],
               'user_login'      => time(),
               'user_lastupdate'   => time(),
            );
            $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
            $db->sql_query($sql);
         }
      }
      whois_online();
      $template->assign_vars(array(
         'TIME'   => time(),
         'DELAY'   => $default_delay,
      ));
   break;
   case 'read':
      $sql = 'SELECT * FROM ' . CHAT_TABLE . " WHERE message_id < ".$_REQUEST['page']." ORDER BY message_id DESC";
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      if (!sizeof($rows) && ((time() - 60) < $last_time))
      {
         exit;
      }
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
            $last_id = $row['message_id'];
                $template->assign_block_vars('soundrow', array(
                'SOUND'   => '<div style="visibility: hidden; position: absolute;"><object data="sound.swf" type="application/x-shockwave-flash"><param name="movie" value="sound.swf" /></object></div>',
                ));
             }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ((time() - 60) > $last_time)
      {
         whois_online();
         $sql_ary = array(
            'username'         => $user->data['username'],
            'user_colour'      => $user->data['user_colour'],
            'user_lastupdate'   => time(),
         );
         $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . '
            SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
            WHERE user_id = {$user->data['user_id']}";
         $result = $db->sql_query($sql);
      }
      $get = true;
   break;
   case 'add':
      if (!$user->data['is_registered'] || $user->data['user_type'] == USER_INACTIVE || $user->data['user_type'] == USER_IGNORE)
      {
         redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'));
      }
      $get = true;
      $read_interval = request_var('read_interval', 0);
      $message = utf8_normalize_nfc(request_var('message', '', true));
      if (!$message)
      {
         break;
      }
      $message = str_replace('---', '- -', $message);
      $uid = $bitfield = $options = '';
      $allow_bbcode = $allow_urls = $allow_smilies = true;
      generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
      $sql_ary = array(
         'chat_id'         => 1,
         'user_id'         => $user->data['user_id'],
         'username'         => $user->data['username'],
         'user_colour'      => $user->data['user_colour'],
         'message'         => $message,
         'bbcode_bitfield'   => $bitfield,
         'bbcode_uid'      => $uid,
         'bbcode_options'   => $options,
         'time'            => time(),
      );
      $sql = 'INSERT INTO ' . CHAT_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
      $db->sql_query($sql);
      $sql_ary = array(
         'username'         => $user->data['username'],
         'user_colour'      => $user->data['user_colour'],
         'user_lastpost'      => time(),
         'user_lastupdate'   => time(),
      );
      $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
      $result = $db->sql_query($sql);
      $sql = 'SELECT * FROM ' . CHAT_TABLE . " WHERE message_id > $last_id ORDER BY message_id DESC";
      $result = $db->sql_query($sql);
      $rows = $db->sql_fetchrowset($result);
      if (!sizeof($rows) && ((time() - 60) < $last_time))
      {
         exit;
      }
      foreach ($rows as $row)
      {
         if ($count++ == 0)
         {
                $template->assign_block_vars('soundrow', array(
                'SOUND'   => '<div style="visibility: hidden; position: absolute;"><object data="soundout.swf" type="application/x-shockwave-flash"><param name="movie" value="soundout.swf" /></object></div>',
                ));
             $last_id = $row['message_id'];
             }
         $template->assign_block_vars('chatrow', array(
            'MESSAGE_ID'   => $row['message_id'],
            'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
            'MESSAGE'      => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
            'TIME'         => $user->format_date($row['time']),
            'CLASS'         => ($row['message_id'] % 2) ? 1 : 2,
         ));
      }
      $db->sql_freeresult($result);
      if ($read_interval != $delay['online'])
      {
         whois_online();
      }
   break;
   case 'delete':
      $get = true;
      $chat_id = request_var('chat_id', 0);
      if (!$chat_id)
      {
         break;
      }
      if (!$auth->acl_get('a_') && !$auth->acl_get('m_'))
      {
         break;
      }
      $sql = 'DELETE FROM ' . CHAT_TABLE . " WHERE message_id = $chat_id";
      $db->sql_query($sql);
   break;
}
$mode = strtoupper($mode);
$template->assign_vars(array(
   'FILENAME'      => append_sid("{$phpbb_root_path}chat.$phpEx"),
   'LAST_ID'      => $last_id,
   'S_CHAT'      => (!$get) ? true : false,
   'S_GET_CHAT'   => ($get) ? true : false,
   'S_' . $mode   => true,
));
$template->assign_block_vars('navlinks', array(
   'FORUM_NAME'   => 'Chat Archive',
   'U_VIEW_FORUM'   => append_sid("{$phpbb_root_path}chat.$phpEx"))
);
      
page_header($user->lang['PAGE_TITLE']);
$template->assign_vars(array(
   'MAKE_FORUM_ACTIVE' => ' class="activetab"',
   'SUB_NAV' => 'sub_nav_forum',
  'PAGE'  => $_REQUEST['page'],
  'PAGINATION' => generate_pagination($_SERVER['PHP_SELF'], $last_post_id, $postlimit, $pagenumber, true),
));
$template->set_filenames(array(
   'body' => 'chat_arch_body.html')
);
page_footer();
function whois_online()
{
   global $db, $template, $user;
   global $delay, $last_post, $session_time;
   $check_time = time() - $session_time;
   $sql_ary = array(
      'username'         => $user->data['username'],
      'user_colour'      => $user->data['user_colour'],
      'user_lastupdate'   => time(),
   );
   $sql = 'UPDATE ' . CHAT_SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$user->data['user_id']}";
   $db->sql_query($sql);
   $sql = 'DELETE FROM ' . CHAT_SESSIONS_TABLE . " WHERE user_lastupdate < $check_time";
   $db->sql_query($sql);
   $sql = 'SELECT *
      FROM ' . CHAT_SESSIONS_TABLE . "
      WHERE user_lastupdate > $check_time
      ORDER BY username ASC";
   $result = $db->sql_query($sql);
   $status_time = time();
   while ($row = $db->sql_fetchrow($result))
   {
      if ($row['user_id'] == $user->data['user_id'])
      {
         $last_post = $row['user_lastpost'];
         $login_time = $row['user_login'];
         $status_time = ($last_post > $login_time) ? $last_post : $login_time;
      }
      $status = get_status($row['user_lastpost']);
      $template->assign_block_vars('whoisrow', array(
         'USERNAME_FULL'   => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']),
         'USER_STATUS'   => $status,
      ));
   }
   $db->sql_freeresult($result);
   $template->assign_vars(array(
      'DELAY'         => ($status_time) ? $delay[get_status($status_time)] : $delay['idle'],
      'LAST_TIME'      => time(),
      'S_WHOISONLINE'   => true,
   ));
   return false;
}
function get_status($last)
{
   global $times;
   $status = 'online';
   if ($last < (time() - $times['offline']))
   {
      $status = 'offline';
   }
   else if ($last < (time() - $times['idle']))
   {
      $status = 'idle';
   }
   return $status;
}
?>


chat_arch_body.html
Code: Select all
<!-- IF S_GET_CHAT -->
  <!-- IF S_READ or S_ADD -->
    <!-- BEGIN chatrow -->
  <div id="p{chatrow.MESSAGE_ID}" class="post bg{chatrow.CLASS}">
      <!-- IF S_USER_LOGGED_IN -->
    <span class="profile-icons postprofile">
      <nobr>
      <!-- ENDIF -->
      <!-- IF U_ACP or U_MCP -->
        <span class="delete-icon">
          <a href="javascript:void({chatrow.MESSAGE_ID})" title="{L_DELETE_POST}" onclick="delete_post('{chatrow.MESSAGE_ID}')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
        </span>
      <!-- ENDIF -->
      <!-- IF S_USER_LOGGED_IN -->
      {chatrow.TIME}</nobr>
    </span>
      <!-- ENDIF -->
    <span class="author" id="profile{postrow.POST_ID}">&nbsp;{chatrow.USERNAME_FULL}:</span>
    <span class="chatrow"><span class="content">&nbsp;{chatrow.MESSAGE}</span></span>
  </div>
    <!-- END chatrow -->---{LAST_ID}---
  <!-- ENDIF -->
  <!-- ELSE -->
    <!-- IF S_CHAT -->
      <!-- INCLUDE overall_header.html -->
    <!-- ENDIF -->
  <script type="text/javascript">
    <!--
      var fieldname = 'chat';
      var last_time = 0;
      var xmlHttp = http_object();
      var last_id = {LAST_ID};
      var type = 'receive';
      var post_time = {TIME};
      var read_interval = 15000;
      var interval = setInterval('handle_send("read", last_id);', read_interval);
      function handle_send(mode, f) {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
          indicator_switch('on');
          type = 'receive';
          param = 'mode=' + mode;   
          param += '&last_id=' + last_id;
          param += '&last_time=' + last_time;         
          param += '&last_post=' + post_time;         
          param += '&read_interval=' + read_interval;      
          if (mode == 'delete') {
            type = 'delete';
            param += '&chat_id=' + f;
          }
          xmlHttp.open("POST", '{FILENAME}', true);
          xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          xmlHttp.onreadystatechange = handle_return;
          xmlHttp.send(param);
        }
      }
      function handle_return() {
        if (xmlHttp.readyState == 4) {
        }
      }
      function delete_post(chatid) {
        document.getElementById('p' + chatid).style.display = 'none';
        handle_send('delete', chatid);
      }
      function indicator_switch(mode) {
        if(document.getElementById("act_indicator")) {
          var img = document.getElementById("act_indicator");
          if(img.style.visibility == "hidden" && mode == 'on') {
            img.style.visibility = "visible";
          }
          else if (mode == 'off') {
            img.style.visibility = "hidden"
          }   
        }
      }
      function http_object() {
        if (window.XMLHttpRequest) {
          return new XMLHttpRequest();
        }
        else if(window.ActiveXObject) {
          return new ActiveXObject("Microsoft.XMLHTTP");
        }
        else {
          document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
        }
      }
    -->
  </script>
  <style type="text/css">
    <!--
      #act_indicator {visibility:hidden;}
      .shouts {width: 100%;height:400px;overflow:auto;float:left;}
      #chat {width: 100%;text-align:left;}
      #chat * {margin:0px;padding:0px;min-height:0px;}
      .post {font-size:1.2em;}
      .postprofile {min-height: 5px !important;width:auto;}
      .chatarchf {float:right;border-left:none;}
      .chatform {width: 90%;text-align:center;}
      .onlinelist {width: 15%;overflow:auto;height:230px;}
      .users {width: 90%;text-align: left;text-indent: 5px;margin-left:auto;margin-right:auto;}
      .user {width: 95%;font-size: 1.1em;font-family:Verdana, Arial, Helvetica, sans-serif;line-height: 1.4em;}
      .chatrow {font-size: 1.1em;font-family:Verdana, Arial, Helvetica, sans-serif;line-height: 1.4em;}
      #act_indicator {visibility: hidden;}
      .chatinput {width: 80% !important;}
      .online_img {vertical-align:middle;}
      .chatbg1 {background-color: #ffffdf;}
      .chatbg2 {background-color: #efefd1;}
      .messagelabel {font-weight:bold;clear: left;color:#fff;}
      .messagelabel:hover {color:dfdfdf;}
      div#refresh {float:left;width:14%;padding-bottom:4px;}
      div#archive{float:left;width:42%;text-align:center;padding-top:4px;}
      div#author{float:right;padding-top:4px;width:26%;}
    -->
  </style>
  <ul class="linklist">
    <li class="rightside pagination"><!-- IF PAGINATION --><span>{PAGINATION}</span><!-- ELSE -->{PAGE_NUMBER}<!-- ENDIF --></li>
  </ul>
  <div class="forabg" align="left">
    <div class="inner">
      <span class="corners-top"><span></span></span>
      <div class="shouts">
        <div id="chat">
          <!-- BEGIN chatrow -->
          <div id="p{chatrow.MESSAGE_ID}" class="post bg{chatrow.CLASS}">
            <!-- IF S_USER_LOGGED_IN -->
            <span class="chatrow">
              <span class="profile-icons postprofile chatarchf">
                <nobr>
            <!-- ENDIF -->
            <!-- IF U_ACP or U_MCP -->
                  <span class="delete-icon">
                    <a href="javascript:void({chatrow.MESSAGE_ID})" title="{L_DELETE_POST}" onclick="delete_post('{chatrow.MESSAGE_ID}')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                  </span>
            <!-- ENDIF -->
            <!-- IF S_USER_LOGGED_IN -->
                {chatrow.TIME}</nobr>
              </span>
            </span>
            <!-- ENDIF -->
            <span class="author" id="profile{postrow.POST_ID}">&nbsp;{chatrow.USERNAME_FULL}:</span>
            <span class="chatrow"><span class="content">&nbsp;{chatrow.MESSAGE}</span></span>
          </div>
          <!-- END chatrow -->
        </div>
      </div>
      <span class="corners-bottom"><span></span></span>
    </div>
  </div>
  <div class="forabg" align="center">
    <div class="inner">
      <span class="corners-top"><span></span></span>
      <div class="post">
        <div id="refresh">
          <strong><span><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></span></strong>
        </div>
        <div id="archive">
          <strong><span><a href="{U_CHAT}" title="{L_CHAT_EXPLAIN}">{L_CHAT}</a></span></strong>
        </div>
        <div id="author">{L_DETAILS}</div>
      </div>
      <span class="corners-bottom"><span></span></span>
    </div>
  </div>
  <!-- IF S_CHAT -->
    <!-- INCLUDE overall_footer.html -->
  <!-- ENDIF -->
<!-- ENDIF -->
tsouliang    
Crewman
Crewman
 
Posts: 4
Joined: 16 Dec 2009, 07:57
Gender: Male
phpBB Knowledge: 2

Re: [Released] Chat Archive for AJAX Chat

Postby tsouliang » 18 Feb 2012, 13:50

up :wave:
tsouliang    
Crewman
Crewman
 
Posts: 4
Joined: 16 Dec 2009, 07:57
Gender: Male
phpBB Knowledge: 2

Re: [Released] Chat Archive for AJAX Chat

Postby tsouliang » 19 Feb 2012, 17:28

... hello !!
is there anybody here ?? ^^
nobody knows some sql / php ?? :blink:
tsouliang    
Crewman
Crewman
 
Posts: 4
Joined: 16 Dec 2009, 07:57
Gender: Male
phpBB Knowledge: 2

Re: [Released] Chat Archive for AJAX Chat

Postby tsouliang » 05 Mar 2012, 16:39

:confused:
ho oki ... every body is dead here ?? ^^
oki bye bye good luck all :scratch:
tsouliang    
Crewman
Crewman
 
Posts: 4
Joined: 16 Dec 2009, 07:57
Gender: Male
phpBB Knowledge: 2

Re: [Released] Chat Archive for AJAX Chat

Postby Jackuul » 27 Mar 2012, 01:06

Hi, I basically registered to see if I could get help on this modification.

Currently it works on smaller boards, however I have a seriously active chat and I think its trying to load too much data at once. Is there perhaps a way to limit how much it actually loads and displays, and thus, separate it into pages?

The current error I am getting is: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 51 bytes) in /home/k5p/public_html/sites/mafiarpg/includes/db/mysqli.php on line 255

I cannot increase the allowed memory size, mind you, and 33 megs is a pretty big allowance.

The reason I need the archive is for moderation, as when things pass - there is no way to moderate them.

Thank you :3
Jackuul    
Crewman
Crewman
 
Posts: 1
Joined: 27 Mar 2012, 01:03
Gender: Male

Re: [Released] Chat Archive for AJAX Chat

Postby sweetchariot » 27 Mar 2012, 21:27

Is the creator is providing support for this mod here???
As i see last few people didnt got any reply,
I am also getting lots of problem using this, i hope to get any help here or some one guide me to any alternative for this mod.

THanks,
Sid
sweetchariot    
Crewman
Crewman
 
Posts: 1
Joined: 27 Mar 2012, 17:19
Gender: Male
phpBB Knowledge: 9

PreviousNext

Return to phpBB3 Customizations

Who is online

Users browsing this forum: EasouSpider, Majestic-12 [Bot] and 21 guests

cron