<?php
if (!defined('MOD')) die("access die");
$sid      = intval($_GET['sid']);
$pageno   = intval( $_GET[pageno]) > 0 ? intval( $_GET[pageno]) : 1;
$pagesize = 15;
$total    = qdb::QueryAlone("select count(id) from ".TABLEPRE."{$_MODULE[$channelselect][table_name]}_{$channelid}_special as s left join ".TABLEPRE."{$_MODULE[$channelselect][table_name]}_{$channelid} as c on s.aid=c.id where s.sid='$sid' ");
if ( $total > 0)
{
	$pages    = ceil( $total/$pagesize);
	if( $pageno > $pages) $pageno = $pages ;
	$start    = ( $pageno -1) * $pagesize ;
	$sql      = "select c.subject, c.cid, c.is_comend, s.aid from ".TABLEPRE."{$_MODULE[$channelselect][table_name]}_{$channelid}_special as s left join ".TABLEPRE."{$_MODULE[$channelselect][table_name]}_{$channelid} as c on s.aid=c.id where s.sid='$sid' order by c.id desc limit $start, $pagesize";
	$result   = qdb::Query( $sql);

	while( $list = qdb::fetchArray( $result))
	{
		$list[subject] = charset::gb2utf8( qbase::substrs($list[subject], 32));
		$lists[] = $list;
	}
	if( isset( $lists) && is_array($lists))
	{
		$data = array( 'status'=>200 , 'total'=>$total, 'pagesize'=>$pagesize, 'message'=> $lists );
		header("x-json: " . qbase::jsonencode($data));
	}
	else
	{
		$data = array( 'status'=>404 , 'message'=> 10 );
		header("x-json: " . qbase::jsonencode($data));
	}
}
else
{
	$data = array( 'status'=>404 , 'message'=> 10 );
	header("x-json: " . qbase::jsonencode($data));
}
exit();
?>