<?php
//ask

require_once './include/common.inc.php';

//问答分类
$query = "select id, name, asknum, reid from {$cfg_dbprefix}asktype order by disorder desc, id asc";
$dsql->Execute('me',$query);
$tids = $tid2s = $asktypes = array();
while($asktype = $dsql->getarray())
{
	if($asktype['reid'] == 0)
	{
		$tids[] = $asktype;
	}else
	{
		$tid2s[] = $asktype;
	}

}
foreach($tids as $tid)
{
	$asktypes[] = $tid;
	foreach($tid2s as $key => $tid2)
	{
		if($tid2['reid'] == $tid['id'])
		{
			$asktypes[] = $tid2;
			unset($tid2s[$key]);
		}
	}
}


//快到期的问题
$query = "select id, tid, tidname, tid2, tid2name, title from {$cfg_dbprefix}ask where status=0 order by expiredtime asc, dateline desc limit 15";
$dsql->Execute('me',$query);
$expiredasks = array();
while($row = $dsql->getarray())
{
	$row['title'] = cn_substr($row['title'],22);
	$expiredasks[] = $row;
}


//会员排行
$query = "select ID, userid, scores from {$cfg_dbprefix}member order by scores desc limit 20";
$dsql->Execute('me',$query);
$topmembers = array();
while($row = $dsql->getarray())
{
	$topmembers[] = $row;
}


$dsql->Close();

include DEDE.'./template/default/type.htm';

?>