Необходимо объеденить функцию 3х блоков в один. Комментарии должны сортироваться по дате и не должно быть деления на категории внутри блока.
Комменты для Voting, News и Files находятся в таблице Slaed_comments
А вот для модулей Album и Pages они лежат в таблицах Slaed_album_comments и Slaed_pages_comments соответственно.
Цена вопроса 500 р.
block-LastComments.php
<?php
if (!defined('BLOCK_FILE')) {
Header("Location: ../index.php");
exit;
}
global $prefix, $db;
$strip = 20; #обрезка текста комментария
$limit = 5; #количество комментариев (тем)
$raz_tag = "<b><i><u><s><li><tt>"; #разрешенные теги в комментарии. Набирать БЕЗ ПРОБЕЛОВ между тегами!
$result = $db->sql_query("SELECT MAX(id) AS maxid, modul, cid FROM ".$prefix."_comment GROUP BY modul, cid ORDER BY maxid DESC LIMIT $limit ");
while (list($maxid, $modul, $cid) = $db->sql_fetchrow($result)) {
$mmaxid[] = $maxid;
switch($modul) {
case "Voting":
$mVoting[] = "$cid";
break;
case "News":
$mNews[] = "$cid";
break;
case "Files":
$mFiles[] = "$cid";
break;
}
}
//--------- News
$const = sizeof ($mNews);
if ($const>0) {
$sql = " SELECT sid, title FROM ".$prefix."_stories WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " sid='".$mNews[$i]."' OR ";
}
$sql .= " sid='".$mNews[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtNews[$sid] = $title;
}
//--------- Voting
$const = sizeof ($mVoting);
if ($const>0) {
$sql = " SELECT poll_id, poll_title FROM ".$prefix."_survey WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " poll_id='".$mVoting[$i]."' OR ";
}
$sql .= " poll_id='".$mVoting[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtVoting[$sid] = $title;
}
//--------- Files
$const = sizeof ($mFiles);
if ($const>0) {
$sql = " SELECT lid, title FROM ".$prefix."_files WHERE ";
for ($i=0; $i<($const-1); $i++) {
$sql .= " lid='".$mFiles[$i]."' OR ";
}
$sql .= " lid='".$mFiles[$const-1]."' ";
$result = $db->sql_query($sql);
while(list($sid, $title) = $db->sql_fetchrow($result)) $mtFiles[$sid] = $title;
}
//---------- Сам блок
$sql = " SELECT cid, modul, date, name, comment FROM ".$prefix."_comment WHERE ";
for ($i=0; $i<($limit-1); $i++) {
$sql .= " id='".$mmaxid[$i]."' OR ";
}
$sql .= " id='".$mmaxid[$limit-1]."' ORDER BY id DESC ";
$i=0;
$result = $db->sql_query($sql);
while(list($cid, $modul, $date, $name, $comment) = $db->sql_fetchrow($result)) {
$i++;
$comment = preg_replace("#
092;[quote
092;](.*?)
092;[/quote
092;]#si","",$comment);
$comment = preg_replace("#
092;[php
092;](.*?)
092;[/php
092;]#si","",$comment);
$comment = preg_replace("#
092;[code
092;](.*?)
092;[/code
092;]#si","",$comment);
$comment = preg_replace("#
092;[hide
092;](.*?)
092;[/hide
092;]#si","",$comment);
$comment = cutstr(strip_tags(($comment), $raz_tag), $strip);
$date = formatTimestamp($date);
switch($modul) {
case "Voting":
$link = "<a href=
092;"index.php?name=Voting&op=poll_result&poll_id=$cid
092;" title=
092;"".$mtVoting[$cid]."
092;">";
break;
case "News":
$link = "<a href=
092;"index.php?name=News&file=article&sid=$cid
092;" title=
092;"".$mtNews[$cid]."
092;">";
break;
case "Files":
$link = "<a href=
092;"index.php?name=Files&op=view_file&lid=$cid
092;" title=
092;"".$mtFiles[$cid]."
092;">";
break;
}
$content .= "
<table width=
092;"100%
092;" border=
092;"0
092;" cellspacing=
092;"0
092;" cellpadding=
092;"0
092;">
<tr style=
092;"padding-top: 7px;
092;">
<td style=
092;"padding-right: 5px;
092;">"."$link"."<img src=
092;"images/blocks/$modul.gif
092;" border=
092;"0
092;"></a></td>
<td width=
092;"100%
092;"><b>$name</b> $date</td>
</tr>
<tr>
<td colspan=
092;"2
092;">"."$link"."$comment</a></td>
</tr>";
if ($i!=$limit) {$content .= "<tr><td colspan=
092;"2
092;"><hr width=
092;"90%
092;"></td></tr>";}
$content .= "</table>";
}
?>
block-Album_comments.php
<?php
if (!defined('BLOCK_FILE')) {
Header("Location: ../index.php");
exit;
}
global $prefix, $db;
$i = 1;
$result = $db->sql_query("SELECT pid,comment,name FROM ".$prefix."_album_comments ORDER BY cid DESC LIMIT 20");
while($data = $db->sql_fetchrow($result)) {
$content .= "
<table>
<tr>
<td width=
092;"15px
092;" class=
092;"bgcolor1
092;" align=
092;"center
092;">".$i++."</td>
<td width=
092;"100%
092;" class=
092;"bgcolor1
092;"><a href=
092;"albumpic-".$data['pid'].".html
092;" title=
092;"albumpic-".$data['pid'].".html
092;">".substr($data['comment'],0,18)."...</a></td>
</tr></table>";
}
?>
block-Pages_comments.php
<?php
if (!defined('BLOCK_FILE')) {
Header("Location: ../index.php");
exit;
}
global $prefix, $db;
$i = 1;
$result = $db->sql_query("SELECT pid,comment,name FROM ".$prefix."_pages_comments ORDER BY tid DESC LIMIT 10");
while($data = $db->sql_fetchrow($result)) {
$content .= "
<table>
<tr>
<td width=
092;"15px
092;" class=
092;"bgcolor1
092;" align=
092;"center
092;">".$i++."</td>
<td width=
092;"100%
092;" class=
092;"bgcolor1
092;"><a href=
092;"pagestop-".$data['pid'].".html
092;" title=
092;"pagestop-".$data['pid'].".html
092;">".substr($data['comment'],0,18)."...</a></td>
</tr></table>";
}
?>
SLAED CMS: 2 Lite
PHP: 5.2.12
Сервер в интернете