( Gelöst ) Recent Topics mit CH !?

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Lighty
Mitglied
Beiträge: 73
Registriert: 16.09.2006 18:59
Kontaktdaten:

Beitrag von Lighty »

... da tut sich was ! ;)
http://computer.j-remmer.de/forum/recent.php

( noch nicht zurück geändert, da eh ein Test-Bereich )
Benutzeravatar
metty84
Mitglied
Beiträge: 159
Registriert: 08.03.2007 13:13
Wohnort: Marienberg
Kontaktdaten:

Beitrag von metty84 »

ok hab das script bissel verändert damit alles funzt hier die veränderten datein

recent_body.tpl

Code: Alles auswählen

<form name="form" method="get" action="{FORM_ACTION}">
<table width="60%" cellpadding="1" cellspacing="1" border="0" align="center">
  <tr>
        <td align="center"><span class="genmed">{L_SHOWING_POSTS} <b>{STATUS}</b></span></td>
  </tr>
  <tr>
        <td align="center"><span class="gensmall">{L_SELECT_MODE}
                                                  [ <a href="{FORM_ACTION}&mode=today" class="mainmenu">{L_TODAY}</a> ]
                                                  [ <a href="{FORM_ACTION}&mode=yesterday" class="mainmenu">{L_YESTERDAY}</a> ]
                                                  [ <a href="{FORM_ACTION}&mode=last24" class="mainmenu">{L_LAST24}</a> ]
                                                  [ <a href="{FORM_ACTION}&mode=lastweek" class="mainmenu">{L_LASTWEEK}</a> ]
                                                  [ {L_LAST} <input type="hidden" name="mode" value="lastXdays" />
                                                                   <input type="text" name="amount_days" size="2" value="{AMOUNT_DAYS}" maxlength="3" class="post" />
                                                                   <a href="javascript:document.form.submit();" class="mainmenu">{L_DAYS}</a> ]</span></td>
  </tr>
</table></form>

<table width="100%" cellpadding="1" cellspacing="1" border="0" align="center">
  <tr>
        <td><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
  </tr>
</table>

<table width="100%" cellpadding="1" cellspacing="1" border="0" align="center" class="forumline">
  <tr>
        <th colspan="5">{L_RECENT_TITLE}</th>
  </tr>
  <!-- BEGIN recent -->
  <tr> 
        <td class="{recent.ROW_CLASS}" align="center" valign="middle"><img src="{recent.TOPIC_FOLDER_IMG}" alt="{recent.TOPIC_FOLDER_ALT}" title="{recent.TOPIC_FOLDER_ALT}" /></td>
        <td class="{recent.ROW_CLASS}" nowrap="nowrap"><span class="topictitle">{recent.NEWEST_IMG}{recent.TOPIC_TYPE}<a href="{recent.U_VIEW_TOPIC}" class="topictitle">{recent.TOPIC_TITLE}</a></span>
                                                                                       <span class="gensmall">{recent.GOTO_PAGE}<br />{recent.FIRST_TIME}{recent.FIRST_AUTHOR}</span></td>
        <td class="{recent.ROW_CLASS}" width="10%" align="left"><span class="postdetails">&nbsp;{recent.L_REPLIES}: {recent.REPLIES}
                                                                                                   <br />&nbsp;{recent.L_VIEWS}: {recent.VIEWS}</span></td>
        <td class="{recent.ROW_CLASS}" width="25%" nowrap="nowrap">&nbsp;<span class="genmed"><a href="{recent.U_VIEW_FORUM}" class="genmed">{recent.FORUM_NAME}</span></td>
        <td class="{recent.ROW_CLASS}" align="right" width="20%" nowrap="nowrap"><span class="gensmall"> {recent.LAST_URL} {recent.LAST_TIME}&nbsp;&nbsp;
                                                                                                                             <br />{recent.LAST_AUTHOR}</span>&nbsp;&nbsp;</td>
  </tr>
  <!-- END recent -->
  <!-- BEGIN switch_no_topics -->
  <tr>
        <td colspan="5" class="row1" align="center" height="28"><span class="gen"><i>{L_NO_TOPICS}</i></span></td>
  </tr>
  <!-- END switch_no_topics -->
  <tr>
        <td colspan="5" class="catBottom" height="28">&nbsp;</td>
  </tr>
