Config.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller;
  15. use think\admin\Controller;
  16. /**
  17. * 系统参数配置
  18. * Class Config
  19. * @package app\admin\controller
  20. */
  21. class Config extends Controller
  22. {
  23. /**
  24. * 绑定数据表
  25. * @var string
  26. */
  27. protected $table = 'SystemConfig';
  28. /**
  29. * 阿里数据中心
  30. * @var array
  31. */
  32. protected $points = [
  33. 'oss-cn-hangzhou.aliyuncs.com' => '华东 1(杭州)',
  34. 'oss-cn-shanghai.aliyuncs.com' => '华东 2(上海)',
  35. 'oss-cn-qingdao.aliyuncs.com' => '华北 1(青岛)',
  36. 'oss-cn-beijing.aliyuncs.com' => '华北 2(北京)',
  37. 'oss-cn-zhangjiakou.aliyuncs.com' => '华北 3(张家口)',
  38. 'oss-cn-huhehaote.aliyuncs.com' => '华北 5(呼和浩特)',
  39. 'oss-cn-shenzhen.aliyuncs.com' => '华南 1(深圳)',
  40. 'oss-cn-chengdu.aliyuncs.com' => '西南 1(成都)',
  41. 'oss-cn-hongkong.aliyuncs.com' => '中国(香港)',
  42. 'oss-us-west-1.aliyuncs.com' => '美国西部 1(硅谷)',
  43. 'oss-us-east-1.aliyuncs.com' => '美国东部 1(弗吉尼亚)',
  44. 'oss-ap-southeast-1.aliyuncs.com' => '亚太东南 1(新加坡)',
  45. 'oss-ap-southeast-2.aliyuncs.com' => '亚太东南 2(悉尼)',
  46. 'oss-ap-southeast-3.aliyuncs.com' => '亚太东南 3(吉隆坡)',
  47. 'oss-ap-southeast-5.aliyuncs.com' => '亚太东南 5(雅加达)',
  48. 'oss-ap-northeast-1.aliyuncs.com' => '亚太东北 1(日本)',
  49. 'oss-ap-south-1.aliyuncs.com' => '亚太南部 1(孟买)',
  50. 'oss-eu-central-1.aliyuncs.com' => '欧洲中部 1(法兰克福)',
  51. 'oss-eu-west-1.aliyuncs.com' => '英国(伦敦)',
  52. 'oss-me-east-1.aliyuncs.com' => '中东东部 1(迪拜)'
  53. ];
  54. /**
  55. * 系统参数配置
  56. * @auth true
  57. * @menu true
  58. */
  59. public function index()
  60. {
  61. $this->title = '系统参数配置';
  62. $this->fetch();
  63. }
  64. /**
  65. * 修改系统参数
  66. * @auth true
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\DbException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. */
  71. public function system()
  72. {
  73. $this->_applyFormToken();
  74. if ($this->request->isGet()) {
  75. $this->title = '修改系统参数';
  76. $this->fetch();
  77. } else {
  78. foreach ($this->request->post() as $name => $value) {
  79. sysconf($name, $value);
  80. }
  81. $this->success('修改系统参数成功!');
  82. }
  83. }
  84. /**
  85. * 修改文件存储
  86. * @auth true
  87. * @throws \think\db\exception\DataNotFoundException
  88. * @throws \think\db\exception\DbException
  89. * @throws \think\db\exception\ModelNotFoundException
  90. */
  91. public function storage()
  92. {
  93. $this->_applyFormToken();
  94. if ($this->request->isGet()) {
  95. $this->type = input('type', 'local');
  96. $this->fetch("storage-{$this->type}");
  97. }
  98. $post = $this->request->post();
  99. if (!empty($post['storage']['allow_exts'])) {
  100. $exts = array_unique(explode(',', strtolower($post['storage']['allow_exts'])));
  101. sort($exts);
  102. if (in_array('php', $exts)) {
  103. $this->error('禁止上传可执行文件到本地服务器!');
  104. }
  105. $post['storage']['allow_exts'] = join(',', $exts);
  106. }
  107. foreach ($post as $key => $value) sysconf($key, $value);
  108. $this->success('修改文件存储成功!');
  109. }
  110. }