[final] Recent topics for phpBB3 (Темы на стр. сайта)

Здесь авторы могут постить бета-версии своих модификаций для phpBB 3.0.x. Внимание! Не устанавливайте бета-версии модов на работающие форумы!
Правила форума
Местная Конституция | Шаблон запроса | Документация (phpBB3) | Переход на 3.0.6 и выше | FAQ-3 (phpbb3) | Как задавать вопросы | Как устанавливать моды

Ваш вопрос может быть удален без объяснения причин, если на него есть ответы по приведённым ссылкам (а вы рискуете получить предупреждение ;) ).
Аватара пользователя
andromeda68
phpBB 1.4.3
Сообщения: 97
Стаж: 13 лет 11 месяцев
Откуда: Ижевск
Благодарил (а): 22 раза
Поблагодарили: 1 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение andromeda68 »

Форум на сайте, в папке /forum/ вывожу код на главную сайта.
Помогите исправить ссылку на автора поста, то есть дописать /forum/
Сайт http://honey-land.ru/

Привожу код: recent.php

Код: Выделить всё

<?php
/** 
*
* @package phpBB3
* @version $Id: recent.php,v 1.1.2 2007/08/21 23:21:39 rxu Exp $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/


/* Config section */
$cfg_ignore_forums = '92'; 		// ids of forums you don't want to display, separated by commas or empty
$cfg_only_forums = ''; 			// ids of forums you only want to display, separated by commas or empty
$cfg_nm_topics = 15;			// number of topics to output
$cfg_max_topic_length = 100; 	// max topic length, if more, title will be shortened
$cfg_show_replies = true; 		// show number of replies to topics
$cfg_show_first_post = false;	// show first posts of the recent topics
$cfg_show_attachments = false;	// show attachments in the first posts of recent topics
/* End of config */

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

//
// Let's prevent caching
//
/*
if (!empty($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2'))
{
	header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
	header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header('Expires: 0');
header('Pragma: no-cache');
*/
header('Content-type: text/html; charset=Windows-1251');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

//
// Building URL
//
$board_path = generate_board_url();
$viewtopic_url = $board_path . '/viewtopic.' . $phpEx;
$view_topic_url = $board_path . '/viewtopic.' . $phpEx;

// Fetching forums that should not be displayed
$forums = implode(',', array_keys($auth->acl_getf('!f_read', true)));
$cfg_ignore_forums = (!empty($cfg_ignore_forums) && !empty($forums)) ? $cfg_ignore_forums . ',' . $forums : ((!empty($forums)) ? $forums : ((!empty($cfg_ignore_forums)) ? $cfg_ignore_forums : ''));

// Building sql for forums that should not be displayed
$sql_ignore_forums = (!empty($cfg_ignore_forums)) ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums .') ' : '';

// Building sql for forums that should only be displayed
$sql_only_forums = (!empty($cfg_only_forums)) ? ' AND t.forum_id IN(' . $cfg_only_forums .') ' : '';

// Fetching topics of public forums
$sql = 'SELECT t.*,
	p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment, p.post_approved
	FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f
	WHERE t.forum_id = f.forum_id
		$sql_ignore_forums
		$sql_only_forums 
		AND p.post_id = t.topic_first_post_id
		AND t.topic_moved_id = 0
	ORDER BY t.topic_last_post_id DESC LIMIT $cfg_nm_topics";

$result = $db->sql_query($sql);

$recent_topics = $db->sql_fetchrowset($result);

//
// BEGIN ATTACHMENT DATA
//
if($cfg_show_first_post && $cfg_show_attachments)
{
	$attach_list = $update_count = array();
	foreach ($recent_topics as $post_attachment)
	{
		if ($post_attachment['post_attachment'] && $config['allow_attachments'])
		{
			$attach_list[] = $post_attachment['post_id'];

			if ($post_attachment['post_approved'])
			{
				$has_attachments = true;
			}
		}
	}

	// Pull attachment data
	if (sizeof($attach_list))
	{
		if ($auth->acl_get('u_download') )
		{
			$sql_attach = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
			$result_attach = $db->sql_query($sql_attach);

			while ($row_attach = $db->sql_fetchrow($result_attach))
			{
				$attachments[$row_attach['post_msg_id']][] = $row_attach;
			}
			$db->sql_freeresult($result_attach);
		}
		else
		{
			$display_notice = true;
		}
	}
}
//
// END ATTACHMENT DATA
//


