Webconfig.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 中闽 < 1464674022@qq.com >
  5. * Date: 2019/12/5
  6. * Time: 17:44
  7. */
  8. namespace app\admin\controller;
  9. use app\admin\controller\base\Permissions;
  10. use app\admin\model\AdminLog;
  11. use app\admin\model\Urlconfig;
  12. use app\common\model\ConfigTab as configTabModel;
  13. use think\Cache;
  14. use think\Db;
  15. class Webconfig extends Permissions
  16. {
  17. public function index()
  18. {
  19. $this->assign('web_config', Db::name('webconfig')->where('id', 1)->find());
  20. $this->assign('is_close_site_key', (new Urlconfig())->getCloseSiteKey());
  21. $this->assign('admin_log_num', (new AdminLog())->count());
  22. $this->assign('backend_pass', (new Urlconfig())->getBackendPass());
  23. //扩展配置标签
  24. $tabs = (new configTabModel())->where('status', configTabModel::STATUS_OPEN)->order('sort desc')->select();
  25. $this->assign('tabs', $tabs);
  26. return $this->fetch();
  27. }
  28. public function publish()
  29. {
  30. if ($this->request->isPost()) {
  31. $post = $this->request->post();
  32. $validate = new \think\Validate([
  33. ['file_type', 'requireWith:name', '上传类型不能为空'],
  34. ['file_size', 'requireWith:name', '上传大小不能为空'],
  35. ['host', 'url'],
  36. ]);
  37. if (!$validate->check($post)) {
  38. $this->error('提交失败:' . $validate->getError());
  39. }
  40. if (!isset($post['is_log'])) {
  41. $post['is_log'] = 0;
  42. }
  43. if (!isset($post['is_close_site'])) {
  44. $post['is_close_site'] = 0;
  45. }
  46. $model = (new \app\common\model\Webconfig())->where('id', 1)->find();
  47. if (false == $model->allowField(true)->save($post)) {
  48. $this->error('提交失败');
  49. } else {
  50. Cache::clear();
  51. $this->success('提交成功', 'admin/webconfig/index');
  52. }
  53. }
  54. }
  55. public function appointmentConfig()
  56. {
  57. }
  58. }