<?php

/**
 * author_list key 방식으로 변경
 * 2025년 7월 29일
 */

$akey = (isset($_GET['akey']) && is_numeric($_GET['akey'])) ? $_GET['akey'] : '';

if($akey == '') {
    exit;
}
 
// 기자의 다른 기사보기 리스트
include_once("./_common.php");
$mode = "";
$mcode='repoter'; 

$mc1 = $mc2 = "";

$news_skin_path = $g4['path']."/skin/news/".$minfo['m_skin']; // 스킨 경로
if ($minfo['m_skin'] == "") {
    $news_skin_path = $g4['path']."/skin/news/basic"; // 스킨 경로
}

$call_rows = 20; // 호출쿼리

$sql_common = " from kc_article ";
$sql_search = "where w_status=6 and author_key = '$akey' ";

if ($stx) { 
    $sql_search .= " and ( ";
    switch ($sfl) 
    {
        case "w_subj" : $sql_search .= " ($sfl like '%$stx%') "; break;
        default :	$sql_search .= " ($sfl like '%$stx%') ";	break;
    }
    $sql_search .= " ) ";
    
    if($mc2 == "")	$all_list = "<a href='".$g4['news_path']."/list_r.php?mcode=$mc1'><img src='".$g4['admin_path']."/img/btn_list_all.gif' border='0'></a>";
    else $all_list = "<a href='".$g4['news_path']."/list_r.php?mcode=$mc2'><img src='".$g4['admin_path']."/img/btn_list_all.gif' border='0'></a>";
}

if (!$sst) { 
    $sst = "w_webprint_datetime"; 
    $sod = "desc"; 
} 
$sql_order = " order by $sst $sod ";

//=========== 페이징을 위한 Query 시작=================
$sql = " select count(*) as cnt $sql_common $sql_search ";
$row = sql_fetch($sql);
$total_count = $row['cnt']; 

//$page_rows = $config['cf_page_rows'];
$page_rows = $call_rows;
$total_page  = ceil($total_count / $page_rows);  // 전체 페이지 계산
if (!$page) {
    $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
}

// 검색시 검색리스트로 돌아오기 위한 로직추가
if ($pgchk) {
    if ($pgchk > $total_page) {
        $page = $total_page;
    }
    if ($total_page == 0) {
        $page = 1;
    }
}

$from_record = ($page - 1) * $page_rows; // 시작 열을 구함
$nListorder = $total_count - (($page-1) * $page_rows) + 1; //게시물 일련번호추출

$pagelist = get_paging(10, $page, $total_page, "?akey=$akey&page=");
//=========== 페이징을 위한 Query 끝===================

//=========== 리스트를 뽑아오는 Query 시작=============
$sql = " select * ,(select s2_name from kc_section2 where s1_idx = w_section1 and s2_idx = w_section2 ) as section $sql_common $sql_search $sql_order limit $from_record, $page_rows ";
$result = sql_query($sql);
//=========== 리스트를 뽑아오는 Query 끝===============

//=========== 정렬에 사용하는 QUERY_STRING=============
$qstr2 = "sop=$sop";
//=========== 정렬에 사용하는 QUERY_STRING=============

for ($i=0; $row=sql_fetch_array($result); $i++) 
{ 
	//$list[$i] = $row;
	$list[$i] = get_list_news($row, 255, "");
	
	if ($stx != "")
	{ 
		$list[$i]['href'] = $g4['news_path']."/{$list[$i]['idx']}?".$qstr;
	}	
	else
	{
		$list[$i]['href'] = $g4['news_path']."/{$list[$i]['idx']}";
	}	
}

include_once($g4['news_path']."/_head.php");

$g4['title'] = " 기사리스트 ";
$stx = get_text(stripslashes($stx));
include_once("$news_skin_path/list_r.skin.php");

include_once($g4['news_path']."/_tail.php");
?>