-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch_helper.php
36 lines (32 loc) · 1.47 KB
/
search_helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$headerGiven = 'Content-Type: text/xml; charset=utf-8';
include 'class/common.php';
$GR = new COMMON;
$GR->dbConn();
// 결과값 주기 @sirini
if($_POST['searchText']) {
$boardID = $_POST['boardID'];
$test = $GR->getArray("select view_level from ".$dbFIX."board_list where id='".$boardID."';");
if($test['view_level'] != 1 && $test['view_level'] > $_SESSION['level']){
//일단은 게시물보기 권한으로 판단. 차후 권한 세분화 필요 by pico
$xml = '<?xml version="1.0" encoding="utf-8"?><lists>';
$xml .= '<item no="0"><title>권한이 없습니다.</title></item></lists>';
echo $xml; die();
}
$searchText = $_POST['searchText'];
$searchOption = $_POST['searchOption'];
$searchText = str_replace(array('_', '%', '\\'), array('\_', '\%', '\\\\\\\\'), $searchText);
$xml = '<?xml version="1.0" encoding="utf-8"?><lists>';
$test = $GR->getArray('select no from '.$dbFIX.'bbs_'.$boardID.' where '.$searchOption." like '%".$searchText."%' limit 1");
if(!$test['no']) {
$xml .= '<item no="0"><title>검색 결과가 없습니다.</title></item></lists>';
die($xml);
}
$result = $GR->query('select no, subject from '.$dbFIX.'bbs_'.$boardID.' where '.$searchOption." like '%".$searchText."%' limit 10");
while($list = $GR->fetch($result)) {
$xml .= '<item no="'.$list['no'].'"><title>'.htmlspecialchars($GR->unescape($list['subject'])).'</title></item>';
}
$xml .= '</lists>';
echo $xml;
}
?>