<?php

error_reporting(E_ERROR);
include('../common.php');
include('../sql.php');
$cache_ret = $AM_CACHE->am_get();
if (!$cache_ret){
$keyvalue = $_REQUEST['key'];
$keyvalue = urldecode($keyvalue);
$pagesize = $_REQUEST['pagesize'];
$page = $_REQUEST['page'];
if ($page=="")
	$page = 0;
if ($pagesize=="")
	$pagesize = 20;


if ($keyvalue=="")
	exit();

$query = search_list_1($keyvalue, $page, $pagesize, $pagesize);
$listmov = $_TD->FM($query);
// $listmov = $_TD->FM("SELECT amvod.*,amlist.list_name  FROM ".tname('vod')." amvod left join ".tname("list")." amlist on amlist.list_id=amvod.vod_cid  where vod_name like '%$keyvalue%' or vod_content like '%$keyvalue%' or vod_keywords like '%$keyvalue%' or vod_actor like '%$keyvalue%' or  vod_director like '%$keyvalue%'  order by vod_hits desc limit ".$page*$pagesize.",".$pagesize);

if(is_array($listmov))
{
	
	$obj = appmaker_listtackle($listmov);

	$query2 = search_list_2($keyvalue);
   $listcnt = $_TD->FM($query2);
//    $listcnt = $_TD->FM("SELECT count(*) as t FROM ".tname('vod')." where vod_name like '%$keyvalue%' or vod_content like '%$keyvalue%' or vod_keywords like '%$keyvalue%' or vod_actor like '%$keyvalue%' or  vod_director like '%$keyvalue%'  order by vod_hits desc ");
   $arr = array(
   'key' => $keyvalue,
	'keylist' => $obj,
	'count' => count($obj),
	'total' => intval($listcnt[0]['t'])

	);
	$str = myjsoncode($arr);
	 
}
$AM_CACHE->am_set($str);
}else{
	$str = $cache_ret;
}

$callback = $_REQUEST['callback'];
if ($callback=="")
	echo $str;
else
	echo $callback."(".$str.")";

?>