<?php
    
    if(!defined('IN_DISCUZ')) {
        exit('Access Denied');
    }

    
    $tid = intval($_GET['tid']);

    $page = intval($_GET['page']);
    $page = $page > 0 ? $page : 1;
    $pagesize  = 20;
    $start = ($page - 1)*$pagesize;

    $sql = "SELECT  * FROM ".DB::table('mocuz_reward_list')." WHERE tid = {$tid} order by date desc limit {$start},{$pagesize}";
    $res = DB::query($sql);
    $info = array();
    $i = 0;
    while($rs = DB::fetch($res)){
        $info[$i]['scorename'] = $rs['score_name'];
        $info[$i]['date'] = my_date_format($rs['date'],'Y-m-d');
        $info[$i]['username'] = $rs['username'];
        $info[$i]['avatar'] = avatar($rs['ruid'], 'small', true);
        $info[$i]['score'] = $rs['score'];
        $i++;
    }

    if($page == 1){
        include './template/rewards_list.php';
    }else{
        if(empty($info)){
            exit;
        }
        include './template/rewards_comment.php';
    }