+++ (+/-)
function LastNotes($switch = 'F', $lmt = 5) {
if (($switch == 'F' || $switch == 'L') && $lmt > 0) {
if ($switch == 'F')
$sql = "SELECT COUNT(*) FROM forum WHERE type = 't'";
elseif ($switch == 'L')
$sql = "SELECT COUNT(*) FROM library_texts";
$total = mysql_result(mysql_query($sql), 0);
if ($total) {
if ($switch == 'F') {
$out = '<div class="bmenu">Последние <b>'. $lmt .'</b> тем форума</div>';
$sql = "SELECT forum.id, forum.text, users.name FROM forum JOIN users ON forum.user_id = users.id AND type = 't' ORDER BY time DESC LIMIT $lmt";
} else {
$out = '<div class="bmenu">Последние <b>'. $lmt .'</b> статей библиотеки</div>';
$sql = "SELECT id, uploader_id, uploader, name, count_views, count_comments FROM library_texts
WHERE premod = 1 ORDER BY time DESC LIMIT $lmt";
}
$res = mysql_query($sql) or die (mysql_error());
$i = 0;
while ($row = mysql_fetch_assoc($res)) {
if ($switch == 'F') {
$out .= ($i % 2 ? '<div class="list2">' : '<div class="list1">') .
'<a href="/forum/?id='. $row['id'] .'">'. $row['text'] .'</a> (' . $row['name'] . ')</div>';
} else {
$color_views = ($row['count_views'] > 0 ? 'green' : 'red');
$color_comments = ($row['count_comments'] > 0 ? 'green' : 'red');
$out .= ($i % 2 ? '<div class="list2">' : '<div class="list1">') .
'<a href="/library/?id='. $row['id'] .'">'. $row['name'] .'</a>' .
'<div class="topmenu">просмотры: <span style="color:'. $color_views .'">'.
$row['count_views'] .'</span> комментарии: <span style="color:'. $color_comments .'">'.
$row['count_comments'] .'</span> автор:
<a href="users/profile.php?user=' . $row['uploader_id'] . '">' . $row['uploader'] . '</a></div></div>';
}
$i++;
}
} else {
$out = '<div class="gmenu">Пока что ' . ($switch == 'F' ? 'форум пустой' : 'библиотека пустая') . '</div>';
}
} else {
$out = FALSE;
}
return $out;
}