Esempio n. 1
0
 function ac_index()
 {
     $askaid = request('askaid', '');
     $askaid = is_numeric($askaid) ? $askaid : 0;
     if (!is_numeric($askaid)) {
         ShowMsg("您提交的参数有问题", '-1');
         exit;
     }
     $question = $this->question->get_info($askaid);
     if (!is_array($question)) {
         ShowMsg("您浏览的问题不存,请重新操作!", '-1');
         exit;
     }
     if ($question) {
         if ($question['status'] == 1) {
             $question['dbstatus'] = 1;
             $question['status'] = 'solved';
         } else {
             if ($question['expiredtime'] < $GLOBALS['cfg_ask_timestamp']) {
                 $question['dbstatus'] = 2;
                 $question['status'] = 'epired';
                 //设置一个问题已过期
                 $set = "solvetime=expiredtime, status = '2'";
                 $wheresql = "id='{$askaid}'";
                 $this->question->update_ask($set, $wheresql);
             } else {
                 if ($question['status'] == -1 && $question['uid'] != $this->cfg_ml->M_ID) {
                     ShowMsg('该问题还未通过审核,请耐心等待...', '-1');
                     exit;
                 } else {
                     $question['dbstatus'] = 0;
                     $question['status'] = 'no_solve';
                 }
             }
         }
         $question['toendsec'] = $question['expiredtime'] - $GLOBALS['cfg_ask_timestamp'];
         $question['toendday'] = floor($question['toendsec'] / 86400);
         $question['toendhour'] = floor($question['toendsec'] % 86400 / 3600);
         //头像
         $question['face'] = empty($question['face']) ? 'static/images/user.gif' : $question['face'];
         //判断问题是否属于当前登陆者
         $publisher = 0;
         if ($question['uid'] == $this->cfg_ml->M_ID) {
             $publisher = 1;
         }
     } else {
         ShowMsg('回答的问题不存在', '-1');
         exit;
     }
     //获取积分头衔
     $question['honor'] = gethonor($question['scores']);
     //网站title
     $navtitle = $question['title'] . '-' . $GLOBALS['cfg_ask_sitename'];
     //当前位置
     $nav = $GLOBALS['cfg_ask_position'] . ' <a href="?ct=browser&tid=' . $question['tid'] . '">' . $question['tidname'] . '</a>';
     if ($question['tid2']) {
         $nav .= ' ' . $GLOBALS['cfg_ask_symbols'] . ' <a href="?ct=browser&tid2=' . $question['tid2'] . '">' . $question['tid2name'] . '</a>';
         $navtitle .= ' ' . $question['tid2name'];
     }
     $nav .= ' ' . $GLOBALS['cfg_ask_symbols'] . ' ' . $question['title'];
     //获取问题的答案
     $rows = $this->answer->get_answers($askaid);
     $answers = array();
     $first = $goodrateper = $badrateper = $goodrate = $badrate = $ratenum = $answernum = $myanswer = 0;
     if (count($rows) > 0) {
         foreach ($rows as $key => $row) {
             //获取回答者的积分等级
             $row['honor'] = gethonor($row['scores']);
             //判断问题是否是自己回答的问题
             if ($this->cfg_ml->M_ID == $row['uid']) {
                 $myanswer = 1;
             }
             //判断是否已经有最佳答案了
             if ($row['id'] == $question['bestanswer']) {
                 $digestanswer = $row;
                 $ratenum = $row['goodrate'] + $row['badrate'];
                 $goodrate = $row['goodrate'];
                 $badrate = $row['badrate'];
                 $goodrateper = @ceil($goodrate * 100 / $ratenum);
                 $badrateper = 100 - $goodrateper;
                 //设定变量值
                 $arrs = array('digestanswer', 'goodrate', 'badrate', 'goodrateper', 'badrateper', 'ratenum');
                 foreach ($arrs as $val) {
                     $GLOBALS[$val] = ${$val};
                 }
             } else {
                 $answernum = $answernum + 1;
                 $row['floor'] = $answernum;
                 $answers[] = $row;
             }
         }
     }
     //设定变量值
     $arrs = array('nav', 'navtitle', 'question', 'publisher', 'myanswer', 'answernum', 'answers');
     foreach ($arrs as $val) {
         $GLOBALS[$val] = ${$val};
     }
     //载入模板
     $this->SetTemplate('question.htm');
     $this->Display();
 }
Esempio n. 2
0
$question['honor'] = gethonor($question['scores'], $honors);
$nav = '<a href="' . $indexname . '">' . $sitename . '</a> ' . $symbols . ' <a href="browser.php?tid=' . $question['tid'] . '">' . $question['tidname'] . '</a>';
$navtitle = $question['title'];
if ($question['tid2']) {
    $nav .= ' ' . $symbols . ' <a href="browser.php?tid2=' . $question['tid2'] . '">' . $question['tid2name'] . '</a>';
    $navtitle .= ' ' . $question['tid2name'];
}
$navtitle .= ' ' . $question['tidname'] . ' ' . $sitename;
$dsql->Execute('me', "select answer.*,m.scores from #@__askanswer answer left join `#@__member` m on m.mid=answer.uid where askid='{$id}' and ifcheck='1'");
$comments = $answers = array();
$first = $goodrateper = $badrateper = $goodrate = $badrate = $ratenum = $commentnum = $answernum = $myanswer = 0;
while ($row = $dsql->getarray()) {
    $row['dateline'] = gmdate('m-d h:i', $row['dateline'] + $timeoffset * 3600);
    $row['dbcontent'] = $row['content'];
    $row['content'] = nl2br(ihtmlspecialchars($row['content']));
    $row['honor'] = gethonor($row['scores'], $honors);
    if ($row['ifanswer'] == 1) {
        //回答
        if ($uid == $row['uid']) {
            $myanswer = 1;
        }
        if ($row['id'] == $question['bestanswer']) {
            $digestanswer = $row;
            $ratenum = $row['goodrate'] + $row['badrate'];
            $goodrate = $row['goodrate'];
            $badrate = $row['badrate'];
            $goodrateper = @ceil($goodrate * 100 / $ratenum);
            $badrateper = 100 - $goodrateper;
        } else {
            $answers[] = $row;
            $answernum++;