SysController.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. ini_set('display_errors', 1);
  3. session_start(); // starts new or resumes existing session
  4. Doo::loadModelAt('aconfig', 'admin');
  5. Doo::loadModelAt('auser', 'admin');
  6. Doo::loadClass('mailer');
  7. /*
  8. * To change this license header, choose License Headers in Project Properties.
  9. * To change this template file, choose Tools | Templates
  10. * and open the template in the editor.
  11. */
  12. // 列表停用 编辑 重置密码
  13. // 管理员权限管理
  14. // 管理员修改密码
  15. class SysController extends DooController
  16. {
  17. private $data, $aconfig, $auser, $profile, $ph, $userz, $mailer;
  18. public function beforeRun($resource, $action)
  19. {
  20. if (!isset($_SESSION['auid'])) {
  21. return Doo::conf()->APP_URL . 'manage';
  22. }
  23. }
  24. public function __construct()
  25. {
  26. $this->aconfig = new AConfig();
  27. $this->auser = new AUser();
  28. $this->mailer = new Mailer();
  29. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  30. }
  31. function sysinfo()
  32. {
  33. if (isset($_POST['proname']) || isset($_POST['aemail'])) {
  34. if ($_POST['proname']) {
  35. $this->aconfig->proname = $_POST['proname'];
  36. $this->aconfig->update(array('where' => 'conid = 1'));
  37. }
  38. if ($_POST['aemail'] && filter_var($_POST['aemail'], FILTER_VALIDATE_EMAIL)) {
  39. $this->auser->aemail = $_POST['aemail'];
  40. $this->auser->update(array('where' => 'auid = 1'));
  41. $this->mailer->setEmails($_POST['aemail']);
  42. $this->mailer->seteTitle('管理员邮箱地址已修改');
  43. $this->mailer->setClientName($_SESSION['aname']);
  44. $signupConfigStr = '<h3>管理员邮箱地址已修改</h3><p><h2>' . $_POST['aemail'] . '</h2></p>';
  45. $this->mailer->setContent($signupConfigStr);
  46. $this->mailer->send_mail();
  47. }
  48. return Doo::conf()->APP_URL . 'manage/sys/info';
  49. }
  50. $this->data['proName'] = $this->aconfig->getOne(array('select' => 'proName', 'asArray' => TRUE))['proName'];
  51. $this->data['aemail'] = $this->auser->getOne(array('select' => 'aemail', 'asArray' => TRUE))['aemail'];
  52. $this->data['ver'] = DOO::conf()->ver;
  53. $this->data['aname'] = $_SESSION['aname'];
  54. $this->data['menu'] = 1;
  55. $this->render('admin-sysinfo', $this->data, TRUE);
  56. }
  57. function smsSwitch()
  58. {
  59. if (isset($_POST['switch'])) {
  60. if ($_POST['switch'] == 'off') {
  61. $this->aconfig->smsswitch = 0;
  62. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  63. exit(json_encode(array('switch' => 'off')));
  64. }
  65. if ($_POST['switch'] == 'on') {
  66. $this->aconfig->smsswitch = 1;
  67. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  68. exit(json_encode(array('switch' => 'on')));
  69. }
  70. }
  71. $this->data['smsSwitch'] = $this->aconfig->getOne(array('select' => 'smsswitch', 'asArray' => TRUE))['smsswitch'];
  72. $this->data['menu'] = 4;
  73. $this->render('admin-sms', $this->data, TRUE);
  74. }
  75. }