GTConfig.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. class GTConfig
  3. {
  4. public static function isNeedOSAsigned()
  5. {
  6. return "true" == GTConfig::getProperty("getui_isNeedAssign", "false");
  7. }
  8. public static function getHttpProxyIp()
  9. {
  10. return GTConfig::getProperty("getui_http_proxy_ip");
  11. }
  12. public static function getHttpProxyPort()
  13. {
  14. return (int)GTConfig::getProperty("getui_http_proxy_port", 80);
  15. }
  16. public static function getHttpProxyUserName()
  17. {
  18. return GTConfig::getProperty("getui_http_proxy_username");
  19. }
  20. public static function getHttpProxyPasswd()
  21. {
  22. return GTConfig::getProperty("getui_http_proxy_passwd");
  23. }
  24. public static function getHttpConnectionTimeOut()
  25. {
  26. return (int)GTConfig::getProperty("getui_http_connecton_timeout", 60000);
  27. }
  28. public static function getHttpInspectInterval()
  29. {
  30. return (int)GTConfig::getProperty("getui_inspect_interval", 300000);
  31. }
  32. public static function getHttpSoTimeOut()
  33. {
  34. return (int)GTConfig::getProperty("getui_http_so_timeout", 30000);
  35. }
  36. public static function getHttpTryCount()
  37. {
  38. return (int)GTConfig::getProperty("getui_http_tryCount", 3);
  39. }
  40. public static function getDefaultDomainUrl($useSSL)
  41. {
  42. $urlStr = GTConfig::getProperty("getui_default_domainurl");
  43. if ($urlStr == null || "" . equals(trim($urlStr))) {
  44. if ($useSSL) {
  45. $hosts = array("https://restapi.getui.com", "https://cncrestapi.getui.com",
  46. "https://nzrestapi.getui.com");
  47. } else {
  48. $hosts = array("http://restapi.getui.com", "http://cncrestapi.getui.com",
  49. "http://nzrestapi.getui.com");
  50. }
  51. } else {
  52. $list = explode(",", $urlStr);
  53. $hosts = array();
  54. foreach ($list as $value) {
  55. if (strpos($value, "https://") === 0 && !$useSSL) {
  56. continue;
  57. }
  58. if (strpos($value, "http://") === 0 && $useSSL) {
  59. continue;
  60. }
  61. if ($useSSL && strpos($value, "http") != 0) {
  62. $value = "https://" . $value;
  63. }
  64. array_push($hosts, $value);
  65. }
  66. }
  67. return $hosts;
  68. }
  69. private static function getProperty($key, $defaultValue = null)
  70. {
  71. $value = getenv($key);
  72. if ($value != null) {
  73. return $value;
  74. } else {
  75. return $defaultValue;
  76. }
  77. }
  78. public static function getSDKVersion()
  79. {
  80. return "1.0.0.0";
  81. }
  82. }