<?php

error_reporting(E_ERROR);
include('../common.php');
include('../sql.php');


$cache_ret = $AM_CACHE->am_get();
if (!$cache_ret){
$query1 = category_list_1();
// echo  $query1;
// exit();

$listpro = $_TD->FM($query1);
// $listpro = $_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($listpro))
{
$caculatecount = 0;
$obj = array();

foreach ($listpro as $key=>$val)
{
	$query2 = category_list_2($val);
	$listpro2 = $_TD->FM($query2);
// 	$listpro2 = $_TD->FM("SELECT * FROM ".tname('list')." where list_pid=".$val['list_id']." order by list_id asc");
	$filmarr = $val;
	$filmarr["list_child"] = $listpro2;
	$obj[$caculatecount] = $filmarr;
	$caculatecount = $caculatecount +1;

} 

$arr = array(
	'category' => $obj,
);
$str = json_encode($arr);


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

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