/**
  * 获取配置列表与ThinkPHP配置合并
  * @return array 配置数组
  * @author jry <*****@*****.**>
  */
 public function lists()
 {
     $map['status'] = array('eq', 1);
     $list = $this->where($map)->field('name,value,type')->select();
     foreach ($list as $key => $val) {
         switch ($val['type']) {
             case 'array':
                 $config[$val['name']] = \Common\Util\Think\Str::parseAttr($val['value']);
                 break;
             case 'checkbox':
                 $config[$val['name']] = explode(',', $val['value']);
                 break;
             default:
                 $config[$val['name']] = $val['value'];
                 break;
         }
     }
     return $config;
 }
    public function step4()
    {
        if (session('step') !== '3') {
            $this->error('请按顺序安装', U('step3'));
        }
        session('step', '4');
        session('error', false);
        $this->assign('meta_title', "step4");
        $this->display();
        //连接数据库
        $db_config = session('db_config');
        $db_instance = Db::getInstance($db_config);
        //创建数据表
        create_tables($db_instance, $db_config['DB_PREFIX']);
        //生成加密字符串
        $add_chars .= '`~!@#$%^&*()_+-=[]{};:"|,.<>/?';
        $auth = Str::randString(64, '', $add_chars);
        //生成随机数
        //创建配置文件
        $conf = write_config($db_config, $auth);
        //根据加密字符串更新admin密码的加密结果
        $new_admin_password = user_md5('admin', $auth);
        $sql = <<<SQL
        UPDATE `{$db_config["DB_PREFIX"]}admin_config` SET `value`='{$auth}' WHERE `name` = 'AUTH_KEY';
        UPDATE `{$db_config["DB_PREFIX"]}admin_user` SET `password`='{$new_admin_password}' WHERE `id` = 1;
SQL;
        $result = $db_instance->execute($sql);
        if (!$result) {
            $this->error('写入系统加密KEY或管理员新密码出错!');
        }
        if (session('error')) {
            $this->error('安装出错', 'index');
        } else {
            $this->redirect('complete');
        }
    }
 /**
  * 获取某个分组的配置参数
  * @author jry <*****@*****.**>
  */
 public function group($group = 1)
 {
     //根据分组获取配置
     $map['status'] = array('egt', '0');
     // 禁用和正常状态
     $map['group'] = array('eq', $group);
     $data_list = D('Config')->where($map)->order('sort asc,id asc')->select();
     // 设置Tab导航数据列表
     $config_group_list = C('CONFIG_GROUP_LIST');
     // 获取配置分组
     foreach ($config_group_list as $key => $val) {
         $tab_list[$key]['title'] = $val;
         $tab_list[$key]['href'] = U('group', array('group' => $key));
     }
     // 构造表单名、解析options
     foreach ($data_list as &$data) {
         $data['name'] = 'config[' . $data['name'] . ']';
         $data['options'] = \Common\Util\Think\Str::parseAttr($data['options']);
     }
     // 使用FormBuilder快速建立表单页面。
     $builder = new \Common\Builder\FormBuilder();
     $builder->setMetaTitle('系统设置')->SetTabNav($tab_list, $group)->setPostUrl(U('groupSave'))->setExtraItems($data_list)->display();
 }
Exemple #4
0
/**
 * 过滤标签,输出纯文本
 * @param string $str 文本内容
 * @return string 处理后内容
 * @author jry <*****@*****.**>
 */
function html2text($str)
{
    return \Common\Util\Think\Str::html2text($str);
}