Просмотр файла module/recent.php

Размер файла: 2.31Kb
<?php	
/*************************************************
 *    apwa.ru       recent.php
 *                 -------------
 * [email protected] 2009 Модуль портала для phpbb 2.0.23
 ************************************************/
if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
} 

$template->set_filenames(array(
	'recent' => 'module/recent_body.tpl')
);

$template->assign_block_vars('recent', array());

$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

$limit = ($template_name == 'web') ? $CFG['nm_topics']+$CFG['nm_topics'] : $CFG['nm_topics'];
        
$sql = "SELECT t.topic_title, t.topic_last_post_id
	FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p
	WHERE t.forum_id NOT IN(" . $CFG['ignore_forums'] . ")
	AND p.post_id = t.topic_last_post_id
	AND t.topic_moved_id = 0
	ORDER BY p.post_time DESC LIMIT $limit";
if ( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, "Не возможно отобразить информацию о случайных темах.", '', __LINE__, __FILE__, $sql);
}
$recentrow = array();
while( $row = $db->sql_fetchrow($result) )
{
	$recentrow[] = $row;
}
for ($i = 0; $i < count($recentrow); $i += 2)      
{
        $template->assign_block_vars('recent.topic', array());
		
	for ($j = $i; $j < ($i + 2); $j++)
	{ 
		if( $j >= count($recentrow) )
		{
			break;
		}
	        $topic_title = $recentrow[$j]['topic_title'];
	        $topic_title = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $topic_title);
	        $topic_title = ( strlen($topic_title) > $CFG['topic_length']) ? substr($topic_title, 0, $CFG['topic_length']-strlen(strrchr(substr($topic_title, 0, $CFG['topic_length']), ' '))) . '&hellip;' : $topic_title;
	        if ( count($orig_word) )
	        {
	                $topic_title = str_replace($orig_word, $replacement_word, $topic_title);
	        }	        
                      		
		$template->assign_block_vars('recent.topic.row', array(
		         'U_LAST_POST' => append_sid('post' . $recentrow[$j]['topic_last_post_id'] . '.xhtml#' . $recentrow[$j]['topic_last_post_id']),
		         'TOPIC_TITLE' => str_replace("'", "\'", $topic_title))
		);
        }
} 

$template->assign_var_from_handle('MODULE_RECENT', 'recent');

?>