사이트의 모든글에서 베스트 축출하기. 정보
사이트의 모든글에서 베스트 축출하기.첨부파일
본문
예) 사이트의 모든글에서 특정기간설정하여 베스트글 출력하기
 --> http://www.sksna.com  좌측 하단스킨에 적용.
구현은 여러가지가 있으나..  속도를 고려해야 하기때문에 최종적으로 아래와 같은 방식으로 하였습니다.
--------------------------------------------------------
1. db sql  추가.
----------------
-- 2007.12.16  모든 테이블 게시글 관리 추가
-- 
-- 테이블 구조 `g4_site_count`
-- 
DROP TABLE IF EXISTS `g4_site_count`;
CREATE TABLE `g4_site_count` (
  `bn_id` int(11) NOT NULL auto_increment,
  `bo_table` varchar(20) NOT NULL default '',
  `wr_id` int(11) NOT NULL default '0',
  `wr_parent` int(11) NOT NULL default '0',
  `bn_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
  `mb_id` varchar(20) NOT NULL default '',
  `wr_subject` varchar(255) NOT NULL default '',
  `wr_content` text NOT NULL,
  `wr_hit` int(11) NOT NULL default '0',
  `ne_1` varchar(255) NOT NULL default '',
  `ne_2` varchar(255) NOT NULL default '',
  `ne_3` varchar(255) NOT NULL default '',
  `ne_4` varchar(255) NOT NULL default '',
  `ne_5` varchar(255) NOT NULL default '',
  `ne_6` varchar(255) NOT NULL default '',
  `ne_7` varchar(255) NOT NULL default '',
  `ne_8` varchar(255) NOT NULL default '',
  `ne_9` varchar(255) NOT NULL default '',
  `ne_10` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`bn_id`),
  KEY `mb_id` (`mb_id`)
) ;
-----------------------
2. g4/config.php  중간에 아래 코드 추가
$g4['site_count']            = "g4_site_count";  //모든글 관리 테이블
3. g4/write_update.php   변경.  ( 소스참고 )
4. g4/delete.php  변경  (소스참고)
5. g4/delete_all.php 변경 (소스참고)
6. g4/board.php 152 라인에 히트 추가. (소스참고)
---------------------------
        //$g4['site_count'] 
        sql_query(" update $g4[site_count]  set wr_hit = wr_hit + 1 where wr_id = '$wr_id' and bo_table='$bo_table' ");
---------------------------
7. g4/bbs/count_hit.php  최신글 축출스킨 예시.
------------------------------------
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
$c_w = 7;
$c_h = 7;
//제목길이
if(!$row_len){
$row_len = 18;
}
 
 if(!$num_rows){
 $num_rows = 10;  //출력수량
 }
 $hit_subject = "<b>BEST 10 HIT</b>";
 $latest_skin_path = $g4[bbs_path];
/*****검색할 날짜 지정****/
$day_s_ago =  10;  // 검색 시작일
$day_e_ago  = 0;   //검색 종료일
/*****검색할 날짜 지정****/
$day_s = 60*60*24*$day_s_ago;
$day_e = 60*60*24*$day_e_ago;
$start_t = time() - $day_s;
$g4[time_s_ago] = date("Y-m-d H:i:s",$start_t);
$end_t = time() - $day_e;
$g4[time_e_ago] = date("Y-m-d H:i:s",$end_t);
  $ss_mct      = " where bn_datetime between  '$g4[time_s_ago]' AND '$g4[time_e_ago]' ";
  $sql         = " select * from {$g4[site_count]}  $ss_mct order by wr_hit desc limit 0, $num_rows "; 
  $result    = sql_query($sql);
  $total_count     = mysql_num_rows($result);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="<?=$c_w?>" height="<?=$c_h?>"><img src="<?=$latest_skin_path?>/img_count/line_1.gif"></td>
    <td background="<?=$latest_skin_path?>/img_count/line_2.gif"></td>
    <td width="<?=$c_w?>" height="<?=$c_h?>"><img src="<?=$latest_skin_path?>/img_count/line_3.gif" ></td>
</tr>
<tr>
    <td background="<?=$latest_skin_path?>/img_count/line_4.gif"  width="<?=$c_w?>" ></td>
    <td>
<div style="padding:5px; background-color:#efefef;">
<strong><?=$hit_subject?> [<font color="red"><?=$day_s_ago?>일</font>]</strong>
</div>
<table width=100% cellpadding=0 cellspacing=0>
<?
for ($si=1;$list = sql_fetch_array($result);$si++) 
{
    $wr_id        = $list[wr_id];
    $wr_subject   = cut_str($list[wr_subject], $row_len,"");
    $list_href   = "$g4[bbs_path]/board.php?bo_table={$list[bo_table]}&wr_id={$wr_id}";
 
 ?>
 <tr><td height="20"><img src='<?=$latest_skin_path?>/img_count/hit_<?=$si?>.gif' align=absmiddle>
            <?
            echo "<a href='{$list_href}'>";
            if ($list[$i]['is_notice'])
                echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$wr_subject}</strong></font>";
            else
                echo "<font style='font-family:돋움; font-size:9pt; color:#6A6A6A;'>{$wr_subject}</font>";
            echo "</a>";
   echo "(".$list[wr_hit].")"
            ?>
     </td>
 </tr>
    <tr><td bgcolor=#EBEBEB height=1></td></tr>
<? } ?>
<? if ($total_count == 0) { ?><tr><td align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>
</table>
    </td>
    <td background="<?=$latest_skin_path?>/img_count/line_5.gif"  width="<?=$c_w?>" ></td>
</tr>
<tr>
    <td  width="<?=$c_w?>" height="<?=$c_h?>"><img src="<?=$latest_skin_path?>/img_count/line_6.gif" ></td>
    <td background="<?=$latest_skin_path?>/img_count/line_7.gif" height="<?=$c_h?>"></td>
    <td  width="<?=$c_w?>" height="<?=$c_h?>"><img src="<?=$latest_skin_path?>/img_count/line_8.gif" ></td>
</tr>
</table>
6
댓글 11개


잘 되네요 ^^

그룹 베스트사진 추출하는 소스는 안되나요
부탁드립니다
잘 활용할께요^^




