UpgradeController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. Doo::loadModelAt('aconfig', 'admin');
  3. /**
  4. * MainController
  5. * Feel free to delete the methods and replace them with your own code.
  6. *
  7. * @author NoNZero
  8. */
  9. class UpgradeController extends DooController
  10. {
  11. private $data, $modelconfig, $onoff = array('on', 'off');
  12. public function __construct()
  13. {
  14. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  15. $this->modelconfig = new AConfig();
  16. }
  17. public function getWebVersion()
  18. {
  19. exit(json_encode(array('version' => DOO::conf()->ver), JSON_UNESCAPED_UNICODE));
  20. }
  21. public function getVersionAndStatus()
  22. {
  23. header("Access-Control-Allow-Origin: *");
  24. $onoff = $this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'];
  25. exit(json_encode(array('version' => DOO::conf()->ver, 'onoff' => $onoff), JSON_UNESCAPED_UNICODE));
  26. }
  27. public function getSoftwareVersion()
  28. {
  29. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  30. }
  31. public function setOnOff()
  32. {
  33. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  34. }
  35. public function getSwitchStatus()
  36. {
  37. $onoff = $this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'];
  38. echo json_encode(array('onoff' => $onoff), JSON_UNESCAPED_UNICODE);
  39. die();
  40. }
  41. public function setSwitchStatus()
  42. {
  43. header("Access-Control-Allow-Origin: *");
  44. if (in_array($this->params['onoff'], $this->onoff)) {
  45. if ($this->params['onoff'] == 'on') {
  46. $this->modelconfig->onoff = 0;
  47. $stronoff = $this->modelconfig->update(array('where' => 'conid=1'));
  48. } else {
  49. $this->modelconfig->onoff = 1;
  50. $stronoff = $this->modelconfig->update(array('where' => 'conid=1',));
  51. }
  52. }
  53. echo json_encode(array('onoff' => $stronoff), JSON_UNESCAPED_UNICODE);
  54. die();
  55. }
  56. public function setUpgradeInfo()
  57. {
  58. // error_log(var_dump($_POST, TRUE), 3, '/opt/html/dev/data/sss.txt');
  59. // if (in_array($this->params['onoff'], $this->onoff)) {
  60. // if ($this->params['onoff'] == 'on') {
  61. $this->modelconfig->upgradeinfo = $_POST['json'];
  62. $stronoff = $this->modelconfig->update(array('where' => 'conid=1'));
  63. // }
  64. // }
  65. echo json_encode(array('onoff' => $stronoff), JSON_UNESCAPED_UNICODE);
  66. die();
  67. }
  68. }