<?
/*
실험주소
http://www.owllab.com/ios/smartreports.php
*/

header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/xml; charset=UTF-8");

include_once ("session.php");
include_once ("dbcon_light.php");

$table = "report_demo";
$result = -1;
$msg = "죄송합니다.\n시스템장애로 작업을 취소했습니다.\n나중에 다시 시도해 주세요.";

$sql = " select rowid,writer,subject,reg_date,reg_id,type,publish,cryptid,latitude,longitude,content from $table where publish>0 ";
if ($keyword!="") {
	$sql .= " and subject like '%".$keyword."%' ";
}

if ($lastid!="") {
	$sql .= " and rowid < '$lastid' ";
}

$sql .= " limit 10 ";
$rs = mysql_select_list($sql);
if (count($rs[rowid])>0) {
	$result = 1;
	$msg = "데이터를 가져왔습니다.";
}

?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">"; ?>
<lists>
	<info>
		<result><? echo $result;?></result>
		<totrec><? echo count($rs[rowid]);?></totrec>
		<msg><![CDATA[<? echo $msg;?>]]></msg>
	</info>
	<? for ($i=0;$i<count($rs[rowid]);$i++) { ?>  
	<data>
		<rowid><? echo $rs[rowid][$i];?></rowid>
		<writer><![CDATA[<? echo $rs[writer][$i];?>]]></writer>
		<subject><![CDATA[<? echo $rs[subject][$i];?>]]></subject>
		<reg_date><? echo $rs[reg_date][$i];?></reg_date>
		<reg_id><![CDATA[<? echo $rs[reg_id][$i];?>]]></reg_id>
		<type><![CDATA[<? echo $rs[type][$i];?>]]></type>
		<publish><? echo $rs[publish][$i];?></publish>
		<cryptid><? echo md5($rs[rowid][$i]);?></cryptid>
		<latitude><? echo $rs[latitude][$i];?></latitude>
		<longitude><? echo $rs[longitude][$i];?></longitude>
		<content><![CDATA[<? echo $rs[content][$i];?>]]></content>
	</data>
	<? }// for i?>
</lists>