chengkun
2025-04-24 5d55579fd424e024c52e62265b72e24c38a45004
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
274
275
276
277
278
<?php
 
/*
 * $Author :PHPYUN开发团队
 *
 * 官网: http://www.phpyun.com
 *
 * 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
 *
 * 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
 
class config_controller extends adminCommon {
    
    /**
     * 系统-网站设置
     */
    function index_action() {
        if (strpos($this->config['sy_weburl'], 'https') !== FALSE) {
            
            $this->config['mapurl'] = 'https://api.map.baidu.com/api?v=2.0&ak=' . $this->config['map_key'] . '&s=1';
        } else {
            $this->config['mapurl'] = 'http://api.map.baidu.com/api?v=2.0&ak=' . $this->config['map_key'];
        }
        if ($this->config['sy_ossurl'] == '') {
            $this->config['sy_ossurl'] = $this->config['sy_weburl'];
        }
        $this->yunset("config", $this->config);
        
        $this->yunset('sphinxSearchd', $sphinxSearchd);
        
        $this->yuntpl(array('admin/admin_web_config'));
    }
    
    /**
     * 系统-网站设置-网站logo
     */
    function save_logo_action() {
        if ($_POST['waterconfig']) {
            
            $this->web_config();
            
            $this->ACT_layer_msg('网站LOGO配置设置成功!', 9, $_SERVER['HTTP_REFERER'], 2, 1);
        }
    }
    
    // 保存
    function save_action() {
//       var_dump($_POST);exit;
        if ($_POST['config']) {
            
            if ($_POST['config'] == 'uploadconfig') {
                
                // 上传参数为空,保存默认值
                if (!$_POST['pic_maxsize'] || ($_POST['pic_maxsize'] == '' || $_POST['pic_maxsize'] < 1)) {
                    $_POST['pic_maxsize'] = 5;
                }
                if (!$_POST['file_maxsize'] || ($_POST['file_maxsize'] == '' || $_POST['file_maxsize'] < 1)) {
                    $_POST['file_maxsize'] = 5;
                }
                
                if (!$_POST['pic_type']) {
                    $_POST['pic_type'] = 'jpg,png,jpeg,bmp,gif';
                } else {
                    $pic_type = explode(',', str_replace(' ', '', $_POST['pic_type']));
                    
                    //禁止后台设定可执行程序后缀
                    foreach ($pic_type as $pickey => $picvalue) {
                        
                        $new_pic_type = strtolower(str_replace('.', '', trim($picvalue)));
                        if (in_array($new_pic_type, array('php', 'asp', 'aspx', 'jsp', 'exe', 'do'))) {
                            
                            unset($pic_type[$pickey]);
                        }
                    }
                    $_POST['pic_type'] = implode(',', $pic_type);
                }
                if (!$_POST['file_type']) {
                    $_POST['file_type'] = 'rar,zip,doc,docx,xls';
                } else {
                    $file_type = explode(',', str_replace(' ', '', $_POST['file_type']));
                    
                    //禁止后台设定可执行程序后缀
                    foreach ($file_type as $filekey => $filevalue) {
                        
                        $new_file_type = strtolower(str_replace('.', '', trim($filevalue)));
                        if (in_array($new_file_type, array('php', 'asp', 'aspx', 'jsp', 'exe', 'do'))) {
                            
                            unset($file_type[$filekey]);
                        }
                    }
                    $_POST['file_type'] = implode(',', $file_type);
                }
                if (!$_POST['wmark_position']) {
                    $_POST['wmark_position'] = 1;
                }
            }
            unset($_POST['config']);
            unset($_POST['pytoken']);
            if (isset($_POST['map_key'])) {
                if (strpos($this->config['sy_weburl'], 'https') !== FALSE) {
                    
                    $_POST['mapurl'] = 'https://api.map.baidu.com/api?v=2.0&ak=' . $_POST['map_key'] . '&s=1';
                } else {
                    $_POST['mapurl'] = 'http://api.map.baidu.com/api?v=2.0&ak=' . $_POST['map_key'];
                }
            }
            if (!empty($_POST['sy_weburl'])) {
                $weburl = trim($_POST['sy_weburl']);
                if (stripos($weburl, 'http') === FALSE) {
                    $this->layer_msg('网站地址缺少http://或https://', 8, 1, '');
                }
                // 保存域名时,相关的内容要重新保存,防止域名或http头改变后,有关功能异常
                if (!empty($this->config['map_key'])) {
                    // 百度地图地址
                    $protocol = getprotocol($weburl);
                    $_POST['mapurl'] = $protocol . 'api.map.baidu.com/api?v=2.0&ak=' . $this->config['map_key'] . '&s=1';
                }
                if (!empty($this->config['sy_indexdomain'])) {
                    // 分站默认域名
                    $protocol = getprotocol($weburl);
                    $indexUrl = parse_url($this->config['sy_indexdomain']);
                    $indexPath = !empty($indexUrl['path']) ? $indexUrl['path'] : '';
                    $_POST['sy_indexdomain'] = $protocol . $indexUrl['host'] . $indexPath;
                }
                if (file_exists(DATA_PATH . '/api/alipay/alipay_data.php')) {
                    // 支付宝配置参数中网站域名,跟随调整
                    @include(DATA_PATH . 'api/alipay/alipay_data.php');
                    if (!empty($alipaydata)) {
                        $alipaydata['sy_weburl'] = $weburl;
                        made_web(DATA_PATH . 'api/alipay/alipay_data.php', ArrayToString($alipaydata), 'alipaydata');
                    }
                }
            }
            $configM = $this->MODEL('config');
            
            $configM->setConfig($_POST);
            
            // 判断验证字符
            if ($_POST['code_strlength'] < 5) {
                $this->web_config();
                $this->layer_msg("网站配置设置成功!", 9, 1);
            } else {
                $this->layer_msg("验证码字符数不要大于4!", 8, 1, '');
            }
        }
    }
    
    // 加载模板缓存
    function settplcache_action() {
        include(CONFIG_PATH . "db.data.php");
        include(PLUS_PATH . "cache.config.php");
        $modelconfig = $arr_data['modelconfig'];
        
        foreach ($modelconfig as $key => $value) {
            $newModel[$key]['value'] = $value;
            $newModel[$key]['cache'] = $cache_config['sy_' . $key . '_cache'];
        }
        $this->yunset('newModel', $newModel);
        $this->yunset('cache_config', $cache_config);
        
        $this->yuntpl(array(
            'admin/admin_tplcache'
        ));
    }
    
    // 保存设置模板缓存
    function savetplcache_action() {
        if ($_POST["config"]) {
            unset($_POST["config"]);
            include(CONFIG_PATH . "db.data.php");
            $modelconfig = array_keys($arr_data['modelconfig']);
            $config_new = array();
            foreach ($_POST as $key => $v) {
                $model = explode('_', $key);
                if (in_array($model[1], $modelconfig) || $model[1] == 'index') {
                    $config_new[$key] = $v;
                }
            }
            
            made_web(PLUS_PATH . 'cache.config.php', ArrayToString($config_new), 'cache_config');
            $this->ACT_layer_msg("模块缓存设置修改成功!", 9, "index.php?m=config&c=settplcache", 2, 1);
        }
    }
    
    // 刷新sphinx主索引
    function refresh_sphinx_main_index_action() {
        require_once(APP_PATH . 'app/include/cron/sphinx_indexer_main.php');
        echo '1';
        exit();
    }
    
    // 开启sphinx时,检查searchd是否运行,生成sphinx.conf配置文件
    function check_usesphinx_action() {
        include_once(LIB_PATH . "sphinx.class.php");
        $useSphinx = FALSE;
        if (sphinx::isRun($this->config['sphinxhost'], $this->config['sphinxport'])) {
            $useSphinx = TRUE;
        }
        
        if ($useSphinx) {
            require_once(LIB_PATH . 'sphinxhelper.class.php');
            $helper = new sphinxhelper();
            $helper->generateConf();
            echo '1';
            exit();
        } else {
            echo '2';
            exit();
        }
    }
    
    // 生成sphinx.conf配置文件
    function generate_conf_action() {
        require_once(LIB_PATH . 'sphinxhelper.class.php');
        $helper = new sphinxhelper();
        $helper->generateConf();
        echo '1';
        exit();
    }
    
    // 启动/停止sphinx的searchd搜索服务
    public function sphinx_searchd_action() {
        if (!isset($_POST['status']) || ($_POST['status'] != 'start' && $_POST['status'] != 'stop')) {
            echo '2';
            exit();
        }
        
        if (isServerOsWindows()) { // windows服务器
            if ($_POST['status'] == 'start') {
                exec('net start SphinxSearch');
            } else {
                exec('net stop SphinxSearch');
            }
        } else { // linux服务器
            if ($_POST['status'] == 'start') {
                exec('searchd');
            } else {
                exec('searchd --stop');
            }
        }
        echo '1';
        exit();
    }
    
    //后台专用,layui上传图片公共方法
    function layui_upload_action() {
        
        if ($_FILES['file']['tmp_name']) {
            
            $data = array(
                'name'  => $_POST['name'],
                'path'  => $_POST['path'],
                'imgid' => $_POST['imgid'],
                'file'  => $_FILES['file']
            );
            
            
            $UploadM = $this->MODEL('upload');
            
            $return = $UploadM->layUpload($data);
            
            if (!empty($_POST['name']) && $return['code'] == 0) {
                // 后台上传logo后,重新生成缓存
                $this->web_config();
            }
        } else {
            $return = array(
                'code' => 1,
                'msg'  => '请上传文件',
                'data' => array()
            );
        }
        echo json_encode($return);
    }
}
 
?>