chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
<?php
 
class ask_controller extends common{ 
    function ask_tpl($tpl){ 
        $this->yuntpl(array('ask/'.$tpl));
    }
    function  is_login(){
        if($this->uid==""||$this->username==''){
            echo 'no_login';die;
        }
    }
    function atnask($M){
        if($this->uid){ 
            $my_attention    =    $M -> getAtnInfo(array('uid'=>$this->uid,'type'=>1));
            
            $my_atten        =    @explode(',',rtrim($my_attention['ids'],","));
            
            $this->yunset("my_atten",$my_atten);
        } 
    }
    function hotclass(){
        $CacheM        =    $this -> MODEL('cache');
        
        $CacheList    =    $CacheM -> GetCache(array('ask'));
        
        $rows=array();
        
        $i=0;
        foreach($CacheList['ask_name'] as $key=>$val){
            if($i<'10'){
                $rows[$key]=$val;
            }
            $i++; 
        } 
        $this->yunset("hotclass",$rows); 
    }
    function autosearch_action(){
        $M            =    $this->MODEL('ask');
        
        $keyword    =    trim($_POST['keyword']);
        
        $rows        =    $M -> getList(array('title'=>array('like',$keyword), 'orderby'=>'answer_num,desc', 'limit'=>'6'),array('field'=>'`id`,`title`,`answer_num`'));
        
        if($rows&&is_array($rows)){
            foreach($rows as $key=>$val){
                $rows[$key]['url']=Url('ask',array("c"=>"content","id"=>$val['id']));
                $rows[$key]['title']=urlencode(str_replace($keyword,"<b>".$keyword."</b>",$val['title']));
            }
        }
        $rows = json_encode($rows);
        echo urldecode($rows);die;
    }
}
?>