<?php
error_reporting(0); 
session_start();
include("../config/os.php");
$flid=ubo($_POST["flid"]);
$lx=ubo($_POST["lx"]);
$userid=ubo($_POST["userid"]);
$type="where userid='$userid'";
$user=queryall(user,$type);
if(!$user){echo err();}
//首页调用
if($lx=='shouye'){
$query="select * from daili  where  userid='$userid' and flid='$flid'"; 
$q = mysql_query(" ".$query."   order by rand()      limit 6"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));
//最近更新
}elseif($lx=='new'){
$query="select * from daili  where  userid='$userid'  and shijian  like '%".$day."%'"; 
$q = mysql_query(" ".$query."   order by id desc"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));
}elseif($lx=='fenlei'){
$pagesize=10; 
if(empty($_POST["page"]))  {  
$page = 1;  
$startrow = 0;  
}else {  
$page = $_POST["page"];  
$startrow = ($page-1)*$pagesize;  
}  
$query="select * from daili  where  userid='$userid' and flid='$flid'"; 
$q = mysql_query(" ".$query."    order by id desc         limit $startrow,$pagesize"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));

}elseif($lx=='list'){
$pagesize=10; 
if(empty($_POST["page"]))  {  
$page = 1;  
$startrow = 0;  
}else {  
$page = $_POST["page"];  
$startrow = ($page-1)*$pagesize;  
}  
$query="select * from daili  where  userid='$userid'"; 
$q = mysql_query(" ".$query."    order by id desc         limit $startrow,$pagesize"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));

}elseif($lx=='hezi'){
$query="select * from daili  where  userid='$userid'"; 
$q = mysql_query(" ".$query."   order by id desc limit 6"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));

}elseif($lx=='bofang'){
$query="select * from daili  where  userid='$userid'"; 
$q = mysql_query(" ".$query."   order by id desc limit 6"); 
$data= array();   
while($row=mysql_fetch_array($q)){  
$tzurl =iconv('gbk', 'UTF-8', $row['link']);
if($row[lx]==1){
$lx=iconv('gbk', 'UTF-8', '打赏');
}else{
$lx=iconv('gbk', 'UTF-8', '免费');
}
$cs=rand(999,100000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'lx' =>$lx,
'cs' => iconv('gbk', 'UTF-8', $cs),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));
}
?>