foreach ( $recent_topics as $row )
{
	$topic_title = censor_text($row['topic_title']);
	$topic_title = (utf8_strlen($topic_title) > $cfg_max_topic_length) ? utf8_substr($topic_title, 0, $cfg_max_topic_length) . '&hellip;' : $topic_title;
	$topic_title = str_replace(array("\r\n", "\r", "\n"), '<br />', $topic_title);
	$topic_title = addslashes($topic_title);
	$user_colour = ($row['topic_last_poster_colour']) ? ' style="color:#' . $row['topic_last_poster_colour'] . '" class="username-coloured"' : '';	

	// Replies
	$replies = ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'];

	//         font color="#FF0033"
	if ($replies == 0)
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}
	else
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}

	// Instantiate BBCode if need be
	if ($row['bbcode_bitfield'] !== '')
	{
		$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
	}

	$message = $row['post_text'];

	// Parse the message
	$message = censor_text($message);

	// Second parse bbcode here
	if ($row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = str_replace("\n", '<br />', $message);

	// Always process smilies after parsing bbcodes
	$message = smiley_text($message);
	
	// Parse attachments
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
	}
	
	$message = str_replace(array("\r\n", "\r", "\n"), '<br />', $message);
	$message = addslashes($message);
	$message = str_replace('./', $board_path . '/', $message);
	$tags = array('dl', 'dt', 'dd');
	$message = strip_selected_tags($message, $tags);
	
	$template->assign_block_vars('topicrow', array(
		'NEWEST_POST_IMG'		=> $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
		'LAST_POST_IMG' 		=> $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
		'U_NEWEST_POST'			=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC' 			=> $viewtopic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		
'U_TOPIC_AUTHOR'		=> get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
		
		
		'LAST_POST_AUTHOR_COLOUR'	=> get_username_string('colour', $row['topic_last_poster_id'], iconv('UTF-8', 'cp1251', iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'LAST_POST_AUTHOR_FULL'		=> get_username_string('full', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'TOPIC_TITLE' 			=> $color_empty_topic_beg . iconv("UTF-8", "cp1251", $topic_title) . $color_empty_topic_end,
		'LAST_POST_TIME' 		=> $user->format_date($row['topic_last_post_time'],"H:i"),
		'TOPIC_REPLIES'			=> ($cfg_show_replies) ? '<font color="#006600">[' . $replies . ']</font>' : '', 
		'S_HAS_ATTACHMENTS'		=> ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']])) ? true : false,
		'POSTER_LAST_POST'    		=> get_username_string('full', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
//                'POSTER_LAST_POST' 		=> '<font color="#' . $row['topic_last_poster_colour'] . '">' . $last_post_poster . '</font>',
	));

	if ($cfg_show_first_post)
	{
		$template->assign_block_vars('topicrow.first_post_text', array(
			'TOPIC_FIRST_POST_TEXT' => ($cfg_show_first_post) ? iconv("UTF-8", "cp1251", $message) : ''
		));
	}

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		foreach ($attachments[$row['post_id']] as $attachment)
		{
			$attachment = str_replace(array("\r\n", "\r", "\n"), '<br />', $attachment);
			$attachment = str_replace('"./', '"' . $board_path . '/', $attachment);
			$tags = array('span', 'dt', 'dd');
			$attachment = strip_selected_tags($attachment, $tags);

			$template->assign_block_vars('topicrow.first_post_text.attachment', array(
				'DISPLAY_ATTACHMENT'	=>  iconv("UTF-8", "cp1251", $attachment))
			);
		}
	}

}
$db->sql_freeresult($result);
		
// Load template
$template->set_filenames(array(
	'body' => 'recent_body.html')
);


// Output
$template->display('body');

/**
* Works like PHP function strip_tags, but it only removes selected tags.
* Example: * strip_selected_tags('<b>Person:</b> <strong>Larcher</strong>', 'strong') => <b>Person:</b> Larcher
* by Matthieu Larcher 
* http://ru2.php.net/manual/en/function.strip-tags.php#76045
*/
function strip_selected_tags($text, $tags = array())
{
	$args = func_get_args();
	$text = array_shift($args);
	$tags = (func_num_args() > 2) ? array_diff($args,array($text)) : (array)$tags;
	foreach ($tags as $tag)
	{
		while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag .'>/iusU', $text, $found))
		{
			$text = str_replace($found[0],$found[2],$text);
		}
	}

	return preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU', '', $text);
}
?>
Вот код recent_body.html

Код: Выделить всё

<!-- BEGIN topicrow -->
document.writeln('<a href="{topicrow.U_TOPIC}">{topicrow.TOPIC_TITLE}</a> [{topicrow.POSTER_LAST_POST}, {topicrow.LAST_POST_TIME}] {topicrow.TOPIC_REPLIES}<br />\n');
	<!-- BEGIN first_post_text -->
	document.writeln('{topicrow.first_post_text.TOPIC_FIRST_POST_TEXT}<br />\n');
		<!-- BEGIN attachment -->
		document.writeln('{topicrow.first_post_text.attachment.DISPLAY_ATTACHMENT}<br />\n');
		<!-- END attachment -->
	document.writeln('<br />\n');
	<!-- END first_post_text -->
<!-- END topicrow -->
Аватара пользователя
Sheer
Former team member
Сообщения: 12113
Стаж: 19 лет 7 месяцев
Откуда: Калининград не Кенигсберг
Благодарил (а): 54 раза
Поблагодарили: 2756 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Sheer »

Так должно работать
recent.rar
У вас нет необходимых прав для просмотра вложений в этом сообщении.
Изображение
Общие ошибки новичков (07.11.2005) & Как задавать вопросы
Мини FAQ
Если ничто другое не помогает, прочтите, наконец, инструкцию!
"Никакая инструкция не может перечислить всех обязанностей должностного лица, предусмотреть все отдельные случаи и дать вперёд соответствующие указания, а поэтому господа инженеры должны проявить инициативу и, руководствуясь знаниями своей специальности и пользой дела, принять все усилия для оправдания своего назначения".
Циркуляр Морского технического комитета №15 от 29.11.1910 г.
Аватара пользователя
andromeda68
phpBB 1.4.3
Сообщения: 97
Стаж: 13 лет 11 месяцев
Откуда: Ижевск
Благодарил (а): 22 раза
Поблагодарили: 1 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение andromeda68 »

