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;
}
?>