Kod: Zaznacz cały
<?php
// USTAWIENIA
// (t) ilość wyświetlanych tematów
$default_tps_number = 5;
// (w) długość tytułów
$default_tps_title_width = 30;
// (s) miejsce, w jakim zostanie otwarty temat; topic - początek tematu, post - ostatni post
$default_tps_show = 'post';
// (p) miejsce wyświetlania tematu
$default_tps_display_place = '_blank';
// (a) pokazuje liczbe odpowiedzi; 1 - tak, 0 - nie
$default_show_answers = 0;
// (u) pokazuje autora postu; 2 - ostatniego, 1 - pierwszego, 0 - nie pokazuje autora
$default_show_posters = 1;
// (f) pokazuje nazwę forum, w którym znajduję się temat; 1 - tak, 0 - nie
$default_show_forumname = 1;
$db = 'konuss_baza';
$dbhost = 'host';
$dbuser = 'user';
$dbpasswd = 'pass';
$table_prefix = 'forum_';
$adres_forum = 'http://ekonin.net/forum';
// adres forum bez końcowego "/", z "http://" na początku
// KONIEC USTAWIEN
if($_GET['t']) { $t = $_GET['t']; } else { $t = $default_tps_number; }
if($_GET['w']) { $w = $_GET['w']; } else { $w = $default_tps_title_width; }
if($_GET['s']) { $s = $_GET['s']; } else { $s = $default_tps_show; }
if($_GET['p']) { $p = $_GET['p']; } else { $p = $default_tps_display_place; }
if($_GET['a']) { $a = $_GET['a']; } else { $a = $default_show_answers; }
if($_GET['u']) { $u = $_GET['u']; } else { $u = $default_show_posters; }
if($_GET['f']) { $f = $_GET['f']; } else { $f = $default_show_forumname; }
if(!$db = mysql_connect($dbhost, $dbuser, $dbpasswd)) {
echo '<b>Błąd!</b><br />Nie można połączyć się z bazą!';
}
if(!mysql_select_db($dbname, $db)) {
echo '<b>Błąd!</b><br />Nie można wybrać bazy danych!';
}
$result = mysql_query("SELECT * FROM `". $table_prefix ."topics` WHERE forum_id ORDER BY `topic_last_post_id` DESC LIMIT 0 , ". $t);
while($row = mysql_fetch_array($result))
{
$out_title = '<a href="'. $adres_forum .'/viewtopic.php?f='. $row['forum_id'] .'&t='. $row['topic_id'] .'" target="'. $p .'" class="foncik_w15">'. $row['topic_title'] .'</a>';
if( $f ) {
$result_forum = mysql_query("SELECT `forum_name` FROM `". $table_prefix ."forums` WHERE `forum_id` = '". $row['forum_id'] ."'");
$row['forum_name'] = mysql_result($result_forum, 0);
$out_forum = '[<a href="'. $adres_forum .'/viewforum.php?f='. $row['forum_id'] .'" target="'. $p .'" class="foncik_w15">'. $row['forum_name'] .'</a>] ';
}
if( $a ) {
$out_answers = ' <font size=1 color=white face="Tahoma">('. $row['topic_replies'] .')</font>';
}
if( $u ) {
switch($u) {
case 2:
$poster[0] = $row['topic_last_poster_id'];
$poster[1] = $row['topic_last_poster_name'];
break;
case 1:
$poster[0] = $row['topic_poster'];
$poster[1] = $row['topic_first_poster_name'];
break;
}
$out_poster = ' [<a href="'. $adres_forum .'/memberlist.php?mode=viewprofile&u='. $poster[0] .'" target="'. $p .'" class="foncik_w15">'. $poster[1] .'</a>]';
}
if(strlen($row['topic_title']) > $w) { $row['topic_title'] = substr($row['topic_title'], 0, $w); }
$output .= '<span class="block_czarny">Dział: '.$out_forum . '<br> Tytuł: '.$out_title .'...'. $out_answers . '<br> Autor: '. $out_poster .'<br /></span>
<table width="235" border="0" cellspacing="0" cellpadding="0" style="padding-top: 5px; padding-bottom: 5px;" align="center">
<tr>
<td background="theme/Default/img/stopa.gif" height="1"></td>
</tr>
</table>';
}
echo $output;
?>