Спасибо Вам, плюсанул! Еще немного и можно архив выкладывать посетителям :)
В этом коде у автора модификации иконка на последнее сообщение в начале строки каждой стоит.
Но у меня форум в папке /forum/, поэтому нужно где-то добавить путь к иконке, помогите пжл.?
Выкладываю последний код...

Код: Выделить всё

<?php
/**
*
* @package phpBB3
* @version $Id: recent.php,v 1.1.2 2007/08/21 23:21:39 rxu Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/


/* Config section */
$cfg_ignore_forums = '92'; 		// ids of forums you don't want to display, separated by commas or empty
$cfg_only_forums = ''; 			// ids of forums you only want to display, separated by commas or empty
$cfg_nm_topics = 15;			// number of topics to output
$cfg_max_topic_length = 100; 	// max topic length, if more, title will be shortened
$cfg_show_replies = true; 		// show number of replies to topics
$cfg_show_first_post = false;	// show first posts of the recent topics
$cfg_show_attachments = false;	// show attachments in the first posts of recent topics
/* End of config */

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

header('Content-type: text/html; charset=Windows-1251');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

//
// Building URL
//
$board_path = generate_board_url();
$viewtopic_url = $board_path . '/viewtopic.' . $phpEx;
$view_topic_url = $board_path . '/viewtopic.' . $phpEx;
$view_profile_url = $board_path . '/memberlist.' . $phpEx;

// Fetching forums that should not be displayed
$forums = implode(',', array_keys($auth->acl_getf('!f_read', true)));
$cfg_ignore_forums = (!empty($cfg_ignore_forums) && !empty($forums)) ? $cfg_ignore_forums . ',' . $forums : ((!empty($forums)) ? $forums : ((!empty($cfg_ignore_forums)) ? $cfg_ignore_forums : ''));

// Building sql for forums that should not be displayed
$sql_ignore_forums = (!empty($cfg_ignore_forums)) ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums .') ' : '';

// Building sql for forums that should only be displayed
$sql_only_forums = (!empty($cfg_only_forums)) ? ' AND t.forum_id IN(' . $cfg_only_forums .') ' : '';

// Fetching topics of public forums
$sql = 'SELECT t.*,
	p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment, p.post_approved
	FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f
	WHERE t.forum_id = f.forum_id
		$sql_ignore_forums
		$sql_only_forums
		AND p.post_id = t.topic_first_post_id
		AND t.topic_moved_id = 0
	ORDER BY t.topic_last_post_id DESC LIMIT $cfg_nm_topics";

$result = $db->sql_query($sql);

$recent_topics = $db->sql_fetchrowset($result);

//
// BEGIN ATTACHMENT DATA
//
if($cfg_show_first_post && $cfg_show_attachments)
{
	$attach_list = $update_count = array();
	foreach ($recent_topics as $post_attachment)
	{
		if ($post_attachment['post_attachment'] && $config['allow_attachments'])
		{
			$attach_list[] = $post_attachment['post_id'];

			if ($post_attachment['post_approved'])
			{
				$has_attachments = true;
			}
		}
	}

	// Pull attachment data
	if (sizeof($attach_list))
	{
		if ($auth->acl_get('u_download') )
		{
			$sql_attach = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
			$result_attach = $db->sql_query($sql_attach);

			while ($row_attach = $db->sql_fetchrow($result_attach))
			{
				$attachments[$row_attach['post_msg_id']][] = $row_attach;
			}
			$db->sql_freeresult($result_attach);
		}
		else
		{
			$display_notice = true;
		}
	}
}
//
// END ATTACHMENT DATA
//