</table>

<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr> 
        <td><span class="nav">{PAGE_NUMBER}</span></td>
        <td align="right"><span class="nav">{PAGINATION}</span></td>
  </tr>
</table>
und die recent.php

Code: Alles auswählen

<?php
// ############         Edit below         ########################################
$topic_length = '40';	// length of topic title
$topic_limit = '10';	// limit of displayed topics per page
$forum_ids = '';		// Exceptional Forums, eg. '2,4,10' (note: the script has its own permission checking, so you can leave this variable blank)
$set_mode = 'today';	// set default mode ('today', 'yesterday', 'last24', 'lastweek', 'lastXdays')
$set_days = '3';		// set default days (used for lastXdays mode)
// ############         Edit above         ########################################

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path .'extension.inc');
include($phpbb_root_path .'common.'.$phpEx);

$userdata = session_pagestart($user_ip, PAGE_RECENT);
init_userprefs($userdata);

$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;

if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
	$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
}
else
{
	$mode = $set_mode;
}

if( isset($HTTP_GET_VARS['amount_days']) || isset($HTTP_POST_VARS['amount_days']) )
{
	$amount_days = ( isset($HTTP_GET_VARS['amount_days']) ) ? $HTTP_GET_VARS['amount_days'] : $HTTP_POST_VARS['amount_days'];
}
else
{
	$amount_days = $set_days;
}

$page_title = $lang['Recent_topics'];
include($phpbb_root_path .'includes/page_header.'.$phpEx);

$sql_auth = "SELECT * FROM ". FORUMS_TABLE;
if( !$result_auth = $db->sql_query($sql_auth) )
{
	message_die(GENERAL_ERROR, 'could not query forums information.', '', __LINE__, __FILE__, $sql_auth);
}
$forums = array();
while( $row_auth = $db->sql_fetchrow($result_auth) )
{
	$forums[] = $row_auth;
}
$db->sql_freeresult($result_auth);

$is_auth_ary = array();
$is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata, $forums);

if( $forum_ids == '' )
{
	$except_forums = '\'start\'';
}
else
{
	$except_forums = $forum_ids;
}

for ($i = 0; $i < count($forums); $i++)
{
	if (( $forums[$i]['forum_password'] != '' )  or ($forums[$i]['forum_password'] != '') or (!$is_auth_ary[$forums[$i]['forum_id']]['auth_view']))
	{
		if ($except_forums == '\'start\'')
		{
			$except_forums = $forums[$i]['forum_id'];
		}
		else
		{
			$except_forums .= ',' . $forums[$i]['forum_id'];
		}
	}
}

$where_forums = 't.forum_id NOT IN ('. $except_forums .')';
$sql_start = "SELECT t.*, p.poster_id, p.post_username AS last_poster_name, p.post_id, p.post_time, f.forum_name, f.forum_id, u.username AS last_poster, u.user_id AS last_poster_id, u2.username AS first_poster, u2.user_id AS first_poster_id, p2.post_username AS first_poster_name
	        FROM ". TOPICS_TABLE ." t, ". POSTS_TABLE ." p
		LEFT OUTER JOIN ". POSTS_TABLE ." p2 ON p2.post_id = t.topic_first_post_id
		LEFT OUTER JOIN ". FORUMS_TABLE ." f ON p.forum_id = f.forum_id
		LEFT OUTER JOIN ". USERS_TABLE ." u ON p.poster_id = u.user_id
		LEFT OUTER JOIN ". USERS_TABLE ." u2 ON u2.user_id = t.topic_poster
	        WHERE $where_forums AND p.post_id = t.topic_last_post_id AND ";
$sql_end = "  ORDER BY t.topic_last_post_id DESC LIMIT $start, $topic_limit";

