KodExplorer/app/controller/setting.class.php

147 lines
3.6 KiB
PHP
Raw Normal View History

2016-12-21 08:01:06 +00:00
<?php
2015-03-22 20:54:54 +00:00
/*
2017-08-23 19:40:27 +00:00
* @link http://kodcloud.com/
* @author warlee | e-mail:kodcloud@qq.com
2015-03-22 20:54:54 +00:00
* @copyright warlee 2014.(Shanghai)Co.,Ltd
2017-08-23 19:40:27 +00:00
* @license http://kodcloud.com/tools/license/license.txt
2015-03-22 20:54:54 +00:00
*/
class setting extends Controller{
2016-12-21 08:01:06 +00:00
private $sql;
function __construct(){
parent::__construct();
}
2015-03-22 20:54:54 +00:00
2016-12-21 08:01:06 +00:00
/**
* 用户首页展示
*/
public function index() {
2017-08-23 19:40:27 +00:00
$this->display('index.html');
2016-12-21 08:01:06 +00:00
}
2015-03-22 20:54:54 +00:00
2016-12-21 08:01:06 +00:00
/**
* 用户首页展示
*/
public function slider() {
switch ($this->in['slider']) {
2017-08-23 19:40:27 +00:00
case 'about':show_json(file_get_contents(LANGUAGE_PATH.I18n::getType().'/about.html'));break;
case 'help':show_json(file_get_contents(LANGUAGE_PATH.I18n::getType().'/help.html'));break;
2016-12-21 08:01:06 +00:00
case 'member':break;
case 'fav':break;
case 'user':
case 'theme':
case 'wall':
show_json(array(
2017-08-23 19:40:27 +00:00
'settingAll' => $this->config['settingAll'],
2016-12-21 08:01:06 +00:00
'user' => $this->config['user']
));
break;
case 'system':
2017-08-23 19:40:27 +00:00
if($GLOBALS['isRoot']){
2017-04-12 12:16:09 +00:00
if(isset($this->in['env_check'])){
show_json(php_env_check());
}
2017-08-23 19:40:27 +00:00
$result = $this->config['settingSystem'];
unset($result['systemPassword']);
2017-04-12 12:16:09 +00:00
show_json($result,true);
2016-12-21 08:01:06 +00:00
}else{
show_json('error',false);
}
break;
default:break;
}
}
2015-03-22 20:54:54 +00:00
2017-08-23 19:40:27 +00:00
public function phpInfo(){
2016-12-21 08:01:06 +00:00
phpinfo();
}
2015-03-22 20:54:54 +00:00
2016-12-21 08:01:06 +00:00
//管理员 系统设置全局数据
2017-08-23 19:40:27 +00:00
public function systemSetting(){
$settingFile = USER_SYSTEM.'system_setting.php';
2016-12-21 08:01:06 +00:00
$data = json_decode($this->in['data'],true);
if (!$data) {
2017-08-23 19:40:27 +00:00
show_json(LNG('error'),false);
2016-12-21 08:01:06 +00:00
}
2017-08-23 19:40:27 +00:00
$setting = $GLOBALS['config']['settingSystem'];
2016-12-21 08:01:06 +00:00
foreach ($data as $key => $value){
if ($key=='menu') {
$setting[$key] = $value;
}else{
$setting[$key] = rawurldecode($value);
}
}
//为了保存更多的数据;不直接覆盖文件 $data->setting_file;
2017-08-23 19:40:27 +00:00
FileCache::save($settingFile,$setting);
show_json(LNG('success'));
2016-12-21 08:01:06 +00:00
}
2015-03-22 20:54:54 +00:00
2017-08-23 19:40:27 +00:00
public function systemTools(){
2017-04-07 13:11:01 +00:00
$action = $this->in['action'];
switch($action){
2017-08-23 19:40:27 +00:00
case 'clearCache':$this->_clearCache();break;
case 'clearSession':$this->_clearSession();break;
case 'clearUserRecycle':$this->_clearUserRecycle();break;
2017-04-07 13:11:01 +00:00
default:break;
}
2017-08-23 19:40:27 +00:00
show_json(LNG('success'),true);
2017-04-07 13:11:01 +00:00
}
2017-08-23 19:40:27 +00:00
private function clearSession(){
2017-04-07 13:11:01 +00:00
del_dir(KOD_SESSION);
}
2017-08-23 19:40:27 +00:00
private function _clearCache(){
2017-04-07 13:11:01 +00:00
del_dir(TEMP_PATH);
mk_dir(TEMP_PATH.'log');
mk_dir(TEMP_PATH.'thumb');
}
2017-08-23 19:40:27 +00:00
private function _clearUserRecycle(){
$sql = systemMember::loadData();
2017-04-07 13:11:01 +00:00
$user_arr = $sql->get();
foreach ($user_arr as $key => $user) {
2017-08-23 19:40:27 +00:00
$userPath = USER_PATH.$user['path']."/";
$pathArr = array(
$userPath.'data/temp',
$userPath.'data/share_temp',
$userPath.'recycle_kod'
2017-04-07 13:11:01 +00:00
);
2017-08-23 19:40:27 +00:00
foreach ($pathArr as $value) {
2017-04-07 13:11:01 +00:00
del_dir($value);
mk_dir($value);
}
}
}
2016-12-21 08:01:06 +00:00
/**
* 参数设置
* 可以同时修改多个key=a,b,c&value=1,2,3
* 防xss 做过滤
*/
public function set(){
$file = USER.'data/config.php';
2016-12-30 15:55:50 +00:00
if (!path_writeable(iconv_system($file))) {//配置不可写
2017-08-23 19:40:27 +00:00
show_json(LNG('no_permission_write_file'),false);
2016-12-21 08:01:06 +00:00
}
$key = $this->in['k'];
$value = $this->in['v'];
if ($key !='' && $value != '') {
$conf = $this->config['user'];
if(!strpos($key,',')){//多个参数value不能包含','
$conf[$key] = clear_html($value);
}else{
$arr_k = explode(',', $key);
$arr_v = explode(',',$value);
$num = count($arr_k);
for ($i=0; $i < $num; $i++) {
$conf[$arr_k[$i]] = clear_html($arr_v[$i]);
}
}
2017-08-23 19:40:27 +00:00
FileCache::save($file,$conf);
show_json(LNG('setting_success'));
2016-12-21 08:01:06 +00:00
}else{
2017-08-23 19:40:27 +00:00
show_json(LNG('error'),false);
2016-12-21 08:01:06 +00:00
}
}
2015-03-22 20:54:54 +00:00
}