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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
 
class link_controller extends adminCommon{
    //设置高级搜索功能
    function set_search(){
        $lo_time        =    array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月');
        if($this->config["sy_web_site"]=='1'){
            $cacheM      =    $this -> MODEL('cache');
            $domains    =    $cacheM -> GetCache('domain',$Options=array('needreturn'=>true,'needassign'=>true,'needall'=>true));
            
            $domain=array();
            foreach($domains['site_domain'] as $val){
                $domain[$val['id']]    =    $val['cityname'];
            }
            $search_list[]    =    array("param"=>"did","name"=>'显示站点',"value"=>$domain);
        }
        $search_list[]    =    array("param"=>"link","name"=>'发布时间',"value"=>$lo_time);    
        $search_list[]    =    array("param"=>"type","name"=>'类型',"value"=>array("1"=>"文字链接","2"=>"图片链接"));
        $search_list[]    =    array("param"=>"state","name"=>'审核状态',"value"=>array("1"=>"已审核","2"=>"未审核"));
        
        $this->yunset("search_list",$search_list);
    }
    function index_action(){
        $this->set_search();
        if($_GET['state']=='1'){
            
            $where['link_state']    =    1;
            $urlarr['state']        =    1;
            
        }elseif($_GET['state']=='2'){
            
            $where['link_state']    =    0;
            $urlarr['state']        =    2;
            
        }
        if($_GET['type']){
            
            $where['link_type']        =    $_GET['type'];
            $urlarr['type']            =    1;
            
        }
        if($_GET['did']){
            
            $where['did']            =    $_GET['did'];
            $urlarr['did']            =    $_GET['did'];
        }
        if($_GET['link']){
            if($_GET['link']=='1'){
                $where['link_time']        =    array('>=',strtotime(date("Y-m-d 00:00:00")));
            }else{
                $where['link_time']        =    array('>',strtotime('-'.intval($_GET['link']).' day'));
            }
            $urlarr['link']                =    $_GET['link'];
        }
        if($_GET['news_search']!=''){
            if ($_GET['type']=='1'){
                
                $where['link_name']        =    array('like',trim($_GET['keyword']));
                $where['link_type']        =    1;
                
            }elseif ($_GET['type']=='2'){
                
                $where['link_name']        =    array('like',trim($_GET['keyword']));
                $where['link_type']        =    2;
                
            }else{
                
                $where['link_name']        =    array('like',trim($_GET['keyword']));
            }
            $urlarr['type']                =    $_GET['type'];
            $urlarr['keyword']            =    $_GET['keyword'];
            $urlarr['news_search']        =    $_GET['news_search'];
        }
        $urlarr         =   $_GET;
        $urlarr['page']    =    "{{page}}";
        $pageurl        =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM            =    $this  -> MODEL('page');
        
        $pages            =    $pageM -> pageList('admin_link',$where,$pageurl,$_GET['page']);
 
        if($pages['total'] > 0){
            
            if($_GET['order']){
                $where['orderby']    =    $_GET['t'].','.$_GET['order'];
 
                $urlarr['order']    =    $_GET['order'];
                $urlarr['t']        =    $_GET['t'];
            }else{
                $where['orderby']    =    array('link_state,asc','link_time,desc');
            }
            $where['limit']            =    $pages['limit'];
            
            $linkM                    =    $this  -> MODEL('link');
            $rows                    =   $linkM -> getList($where);
            $this -> yunset("linkrows",$rows);
        }
        
        //提取分站内容
        $cacheM  =    $this -> MODEL('cache');
        $domain  =    $cacheM -> GetCache('domain',$Options=array('needreturn'=>true,'needassign'=>true,'needall'=>true));
        
        $this -> yunset('Dname', $domain['Dname']);
        /***分站******/
        
        $this->yuntpl(array('admin/admin_link_list'));
    }
 
    function add_action(){
        //提取分站内容
        $cacheM  =    $this -> MODEL('cache');
        $domain  =    $cacheM -> GetCache('domain',$Options=array('needreturn'=>true,'needassign'=>true,'needall'=>true));
        
        $this -> yunset('Dname', $domain['Dname']);
        
        if($_GET['id']){
            $linkM    =    $this  -> MODEL('link');
            $info    =    $linkM -> getInfo(array('id'=>$_GET['id'])); 
            $this->yunset("info",$info);
            
            $this->yunset("lasturl",$_SERVER['HTTP_REFERER']);
        }
        $this->yuntpl(array('admin/admin_link_add'));
    }
    //删除链接
    function del_action(){
        
        if(is_array($_POST['del'])){
            $id    =    $_POST['del'];
        }else{
            $id    =    $_GET['id'];
        }
        
        $linkM    =    $this  -> MODEL('link');
        
        $return    =    $linkM -> delInfo($id);
        $this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
    }
    //审核链接
    function status_action(){
            
        $id        =    $_POST['yesid'];
        $linkM    =    $this  -> MODEL('link');
        
        $return    =    $linkM -> setLinkStatus($id,array('status'=>$_POST['status']));
        $this->ACT_layer_msg($return['msg'],$return['errcode'],$_SERVER['HTTP_REFERER']);
    }
    //保存信息
    function save_action(){
        
        $linkM            =    $this  -> MODEL('link');
        if($_POST['phototype']==1){
            
            if($_FILES['file']['tmp_name']){
                 $upArr    =  array(
                    'file'  =>  $_FILES['file'],
                    'dir'   =>  'link'
                );
 
                $uploadM  =  $this->MODEL('upload');
 
                $pic      =  $uploadM->newUpload($upArr);
                
                if (!empty($pic['msg'])){
 
                    $this->ACT_layer_msg($pic['msg'],8);
 
                }elseif (!empty($pic['picurl'])){
 
                    $pictures     =      $pic['picurl'];
                }
             }
 
            
        }else{
            $pictures        =    $_POST['uplocadpic'];
        }
        
        $post    =    array(
            'did'            =>    $_POST['did'],
            'link_name'        =>    trim($_POST['title']),
            'link_url'        =>    $_POST['url'],
            'link_type'        =>    $_POST['type'],
            'tem_type'        =>    $_POST['tem_type'],
            'img_type'        =>    $_POST['phototype'],
            'link_sorting'    =>    $_POST['sorting'],
            'link_state'    =>    1,
        );
 
        if(isset($pictures)){
 
            $post['pic']    =    $pictures;
 
        }
 
        $data    =    array(
            'post'    =>    $post,
            'id'    =>    $_POST['id'],
            'utype'    =>    'admin'
        );
        
        $return    =    $linkM -> addInfo($data);
        
        $this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=link");
    }
    function checksitedid_action(){
        $linkM    =    $this  -> MODEL('link');
        $data    =    array(
            'uid'=>$_POST['uid'],
            'did'=>$_POST['did']
        );
        
        $return    =    $linkM -> setLinkSite($data);
        $this->ACT_layer_msg($return['msg'],$return['errcode'],$_SERVER['HTTP_REFERER']);
    }
}
 
?>