<?php

error_reporting(E_ERROR);
include('../common.php');
include('../sql.php');
$cache_ret = $AM_CACHE->am_get();
if (!$cache_ret){
$query = gallary_1();
$listmov = $_TD->FM($query);
// $listmov = $_TD->FM("SELECT * FROM ".tname('list')." where list_pid=0 and list_status=1 and list_sid=1 order by list_id asc");
$icount = 0;
$listpro = array();

if(is_array($listmov))
{

	foreach ($listmov as $key=>$val){
		$query2 = gallary_2($val);
		
		$listmov1 = $_TD->FM($query2);
// 		$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_stars desc , vod_hits_week desc limit 1");
		
		if(count($listmov1)>0){
	
			$listpro[$icount] = appmaker_gallarytackle($listmov1);
			$icount++;
		}
	}
}	

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

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

                   
?>