SysController.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. $this->aconfig->smssignswitch = 0;
  63. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  64. exit(json_encode(array('switch' => 'off')));
  65. }
  66. if ($_POST['switch'] == 'on') {
  67. $this->aconfig->smsswitch = 1;
  68. $this->aconfig->smssignswitch = 1;
  69. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  70. exit(json_encode(array('switch' => 'on')));
  71. }
  72. }
  73. if (isset($_POST['status']) && isset($_POST['type'])) {
  74. if($_POST['status'] == 'close'){
  75. $ststus = 0;
  76. }else{
  77. $ststus = 1;
  78. }
  79. if ($_POST['type'] == 'sign') {
  80. $this->aconfig->smssignswitch = $ststus;
  81. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  82. exit(json_encode(array('switch' => $ststus)));
  83. }else if ($_POST['type'] == 'switch') {
  84. $this->aconfig->smsswitch = $ststus;
  85. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  86. exit(json_encode(array('switch' => $ststus)));
  87. }
  88. }
  89. $this->data['smsSwitch'] = $this->aconfig->getOne(array('select' => 'smsswitch', 'asArray' => TRUE))['smsswitch'];
  90. $this->data['smsSignSwitch'] = $this->aconfig->getOne(array('select' => 'smssignswitch', 'asArray' => TRUE))['smssignswitch'];
  91. $this->data['Switch'] = $this->data['smsSwitch'] || $this->data['smsSignSwitch'] ? 1 : 0;
  92. $this->data['menu'] = 4;
  93. $this->render('admin-sms', $this->data, TRUE);
  94. }
  95. function signSwitch()
  96. {
  97. if(isset($_POST['type']) && isset($_POST['status'])){
  98. if($_POST['status'] == 'close'){
  99. $ststus = 0;
  100. }else{
  101. $ststus = 1;
  102. }
  103. switch($_POST['type']){
  104. case 'report':
  105. $this->aconfig->reportswitch = $ststus;
  106. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  107. exit('1');
  108. break;
  109. case 'sign':
  110. $this->aconfig->signswitch = $ststus;
  111. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  112. exit('1');
  113. break;
  114. case 'launch':
  115. $this->aconfig->launchsignswitch = $ststus;
  116. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  117. exit('1');
  118. break;
  119. }
  120. exit(0);
  121. }
  122. $this->data['reportSwitch'] = $this->aconfig->getOne(array('select' => 'reportswitch', 'asArray' => TRUE))['reportswitch'];
  123. $this->data['signSwitch'] = $this->aconfig->getOne(array('select' => 'signswitch', 'asArray' => TRUE))['signswitch'];
  124. $this->data['launchsignSwitch'] = $this->aconfig->getOne(array('select' => 'launchsignswitch', 'asArray' => TRUE))['launchsignswitch'];
  125. $this->data['menu'] = 6;
  126. $this->render('admin-sign', $this->data, TRUE);
  127. }
  128. function interMediateSwitch()
  129. {
  130. if (isset($_POST['switch'])) {
  131. if ($_POST['switch'] == 'off') {
  132. $this->aconfig->imediateswitch = 0;
  133. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  134. exit(json_encode(array('switch' => 'off')));
  135. }
  136. if ($_POST['switch'] == 'on') {
  137. $this->aconfig->imediateswitch = 1;
  138. if ($this->aconfig->update(array('where' => "conid = 1")) > 0)
  139. exit(json_encode(array('switch' => 'on')));
  140. }
  141. }
  142. $this->data['imediateswitch'] = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];
  143. $this->data['menu'] = 7;
  144. $this->render('admin-intermediate', $this->data, TRUE);
  145. }
  146. }