foreach ( $recent_topics as $row )
{
	$topic_title = censor_text($row['topic_title']);
	$topic_title = (utf8_strlen($topic_title) > $cfg_max_topic_length) ? utf8_substr($topic_title, 0, $cfg_max_topic_length) . '&hellip;' : $topic_title;
	$topic_title = str_replace(array("\r\n", "\r", "\n"), '<br />', $topic_title);
	$topic_title = addslashes($topic_title);
	$user_colour = ($row['topic_last_poster_colour']) ? ' style="color:#' . $row['topic_last_poster_colour'] . '" class="username-coloured"' : '';

	// Replies
	$replies = ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'];

	if ($replies == 0)
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}
	else
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}

	// Instantiate BBCode if need be
	if ($row['bbcode_bitfield'] !== '')
	{
		$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
	}

	$message = $row['post_text'];

	// Parse the message
	$message = censor_text($message);

	// Second parse bbcode here
	if ($row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = str_replace("\n", '<br />', $message);

	// Always process smilies after parsing bbcodes
	$message = smiley_text($message);

	// Parse attachments
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
	}

	$message = str_replace(array("\r\n", "\r", "\n"), '<br />', $message);
	$message = addslashes($message);
	$message = str_replace('./', $board_path . '/', $message);
	$tags = array('dl', 'dt', 'dd');
	$message = strip_selected_tags($message, $tags);

	$template->assign_block_vars('topicrow', array(
		'NEWEST_POST_IMG'			=> $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
		'LAST_POST_IMG' 			=> $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
		'U_NEWEST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC' 					=> $viewtopic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC_AUTHOR'			=> ''.$board_path.'/'.get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']).'',
		'LAST_POST_AUTHOR_COLOUR'	=> get_username_string('colour', $row['topic_last_poster_id'], iconv('UTF-8', 'cp1251', iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'LAST_POST_AUTHOR_FULL'		=> get_username_string('full', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'TOPIC_TITLE' 				=> $color_empty_topic_beg . iconv("UTF-8", "cp1251", $topic_title) . $color_empty_topic_end,
		'LAST_POST_TIME' 			=> $user->format_date($row['topic_last_post_time'],"H:i"),
		'TOPIC_REPLIES'				=> ($cfg_show_replies) ? '<font color="#006600">[' . $replies . ']</font>' : '',
		'S_HAS_ATTACHMENTS'			=> ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']])) ? true : false,
		'POSTER_LAST_POST'    		=> get_username_string('username', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'U_POSTER_LAST_POST'		=> $view_profile_url . '?mode=viewprofile&u=' . $row['topic_last_poster_id'] . '',
	));

	if ($cfg_show_first_post)
	{
		$template->assign_block_vars('topicrow.first_post_text', array(
			'TOPIC_FIRST_POST_TEXT' => ($cfg_show_first_post) ? iconv("UTF-8", "cp1251", $message) : ''
		));
	}

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		foreach ($attachments[$row['post_id']] as $attachment)
		{
			$attachment = str_replace(array("\r\n", "\r", "\n"), '<br />', $attachment);
			$attachment = str_replace('"./', '"' . $board_path . '/', $attachment);
			$tags = array('span', 'dt', 'dd');
			$attachment = strip_selected_tags($attachment, $tags);

			$template->assign_block_vars('topicrow.first_post_text.attachment', array(
				'DISPLAY_ATTACHMENT'	=>  iconv("UTF-8", "cp1251", $attachment))
			);
		}
	}

}
$db->sql_freeresult($result);

// Load template
$template->set_filenames(array(
	'body' => 'recent_body.html')
);


// Output
$template->display('body');

/**
* Works like PHP function strip_tags, but it only removes selected tags.
* Example: * strip_selected_tags('<b>Person:</b> <strong>Larcher</strong>', 'strong') => <b>Person:</b> Larcher
* by Matthieu Larcher
* http://ru2.php.net/manual/en/function.strip-tags.php#76045
*/
function strip_selected_tags($text, $tags = array())
{
	$args = func_get_args();
	$text = array_shift($args);
	$tags = (func_num_args() > 2) ? array_diff($args,array($text)) : (array)$tags;
	foreach ($tags as $tag)
	{
		while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag .'>/iusU', $text, $found))
		{
			$text = str_replace($found[0],$found[2],$text);
		}
	}

	return preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU', '', $text);
}
?>
Аватара пользователя
Sheer
Former team member
Сообщения: 12113
Стаж: 19 лет 7 месяцев
Откуда: Калининград не Кенигсберг
Благодарил (а): 54 раза
Поблагодарили: 2756 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Sheer »

Код: Выделить всё

		'NEWEST_POST_IMG'			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_newest', 'VIEW_NEWEST_POST')),
		'LAST_POST_IMG' 			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_latest', 'VIEW_LATEST_POST')),
		'U_LAST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p='. $row['topic_last_post_id'] .'#p'.$row['topic_last_post_id'].'',

Код: Выделить всё

document.writeln('<a href="{topicrow.U_TOPIC}">{topicrow.TOPIC_TITLE}</a> [<a style="color:{topicrow.LAST_POST_AUTHOR_COLOUR}" href="{topicrow.U_POSTER_LAST_POST}">{topicrow.POSTER_LAST_POST}</a>, {topicrow.LAST_POST_TIME}] {topicrow.TOPIC_REPLIES}&nbsp;<a href="{topicrow.U_NEWEST_POST}">{topicrow.NEWEST_POST_IMG}</a>&nbsp;<a href="{topicrow.U_LAST_POST}">{topicrow.LAST_POST_IMG}</a><br />\n');
Изображение
Общие ошибки новичков (07.11.2005) & Как задавать вопросы
Мини FAQ
Если ничто другое не помогает, прочтите, наконец, инструкцию!
"Никакая инструкция не может перечислить всех обязанностей должностного лица, предусмотреть все отдельные случаи и дать вперёд соответствующие указания, а поэтому господа инженеры должны проявить инициативу и, руководствуясь знаниями своей специальности и пользой дела, принять все усилия для оправдания своего назначения".
Циркуляр Морского технического комитета №15 от 29.11.1910 г.
Аватара пользователя
andromeda68
phpBB 1.4.3
Сообщения: 97
Стаж: 13 лет 11 месяцев
Откуда: Ижевск
Благодарил (а): 22 раза
Поблагодарили: 1 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение andromeda68 »

Спасибо! Неожиданность для меня, 2 иконки в строке: я так понял 1 иконка идёт на тему, 2 иконка на последний пост. Пока темы у меня маленькие. Ещё бы подсказку вылечить от ироглифов, как ранее лечили?

Код: Выделить всё

<?php
/**
*
* @package phpBB3
* @version $Id: recent.php,v 1.1.2 2007/08/21 23:21:39 rxu Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/


/* Config section */
$cfg_ignore_forums = '92'; 		// ids of forums you don't want to display, separated by commas or empty
$cfg_only_forums = ''; 			// ids of forums you only want to display, separated by commas or empty
$cfg_nm_topics = 15;			// number of topics to output
$cfg_max_topic_length = 100; 	// max topic length, if more, title will be shortened
$cfg_show_replies = true; 		// show number of replies to topics
$cfg_show_first_post = false;	// show first posts of the recent topics
$cfg_show_attachments = false;	// show attachments in the first posts of recent topics
/* End of config */

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

