<?php // (2020.10.23, 차재복, Cha Jae Bok, http://www.ktword.co.kr)
# 세션 설정
// 세션 스타트 (매 웹페이지 마다 필요)
session_start();
# db 접속
include "../base_utils/db_conn.php";
# 전송 입력 매개변수
$no = $_GET['no'];
if ( isset($_REQUEST[no]) and !empty($no) and !is_numeric($no) or $no<0 ) exit; // 해킹방지 (수치>0)
$id = $_GET['id'];
if ( isset($_REQUEST[id]) and !empty($id) and !is_numeric($id) or $id<0 ) exit; // 해킹방지 (수치>0)
$id = substr($id,0,10); // 해킹 방지 (글자 수 제한)
if(empty($id)) $id=0; // 디폴트
$type = $_GET['type'];
if ( isset($_REQUEST[type]) and !empty($type) and !is_numeric($type) or $type<0 ) exit; // 해킹방지 (수치>0)
# json 형식 헤더 알림
header('content-type: application/json; charset=utf-8');
# type별로 퀴리 실행 및 출력 리턴
// code
if ($type == '1') {
$query = "select no,type,code,date_format(date,'%Y-%m-%d') as date from code where id={$id} order by id_seq";
$result = mysqli_query($dbi,$query);
if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
while ($matched = mysqli_fetch_assoc($result)) {
$arr[] = array('no'=>$matched[no],'type'=>$matched[type],'code'=>$matched[code],'date'=>$matched[date]);
}
echo json_encode($arr, JSON_UNESCAPED_UNICODE);
// manual
} else if ($type == '2') {
$query = "select no,id_name,txt,date_format(date,'%Y-%m-%d') as date,id_seq from manual where id={$id} order by id_seq";
$result = mysqli_query($dbi,$query);
if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
while ($matched = mysqli_fetch_assoc($result)) {
$arr[] = array('no'=>$matched[no],'type'=>$matched[id_name],'code'=>$matched[txt],'date'=>$matched[date],
'seq'=>$matched[id_seq]);
}
if (count($arr) > 0) echo json_encode($arr, JSON_UNESCAPED_UNICODE);
else echo false;
}
?>
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"