무와보

지난달 게시글 순위 5위를 뽑는 소스에서 제가 한 해석좀 봐주세요 ^^

· 2009-01-29 (목) 20:05:07 · 938
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=10588

활용팁에서 지난달의 게시글,코멘트,로그인 순위5위를 뽑는 것을 공부중입니다.
여기 소스를 보면 지난달을 뽑는 것으로 나오는데요..
혹시 이 부분을 지난달이 아닌 지난 일주일이나 지난 보름, 또는 지난 하루 등 다른 방법으로 뽑을 수 있는지를 모르겠네요..

제가 보기에 그 부분에 해당하는 소스는 이것 같은데요..

$year = date("Y");
$month = date("m");
$day = date("d");

$tmp = mktime(0, 0, 0, $month - 1 , $day, $year, 0);
$lastmonth = date("Y-m",$tmp);

이 부분에서 $month - 1 < 이 부분이 지난 달을 뽑아오는 것이 맞나요?
그렇다면 $day - 15 이런 식으로 쓰게되면 지난 15일 것을 뽑아오게 되는건가요?

정확하게 구문을 이해할 능력이 안돼서 자꾸 들여다봐도 잘 모르겠습니다 ^^
고수님들의 정확한 해석 부탁드립니다 ^^

아래 소스는 이 소스의 원문 소스 전체입니다..

//Rank Top5 추출
function Rank5($skin_dir="", $rows=5, $subject_len=8, $options="")
{
global $g4;
global $g_id;

$year = date("Y");
$month = date("m");
$day = date("d");

$tmp = mktime(0, 0, 0, $month - 1 , $day, $year, 0);
$lastmonth = date("Y-m",$tmp);

if ($skin_dir)
$skin_path = "$g4[path]/skin/top10/$skin_dir";
else
$skin_path = "$g4[path]/skin/top10/rank5";

$Writelist = array();
$Commentlist = array();
$Visitlist = array();

//글쓰기 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime like '" . $lastmonth . "%' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id = a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 10 ";
$sql_order = " order by cnt desc ";


$sql = " SELECT b.mb_nick,count(*) cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0,$rows";

$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{

$Writelist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Writelist[$i][mb_cnt] = $row[cnt];
}

//코멘트 랭킹
$sql_common = " from $g4[board_new_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.bn_datetime like '" . $lastmonth . "%' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.wr_id <> a.wr_parent ";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and b.mb_level < 10 ";
$sql_order = " order by cnt desc ";

$sql = " SELECT b.mb_nick,count(*)cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0, $rows";

$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{

$Commentlist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Commentlist[$i][mb_cnt] = $row[cnt];
}

//방문자 랭킹
$sql_common = " from $g4[point_table] a, $g4[member_table] b "; //where mb_level < 10 ";
$sql_common = $sql_common . " where a.po_datetime like '" . $lastmonth . "%' ";
$sql_common = $sql_common . " and a.mb_id <> ''";
$sql_common = $sql_common . " and a.mb_id = b.mb_id ";
$sql_common = $sql_common . " and po_rel_table = '@login' ";
$sql_common = $sql_common . " and b.mb_level < 10 ";
$sql_order = " order by cnt desc ";

$sql = " SELECT b.mb_nick,count(*)cnt
$sql_common
group by b.mb_nick
$sql_order
limit 0, $rows";

$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{

$Visitlist[$i][mb_nick] = conv_subject($row[mb_nick], $subject_len, "..");
$Visitlist[$i][mb_cnt] = $row[cnt];
}

ob_start();
include "$skin_path/rank.skin.php";
$content = ob_get_contents();
ob_end_clean();

return $content;
}
댓글을 작성하시려면 로그인이 필요합니다.

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

+
제목 글쓴이 날짜 조회
09-01-30 조회 1,228
09-01-30 조회 1,086
09-01-30 조회 1,633
09-01-30 조회 1,157
09-01-30 조회 836
09-01-30 조회 910
09-01-30 조회 1,053
09-01-30 조회 963
09-01-30 조회 810
09-01-30 조회 1,046
09-01-30 조회 834
09-01-30 조회 1,046
09-01-29 조회 929
09-01-29 조회 1,015
09-01-29 조회 872
09-01-29 조회 984
09-01-29 조회 939
09-01-29 조회 1,004
09-01-29 조회 818
09-01-29 조회 869