diagnose.ctrl.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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()->model('cloud');
  8. load()->model('setting');
  9. $dos = array('display', 'testapi');
  10. $do = in_array($do, $dos) ? $do : 'display';
  11. uni_user_permission_check('system_cloud_diagnose');
  12. $_W['page']['title'] = '云服务诊断 - 云服务';
  13. if ($do == 'testapi') {
  14. $starttime = microtime(true);
  15. $response = cloud_request('http://we7.cc', array(), array('ip' => $_GPC['ip']));
  16. $endtime = microtime(true);
  17. iajax(0,'请求接口成功,耗时 '.(round($endtime - $starttime, 5)).' 秒');
  18. } else {
  19. if(checksubmit()) {
  20. setting_save('', 'site');
  21. itoast('成功清除站点记录.', 'refresh', 'success');
  22. }
  23. if (checksubmit('updateserverip')) {
  24. if (!empty($_GPC['ip'])) {
  25. setting_save(array('ip' => $_GPC['ip'], 'expire' => TIMESTAMP + 201600), 'cloudip');
  26. } else {
  27. setting_save(array(), 'cloudip');
  28. }
  29. itoast('修改云服务ip成功.', 'refresh', 'success');
  30. }
  31. if(empty($_W['setting']['site'])) {
  32. $_W['setting']['site'] = array();
  33. }
  34. $checkips = array();
  35. if (!empty($_W['setting']['cloudip']['ip'])) {
  36. $checkips[] = $_W['setting']['cloudip']['ip'];
  37. }
  38. if (strexists(strtoupper(PHP_OS), 'WINNT')) {
  39. $cloudip = gethostbyname('we7.cc');
  40. if (!in_array($cloudip, $checkips)) {
  41. $checkips[] = $cloudip;
  42. }
  43. } else {
  44. for ($i = 0; $i <= 10; $i++) {
  45. $cloudip = gethostbyname('we7.cc');
  46. if (!in_array($cloudip, $checkips)) {
  47. $checkips[] = $cloudip;
  48. }
  49. }
  50. }
  51. template('cloud/diagnose');
  52. }
  53. ?>