게시판의 게시일을 기준으로

게시판의 게시일을 기준으로

QA

게시판의 게시일을 기준으로

답변 6

본문

게시판을 게시일을 기준으로 금년도만 나타내는거랑

작년이전은 한꺼번에 나타내는거랑

두개로 나누려고하는데 어느부분을 어떻게 수정해야하나요?

latest.lib.php과 list.php을 수정해서 두가지로 만들면 될것이라고 생각하는데요

좀 어렵군요 부탁드립니다


function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $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; // 게시판 테이블 전체お名前
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num 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;
} ​
 
 
 
list.php
 
 
 
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$board_skin_path/list.skin.php");
$is_category = false;
if ($board[bo_use_category])
{
    $is_category = true;
    $category_location = "./board.php?bo_table=$bo_table&sca=";
    $category_option = get_category_option($bo_table); // SELECT OPTION 태그로 넘겨받음
}
$sop = strtolower($sop);
if ($sop != "and" && $sop != "or")
    $sop = "and";
// 分類 선택 또는 검색어가 있다면
$stx = trim($stx);
if ($sca || $stx)
{
    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);
    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 使用)
    $sql = " select MIN(wr_num) as min_wr_num from $write_table ";
    $row = sql_fetch($sql);
    $min_spt = $row[min_wr_num];
    if (!$spt) $spt = $min_spt;
    $sql_search .= " and (wr_num between '".$spt."' and '".($spt + $config[cf_search_part])."') ";
    // 원글만 얻는다. (코멘트의 内容도 검색하기 위함)
    $sql = " select distinct wr_parent from $write_table where $sql_search ";
    $result = sql_query($sql);
    $total_count = mysql_num_rows($result);
}
else
{
    $sql_search = "";
    $total_count = $board[bo_count_write];
}
$total_page  = ceil($total_count / $board[bo_page_rows]);  // 전체 페이지 계산
if (!$page) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $board[bo_page_rows]; // 시작 열을 구함
// 관리자라면 CheckBox 보임
$is_checkbox = false;
if ($member[mb_id] && ($is_admin == "super" || $group[gr_admin] == $member[mb_id] || $board[bo_admin] == $member[mb_id]))
    $is_checkbox = true;
// 정렬에 使用하는 QUERY_STRING
$qstr2 = "bo_table=$bo_table&sop=$sop";
if ($board[bo_gallery_cols])
    $td_width = (int)(100 / $board[bo_gallery_cols]);
// 정렬
// 인덱스 필드가 아니면 정렬에 使用하지 않음
//if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {
if (!$sst)
{
    if ($board[bo_sort_field])
        $sst = $board[bo_sort_field];
    else
        $sst  = "wr_num, wr_reply";
    $sod = "";
}
else {
    // 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16)
    // 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요.
    // $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
    $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
}
if ($sst)
    $sql_order = " order by $sst $sod ";
if ($sca || $stx)
{
    $sql = " select distinct wr_parent from $write_table where $sql_search $sql_order limit $from_record, $board[bo_page_rows] ";
}
else
{
    $sql = " select * from $write_table where wr_is_comment = 0 $sql_order limit $from_record, $board[bo_page_rows] ";
}
$result = sql_query($sql);
// 년도 2자리
$today2 = $g4[time_ymd];
$list = array();
$i = 0;
if (!$sca && !$stx)
{
    $arr_notice = explode("\n", trim($board[bo_notice]));
    for ($k=0; $k<count($arr_notice); $k++)
    {
        if (trim($arr_notice[$k])=='') continue;
        $row = sql_fetch(" select * from $write_table where wr_id = '$arr_notice[$k]' ");
        if (!$row[wr_id]) continue;
        $list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);
        $list[$i][is_notice] = true;
        $i++;
    }
}
$k = 0;
while ($row = sql_fetch_array($result))
{
    // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
    if ($sca || $stx)
        $row = sql_fetch(" select * from $write_table where wr_id = '$row[wr_parent]' ");
    $list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);
    if (strstr($sfl, "subject"))
        $list[$i][subject] = search_font($stx, $list[$i][subject]);
    $list[$i][is_notice] = false;
    //$list[$i][num] = number_format($total_count - ($page - 1) * $board[bo_page_rows] - $k);
    $list[$i][num] = $total_count - ($page - 1) * $board[bo_page_rows] - $k;
    $i++;
    $k++;
}
$write_pages = get_paging($config[cf_write_pages], $page, $total_page, "./board.php?bo_table=$bo_table".$qstr."&page=");
$list_href = '';
$prev_part_href = '';
$next_part_href = '';
if ($sca || $stx)
{
    $list_href = "./board.php?bo_table=$bo_table";
    //if ($prev_spt >= $min_spt)
    $prev_spt = $spt - $config[cf_search_part];
    if (isset($min_spt) && $prev_spt >= $min_spt)
        $prev_part_href = "./board.php?bo_table=$bo_table".$qstr."&spt=$prev_spt&page=1";
    $next_spt = $spt + $config[cf_search_part];
    if ($next_spt < 0)
        $next_part_href = "./board.php?bo_table=$bo_table".$qstr."&spt=$next_spt&page=1";
}
$write_href = "";
if ($member[mb_level] >= $board[bo_write_level])
    $write_href = "./write.php?bo_table=$bo_table";
