diagnose.ctrl.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->classs('cloudapi');
  8. load()->model('cloud');
  9. load()->model('setting');
  10. $dos = array('display', 'testapi');
  11. $do = in_array($do, $dos) ? $do : 'display';
  12. permission_check_account_user('system_cloud_diagnose');
  13. if ($do == 'testapi') {
  14. $starttime = microtime(true);
  15. $_URLTYPE = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
  16. $response = cloud_request($_URLTYPE.'HTTP_HOST', array(), array('ip' => $_GPC['ip']));
  17. $endtime = microtime(true);
  18. iajax(0,'请求接口成功,耗时 '.(round($endtime - $starttime, 5)).' 秒');
  19. } else {
  20. if(checksubmit()) {
  21. $result = cloud_reset_siteinfo();
  22. $api = new CloudApi();
  23. $api->deleteCer();
  24. if (is_error($result)) {
  25. itoast($result['message'], '', 'error');
  26. } else {
  27. cache_delete('cloud_site_register_info');
  28. itoast('重置成功', 'refresh', 'success');
  29. }
  30. }
  31. if (checksubmit('updateserverip')) {
  32. if (!empty($_GPC['ip'])) {
  33. setting_save(array('ip' => $_GPC['ip'], 'expire' => TIMESTAMP + 201600), 'cloudip');
  34. } else {
  35. setting_save(array(), 'cloudip');
  36. }
  37. itoast('修改云服务ip成功.', 'refresh', 'success');
  38. }
  39. if(empty($_W['setting']['site'])) {
  40. $_W['setting']['site'] = array();
  41. }
  42. $checkips = array();
  43. if (!empty($_W['setting']['cloudip']['ip'])) {
  44. $checkips[] = $_W['setting']['cloudip']['ip'];
  45. }
  46. if (strexists(strtoupper(PHP_OS), 'WINNT')) {
  47. $cloudip = gethostbyname('HTTP_HOST');
  48. if (!in_array($cloudip, $checkips)) {
  49. $checkips[] = $cloudip;
  50. }
  51. } else {
  52. for ($i = 0; $i <= 10; $i++) {
  53. $cloudip = gethostbyname('HTTP_HOST');
  54. if (!in_array($cloudip, $checkips)) {
  55. $checkips[] = $cloudip;
  56. }
  57. }
  58. }
  59. template('cloud/diagnose');
  60. }