<?php
	$start=microtime(true);
	require substr(dirname(__FILE__),0,-7).'/include/common.inc.php';
	
	$_GET=array_map('htmlspecialchars',$_GET);
	$moduleid=isset($moduleid)?intval($moduleid):0;

	$k=htmlspecialchars(trim($k));

	if(!$k)
	{
		header('location:'.$LA['siteurl']);exit();
	}

	$userid=intval($userid);
	$page=max(1,intval($page));
	$k=explode(" ",$k);

	$where=$_siteid?'siteid IN('.implode(',',$siteidobj->getchildid($_siteid)).') AND isdeleted=0 AND status=1':'isdeleted=0 AND status=1';
	$where.=$moduleid?' AND moduleid='.$moduleid:'';
	
	$s=array();
	foreach($k as $key => $_k)
	{		
		if(trim($_k))
		{
			$s[$key]=' title LIKE \'%'.$_k.'%\' ';
		}		
	}
	
	if($s)
	{
		$s=implode("OR",$s);
		$where.=' AND ('.$s.')';
	}
	$k=implode(" ",$k);
	$where.=$userid?' AND userid='.$userid:'';

	$orderby='updatetime DESC';

	include_once SYSTEM_ROOT.'include/datalist.class.php';
	$datalist = new datalist();
	$page=max(isset($page)?intval($page):1,1);
	$pagesize=10;
	$data=$datalist->getlist(LA_PRE.'content',$where,$orderby,$page,$pagesize);
	$LA['pagestring']=$datalist->pagestring;
	$totalcount=$datalist->totalcount;
	$cacheobj->set($key,$data);

	$expire=round(microtime(true)-$start,4);
	include template('list','search');
?>