<?php 
if(!defined('IN_DEMOSOSO')) {
	exit('this is wrong page,please back to homepage');
}
$res = array();
$query = @htmlentitdm($_GET['query']);

$sqlwhere = wherecatev($maincate,$v);

$queryV = '';
if($query<>'') $queryV = " and title like '%$query%' ";
 
$sql="select id,title,kvsm,dateedit  from ".TABLE_NODE." where  $sqlwhere and sta_visible='y' and sta_noaccess='n' $queryV  $andlangbh    order by id";
//echo $sql;
$total= getnum($sql);

$total_pager= getnum($sql);
//echo $query; echo $total;
 
if($query=='') {
	 
//---------------------

 if($page>$total) $page=$total;
  $start=($page-1)*$maxline;
 if($start<0) $start=0;
//--------------
 
 $sql="select id,title,kvsm,dateedit  from ".TABLE_NODE." where  $sqlwhere and sta_visible='y' and sta_noaccess='n'  $andlangbh    order by pos desc,dateedit desc limit $start,$maxline";

  //echo $sql;
    /*begin page roll*/
     $total_pager = get_numrows($sql);
 }
     if($total_pager>0){
     	$res['datares'] = 'yes';
		$res['total'] = $total;
		
		 $result = getall($sql);
		// pre($result);
		 
		 foreach( $result as  $k=>$v){
			$res['data'][$k]['id'] =  $v['id'];
			$res['data'][$k]['title'] =  $v['title'];
			$res['data'][$k]['kvsm'] =  UPLOADPATHIMAGE.$v['kvsm'];
			$dateedit  = substr($v['dateedit'],0,10);
			$res['data'][$k]['dateedit'] = $dateedit;
	 

		}

		
	}
		else {
			  $res['datares'] = 'no';
		}

 


	  if($test=='y') pre($res);
		// pre($_SERVER['HTTP_ACCEPT']);
		$jsonv = json_encode($res,JSON_UNESCAPED_UNICODE);
		 //echo $jsonv;
		  echo api_jsonp_encode($jsonv); 
 

		
?>