<?php

error_reporting(E_ERROR);
include('../common.php');
include('../sql.php');
$cache_ret = $AM_CACHE->am_get();
if (!$cache_ret){
$pagesize = $_REQUEST['pagesize'];
$page = $_REQUEST['page'];
$classpath = $_REQUEST['classpath'];

if ($page=="")
	$page = 0;
if ($pagesize=="")
	$pagesize = 20;
if ($classpath=="")
	exit();


$query = itemlist_1($classpath);
$listpro = $_TD->FM($query);
// $listpro = $_TD->FM("SELECT * FROM ".tname('list')." where list_id=$classpath ");

if (intval($listpro[0]['list_pid'])==0){
// 	$listmov = dbfun();
	$query2 = itemlist_2($classpath, $page, $pagesize, $pagesize);
	
	$listmov = $_TD->FM($query2);
// 	$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_cid in (select list_id from ".tname("list")." where list_pid=$classpath) or vod_cid=$classpath  order by vod_addtime desc,vod_gold desc limit ".$page*$pagesize.",".$pagesize);
	$query3 = itemlist_3($classpath);
	$listcnt = $_TD->FM($query3);
// 	$listcnt = $_TD->FM("SELECT count(*) as t FROM ".tname('vod')." where vod_cid in (select list_id from ".tname("list")." where list_pid=$classpath) or vod_cid=$classpath");
}else{
	//子类
	$query4 = itemlist_4($classpath, $page, $pagesize, $pagesize);
	
	$listmov = $_TD->FM($query4);
// 	$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_cid=$classpath  order by vod_addtime desc,vod_gold desc limit ".$page*$pagesize.",".$pagesize);
	$query5 = itemlist_5($classpath);
	
	$listcnt = $_TD->FM($query5);
// 	$listcnt = $_TD->FM("SELECT count(*) as t FROM ".tname('vod')." where vod_cid=$classpath");
}

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

	$arr = array(
		'classpath' => $classpath,
		'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.")";
?>