header('Content-type: text/html; charset=Windows-1251');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

//
// Building URL
//
$board_path = generate_board_url();
$viewtopic_url = $board_path . '/viewtopic.' . $phpEx;
$view_topic_url = $board_path . '/viewtopic.' . $phpEx;
$view_profile_url = $board_path . '/memberlist.' . $phpEx;

// Fetching forums that should not be displayed
$forums = implode(',', array_keys($auth->acl_getf('!f_read', true)));
$cfg_ignore_forums = (!empty($cfg_ignore_forums) && !empty($forums)) ? $cfg_ignore_forums . ',' . $forums : ((!empty($forums)) ? $forums : ((!empty($cfg_ignore_forums)) ? $cfg_ignore_forums : ''));

// Building sql for forums that should not be displayed
$sql_ignore_forums = (!empty($cfg_ignore_forums)) ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums .') ' : '';

// Building sql for forums that should only be displayed
$sql_only_forums = (!empty($cfg_only_forums)) ? ' AND t.forum_id IN(' . $cfg_only_forums .') ' : '';

// Fetching topics of public forums
$sql = 'SELECT t.*,
	p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment, p.post_approved
	FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f
	WHERE t.forum_id = f.forum_id
		$sql_ignore_forums
		$sql_only_forums
		AND p.post_id = t.topic_first_post_id
		AND t.topic_moved_id = 0
	ORDER BY t.topic_last_post_id DESC LIMIT $cfg_nm_topics";

$result = $db->sql_query($sql);

$recent_topics = $db->sql_fetchrowset($result);

//
// BEGIN ATTACHMENT DATA
//
if($cfg_show_first_post && $cfg_show_attachments)
{
	$attach_list = $update_count = array();
	foreach ($recent_topics as $post_attachment)
	{
		if ($post_attachment['post_attachment'] && $config['allow_attachments'])
		{
			$attach_list[] = $post_attachment['post_id'];

			if ($post_attachment['post_approved'])
			{
				$has_attachments = true;
			}
		}
	}

	// Pull attachment data
	if (sizeof($attach_list))
	{
		if ($auth->acl_get('u_download') )
		{
			$sql_attach = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
			$result_attach = $db->sql_query($sql_attach);

			while ($row_attach = $db->sql_fetchrow($result_attach))
			{
				$attachments[$row_attach['post_msg_id']][] = $row_attach;
			}
			$db->sql_freeresult($result_attach);
		}
		else
		{
			$display_notice = true;
		}
	}
}
//
// END ATTACHMENT DATA
//

foreach ( $recent_topics as $row )
{
	$topic_title = censor_text($row['topic_title']);
	$topic_title = (utf8_strlen($topic_title) > $cfg_max_topic_length) ? utf8_substr($topic_title, 0, $cfg_max_topic_length) . '&hellip;' : $topic_title;
	$topic_title = str_replace(array("\r\n", "\r", "\n"), '<br />', $topic_title);
	$topic_title = addslashes($topic_title);
	$user_colour = ($row['topic_last_poster_colour']) ? ' style="color:#' . $row['topic_last_poster_colour'] . '" class="username-coloured"' : '';

	// Replies
	$replies = ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'];

	if ($replies == 0)
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}
	else
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}

	// Instantiate BBCode if need be
	if ($row['bbcode_bitfield'] !== '')
	{
		$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
	}

	$message = $row['post_text'];

	// Parse the message
	$message = censor_text($message);

	// Second parse bbcode here
	if ($row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = str_replace("\n", '<br />', $message);

	// Always process smilies after parsing bbcodes
	$message = smiley_text($message);

	// Parse attachments
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
	}

	$message = str_replace(array("\r\n", "\r", "\n"), '<br />', $message);
	$message = addslashes($message);
	$message = str_replace('./', $board_path . '/', $message);
	$tags = array('dl', 'dt', 'dd');
	$message = strip_selected_tags($message, $tags);

	$template->assign_block_vars('topicrow', array(
		'NEWEST_POST_IMG'			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_newest', 'VIEW_NEWEST_POST')),
		'LAST_POST_IMG' 			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_latest', 'VIEW_LATEST_POST')),
		'U_LAST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p='. $row['topic_last_post_id'] .'#p'.$row['topic_last_post_id'].'',
		'U_NEWEST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC' 					=> $viewtopic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC_AUTHOR'			=> ''.$board_path.'/'.get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']).'',
		'LAST_POST_AUTHOR_COLOUR'	=> get_username_string('colour', $row['topic_last_poster_id'], iconv('UTF-8', 'cp1251', iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'LAST_POST_AUTHOR_FULL'		=> get_username_string('full', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'TOPIC_TITLE' 				=> $color_empty_topic_beg . iconv("UTF-8", "cp1251", $topic_title) . $color_empty_topic_end,
		'LAST_POST_TIME' 			=> $user->format_date($row['topic_last_post_time'],"H:i"),
		'TOPIC_REPLIES'				=> ($cfg_show_replies) ? '<font color="#006600">[' . $replies . ']</font>' : '',
		'S_HAS_ATTACHMENTS'			=> ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']])) ? true : false,
		'POSTER_LAST_POST'    		=> get_username_string('username', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'U_POSTER_LAST_POST'		=> $view_profile_url . '?mode=viewprofile&u=' . $row['topic_last_poster_id'] . '',
	));

	if ($cfg_show_first_post)
	{
		$template->assign_block_vars('topicrow.first_post_text', array(
			'TOPIC_FIRST_POST_TEXT' => ($cfg_show_first_post) ? iconv("UTF-8", "cp1251", $message) : ''
		));
	}

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		foreach ($attachments[$row['post_id']] as $attachment)
		{
			$attachment = str_replace(array("\r\n", "\r", "\n"), '<br />', $attachment);
			$attachment = str_replace('"./', '"' . $board_path . '/', $attachment);
			$tags = array('span', 'dt', 'dd');
			$attachment = strip_selected_tags($attachment, $tags);

			$template->assign_block_vars('topicrow.first_post_text.attachment', array(
				'DISPLAY_ATTACHMENT'	=>  iconv("UTF-8", "cp1251", $attachment))
			);
		}
	}

}
$db->sql_freeresult($result);