switch( $mode )
{
	case 'today':
		$sql = $sql_start ."FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = 0". $sql_end;
		$template->assign_vars(array('STATUS' => $lang['Recent_today']));
		$where_count = "$where_forums AND FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = 0";
		$l_mode = $lang['Recent_title_today'];
		break;

	case 'yesterday':
		$sql = $sql_start ."FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = -1". $sql_end;
		$template->assign_vars(array('STATUS' => $lang['Recent_yesterday']));
		$where_count = "$where_forums AND FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = -1";
		$l_mode = $lang['Recent_title_yesterday'];
		break;

	case 'last24':
		$sql   = $sql_start ."UNIX_TIMESTAMP(NOW()) - p.post_time < 86400". $sql_end;
		$template->assign_vars(array('STATUS' => $lang['Recent_last24']));
		$where_count = "$where_forums AND UNIX_TIMESTAMP(NOW()) - p.post_time < 86400";
		$l_mode = $lang['Recent_title_last24'];
		break;

	case 'lastweek':
		$sql  = $sql_start ."UNIX_TIMESTAMP(NOW()) - p.post_time < 691200". $sql_end;
		$template->assign_vars(array('STATUS' => $lang['Recent_lastweek']));
		$where_count = "$where_forums AND UNIX_TIMESTAMP(NOW()) - p.post_time < 691200";
		$l_mode = $lang['Recent_title_lastweek'];
		break;

	case 'lastXdays':
		$sql    = $sql_start ."UNIX_TIMESTAMP(NOW()) - p.post_time < 86400 * $amount_days". $sql_end;
		$template->assign_vars(array('STATUS' => sprintf($lang['Recent_lastXdays'], $amount_days)));
		$where_count = "$where_forums AND UNIX_TIMESTAMP(NOW()) - p.post_time < 86400 * $amount_days";
		$l_mode = sprintf($lang['Recent_title_lastXdays'], $amount_days);
		break;

	default:
		$message = $lang['Recent_wrong_mode'] .'<br /><br />'. sprintf($lang['Recent_click_return'], '<a href="'. append_sid("recent.$phpEx") .'">', '</a>') .'<br />'. sprintf($lang['Click_return_index'], '<a href="'. append_sid("index.$phpEx") .'">', '</a>');
		message_die(GENERAL_MESSAGE, $message);
		break;
}
if( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'could not obtain main information.', '', __LINE__, __FILE__, $sql);
}
$line = array();
while( $row = $db->sql_fetchrow($result) )
{
	$line[] = $row;
}
$db->sql_freeresult($result);
		
$template->set_filenames(array('body' => 'recent_body.tpl'));

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