$nobr_begin = $nobr_end = "";
if (preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {
    $nobr_begin = "<nobr style='display:block; overflow:hidden;'>";
    $nobr_end   = "</nobr>";
}
// RSS 보기 使用에 체크가 되어 있어야 RSS 보기 가능 061106
$rss_href = "";
if ($board[bo_use_rss_view])
    $rss_href = "./rss.php?bo_table=$bo_table";
$stx = get_text(stripslashes($stx));
include_once("$board_skin_path/list.skin.php");​
 
 
 





 

이 질문에 댓글 쓰기 :

답변 6

<!-- 게시판 검색 시작 { -->
<fieldset id="bo_sch">
    <legend>게시물 검색</legend>

    <form name="fsearch" method="get">
    <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
    <input type="hidden" name="sca" value="<?php echo $sca ?>">
    <input type="hidden" name="sop" value="and">
    <label for="sfl" class="sound_only">검색대상</label>
    <select name="sfl" id="sfl">
        <option value="wr_subject"<?php echo get_selected($sfl, 'wr_subject', true); ?>>제목</option>
        <option value="wr_content"<?php echo get_selected($sfl, 'wr_content'); ?>>내용</option>
        <option value="wr_subject||wr_content"<?php echo get_selected($sfl, 'wr_subject||wr_content'); ?>>제목+내용</option>
        <option value="mb_id,1"<?php echo get_selected($sfl, 'mb_id,1'); ?>>회원아이디</option>
        <option value="mb_id,0"<?php echo get_selected($sfl, 'mb_id,0'); ?>>회원아이디(코)</option>
        <option value="wr_name,1"<?php echo get_selected($sfl, 'wr_name,1'); ?>>글쓴이</option>
        <option value="wr_name,0"<?php echo get_selected($sfl, 'wr_name,0'); ?>>글쓴이(코)</option>
    </select>
    <label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
    <input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx" class="frm_input required" size="15" maxlength="20">
    <input type="submit" value="검색" class="btn_submit">
    </form>
</fieldset>
<!-- } 게시판 검색 끝 -->​

 

 

위에서 날짜 추가 필드 값은 wr_datetime 입니다

 

후 bbs/list.php

 

 

if ($sca || $stx) {
    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows ";
} else {
    $sql = " select * from {$write_table} where wr_is_comment = 0 ";
    if(!empty($notice_array))
        $sql .= " and wr_id not in (".implode(', ', $notice_array).") ";
    $sql .= " {$sql_order} limit {$from_record}, $page_rows ";
}​

 

이부분을 수정 하시면 됩니다

소스를 만들어드리기는 머하고,,

 

if ($sca || $stx) {
    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit

 

에서  $sql_search} {$sql_order} 생성 되는 소스 즉 왠만 하면 기본소스를 건드는 거는 문제가 있으니

 

if($sfl=='wr_datetime'){ 경우

    $sql = " select distinct wr_parent from {$write_table} where 날짜를 검색 하기  limit

}else{

$sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit

}

이런 식으로 하시면 됫듯하네요

 

 

아래코드를 어떻게 바꾸어야 하나요? 검색보다 함수를 수정해서 불러서 쓰고싶은데요

시간비교하는 비교해서 소팅하는 코드를 모르겠어요


금년도글 추출 /작년이전글추출
function this_year($skin_dir="", $bo_table, $rows=10, $subject_len=40, $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; // 게시판 테이블 전체お名前
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num 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;
} 
​

이것도 될것같은데

왜 출력결과가 없는지 모르겠어요




 
$chktime = substr($g4[time_ymdhis], 0, 4);​
$sql = " select * from $tmp_write_table where wr_is_comment = 0 and substr(wr_datetime,0,4) = $chktime order by wr_num limit 0, $rows "; 
 
​ 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 10,637
© SIRSOFT
현재 페이지 제일 처음으로