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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
 
 
class index_controller extends adminCommon{
    
    /**
     * @desc后台首页
     */
    function index_action($set = ''){
    
        global $db_config;
        
        $this -> yunset('db_config', $db_config);
        
        $_POST  =  $this -> post_trim($_POST);
        
        if (! empty($_POST['username']) && ! empty($_POST['password'])) {
            
            if (strpos($this -> config['code_web'], '后台登录') !== false) {
                
                if ($this -> config['code_kind'] > 2) {
                    
                    $check    =    verifytoken($this->config);
                    // 极验验证
                    if ($check['code'] != '200') {
                        $this -> ACT_layer_msg($check['msg'], 8, 'index.php');
                    } else {
                        $this -> admin_get_user_login($_POST['username'], $_POST['password'], 'index.php');
                    }
                    
                } else {
                    
                    if (md5(strtolower($_POST['authcode'])) === $_SESSION['authcode']) {
                        
                        unset($_SESSION['authcode']);
                        
                        $this -> admin_get_user_login($_POST['username'], $_POST['password'], 'index.php');
                        
                    } else {
                        
                        unset($_SESSION['authcode']);
                        
                        $this -> ACT_layer_msg('验证码错误!', 8, 'index.php');
                    }
                    
                }
                
            } else {
                
                $this -> admin_get_user_login($_POST['username'], $_POST['password'], 'index.php');
            }
            
        }
        
        
        $shell   =  $this -> admin_get_user_shell($_SESSION['auid'], $_SESSION['ashell']);
        $tpname  =  $shell ? 'index' : 'login';
        
        if ($tpname == 'login') {
            
            $this->yuntpl(array('admin/' . $tpname));
            
            die;
        }else{
            // 首页判断是否有crm客勤权限
            if ($shell){
                $crm_chat = $this->get_shell_module($shell['m_id'], 'crm_chat', 'getUnloginToken');
                
                if ($crm_chat['error'] != 2){
                    $nav  =  $this->get_shell($shell['m_id'], 'index.php?m=crm_chat');
                    if ($nav){
                        $this->yunset('crm_chat', 1);
                    }
                }
            }
        }
         
        // 权限配置
        
        $adminM    =  $this -> MODEL('admin');
        
        $power     =  $adminM -> getPower(array('uid'=>$_SESSION['auid']));
        
        $this -> yunset('power', $power['power']);
 
        //判断是否业务员 并且无管理权限
        if(in_array('213',$power['power']) && !in_array('226',$power['power'])){
 
            $this -> yunset('indexurl', 'index.php?m=crm_index');
        }else{
 
            $this -> yunset('indexurl', 'index.php?m=admin_right');
        }
        
        $nav_user  =  array(
            'name'        =>  $power['name'],
            'group_name'  =>  $power['group_name']
        );
        
        //查询最近登录时间
        $logM  =  $this->MODEL('log');
 
        $adminLog  =  $logM -> getAdminLog(array('uid' => $_SESSION['auid'],'content' => '登录成功','orderby' => 'ctime'));
        
        // 导航配置
        $navM      =  $this -> MODEL('navigation');
 
        $navList   =  $navM -> getAdminNavList(array('display'=>array('<>',1),'id'=>array('in', pylode(',', $power['power'])),'orderby'=>'sort,ASC'),array('utype'=>'power'));
 
 
        $setarr    =  array(
            'one_menu'        =>  $navList['one_menu'],
            'two_menu'        =>  $navList['two_menu'],
            'navigation'      =>  $navList['navigation'],
            'menu'            =>  $navList['menu'],
            'nav_user'        =>  $nav_user,
            'admin_lasttime'  =>  $adminLog['ctime'] ? $adminLog['ctime'] : time()
        );
        
        $this -> yunset($setarr);
        
        // 获取默认页面
        if (is_array($navList['navigation'])) {
            
            foreach ($navList['navigation'] as $v) {
                
                $navigation_url_id[]  =  $v['id'];
            }
            
            $navigation_url = $this -> GET_web_default($navigation_url_id, $power['power']);
 
            
        }
        
        $this -> yunset('navigation_url', $navigation_url);
        
        if ($set == '') {
            
            $this->yuntpl(array('admin/' . $tpname));
            
        }
    }
    /**
     * @desc 首页-管理员退出
     */
    function logout_action(){
        
        $this -> adminlogout();
        
        $this -> layer_msg('您已成功退出!', 9, 0, 'index.php');
    }
    
