SiteController.class.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace Admin\Controller;
  3. /**
  4. * 站点设置
  5. * @author Devil
  6. * @blog http://gong.gg/
  7. * @version 0.0.1
  8. * @datetime 2016-12-01T21:51:08+0800
  9. */
  10. class SiteController extends CommonController
  11. {
  12. /**
  13. * [_initialize 前置操作-继承公共前置方法]
  14. * @author Devil
  15. * @blog http://gong.gg/
  16. * @version 0.0.1
  17. * @datetime 2016-12-03T12:39:08+0800
  18. */
  19. public function _initialize()
  20. {
  21. // 调用父类前置方法
  22. parent::_initialize();
  23. // 登录校验
  24. $this->Is_Login();
  25. // 权限校验
  26. $this->Is_Power();
  27. }
  28. /**
  29. * [Index 配置列表]
  30. * @author Devil
  31. * @blog http://gong.gg/
  32. * @version 0.0.1
  33. * @datetime 2016-12-06T21:31:53+0800
  34. */
  35. public function Index()
  36. {
  37. // 时区
  38. $this->assign('site_timezone_list', L('site_timezone_list'));
  39. // 站点状态
  40. $this->assign('site_site_state_list', L('site_site_state_list'));
  41. // 是否开启用户注册
  42. $this->assign('site_user_reg_state_list', L('site_user_reg_state_list'));
  43. // 是否开启用户登录
  44. $this->assign('site_user_login_state_list', L('site_user_login_state_list'));
  45. // 获取验证码-开启图片验证码
  46. $this->assign('site_img_verify_state_list', L('site_img_verify_state_list'));
  47. // 配置信息
  48. $data = M('Config')->getField('only_tag,name,describe,value,error_tips');
  49. $this->assign('data', $data);
  50. $this->assign('nav_type', 'site');
  51. $this->display('Index');
  52. }
  53. /**
  54. * [Save 配置数据保存]
  55. * @author Devil
  56. * @blog http://gong.gg/
  57. * @version 0.0.1
  58. * @datetime 2017-01-02T23:08:19+0800
  59. */
  60. public function Save()
  61. {
  62. // 站点logo
  63. if(isset($_FILES['home_site_logo_img']['error']))
  64. {
  65. // 文件上传校验
  66. $error = FileUploadError('home_site_logo_img');
  67. if($error !== true)
  68. {
  69. $this->ajaxReturn($error, -1);
  70. }
  71. // 文件类型
  72. list($type, $suffix) = explode('/', $_FILES['home_site_logo_img']['type']);
  73. $path = 'Public/Upload/Home/image/';
  74. if(!is_dir($path))
  75. {
  76. mkdir(ROOT_PATH.$path, 0777, true);
  77. }
  78. $filename = 'home_logo.'.$suffix;
  79. $home_site_logo = $path.$filename;
  80. if(move_uploaded_file($_FILES['home_site_logo_img']['tmp_name'], ROOT_PATH.$home_site_logo))
  81. {
  82. $_POST['home_site_logo'] = '/'.$home_site_logo;
  83. }
  84. }
  85. // 站点状态值处理
  86. if(!isset($_POST['home_user_reg_state']))
  87. {
  88. $_POST['home_user_reg_state'] = '';
  89. }
  90. // 基础配置
  91. $this->MyConfigSave();
  92. }
  93. }
  94. ?>