chengkun
2025-04-27 a0402d122fee696e2b7684ef7edfc504ade12640
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
 
class content_controller extends ask_controller{
    function index_action(){ 
        $M            =    $this -> MODEL('ask');
        
        $atnM        =    $this -> MODEL('atn');
        
        $UserInfoM    =    $this -> MODEL('userinfo');
        
        $ID            =    (int)$_GET['id'];
        
        $show        =    $M -> getInfo($ID);
        
        if(empty($show)){
            $this->ACT_msg($this->config['sy_weburl'],"问题不存在或被删除!");
        }else{
            // 管理员查看
            $look = isset($_GET['look']) && $_GET['look'] == 'admin' && !empty($_SESSION['auid']) ? 'admin' : '';
            if ($look != 'admin'){
                if ($show['state'] == 0) {
                    $this->ACT_msg($_SERVER['HTTP_REFERER'], '问题审核中!');
                } elseif ($show['state'] == 2) {
                    $this->ACT_msg($_SERVER['HTTP_REFERER'], '该问题未通过审核!');
                }
            }
        }
        
        $where['qid']=    $ID;
 
        $where['status']=    1;
        
        $pageurl    =    Url('ask',array("c"=>$_GET['c'],'id'=>$ID,'orderby'=>$_GET['orderby'],"page"=>"{{page}}"));
        
        $pageM        =    $this  -> MODEL('page');
        $pages        =    $pageM -> pageList('answer',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            if($_GET['orderby']){
                $where['orderby']    =    $_GET['orderby'];
            }else{
                $where['orderby']    =    'add_time';
            }
            $where['limit']        =    $pages['limit'];
            
            $answer    =    $M -> getAnswersList($where);
            $this->yunset('total',$pages['total']);
        }
        
        $Userinfo    =    $UserInfoM -> getInfo(array('uid'=>$show['uid']),array('field'=>'username,usertype,uid'));
        
        $AnswerNum    =    $M -> getAnswersNum(array('qid'=>$show['id'],'status'=>1)); 
        
        $M -> upStatusInfo($show['id'],'',array('answer_num'=>$AnswerNum));
        
        if($this->uid){
            $atten_ask    =    $M -> getAtnInfo(array('uid'=>$this->uid,'type'=>1));
            
            $atn        =    $atnM -> getatnList(array('uid'=>$this->uid),array('field'=>'sc_uid'));
            
        }
        
        $myinfo['pic']=checkpic('',$this->config['sy_friend_icon']);
 
        if(!empty($answer)){
            foreach($answer as $key=>$val){
                if($val['uid']==$this->uid){
                    $answer[$key]['is_atn']='2';
                }else{
                    foreach($atn as $a_v){
                        if($a_v['sc_uid']==$val['uid']){
                            $answer[$key]['is_atn']='1';
                        }
                    }
                }
            }
        }
        if($Userinfo['uid']==$this->uid){
            $Userinfo['useratn']='2';
            $show['qatn']='2';
        }else if(!empty($atn)){
            foreach($atn as $val){
                if($Userinfo['uid']==$val['sc_uid']){
                    $Userinfo['useratn']='1';
                }
            }
        }
        if($atten_ask&&is_array($atten_ask)&&$show['qatn']==''){
            $ids=explode(',',rtrim($atten_ask['ids'],','));
            if(in_array($show['id'],$ids)){
                $show['qatn']='1';
            }
        }
        $data['ask_title']    =    $show['title'];
        
        $this->data            =    $data;
        
        $CacheM    =    $this -> MODEL('cache');
        
        $reason    =    $CacheM -> GetCache('reason');
        
        $M -> upStatusInfo((int)$_GET['id'],'',array("visit"=>array('+','1')));
        
         $this->yunset("userinfo",$Userinfo);
         $this->yunset("myinfo",$myinfo);
        $this->yunset(array("reason"=>$reason,"show"=>$show,"uid"=>$this->uid,"answer"=>$answer,"ask_title"=>$show['title'].' - '.$this->config['sy_webname'],"c"=>"index"));
        $this->seo('ask_content');
        $this->ask_tpl('content');
    }
}
?>