Drupal refreshe
Сделал у себя кое-какие изменения, может кого заинтересует:
1. В таблице phpbb_shout cоздал индекс для shout_session_time
2. Внес изменения в shoutbox_view.php (Изменения выделены жирным)
3. Изменил шаблон shoutbox_view_body.tpl<?php
/***************************************************************************
* shoutbox_view.php
* -------------------
* begin : Feb, 2003
* author : Niels Chr. Denmark <ncr@db9.dk> (http://mods.db9.dk)
*
* version 0.9.3
*
* History:
* 0.9.0. - initial BETA
* 0.9.1. - header added
* 0.9.2. - now support cenzored words
* 0.9.3. - username is a link to users profile
*
* a fully phpBB2 integrated shoutbox
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
require_once($phpbb_root_path . 'extension.inc');
require_once($phpbb_root_path . 'common.'.$phpEx);
require_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
define ('NUM_SHOUT', 20);
//
// gzip_compression
//
$do_gzip_compress = FALSE;
if ( $board_config['gzip_compress'] )
{
$phpver = phpversion();
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;
if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) )
{
if ( extension_loaded('zlib') )
{
ob_start('ob_gzhandler');
}
}
else if ( $phpver > '4.0' )
{
if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') )
{
if ( extension_loaded('zlib') )
{
$do_gzip_compress = TRUE;
ob_start();
ob_implicit_flush(0);
header('Content-Encoding: gzip');
}
}
}
}
// end gzip block
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_SHOUTBOX);
init_userprefs($userdata);
//
// End session management
//
//
// Start auth check
//
switch ($userdata['user_level'])
{
case ADMIN :
case MOD : $is_auth['auth_mod'] = 1;
default:
$is_auth['auth_read'] = 1;
$is_auth['auth_view'] = 1;
if ($userdata['user_id']==ANONYMOUS)
{
$is_auth['auth_delete'] = 0;
$is_auth['auth_post'] = 0;
} else
{
$is_auth['auth_delete'] = 1;
$is_auth['auth_post'] = 1;
}
}
if( !$is_auth['auth_read'] )
{
message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}
//
// End auth check
//
$sql="SELECT MAX(shout_session_time) as tm FROM " . SHOUTBOX_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
}
$row=$db->sql_fetchrow($result);
$shout_time=$row['tm'];
$MyETag='"SH'.gmdate("YmdHis", $shout_time).$verinfo.'"';
$MyGMTtime=gmdate("D, d M Y H:i:s", $shout_time)." GMT";
header("Last-Modified: ".$MyGMTtime);
header("Etag: ".$MyETag);
header("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT");
if(isset($HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH'])) {
if ($HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH'] == $MyETag) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}
else {
if(isset($HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE'])) {
if ($HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE'] == $MyGMTtime) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}}
// see if we need offset
if (isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['start']))
{
$start=(isset($HTTP_POST_VARS['start'])) ? intval($HTTP_POST_VARS['start']) : intval($HTTP_GET_VARS['start']);
} else $start=0;
$template->set_filenames(array(
'body' => 'shoutbox_view_body.tpl'));
//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
//
// display the shoutbox
//
$sql = "SELECT s.*, u.user_allowsmile, u.username FROM " . SHOUTBOX_TABLE . " s, ".USERS_TABLE." u
WHERE s.shout_user_id=u.user_id ORDER BY s.shout_session_time DESC LIMIT $start, ".NUM_SHOUT;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
}
while ($shout_row = $db->sql_fetchrow($result))
{
$i++;
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$user_id = $shout_row['shout_user_id'];
$username = ( $user_id == ANONYMOUS ) ? (( $shout_row['shout_username'] == '' ) ? $lang['Guest'] : $shout_row['shout_username'] ) : "<a href='".append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=".$shout_row['shout_user_id'])."' target='_top'>".$shout_row['username']."</a>" ;
$shout = (! $shout_row['shout_active']) ? $shout_row['shout_text'] : $lang['Shout_censor'];
if ( $board_config['allow_smilies'] && $shout_row['user_allowsmile'] && $shout != '' & $shout_row['enable_smilies'])
{
$shout = smilies_pass($shout);
}
$shout = bbencode_second_pass($shout,$shout_row['shout_bbcode_uid']);
$shout = preg_replace($orig_word, $replacement_word, $shout);
$shout = str_replace("\n", "\n<br />\n", $shout);
$shout = make_clickable($shout);
$template->assign_block_vars('shoutrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'SHOUT' => $shout,
'TIME' => create_date($lang['Shoutbox_date'], $shout_row['shout_session_time'], $board_config['board_timezone']),
'USERNAME' => $username
));
}
$template->assign_vars(array(
'U_SHOUTBOX_VIEW' => append_sid("shoutbox_view.$phpEx?$start"),
'T_NAME' => $theme['template_name'],
'T_URL' => "templates/".$theme['template_name'],
'T_HEAD_STYLESHEET' => $theme['head_stylesheet'],
'S_CONTENT_ENCODING' => $lang['ENCODING']
));
$template->pparse('body');
//
// Compress buffered output if required and send to browser
//
if ( $do_gzip_compress )
{
//
// Borrowed from php.net!
//
$gzip_contents = ob_get_contents();
ob_end_clean();
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
}
exit;
?>
Результат порадовал.<HEAD>
<script>window.setTimeout("location.reload()",60000);</script>
<noscript><META HTTP-EQUIV="Refresh" CONTENT="60"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}" />
<link rel="stylesheet" href="{T_URL}/{T_HEAD_STYLESHEET}" type="text/css">
<style>
</style>
</HEAD>
<body bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">
<table width="100%" height="100%" cellpadding="0" cellspacing="1" border="0" class="forumline">
<!-- BEGIN shoutrow -->
<tr>
<td class="{shoutrow.ROW_CLASS}" width="100%" higth="100%">
<span class="gensmall">
{shoutrow.TIME}<br />
<b>{shoutrow.USERNAME}:</b><br />
{shoutrow.SHOUT}<br/></span>
</td>
</tr>
<!-- END shoutrow -->
</table>
</body>