/endpoint/grandstream/htx86/phone.php

https://github.com/mx504/Provisioner · PHP · 137 lines · 118 code · 10 blank · 9 comment · 1 complexity · 33838d36fe8882d9ba7fd72c05599e09 MD5 · raw file

  1. <?php
  2. /**
  3. * HandyTone 286, 486 GXP Phone File
  4. *
  5. * @author Andrew Nagy
  6. * @license MPL / GPLv2 / LGPL
  7. * @package Provisioner
  8. */
  9. class endpoint_grandstream_htx86_phone extends endpoint_grandstream_base {
  10. public $family_line = 'htx86';
  11. function generate_config() {
  12. //Grandstream likes lower case letters in its mac address
  13. $this->mac = strtolower($this->mac);
  14. // Grandstreams support lines 2-6, so let's add them if they're set
  15. for ($i = 1; $i < 6; $i++) {
  16. $this->lines[$i]['line_active'] = (isset($this->lines[$i]['secret']) ? '1' : '0');
  17. }
  18. $contents = $this->open_config_file("\$mac.cfg");
  19. switch(strtoupper($this->timezone)) {
  20. case "GMT-12:00":
  21. $this->timezone = "0";
  22. break;
  23. case "GMT-11:00":
  24. $this->timezone = "60";
  25. break;
  26. case "GMT-10:00":
  27. $this->timezone = "120";
  28. break;
  29. case "GMT-09:00":
  30. $this->timezone = "180";
  31. break;
  32. case "GMT-08:00":
  33. $this->timezone = "240";
  34. break;
  35. case "GMT-07:00":
  36. $this->timezone = "300";
  37. break;
  38. case "GMT-06:00":
  39. $this->timezone = "360";
  40. break;
  41. case "GMT-05:00":
  42. $this->timezone = "420";
  43. break;
  44. case "GMT-04:30":
  45. $this->timezone = "450";
  46. break;
  47. case "GMT-04:00":
  48. $this->timezone = "480";
  49. break;
  50. case "GMT-03:30":
  51. $this->timezone = "510";
  52. break;
  53. case "GMT-03:00":
  54. $this->timezone = "540";
  55. break;
  56. case "GMT-02:00":
  57. $this->timezone = "600";
  58. break;
  59. case "GMT-01:00":
  60. $this->timezone = "660";
  61. break;
  62. case "GMT":
  63. $this->timezone = "720";
  64. break;
  65. case "GMT+01:00":
  66. $this->timezone = "780";
  67. break;
  68. case "GMT+02:00":
  69. $this->timezone = "840";
  70. break;
  71. case "GMT+03:00":
  72. $this->timezone = "900";
  73. break;
  74. case "GMT+03:30":
  75. $this->timezone = "930";
  76. break;
  77. case "GMT+04:00":
  78. $this->timezone = "960";
  79. break;
  80. case "GMT+04:30":
  81. $this->timezone = "990";
  82. break;
  83. case "GMT+05:00":
  84. $this->timezone = "1020";
  85. break;
  86. case "GMT+05:30":
  87. $this->timezone = "1050";
  88. break;
  89. case "GMT+05:45":
  90. $this->timezone = "1065";
  91. break;
  92. case "GMT+06:00":
  93. $this->timezone = "1080";
  94. break;
  95. case "GMT+06:30":
  96. $this->timezone = "1110";
  97. break;
  98. case "GMT+07:00":
  99. $this->timezone = "1140";
  100. break;
  101. case "GMT+08:00":
  102. $this->timezone = "1200";
  103. break;
  104. case "GMT+09:00":
  105. $this->timezone = "1260";
  106. break;
  107. case "GMT+09:30":
  108. $this->timezone = "1290";
  109. break;
  110. case "GMT+10:00":
  111. $this->timezone = "1320";
  112. break;
  113. case "GMT+11:00":
  114. $this->timezone = "1380";
  115. break;
  116. case "GMT+12:00":
  117. $this->timezone = "1440";
  118. break;
  119. case "GMT+13:00":
  120. $this->timezone = "1500";
  121. break;
  122. }
  123. $final[$this->mac.".cfg"] = $this->parse_config_file($contents);
  124. $final = $this->create_encrypted_file($final);
  125. return($final);
  126. }
  127. }