chengkun
2025-05-23 0d8e263c22903234efea68fd13a27d8b7b59aac1
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
<?php
 
 
class admin_announcement_controller extends adminCommon{
 
    function set_search(){
 
        $ad_time        =    array('1'=>'今天', '3'=>'最近三天', '7'=>'最近七天', '15'=>'最近半月', '30'=>'最近一个月');
 
        $search_list[]    =    array("param"=>"end", "name"=>'发布时间', "value"=>$ad_time);
 
        $this->yunset("search_list",$search_list);
 
    }
    function index_action(){
 
        $this->set_search();
 
        $AnnouncementM        =        $this->MODEL('announcement');
 
        if(trim($_GET['keyword'])){
 
            $where['title']                =    array('like',trim($_GET['keyword']));
 
            $urlarr['keyword']            =    $_GET['keyword'];
        }
 
        if($_GET['end']){
            if($_GET['end'] == 1){
 
                $where['datetime']        =    array('>=',strtotime(date("Y-m-d 00:00:00")));
 
            }else{
 
                $where['datetime']        =    array('>=',strtotime('-'.intval($_GET['end']).' day'));
            }
 
            $urlarr['end']                =    $_GET['end'];
 
        }
        $urlarr                =   $_GET;
        $urlarr['page']        =    "{{page}}";
 
        $pageurl            =    Url($_GET['m'],$urlarr,'admin');
 
        $pageM                =    $this  -> MODEL('page');
 
        $pages                =    $pageM -> pageList('admin_announcement',$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']        =    'id';
 
            }
 
            $where['limit']                =    $pages['limit'];
 
            $ListAnnouncement   =  $AnnouncementM     ->  getList($where);
 
            $this->yunset("announcement" , $ListAnnouncement['list']);
 
        }
 
        //提取分站内容
        $cacheM                             =    $this   -> MODEL('cache');
        $domain                             =    $cacheM -> GetCache('domain',$Options=array('needreturn'=>true,'needassign'=>true,'needall'=>true));
        $this -> yunset('Dname', $domain['Dname']);
 
        $this->yunset("get_type", $_GET);
 
        $this->yuntpl(array('admin/admin_announcement_list'));
 
    }
 
    function add_action(){
 
        $AnnouncementM    =    $this->MODEL('announcement');
 
        if($_GET['id']){
 
            $id            =        intval($_GET['id']);
 
            $info        =        $AnnouncementM   ->  getInfo(array('id'=>$id));
 
            $this         ->  yunset("info",  $info);
 
            $this         ->  yunset('lasturl',   $_SERVER['HTTP_REFERER']);
 
        }
 
        //提取分站内容
        $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_announcement_add'));
 
    }
 
    function save_action(){
 
        $_POST  =  $this->post_trim($_POST);
 
        $AnnouncementM    =    $this->MODEL('announcement');
 
        if($_POST['startime'] == ''){
            $_POST['startime'] = date('Y-m-d H:i:s',time());
        }
        if($_POST['update']){
 
            $lasturl=str_replace("&amp;","&",$_POST['lasturl']);
 
            unset($_POST['lasturl']);
 
            $nid=$AnnouncementM -> upInfo(array('id'=>intval($_POST['id'])),$_POST);
 
            $nid?$this->ACT_layer_msg( "公告(ID:".$_POST['id'].")更新成功!",9,$lasturl,2,1):$this->ACT_layer_msg( "公告(ID:".$_POST['id'].")更新失败!",8,$lasturl,2,1);
        }
 
        if($_POST['add']){
 
            $nid=$AnnouncementM -> addInfo($_POST);
 
            $nid?$this->ACT_layer_msg( "公告添加成功!",9,"index.php?m=admin_announcement",2,1):$this->ACT_layer_msg( "公告添加失败!",8,"index.php?m=admin_announcement",2,1);
        }
    }
 
    function del_action(){
 
        $this->check_token();
 
        $AnnouncementM    =    $this -> Model('announcement');
 
        $delID    =    $_GET['id'] ? intval($_GET['id']) : $_GET['del'];
 
        $addArr    =    $AnnouncementM -> delAnnouncement($delID);
 
        $this   ->  layer_msg( $addArr['msg'],$addArr['errcode'],$addArr['layertype'],$_SERVER['HTTP_REFERER'],2,1);
 
    }
 
    function checksitedid_action(){
 
        if($_POST['uid']){
 
            $uids    =    @explode(',', $_POST['uid']);
 
            $uid    =     pylode(',', $uids);
 
            if($uid){
 
                $siteDomain        =    $this -> MODEL('site');
 
                $siteDomain -> updDid(array('admin_announcement'), array('id' => array('in', $uid)), array('did' => $_POST['did']));
 
                $this -> ACT_layer_msg('公告(ID:'.$_POST['uid'].')分配站点成功!', 9, $_SERVER['HTTP_REFERER']);
 
            }else{
 
                $this -> ACT_layer_msg('请正确选择需分配数据!', 8, $_SERVER['HTTP_REFERER']);
 
            }
 
        }else{
 
            $this -> ACT_layer_msg('参数不全请重试!', 8, $_SERVER['HTTP_REFERER']);
 
        }
 
    }
}
?>