// Load template
$template->set_filenames(array(
	'body' => 'recent_body.html')
);


// Output
$template->display('body');

/**
* Works like PHP function strip_tags, but it only removes selected tags.
* Example: * strip_selected_tags('<b>Person:</b> <strong>Larcher</strong>', 'strong') => <b>Person:</b> Larcher
* by Matthieu Larcher
* http://ru2.php.net/manual/en/function.strip-tags.php#76045
*/
function strip_selected_tags($text, $tags = array())
{
	$args = func_get_args();
	$text = array_shift($args);
	$tags = (func_num_args() > 2) ? array_diff($args,array($text)) : (array)$tags;
	foreach ($tags as $tag)
	{
		while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag .'>/iusU', $text, $found))
		{
			$text = str_replace($found[0],$found[2],$text);
		}
	}

	return preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU', '', $text);
}
?>
Аватара пользователя
Sheer
Former team member
Сообщения: 12113
Стаж: 19 лет 7 месяцев
Откуда: Калининград не Кенигсберг
Благодарил (а): 54 раза
Поблагодарили: 2756 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Sheer »

Раз уж CP-1251, то и php-файл сохраняем в этой кодировке и

Код: Выделить всё

		'NEWEST_POST_IMG'			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_newest', 'Перейти к первому непрочитанному сообщению')),
		'LAST_POST_IMG' 			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_latest', 'Перейти к последнему сообщению')),
Изображение
Общие ошибки новичков (07.11.2005) & Как задавать вопросы
Мини FAQ
Если ничто другое не помогает, прочтите, наконец, инструкцию!
"Никакая инструкция не может перечислить всех обязанностей должностного лица, предусмотреть все отдельные случаи и дать вперёд соответствующие указания, а поэтому господа инженеры должны проявить инициативу и, руководствуясь знаниями своей специальности и пользой дела, принять все усилия для оправдания своего назначения".
Циркуляр Морского технического комитета №15 от 29.11.1910 г.
Аватара пользователя
andromeda68
phpBB 1.4.3
Сообщения: 97
Стаж: 13 лет 11 месяцев
Откуда: Ижевск
Благодарил (а): 22 раза
Поблагодарили: 1 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение andromeda68 »

Супер!!! А можно последнее... автора покрасить в другой цвет, чтоб не сливалось с ссылкой?

Код: Выделить всё

<?php
/**
*
* @package phpBB3
* @version $Id: recent.php,v 1.1.2 2007/08/21 23:21:39 rxu Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/


/* Config section */
$cfg_ignore_forums = '92'; 		// ids of forums you don't want to display, separated by commas or empty
$cfg_only_forums = ''; 			// ids of forums you only want to display, separated by commas or empty
$cfg_nm_topics = 15;			// number of topics to output
$cfg_max_topic_length = 100; 	// max topic length, if more, title will be shortened
$cfg_show_replies = true; 		// show number of replies to topics
$cfg_show_first_post = false;	// show first posts of the recent topics
$cfg_show_attachments = false;	// show attachments in the first posts of recent topics
/* End of config */

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

header('Content-type: text/html; charset=Windows-1251');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

//
// Building URL
//
$board_path = generate_board_url();
$viewtopic_url = $board_path . '/viewtopic.' . $phpEx;
$view_topic_url = $board_path . '/viewtopic.' . $phpEx;
$view_profile_url = $board_path . '/memberlist.' . $phpEx;

// Fetching forums that should not be displayed
$forums = implode(',', array_keys($auth->acl_getf('!f_read', true)));
$cfg_ignore_forums = (!empty($cfg_ignore_forums) && !empty($forums)) ? $cfg_ignore_forums . ',' . $forums : ((!empty($forums)) ? $forums : ((!empty($cfg_ignore_forums)) ? $cfg_ignore_forums : ''));

// Building sql for forums that should not be displayed
$sql_ignore_forums = (!empty($cfg_ignore_forums)) ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums .') ' : '';

// Building sql for forums that should only be displayed
$sql_only_forums = (!empty($cfg_only_forums)) ? ' AND t.forum_id IN(' . $cfg_only_forums .') ' : '';

