<?php include _include(APP_PATH.'view/htm/header.inc.htm');?>

<!--{hook index_start.htm}-->

<div class="row">
<div class="r-1 d-none d-lg-block">
<div class="r-1-1">
<div class="r-1-1-1">
<h5><span class="g-1"></span><span class="g-2">热门话题</span></h5>
					
<?php
$flist = forum_find(array(), array('threads' => '-1'), 1, 5);
foreach($flist as $_forum):
?>
<li class="rmht" fid="<?php echo $_forum['fid'];?>" data-active="fid-<?php echo $_forum['fid'];?>">
<div class="rmht-1">
<div class="rmht-2">
<div class="rmht-3">
<img class="logo-z1 li-left" src="<?php echo $_forum['icon_url'];?>">
</div>
</div>
<div class="rmht-4">	
<div class="rmht-4-bt">	
	<a href="<?php echo url("forum-$_forum[fid]");?>"><?php echo $_forum['name'];?></a>
</div>	
<div class="rmht-4-jj">				
<?php echo mb_substr($_forum['brief'],0,30,'utf-8').'...';?>
</div>
<div class="rmht-4-htsl">	
讨论 <?php echo $_forum['threads'];?> · 今日 <?php echo $_forum['todayposts'];?>

</div>

</div>					
</div>					
					</li>
<?php
endforeach;
?>					
</div>
</div>
</div>
<div class="col-lg-9 main">
		<!--{hook index_main_start.htm}-->
		<div class="card-threadlist">
<?php $themegamelist = db_find('themegame', array(), array('rank'=>-1), 1, 1000, 'themegameid');?>	
<?php if($themegamelist) { foreach ($themegamelist as $key => $link) { ?>				
			<div class="gro-1-1">
	<div class="card-threadlist">
			<div class="card-thread bjys-bs">
	<h5><span class="g-1"></span><span class="g-2"><?php echo  ''.$link['name'].'';?></span></h5>
	</div>
	</div>
	<?php foreach($forumlist_show as $k=>$_forum): ?>
                <?php 
				    $sites2=explode(" ",$link['formid']);
				    if(in_array($k,$sites2)):?>
					  <?php    $link['viewnum'];
					  ?>                  					    
<div class="border-1 margin-bottom-1">	
<a href="<?php echo url("forum-$_forum[fid]");?>">
<div class="gro-3">
<div class="gro-4">
<span class="icon iconfont gro-5"></span>
 <div class="gro-6">话题</div></div>

<img class="gro-7" src="<?php echo $_forum['icon_url'];?>"> 
</div>
</a><div class="gro-2"><a href="<?php echo url("forum-$_forum[fid]");?>" class="">
<span class="rmht-4-bt">
<?php echo ''.$_forum['name'].'';?>
</span> 
<span class="gro-10">
<?php echo mb_substr($_forum['brief'],0,50,'utf-8').'...';?>
 </span>
				<span class="gro-11">讨论 <?php echo $_forum['threads'];?></span> <span class="gro-12"> ·  </span> <span class="gro-11">今日 <?php echo $_forum['todaythreads'];?></span>
				</a></div></div>
	<?php endif;?>
                      <?php endforeach; ?>			
</div>
 <?php }} ?>
	
</div>
		</div>
	<div class="col-lg-3 aside">
	
		<!--{hook index_site_brief_before.htm}-->
		<div class="card card-site-info border-1">
			<!--{hook index_site_brief_start.htm}-->
			<div class="m-3">
				<h5><span class="g-1"></span><span class="g-2">网站数据</span></h5>
				<div class="g-3">
				<span class="g-4">
				<span class="icon iconfont icon1">&#xe7b2;</span>
				<span class="g-5">
				讨论 <?php echo $runtime['threads'];?>
				</span>
				</span>
				
				<span class="g-4">
				<span class="icon iconfont icon1">&#xe773;</span>
				<span class="g-5">
				成员 <?php echo $runtime['users'];?>
				</span>
				</span>
				
				<span class="g-4">
				<span class="icon iconfont icon1">&#xe702;</span>
				<span class="g-5">
				在线 <?php echo $runtime['onlines'];?>
				</span>
				</span>
				</div>
			</div>
			
		</div>
<div class="card border-1">
	<div class="m-3">
	<h5><span class="g-1"></span><span class="g-2">热门讨论</span></h5>
		<?php
			$toplist = get_site_top_list();
			echo '<div class="site-top">';
			foreach ($toplist as $key => $value){
				$_class = $key < 3 ? 'top_span_red' : 'top_span_gray';
				echo '<li class="site-top1"><span class="'.$_class.'">'.($key+1).'</span><a class="top_span_title" href="'.url("thread-$value[tid]").'">'.$value['subject'].'</a></li>';
			}
			echo '</div>'; 
		?>
	</div>
	</div>
<div class="card border-1">
<div class="m-3">
	<h5><span class="g-1"></span><span class="g-2">最近加入</span></h5>
	<div class="card-body col-xs-4-1">
	
		<?php 
		$nIndex = 0;
		$userlist = get_site_new_user();
        foreach ($userlist as $user) {
			if(++$nIndex>16)break;
			$user_avatarimg = 'view/img/avatar.png';
			$user['avatar']!=0 && $user_avatarimg = $conf['upload_url'].'avatar/000/'.$user['uid'].'.png?'.$user['avatar'];
			if($cdn_enable)$user_avatarimg = $theme_plugin['cdn_url'].$user_avatarimg;
        ?>
		<div class="col-xs-4 text-center">
			<a class="tt" href="<?php echo url("user-$user[uid]");?>"
				data-toggle="tooltip" title="<?php echo $user['dname'];?>">
				<img src="<?php echo $user_avatarimg; ?>" alt="<?php echo $user['dname'];?>" width="39" height="39" class="img-circle"><br>
			<?php echo $user['dname'];?>
			</a>
		</div>
		<?php } ?>
	</div>
</div>
</div>
</div>
</div>
<?php

function console_log($text){
    echo '<script type="text/javascript">console.log(\'log:'.$text.'\');</script>';
}

//获取回复最多的文章，默认10篇
function get_site_top_list(){
	$result = cache_get('get_site_top_list');
	if(empty($result)){
		$result = db_find('thread', array(), array('views'=>2));//按views倒序
		cache_set('get_site_top_list',$result,300);//有效期1天
	}
	return $result;
}

function get_site_user_order_by_gold($num=16){
    //先获取用户列表
	$userlist = db_find('user', array(), array('golds'=>2), 1, $num, 'uid');
	 foreach ($userlist as $user) {
		 echo '用户名:'.$user['username'].'积分:'.$user['credits'].'金币:'.$user['golds'].'<br/>';
	 }
}

function get_site_new_user($num=16){
    //先获取用户列表
    $userlist = cache_get('get_site_new_user');
    if(empty($userlist)){
        $userlist = db_find('user', array(), array('uid'=>-1), 1, $num, 'uid');
        foreach ($userlist as &$user) {
            $username = $user['username'];
            xn_strlen($username)>6 && $username = xn_substr($username, 0, 6);
            $user['dname'] = $username;
        }
        cache_set('get_site_new_user',$userlist,60);//有效期1天
    }
    return $userlist;
}
?>


<!--{hook index_end.htm}-->

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>
<script>
$('li[data-active="fid-<?php echo $fid;?>"]').addClass('active');
</script>


<!--{hook index_js.htm}-->