xuanxuan.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class setting extends control
  3. {
  4. /**
  5. * Configuration of xuanxuan.
  6. *
  7. * @access public
  8. * @return void
  9. */
  10. public function xuanxuan($type = '')
  11. {
  12. $this->app->loadLang('im');
  13. $this->app->loadLang('client');
  14. if($_POST)
  15. {
  16. $setting = fixer::input('post')->join('staff', ',')->get();
  17. $errors = array();
  18. if(!is_numeric($setting->chatPort) or (int)$setting->chatPort <= 0 or (int)$setting->chatPort > 65535) $errors['chatPort'] = $this->lang->im->xxdPortError;
  19. if(!is_numeric($setting->commonPort) or (int)$setting->commonPort <= 0 or (int)$setting->commonPort > 65535) $errors['commonPort'] = $this->lang->im->xxdPortError;
  20. if($setting->https == 'on')
  21. {
  22. if(empty($setting->sslcrt)) $errors['sslcrt'] = $this->lang->im->errorSSLCrt;
  23. if(empty($setting->sslkey)) $errors['sslkey'] = $this->lang->im->errorSSLKey;
  24. }
  25. if($setting->turnon and strpos($setting->server, '127.0.0.1') !== false) $errors['server'] = $this->lang->im->xxdServerError;
  26. if(strpos($setting->server, 'https://') !== 0 and strpos($setting->server, 'http://') !== 0) $errors['server'] = $this->lang->im->xxdSchemeError;
  27. if(empty($setting->server)) $errors['server'] = $this->lang->im->xxdServerEmpty;
  28. if($errors) $this->send(array('result' => 'fail', 'message' => $errors));
  29. $result = $this->setting->setItems('system.common.xuanxuan', $setting);
  30. if(!$result) $this->send(array('result' => 'fail', 'message' => dao::getError()));
  31. $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('xuanxuan')));
  32. }
  33. $os = 'win';
  34. if(strpos(strtolower(PHP_OS), 'win') !== 0) $os = strtolower(PHP_OS);
  35. $this->lang->navGroup->im = 'admin';
  36. $this->view->title = $this->lang->im->common;
  37. $this->view->position[] = html::a($this->createLink('admin', 'xuanxuan'), $this->lang->im->common);
  38. $this->view->position[] = $this->lang->setting->common;
  39. $this->view->adminList = $this->loadModel('user')->getPairs('admin');
  40. $this->view->os = $os . '_' . php_uname('m');
  41. $this->view->type = $type;
  42. $this->view->domain = $this->loadModel('im')->getServer('zentao');
  43. $this->view->turnon = isset($this->config->xuanxuan->turnon) ? $this->config->xuanxuan->turnon : 1;
  44. $this->view->https = $this->config->xuanxuan->https ? $this->config->xuanxuan->https : 'off';
  45. $this->display();
  46. }
  47. }