// Fetching topics of public forums
$sql = 'SELECT t.*,
	p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment, p.post_approved
	FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f
	WHERE t.forum_id = f.forum_id
		$sql_ignore_forums
		$sql_only_forums
		AND p.post_id = t.topic_first_post_id
		AND t.topic_moved_id = 0
	ORDER BY t.topic_last_post_id DESC LIMIT $cfg_nm_topics";

$result = $db->sql_query($sql);

$recent_topics = $db->sql_fetchrowset($result);

//
// BEGIN ATTACHMENT DATA
//
if($cfg_show_first_post && $cfg_show_attachments)
{
	$attach_list = $update_count = array();
	foreach ($recent_topics as $post_attachment)
	{
		if ($post_attachment['post_attachment'] && $config['allow_attachments'])
		{
			$attach_list[] = $post_attachment['post_id'];

			if ($post_attachment['post_approved'])
			{
				$has_attachments = true;
			}
		}
	}

	// Pull attachment data
	if (sizeof($attach_list))
	{
		if ($auth->acl_get('u_download') )
		{
			$sql_attach = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
			$result_attach = $db->sql_query($sql_attach);

			while ($row_attach = $db->sql_fetchrow($result_attach))
			{
				$attachments[$row_attach['post_msg_id']][] = $row_attach;
			}
			$db->sql_freeresult($result_attach);
		}
		else
		{
			$display_notice = true;
		}
	}
}
//
// END ATTACHMENT DATA
//

foreach ( $recent_topics as $row )
{
	$topic_title = censor_text($row['topic_title']);
	$topic_title = (utf8_strlen($topic_title) > $cfg_max_topic_length) ? utf8_substr($topic_title, 0, $cfg_max_topic_length) . '&hellip;' : $topic_title;
	$topic_title = str_replace(array("\r\n", "\r", "\n"), '<br />', $topic_title);
	$topic_title = addslashes($topic_title);
	$user_colour = ($row['topic_last_poster_colour']) ? ' style="color:#' . $row['topic_last_poster_colour'] . '" class="username-coloured"' : '';

	// Replies
	$replies = ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'];

	if ($replies == 0)
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}
	else
	{
		$color_empty_topic_beg = '';
		$color_empty_topic_end = '';
	}

	// Instantiate BBCode if need be
	if ($row['bbcode_bitfield'] !== '')
	{
		$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
	}

	$message = $row['post_text'];

	// Parse the message
	$message = censor_text($message);

	// Second parse bbcode here
	if ($row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = str_replace("\n", '<br />', $message);

	// Always process smilies after parsing bbcodes
	$message = smiley_text($message);

	// Parse attachments
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
	}

	$message = str_replace(array("\r\n", "\r", "\n"), '<br />', $message);
	$message = addslashes($message);
	$message = str_replace('./', $board_path . '/', $message);
	$tags = array('dl', 'dt', 'dd');
	$message = strip_selected_tags($message, $tags);

	$template->assign_block_vars('topicrow', array(

		'NEWEST_POST_IMG'			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_newest', 'Перейти к первому непрочитанному сообщению')),
		'LAST_POST_IMG' 			=> str_replace('src=".', 'src="'.$board_path.'', $user->img('icon_topic_latest', 'Перейти к последнему сообщению')),
		'U_LAST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p='. $row['topic_last_post_id'] .'#p'.$row['topic_last_post_id'].'',
		'U_NEWEST_POST'				=> $view_topic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC' 					=> $viewtopic_url . '?f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread#unread',
		'U_TOPIC_AUTHOR'			=> ''.$board_path.'/'.get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']).'',
		'LAST_POST_AUTHOR_COLOUR'	=> get_username_string('colour', $row['topic_last_poster_id'], iconv('UTF-8', 'cp1251', iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'LAST_POST_AUTHOR_FULL'		=> get_username_string('full', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'TOPIC_TITLE' 				=> $color_empty_topic_beg . iconv("UTF-8", "cp1251", $topic_title) . $color_empty_topic_end,
		'LAST_POST_TIME' 			=> $user->format_date($row['topic_last_post_time'],"H:i"),
		'TOPIC_REPLIES'				=> ($cfg_show_replies) ? '<font color="#006600">[' . $replies . ']</font>' : '',
		'S_HAS_ATTACHMENTS'			=> ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']])) ? true : false,
		'POSTER_LAST_POST'    		=> get_username_string('username', $row['topic_last_poster_id'], addslashes(iconv('UTF-8', 'cp1251', $row['topic_last_poster_name'])), $row['topic_last_poster_colour']),
		'U_POSTER_LAST_POST'		=> $view_profile_url . '?mode=viewprofile&u=' . $row['topic_last_poster_id'] . '',
	));

	if ($cfg_show_first_post)
	{
		$template->assign_block_vars('topicrow.first_post_text', array(
			'TOPIC_FIRST_POST_TEXT' => ($cfg_show_first_post) ? iconv("UTF-8", "cp1251", $message) : ''
		));
	}

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		foreach ($attachments[$row['post_id']] as $attachment)
		{
			$attachment = str_replace(array("\r\n", "\r", "\n"), '<br />', $attachment);
			$attachment = str_replace('"./', '"' . $board_path . '/', $attachment);
			$tags = array('span', 'dt', 'dd');
			$attachment = strip_selected_tags($attachment, $tags);

			$template->assign_block_vars('topicrow.first_post_text.attachment', array(
				'DISPLAY_ATTACHMENT'	=>  iconv("UTF-8", "cp1251", $attachment))
			);
		}
	}

}
$db->sql_freeresult($result);

// Load template
$template->set_filenames(array(
	'body' => 'recent_body.html')
);


// Output
$template->display('body');

/**
* Works like PHP function strip_tags, but it only removes selected tags.
* Example: * strip_selected_tags('<b>Person:</b> <strong>Larcher</strong>', 'strong') => <b>Person:</b> Larcher
* by Matthieu Larcher
* http://ru2.php.net/manual/en/function.strip-tags.php#76045
*/
function strip_selected_tags($text, $tags = array())
{
	$args = func_get_args();
	$text = array_shift($args);
	$tags = (func_num_args() > 2) ? array_diff($args,array($text)) : (array)$tags;
	foreach ($tags as $tag)
	{
		while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag .'>/iusU', $text, $found))
		{
			$text = str_replace($found[0],$found[2],$text);
		}
	}

	return preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU', '', $text);
}
?>
Аватара пользователя
Sheer
Former team member
Сообщения: 12113
Стаж: 19 лет 7 месяцев
Откуда: Калининград не Кенигсберг
Благодарил (а): 54 раза
Поблагодарили: 2756 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Sheer »

