<?
$posts = 5;
$showtopiclength = 20;
$topiclength = 35;
$forumexclude = "38,37,71,73,69,44,75,108,74";
$interval = 2;
$showtime = 0;
$datedisplay = 'd F Y';
$timedisplay = 'h:i A T';
require "forum/conf_global.php";
$mysql = mysql_connect( $INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass'] /*, $INFO['sql_driver'] */ );
if ( !$mysql ) {
die( "<b>mysql_connect()</b>: ". mysql_error() );
}
$select_db = mysql_select_db( $INFO['sql_database'], $mysql );
if ( !$select_db ) {
die( "<b>mysql_select_db()</b>: ". mysql_error() );
}
if ($forumexclude <> "") {
$getposts = mysql_query("SELECT posts, last_poster_name, last_poster_id, title, tid, forum_id, last_post FROM ibf_topics WHERE (forum_id NOT IN ($forumexclude)) ORDER BY last_post DESC LIMIT $posts");
}
else {
$getposts = mysql_query("SELECT posts, last_poster_name, last_poster_id, title, tid, forum_id, last_post FROM ibf_topics ORDER BY last_post DESC LIMIT $posts");
}
while ( $post = mysql_fetch_array($getposts)) {
$post[full_title] = $post[title];
if ($showtopiclength == 1 AND strlen($post[full_title]) > $topiclength) {
$post[short_title] = substr($post[full_title],0,$topiclength);
$post[short_title] = $post[short_title]."...";
}
else {
$post[short_title] = $post[full_title];
}
$posted_on = date($datedisplay, $post[last_post]);
$today_date = date($datedisplay, time());
if ($showtime == 0) {
$showtimediff = timediff($interval,time(),$post[last_post]);
$datefield = $showtimediff;
}
else {
// If it was posted today, we want to display "Today, hh:mm AMPM"
If ($posted_on == $today_date) {
$datefield = "Aian";
$datefield = $datefield . ", " . date($timedisplay, $post[last_post]);
}
// If it was posted yesterday, we want to display "Yesterday, hh:mm AMPM"
elseif (date('d F Y',strtotime("-1 day")) == $posted_on) {
$datefield = "A?a?a";
$datefield = $datefield . ", " . date($timedisplay, $post[last_post]);
}
else {
$datefield = $posted_on;
}
}
echo
<<<EOD
<div style="margin: 4px;">
<b><u>Тема:</u></b>
<a target="_blank" href="$INFO[board_url]/index.php?showtopic=$post[tid]">$post[short_title]</a> <br>
<b><u>Последен отговор:</u></b>
<a target="_blank" href="$INFO[board_url]/index.php?showtopic=$post[tid]&view=getnewpost">$post[last_poster_name]</a> </div>
EOD;
}
function timediff($interval, $starttime, $endtime) {
$timediff = $starttime - $endtime;
$days=intval($timediff/86400);
$remain=$timediff%86400;
$hours=intval($remain/3600);
$remain=$remain%3600;
$mins=intval($remain/60);
$secs=$remain%60;
$pluraldays = ($days < 2) ? " Ден " : " Дни ";
$pluralhours = ($hours < 2) ? " Час " : " Часа ";
$pluralmins = ($mins < 2) ? " Минута " : " Минути ";
$pluralsecs = ($secs < 2) ? " Секунда " : " Секунди ";
$hourcount = ($hours == 0) ? 1 : 0;
$minscount = ($mins == 0) ? 1 : 0;
$secscount = ($secs == 0) ? 1 : 0;
if ($days > 1) {
$timediff = $posted_on;
}
elseif ($days == 1) {
$timediff = "Преди ".$days." и ".$hours.$pluralhours."";
}
else {
if ($interval == 0) { $timediff = "Преди ".$days.$pluraldays."";} // show only days
elseif ($interval == 1) { $timediff = "Преди ".$hours.$pluralhours." ";} // show only hours
elseif ($interval == 2) { $timediff = "Преди ".$mins.$pluralmins."";} // show only minutes
elseif ($interval == 3) { $timediff = "Преди ".$secs.$pluralsecs."";} // show only seconds
elseif ($interval == 4) { // show hours and minutes
if ($hourcount) { $timediff = "Преди ".$mins." ".$pluralmins." "; }
else if ($minscount) { $timediff = "Преди ".$hours." ".$pluralhours.""; }
else { $timediff = "Преди ".$hours.$pluralhours." ".$mins." ".$pluralmins.""; }
}
elseif ($interval == 5) { // show hours and seconds
if ($hourscount) { $timediff = "Преди ".$secs." ".$pluralsecs.""; }
else if ($secscount) { $timediff = "Преди ".$hours." ".$pluralhours.""; }
else { $timediff = "Преди ".$hours.$pluralhours." ".$sec."".$pluralsecs.""; }
}
elseif ($interval == 6) { // show minutes and seconds
if ($minscount == 1) { $timediff = "Преди".$secs." ".$pluralsecs.""; }
else if ($secscount == 1 ) { $timediff = "Преди".$mins." ".$pluralmins.""; }
else { $timediff = "Преди ".$mins.$pluralmins." и ".$secs." ".$pluralsecs.""; }
}
else { // show hours, minutes and seconds
$timediff = "Преди".$hours.$pluralhours.", ".$mins." ".$pluralmins." e".$secs." ".$pluralsecs."";
}
}
return $timediff;
}
?>