<?php

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

if ($page=="")
	$page = 0;
if ($pagesize=="")
	$pagesize = 6;
	
	
//总推荐
$query1 = indexlist_1($page, $pagesize, $pagesize);
$listmov = $_TD->FM($query1);
// $listmov = $_TD->FM("SELECT * FROM ".tname('vod')." order by vod_hits_day desc limit ".$page*$pagesize.",".$pagesize);

$list1 = appmaker_listtackle($listmov);

$jsonobj = array('groupid' => 'allfilm',
	'groupname' => '热门榜单',
	'group' => $list1,
	
	);
	
$json = array(
	'recomm' => array(
		$jsonobj
	)
);	
$query2 = indexlist_2();
$listcat = $_TD->FM($query2);
// $listcat = $_TD->FM("SELECT * FROM ".tname('list')." where list_pid=0 and list_status=1 and list_sid=1 order by list_id asc");



if(is_array($listcat))
{
	$jsoncount=0;
	foreach ($listcat as $key=>$val){
		$query3 = indexlist_3($val, $page, $pagesize, $pagesize);
		$listmov = $_TD->FM($query3);
// 		$listmov1 = $_TD->FM("SELECT * FROM ".tname('vod')." where vod_cid in (select list_id from ".tname("list")." where list_pid=".$val["list_id"].") or vod_cid = ".$val["list_id"]." order by vod_addtime desc limit ".$page*$pagesize.",".$pagesize);
		if (count($listmov)>0){
		
			$list2 = appmaker_listtackle($listmov);

			$json['recomm'][$jsoncount+1] = array('groupid' => $val["list_dir"],
				'groupname' => '最新'.$val["list_name"],
				'group' => $list2,
			);
			$jsoncount++;
		}
		
	}
	
}
	

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

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


?>