Просмотр поста

.
ДоХтор

NEIEN,

Исправил (+/-)
<?php

/*
-----------------------------------------------------------------
Последние темы на форуме
-----------------------------------------------------------------
*/
$set_forum = $datauser['set_forum'] ? unserialize($datauser['set_forum']) : array();
$settings = $set['lastThemes'] ? unserialize($set['lastThemes']) : array('totalThemes' => 3, 'timeCache' => 30);

if ($settings['totalThemes'] > 0 && !$set_forum['viewThemes']) {
$themesOut = '';
$file_cache = ROOTPATH .'files/cache/lastThemes.dat';

# В этом запросе была ошибка - после оператора LIMIT небыло пробела
$sql = "SELECT * FROM `forum` WHERE `type`='t' ". ($rights >= 7 ? "" : " AND `close` !='1'") .
"ORDER BY `time` DESC LIMIT ". $settings['totalThemes'];

# А такое написание запроса помогло выявить эту ошибку
$req = mysql_query($sql) or die(mysql_error());

$i = 0;
while (($res = mysql_fetch_assoc($req)) !== false) {
if ($res['close']) $themesOut .= '<div class="rmenu">';
else $themesOut .= $i % 2 ? '<div class="sist2"><a href="forum/index.php?id='. $res['id'] .'&amp;page='. $endPage .'">'
: '<div class="sist1"><a href="forum/index.php?id='. $res['id'] .'&amp;page='. $endPage .'">';
$nickUser = mysql_fetch_assoc(mysql_query("SELECT `from` FROM `forum` WHERE `type`='m' AND `close` != '1' AND `refid`= '".
$res['id'] ."' ORDER BY `time` DESC LIMIT 1"));
$totalPosts = mysql_result(mysql_query("SELECT COUNT(*)FROM `forum` WHERE `type`='m' AND `refid`='". $res['id'] ."'".
($rights >= 7 ? '' : "AND `close`!='1'")), 0);
$endPage = ceil($totalPosts / $kmess);
$icons = array(
(!$res['vip'] ? '<img src="../theme/'. $set_user['skin'] .'/images/op.gif" alt=""/>' : ''),
($res['vip'] ? '<img src="../theme/'. $set_user['skin'] .'/images/pt.gif" alt=""/>' : ''),
($res['realid'] ? '<img src="../theme/'. $set_user['skin'] .'/images/rate.gif" alt=""/>' : ''),
($res['edit']? '<img src="../theme/'. $set_user['skin'] .'/images/tz.gif" alt=""/>' : '')
);

$themesOut .= functions::display_menu($icons, '&#160;', '&#160;') . $res['text'] .'['. $totalPosts .']';
$themesOut .= '<div class="sub">Автор: '. $res['from'];
if (!empty($nickUser['from']))
$themesOut .= '&#160;/&#160;Последний: '. $nickUser['from'];
$themesOut .= '<span class="gray">('. functions::display_date($res['time']) .')</span></a></div></div>';
$i++;
}

if ($settings['timeCache'] > 0 && time() < (filemtime($file_cache) + $settings['timeCache'])) {
echo file_get_contents($file_cache);
} else {
echo $themesOut;
if ($settings['timeCache'] > 0)
file_put_contents($file_cache, $themesOut);
}
}