Код: Выделить всё

		'LAST_POST_AUTHOR_COLOUR'	=> (get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'])) ? get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']) : '#000AFF',
Вместо #000AFF любой другой на вкус...
Изображение
Общие ошибки новичков (07.11.2005) & Как задавать вопросы
Мини FAQ
Если ничто другое не помогает, прочтите, наконец, инструкцию!
"Никакая инструкция не может перечислить всех обязанностей должностного лица, предусмотреть все отдельные случаи и дать вперёд соответствующие указания, а поэтому господа инженеры должны проявить инициативу и, руководствуясь знаниями своей специальности и пользой дела, принять все усилия для оправдания своего назначения".
Циркуляр Морского технического комитета №15 от 29.11.1910 г.
Аватара пользователя
andromeda68
phpBB 1.4.3
Сообщения: 97
Стаж: 13 лет 11 месяцев
Откуда: Ижевск
Благодарил (а): 22 раза
Поблагодарили: 1 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение andromeda68 »

Огромное спасибо Sheer, помог мне довести модификацию как нужно!

Прикладываю шаблон, может кому-нибудь пригодиться для главной страницы сайта:
1. charset=windows-1251
2. форум в папке /forum/
Сайт: http://honey-land.ru/
Скрин:
Изображение
У вас нет необходимых прав для просмотра вложений в этом сообщении.
Аватара пользователя
A190296
phpBB 1.4.1
Сообщения: 42
Стаж: 13 лет 10 месяцев
Благодарил (а): 7 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение A190296 »

Я пролазил всю тему, не нашел. Подскажите как сделать что бы контент темы выводился не весь, а к примеру две строчки...
Заранее благодарен...
Умные люди стремятся владеть информацией, мудрые - результатом её обработки!
Аватара пользователя
Di_Mok
Former team member
Сообщения: 814
Стаж: 16 лет 6 месяцев
Откуда: Родной Гондурас ;)
Благодарил (а): 147 раз
Поблагодарили: 118 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Di_Mok »

В recent.php строка $cfg_nm_topics = 15;
Аватара пользователя
A190296
phpBB 1.4.1
Сообщения: 42
Стаж: 13 лет 10 месяцев
Благодарил (а): 7 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение A190296 »

Di_Mok, Вы не правильно поняли, ни количество тем, а контент темы, ну то бишь описание. Что бы ни все было, а несколько строк. Такое возможно, кто нибудь уже докопался до этого?
Умные люди стремятся владеть информацией, мудрые - результатом её обработки!
Аватара пользователя
Di_Mok
Former team member
Сообщения: 814
Стаж: 16 лет 6 месяцев
Откуда: Родной Гондурас ;)
Благодарил (а): 147 раз
Поблагодарили: 118 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Di_Mok »

$cfg_max_topic_length = 120;
Аватара пользователя
A190296
phpBB 1.4.1
Сообщения: 42
Стаж: 13 лет 10 месяцев
Благодарил (а): 7 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение A190296 »

Di_Mok, к сожалению меняется только длина названия темы. А контент как был так остался полным.
Есть Заголовок, он меня вполне устраивает. А вот описание темы открывается полностью. Например есть 1000 символов в тема, все эти 1000 символов и будут выводится. а мне надо что бы выводилось хотя бы 200.
Умные люди стремятся владеть информацией, мудрые - результатом её обработки!
Аватара пользователя
Di_Mok
Former team member
Сообщения: 814
Стаж: 16 лет 6 месяцев
Откуда: Родной Гондурас ;)
Благодарил (а): 147 раз
Поблагодарили: 118 раз

Re: [final] Recent topics for phpBB3 (Темы на стр. сайта)

Сообщение Di_Mok »

Туго, что то до меня доходит ))) [final] Recent topics for phpBB3 (Темы на стр. сайта)

Но!
rxu писал(а):Обрезание текста сообщений проблематично, т.к. оно может содержать ссылки, смайлы, другие ббкоды, которые могут быть порушены, в результате чего получите вместо сообщения кашу из служебного кода.

Вернуться в «Бета-версии модов для phpBB 3.0.x»