$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_t']) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f']) : array();
for( $i = 0; $i < count($line); $i++ )
{
	$forum_id = $line[$i]['forum_id'];
	$forum_url = append_sid("viewforum.$phpEx?". POST_FORUM_URL ."=$forum_id");
	$topic_id = $line[$i]['topic_id'];
	$topic_url = append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=$topic_id");

	$word_censor = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $line[$i]['topic_title']) : $line[$i]['topic_title'];
	$topic_title = ( strlen($line[$i]['topic_title']) < $topic_length ) ? $word_censor : substr(stripslashes($word_censor), 0, $topic_length) .'...';

	$topic_type =  ( $line[$i]['topic_type'] == POST_ANNOUNCE ) ? $lang['Topic_Announcement'] .' ': '';
	$topic_type .= ( $line[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE ) ? $lang['Topic_global_announcement'] .' ': '';
	$topic_type .= ( $line[$i]['topic_type'] == POST_STICKY ) ? $lang['Topic_Sticky'] .' ': '';
	$topic_type .= ( $line[$i]['topic_vote'] ) ? $lang['Topic_Poll'] .' ': '';

	$views = $line[$i]['topic_views'];
	$replies = $line[$i]['topic_replies'];
	if( ( $replies + 1 ) > $board_config['posts_per_page'] )
	{
		$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
		$goto_page = ' [ ';
		$times = '1';
		for( $j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'] )
		{
			$goto_page .= '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=". $topic_id ."&start=$j") .'">'. $times .'</a>';
			if( $times == '1' && $total_pages > '4' )
			{
				$goto_page .= ' ... ';
				$times = $total_pages - 3;
				$j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
			}
			else if( $times < $total_pages )
			{
				$goto_page .= ', ';
			}
			$times++;
		}
		$goto_page .= ' ] ';
	}
	else
	{
		$goto_page = '';
	}

	if( $line[$i]['topic_status'] == TOPIC_LOCKED )
	{
		$folder = $images['folder_locked'];
		$folder_new = $images['folder_locked_new'];
	}
	else if( $line[$i]['topic_type'] == POST_ANNOUNCE )
	{
		$folder = $images['folder_announce'];
		$folder_new = $images['folder_announce_new'];
	}
	else if( $line[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE )
	{
		$folder = $images['folder_global_announce'];
		$folder_new = $images['folder_global_announce_new'];
	}
	else if( $line[$i]['topic_type'] == POST_STICKY )
	{
		$folder = $images['folder_sticky'];
		$folder_new = $images['folder_sticky_new'];
	}
	else
	{
		if( $replies >= $board_config['hot_threshold'] )
		{
			$folder = $images['folder_hot'];
			$folder_new = $images['folder_hot_new'];
		}
		else
		{
			$folder = $images['folder'];
			$folder_new = $images['folder_new'];
		}
	}

	$newest_img = '';
	if( $userdata['session_logged_in'] )
	{
		if( $line[$i]['post_time'] > $userdata['user_lastvisit'] ) 
		{
			if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all']) )
			{
				$unread_topics = true;
				if( !empty($tracking_topics[$topic_id]) )
				{
					if( $tracking_topics[$topic_id] >= $line[$i]['post_time'] )
					{
						$unread_topics = false;
					}
				}
				if( !empty($tracking_forums[$forum_id]) )
				{
					if( $tracking_forums[$forum_id] >= $line[$i]['post_time'] )
					{
						$unread_topics = false;
					}
				}
				if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all']) )
				{
					if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] .'_f_all'] >= $line[$i]['post_time'] )
					{
						$unread_topics = false;
					}
				}

				if( $unread_topics )
				{
					$folder_image = $folder_new;
					$folder_alt = $lang['New_posts'];
					$newest_img = '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=$topic_id&view=newest") .'"><img src="'. $images['icon_newest_reply'] .'" alt="'. $lang['View_newest_post'] .'" title="'. $lang['View_newest_post'] .'" border="0" /></a> ';
				}
				else
				{
					$folder_image = $folder;
					$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
					$newest_img = '';
				}
			}
			else
			{
				$folder_image = $folder_new;
				$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
				$newest_img = '<a href="'. append_sid("viewtopic.$phpEx?". POST_TOPIC_URL ."=$topic_id&view=newest") .'"><img src="'. $images['icon_newest_reply'] .'" alt="'. $lang['View_newest_post'] .'" title="'. $lang['View_newest_post'] .'" border="0" /></a> ';
			}
		}
		else 
		{
			$folder_image = $folder;
			$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
			$newest_img = '';
		}
	}
	else
	{
		$folder_image = $folder;
		$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
		$newest_img = '';
	}
			
	$first_time = create_date($board_config['default_dateformat'], $line[$i]['topic_time'], $board_config['board_timezone']);
	$first_author = ( $line[$i]['first_poster_id'] != ANONYMOUS ) ? '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $line[$i]['first_poster_id']) .'">'. $line[$i]['first_poster'] .'</a>' : ( ($line[$i]['first_poster_name'] != '' ) ? $line[$i]['first_poster_name'] : $lang['Guest'] );
	$last_time = create_date($board_config['default_dateformat'], $line[$i]['post_time'], $board_config['board_timezone']);
	$last_author = ( $line[$i]['last_poster_id'] != ANONYMOUS ) ? '<a href="'. append_sid("profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $line[$i]['last_poster_id']) .'">'. $line[$i]['last_poster'] .'</a>' : ( ($line[$i]['last_poster_name'] != '' ) ? $line[$i]['last_poster_name'] : $lang['Guest'] );
	$last_url = '<a href="'. append_sid("viewtopic.$phpEx?". POST_POST_URL .'='. $line[$i]['topic_last_post_id']) .'#'. $line[$i]['topic_last_post_id'] .'"><img src="'. $images['icon_latest_reply'] .'" alt="'. $lang['View_latest_post'] .'" title="'. $lang['View_latest_post'] .'" border="0" /></a>';

	$template->assign_block_vars('recent', array(
		'ROW_CLASS' => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'],
		'TOPIC_TITLE' => $topic_title,
		'TOPIC_TYPE' => $topic_type,
		'GOTO_PAGE' => $goto_page,
		'L_VIEWS' => $lang['Views'],
		'VIEWS' => $views,
		'L_REPLIES' => $lang['Replies'],
		'REPLIES' => $replies,
		'NEWEST_IMG' => $newest_img,
		'TOPIC_FOLDER_IMG' => $folder_image,
		'TOPIC_FOLDER_ALT' => $folder_alt,
		'FIRST_TIME' => sprintf($lang['Recent_first'], $first_time),
		'FIRST_AUTHOR' => sprintf($lang['Recent_first_poster'], $first_author),
		'LAST_TIME' => $last_time,
		'LAST_AUTHOR' => $last_author,
		'LAST_URL' => $last_url,
		'FORUM_NAME' => $line[$i]['forum_name'],
		'U_VIEW_FORUM' => $forum_url,
		'U_VIEW_TOPIC' => $topic_url,
	));
}

