<?php
error_reporting(0); 
session_start();
include("../config/wap.php");
$flid=ubo($_POST["flid"]);
$userid=ubo($_POST["userid"]);
$type="where userid='$userid'";
$user=queryall(user,$type);
if(!$user){echo err();}
if($flid=='0'){
$query="select * from daili where   userid='$userid' "; 
}else{
$query="select * from daili  where  userid='$userid' and flid='$flid'"; 
}
$pagesize=10; 
if(empty(ubo($_POST["page"])))  {  
$page = 1;  
$startrow = 0;  
}else {  
$page = ubo($_POST["page"]);  
$startrow = ($page-1)*$pagesize;  
}  
if($user[fs]==1){
$q = mysql_query(" ".$query."   order by rand()      limit $startrow,$pagesize"); 
}elseif($user[fs]==2){
$q = mysql_query(" ".$query."   order by id asc      limit $startrow,$pagesize"); 
}elseif($user[fs]==3){
$q = mysql_query(" ".$query."   order by id desc      limit $startrow,$pagesize"); 
}elseif($user[fs]==4){
$q = mysql_query(" ".$query."   order by cs desc      limit $startrow,$pagesize"); 
}elseif($user[fs]==5){
$q = mysql_query(" ".$query."   order by shijian desc      limit $startrow,$pagesize"); 
}else{
$q = mysql_query(" ".$query."   order by rand()      limit $startrow,$pagesize"); 
}
$data= array();    
while($row=mysql_fetch_array($q)){  
$tzurl =$row['link'];
$cs=rand(999,10000);
$eventObj= array(  
'pic' => iconv('gbk', 'UTF-8', $row['pic']),  
'name' => iconv('gbk', 'UTF-8', $row['name']),
'url' =>$tzurl,
'money' => iconv('gbk', 'UTF-8', $row['money']),
'cs' => iconv('gbk', 'UTF-8', $row['cs']),
);  
array_push($data, $eventObj);  
} 
echo json_encode(array('zt'=>'true','msg'=>'success','data'=>$data,'flid'=>$flid));
?>