    /**
     *@desc 首页-清除缓存
     */
    function del_cache_action(){
        
        $cache   =  $this->del_dir('../data/templates_c', 1);
        
        $cache   =  $this->del_dir('../data/cache', 1);
        
        /* 生成四位JS,css识别码 */
        $configM  =  $this->MODEL('config');
        
        $configM -> cacheCode();
        
        $this -> web_config();
        
        if ($cache == true) {
            
            $this -> layer_msg('更新成功!', 9, 0, 'index.php');
            
        } else {
            
            $this -> layer_msg('更新失败,请检查是否有权限!', 8, 0, 'index.php');
        }
    }
    /**
     * 首页-后台地图
     */
    function map_action(){
        
        $this -> index_action(1);
        
        $this -> yuntpl(array('admin/admin_map'));
    }
    /**
     * 获取页面标题
     */
    function topmenu_action(){
        
        $id  =  (int) $_GET['id'];
        // 解决ie9 $.get $.post 回调函数的返回值为undefine
        header('Content-Type: text/html; charset=UTF-8');
        
        if ($id == '1000') {
            echo '管理首页';
        } else {
            $arr  =  $this -> GET_web_check($id);
            
            $n    =  explode('-', $arr);
            
            unset($n[count($n) - 1]);
            
            echo implode('-', $n);
        }
    }
    /**
     * 首页-设置快捷导航
     */
    function shortcut_menu_action(){
        
        $tpname = $this -> admin_get_user_shell($_SESSION['auid'], $_SESSION['ashell']);
        
        if ($_POST['chk_value'] && is_array($tpname)) {
            
            $navM    =  $this -> MODEL('navigation');
            
            $navM -> upAdminNav(array('menu'=>1),array('menu'=>2));
            
            $navM -> upAdminNav(array('menu'=>2),array('id'=>array('in',@implode(',', $_POST['chk_value']))));
            
            echo 1;
            
            die;
        } else {
            
            $this->ACT_layer_msg("无权操作!",8,$this->config['sy_weburl'],2,1);
            
        }
    }
    /**
     * 首页-查询相关统计数据
     */
    function msgNum_action(){
        
        $MsgNum  =  $this -> MODEL('msgNum');
        echo $MsgNum->msgNum();
    }
 
    function wxbind_action(){
        $WxM=$this->MODEL('weixin');
        $qrcode = $WxM->applyWxQrcode($_COOKIE['wxadminbind'],'wxadminbind');
        if(!$qrcode){
            echo 0;
        }else{
            echo $qrcode;
        }
    }
    function getwxbindstatus_action(){
        if($_SESSION['auid']){
            $adminM  =  $this -> MODEL('admin');
            $uadmin = $adminM ->  getAdminUser(array('uid'=>$_SESSION['auid']));
            if($uadmin['wxid']!=''){
                echo 1;
            }else{
                echo 0;
            }
        }
    }
    function delAdminWxBind_action(){
        if($_SESSION['auid']){
            $adminM  =  $this -> MODEL('admin');
            $uadmin = $adminM ->  getAdminUser(array('uid'=>$_SESSION['auid']));
            if($uadmin['wxid']!=''){
                $adminM ->  upInfo(array('wxid'=>''),array('uid'=>$_SESSION['auid']));
            }
            echo 1;
        }
    }
    
}
?>