$sql = "SELECT count(t.topic_id) AS total_topics FROM ". TOPICS_TABLE ." t , ". POSTS_TABLE ." p
           WHERE $where_count AND p.post_id = t.topic_last_post_id";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'error getting total topics.', '', __LINE__, __FILE__, $sql);
}
if( $total = $db->sql_fetchrow($result) )
{
	$total_topics = $total['total_topics'];
	$pagination = generate_pagination("recent.$phpEx?amount_days=$amount_days&mode=$mode", $total_topics, $topic_limit, $start) .'&nbsp;';
}

if( $total_topics == '0' )
{
	$template->assign_block_vars('switch_no_topics', array());
}

$template->assign_vars(array(
	'L_RECENT_TITLE' => ( $total_topics == '1' ) ? sprintf($lang['Recent_title_one'], $total_topics, $l_mode) : sprintf($lang['Recent_title_more'], $total_topics, $l_mode),
	'L_TODAY' => $lang['Recent_today'],
	'L_YESTERDAY' => $lang['Recent_yesterday'],
	'L_LAST24' => $lang['Recent_last24'],
	'L_LASTWEEK' => $lang['Recent_lastweek'],
	'L_LAST' => $lang['Recent_last'],
	'L_DAYS' => $lang['Recent_days'],
	'L_SELECT_MODE' => $lang['Recent_select_mode'],
	'L_SHOWING_POSTS' => $lang['Recent_showing_posts'],
	'L_NO_TOPICS' => $lang['Recent_no_topics'],
	'AMOUNT_DAYS' => $amount_days,
	'FORM_ACTION' => append_sid("recent.$phpEx"),
	'PAGINATION' => ( $total_topics != '0' ) ? $pagination : '',
	'PAGE_NUMBER' => ( $total_topics != '0' ) ? sprintf($lang['Page_of'], ( floor( $start / $topic_limit ) + 1 ), ceil( $total_topics / $topic_limit )) : '',
));

$template->pparse('body');
include($phpbb_root_path .'includes/page_tail.'.$phpEx);
?>
Lighty
Mitglied
Beiträge: 73
Registriert: 16.09.2006 18:59
Kontaktdaten:

Beitrag von Lighty »

Jopp, und das funzt ! ;)
Riesen Dank an Dich @metty84 !!!

( ... dann brauch ich ja den Text nicht mehr einfügen, war gerade dabei gewesen ) ;)
Antworten

Zurück zu „phpBB 2.0: Mod Support“