SIR 코멘트, 조회수 top, bottom 10 소스에 대한 문의입니다 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

SIR 코멘트, 조회수 top, bottom 10 소스에 대한 문의입니다 정보

SIR 코멘트, 조회수 top, bottom 10 소스에 대한 문의입니다

본문

아래 소스를 적용하여 조회수TOP10과  코멘트TOP10을 적용하였는데..
 
첨부한 이미지의 빨간색 동그라미 속처럼 1 이라는 숫자가 나오는데...
뭔지 모르겠습니다..
나타나지 않게 하고 싶은데... 어디를 수정해야 되는지 알고 싶습니다..
 

<?
include_once("./_common.php");

define("_CO_INDEX_", TRUE);

$html_title = "커뮤니티";
$g4[title] = "" . $html_title;
include_once("./_head.php");

$before_day = 1;
$before_time = date("Y-m-d H:i:s", $g4[server_time] - (86400 * $before_day));

$list1 = array();

$top1 = $top2 = 10;
$gr_id = "community";
$sql = " select bo_table, bo_notice from $g4[board_table]
          where gr_id = '$gr_id'
            and bo_use_search = 1 ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
    $sql2 = " select * from $g4[write_prefix]$row[bo_table]
              where wr_comment > -1
                and wr_datetime >= '$before_time' ";
    $result2 = sql_query($sql2);
    while ($row2 = sql_fetch_array($result2))
    {
        $key = substr('00000'.$row2[wr_comment],-5) . '-' . $row2[wr_id];
        $list1[$key][subject] = conv_subject($row2[wr_subject],40,'…');
        $list1[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
        $list1[$key][bo_table] = $row[bo_table];
        $list1[$key][wr_id] = $row2[wr_id];
        $list1[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
        $list1[$key][comment] = $row2[wr_comment];
        $list1[$key][comment_cnt] = "($row2[wr_comment])";

        $key = substr('00000'.$row2[wr_hit],-5) . '-' . $row2[wr_id];
        $list2[$key][subject] = conv_subject($row2[wr_subject],40,'…');
        $list2[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
        $list2[$key][bo_table] = $row[bo_table];
        $list2[$key][wr_id] = $row2[wr_id];
        $list2[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
        $list2[$key][wr_hit] = $row2[wr_hit];
        $list2[$key][hit] = "($row2[wr_hit])";
    }
}
$list3 = $list1;
$list4 = $list2;

krsort($list1);
krsort($list2);

ksort($list3);
ksort($list4);

$latest_skin_path = "$g4[path]/skin/latest/basic";
?>


<table width="710" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="345" valign=top>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="29" height="38"><img src="<?=$latest_skin_path?>/img/board_title_left.gif" width="29" height="38"></td>
            <td background="<?=$latest_skin_path?>/img/board_title_bg.gif">  <font
                style='font-family:돋움; font-size:9pt; color:#696969;'><strong>코멘트 BOTTOM <?=$top1?></strong></font> </td>
            <td width="60" align="right" background="<?=$latest_skin_path?>/img/board_title_bg.gif"></td>
            <td width="19"><img src="<?=$latest_skin_path?>/img/board_title_right.gif" width="19" height="38"></td>
        </tr>
        </table>

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list3 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="40" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="9" height="13"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list3[$key][icon_reply] . " ";
                echo "<a href='{$list3[$key][href]}'>";
                if ($list3[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list3[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list3[$key][subject]}</font>";
                echo "</a>";

                if ($list3[$key][comment_cnt])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list3[$key][comment_cnt]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>

        <? if (count($list3) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table>
    </td>
    <td width="20"> </td>
    <td width="345" valign=top>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="29" height="38"><img src="<?=$latest_skin_path?>/img/board_title_left.gif" width="29" height="38"></td>
            <td background="<?=$latest_skin_path?>/img/board_title_bg.gif">  <font
                style='font-family:돋움; font-size:9pt; color:#696969;'><strong>조회수 BOTTOM <?=$top1?></strong></font> <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>(hit)</span> </td>
            <td width="60" align="right" background="<?=$latest_skin_path?>/img/board_title_bg.gif"></td>
            <td width="19"><img src="<?=$latest_skin_path?>/img/board_title_right.gif" width="19" height="38"></td>
        </tr>
        </table>

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list4 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="40" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="9" height="13"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list4[$key][icon_reply] . " ";
                echo "<a href='{$list4[$key][href]}'>";
                if ($list4[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list4[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list4[$key][subject]}</font>";
                echo "</a>";

                if ($list4[$key][hit])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list4[$key][hit]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>

        <? if (count($list4) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table>
    </td>

</tr></table>
<br><br>


<table width="710" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="345" valign=top>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="29" height="38"><img src="<?=$latest_skin_path?>/img/board_title_left.gif" width="29" height="38"></td>
            <td background="<?=$latest_skin_path?>/img/board_title_bg.gif">  <font
                style='font-family:돋움; font-size:9pt; color:#696969;'><strong>코멘트 TOP <?=$top1?></strong></font> </td>
            <td width="60" align="right" background="<?=$latest_skin_path?>/img/board_title_bg.gif"></td>
            <td width="19"><img src="<?=$latest_skin_path?>/img/board_title_right.gif" width="19" height="38"></td>
        </tr>
        </table>

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list1 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="40" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="9" height="13"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list1[$key][icon_reply] . " ";
                echo "<a href='{$list1[$key][href]}'>";
                if ($list1[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list1[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list1[$key][subject]}</font>";
                echo "</a>";

                if ($list1[$key][comment_cnt])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list1[$key][comment_cnt]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>

        <? if (count($list1) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table>
    </td>
    <td width="20"> </td>
    <td width="345" valign=top>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="29" height="38"><img src="<?=$latest_skin_path?>/img/board_title_left.gif" width="29" height="38"></td>
            <td background="<?=$latest_skin_path?>/img/board_title_bg.gif">  <font
                style='font-family:돋움; font-size:9pt; color:#696969;'><strong>조회수 TOP <?=$top1?></strong></font> <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>(hit)</span> </td>
            <td width="60" align="right" background="<?=$latest_skin_path?>/img/board_title_bg.gif"></td>
            <td width="19"><img src="<?=$latest_skin_path?>/img/board_title_right.gif" width="19" height="38"></td>
        </tr>
        </table>

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list2 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="40" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="9" height="13"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list2[$key][icon_reply] . " ";
                echo "<a href='{$list2[$key][href]}'>";
                if ($list2[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list2[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list2[$key][subject]}</font>";
                echo "</a>";

                if ($list2[$key][hit])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list2[$key][hit]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>

        <? if (count($list2) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table>
    </td>

</tr></table>
<br><br>

<?
include_once("./_tail.php");
?>
  • 복사

댓글 전체

깜찍한악마 //님 답변감사합니다...

그런데 모르솔라님이신가요..깜찍한 악마 라는 닉네임으로 바꾸셨나요...
홈페이지를 항상 부러워 했었는데...

저의 홈피에 현재 조회수 톱10과 코멘트 톱10을 적용한것은 잘 했는데..

이상하게 맨마직막에 1 이라는 숫자가 붙어서 고민입니다,,,,,
최신글을 불러올 때에는 아래와 같이 입력

<?=latest_top("스킨명", "게시판명", 출력갯수, 제목길이, "형식", "기간");?>

형식 - 코멘트순(C), 조회순(H), 랜덤(R), 추천(G), 비추천(N), 기본 최신글(공백이거나 B)
기간 - 최근 몇일간의 입력된 글을 뽑아옴. 100이라 입력하면 최근 100일간의 글을 뽑아옴

ex)
지난 30일동안 가장 많이 본 게시물
<?=latest_top("basic", "morssola", 5, 40, "H", "30");?>

지난 30일동안 가장 많이 추천을 받은 게시물
<?=latest_top("basic", "morssola", 5, 40, "G", "30");?>

지난 30일동안 가장 많이 코멘트가 등록된 게시물
<?=latest_top("basic", "morssola", 5, 40, "C", "30");?>



latest.lib.php 파일을 아래 디렉토리에 올려주세요.
/그누보드/lib/
<?
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function latest_top($skin_dir="", $bo_table, $rows=10, $subject_len="", $brch="", $time="", $options="")
{
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름

if ($brch == "H")          // 넘어온 값이 "H" 즉 hit 일때
    $brch = "wr_hit";      // hit 순으로 쿼리
elseif ($brch == "C")      // 넘어온 값이 "C" 즉 comment 일때
    $brch ="wr_comment"; // comment 순으로 쿼리
elseif ($brch == "R")        //넘온값이 "R" 즉 random 일때
    $brch = "rand()";            // 랜덤 쿼리
elseif ($brch == "G")        //넘온값이 "G" 즉 추천 일때
    $brch = "wr_good";            // 추천 쿼리
elseif ($brch == "N")        //넘온값이 "N" 즉 비추천 일때
    $brch = "wr_nogood";            // 비추천 쿼리
elseif ($brch == "B")        //넘온값이 "B" 즉 기본 최신글 일때
    $brch = "wr_id";            // 기본 최신글 쿼리
else                                  // 넘어온값이 없거나 그이외 일때
    $brch = "wr_id";        // 걍 최근순으로 쿼리

    $sql = " select * from $tmp_write_table where wr_is_comment = 0 and wr_datetime between date_sub(now(), interval $time day) and now() order by $brch desc limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
답변을 금새 3개나 올리셨네요..

그런데 위의 내용대로 하면 게시판마다 조회수와  코멘트 등이 많은 게시물을 뽑는 것인가요..

현재 그누보드의 관리자님께서 올리신것은 그룹별로 조회수 톱10과 코멘트 톱10을 뽑는 것이거든요..
저도 그룹별로 뽑고 싶고요...

현재 뽑는것 까지는 잘 되었는데...맨마직막의 알수 없는 숫자 때문에 고민중입니다...

하여간 위의 내용은 잘 스크랩했으며 현재 게시판별로도 뽑을 필요가 있어서 적용중입니다..
현재 위의 소스중 일부인 아래와 같이 사용하고 있습니다...
전체가 아니라 문제가 생겼을까요...
<?
include_once("./_common.php");

define("_CO_INDEX_", TRUE);

$html_title = "커뮤니티";
$g4[title] = "" . $html_title;
include_once("./_head.php");

$before_day = 1;
$before_time = date("Y-m-d H:i:s", $g4[server_time] - (86400 * $before_day));

$list1 = array();

$top1 = $top2 = 10;
$gr_id = "$s_gr_id";
$sql = " select bo_table, bo_notice from $g4[board_table]
          where gr_id = '$gr_id'
            and bo_use_search = 1 ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
    $sql2 = " select * from $g4[write_prefix]$row[bo_table]
              where wr_comment > -1
                and wr_datetime >= '$before_time' ";
    $result2 = sql_query($sql2);
    while ($row2 = sql_fetch_array($result2))
    {
        $key = substr('00000'.$row2[wr_comment],-5) . '-' . $row2[wr_id];
        $list1[$key][subject] = conv_subject($row2[wr_subject],40,'…');
        $list1[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
        $list1[$key][bo_table] = $row[bo_table];
        $list1[$key][wr_id] = $row2[wr_id];
        $list1[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
        $list1[$key][comment] = $row2[wr_comment];
        $list1[$key][comment_cnt] = "($row2[wr_comment])";

        $key = substr('00000'.$row2[wr_hit],-5) . '-' . $row2[wr_id];
        $list2[$key][subject] = conv_subject($row2[wr_subject],40,'…');
        $list2[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
        $list2[$key][bo_table] = $row[bo_table];
        $list2[$key][wr_id] = $row2[wr_id];
        $list2[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
        $list2[$key][wr_hit] = $row2[wr_hit];
        $list2[$key][hit] = "($row2[wr_hit])";
    }
}
$list3 = $list1;
$list4 = $list2;

krsort($list1);
krsort($list2);

ksort($list3);
ksort($list4);

$latest_skin_path = "$g4[path]/skin/latest/basic";
?>

<script language="JavaScript">
function right_tab01(no) {
if (no == "") no = "1";
document.all.rigth1.style.display = 'none';
document.all.rigth2.style.display = 'none';
eval("document.all.rigth"+no+".style.display = '';");
}
</script>
<!-- 조회 -->
<span id="rigth1" style="display:">
 <table width=146 border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td>
    <table width="100%"  border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td><a href="//" onmouseover="javascript:right_tab01(1);"><img src="<?=$gnusr[img_btn]?>/top10_onview.gif"></a></td>
<td><a href="//" onmouseover="javascript:right_tab01(2);"><img src="<?=$gnusr[img_btn]?>/top10_ofcomments.gif"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list2 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="10" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="4" height="7"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list2[$key][icon_reply] . " ";
                echo "<a href='{$list2[$key][href]}'>";
                if ($list2[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list2[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list2[$key][subject]}</font>";
                echo "</a>";

                if ($list2[$key][hit])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list2[$key][hit]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>

        <? if (count($list2) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table> </td>
</tr>
</table>
</span>
<!-- 코멘트 -->
<span id="rigth2" style="display:none">
<table width=146 border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td>
<table width="100%"  border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td><a href="//" onmouseover="javascript:right_tab01(1);"><img src="<?=$gnusr[img_btn]?>/top10_ofview.gif"></a></td>
<td><a href="//" onmouseover="javascript:right_tab01(2);"><img src="<?=$gnusr[img_btn]?>/top10_oncomments.gif"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <?
        $i=0;
        foreach($list4 as $key=>$value) {
            if ($i++>=($top1-1)) break;
        ?>
        <tr>
            <td width="10" height="35" align="center" valign="middle" background="<?=$latest_skin_path?>/img/board_bg_line.gif"><img src="<?=$latest_skin_path?>/img/board_icon.gif" width="4" height="7"></td>
            <td background="<?=$latest_skin_path?>/img/board_bg_line.gif" style='word-break:break-all;'>
                <?
                echo $list4[$key][icon_reply] . " ";
                echo "<a href='{$list4[$key][href]}'>";
                if ($list4[$key][is_notice])
                    echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list4[$key][subject]}</strong></font>";
                else
                    echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$list4[$key][subject]}</font>";
                echo "</a>";

                if ($list4[$key][hit])
                    echo " <span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$list4[$key][hit]}</span>";
                ?>
            </td>
        </tr>
        <? } ?>
        <? if (count($list4) == 0) { ?>
        <tr><td colspan=2 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td></tr>
        <? } ?>
        </table> </td>
</tr>
</table>
</span>
© SIRSOFT
현재 페이지 제일 처음으로