v_profiles.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('sip_profiles_view')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. if ($_GET['a'] == "default" && permission_exists('sip_profiles_edit')) {
  32. //get the contents of the sip profile
  33. $sip_profile = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/conf/sip_profiles/'.$_GET['f']);
  34. //write the default config fget
  35. $fd = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f'], "w");
  36. fwrite($fd, $sip_profile);
  37. fclose($fd);
  38. $save_msg = "Restored ".$_GET['f'];
  39. }
  40. if ($_POST['a'] == "save" && permission_exists('sip_profiles_edit')) {
  41. $v_content = $_POST['code'];
  42. $fd = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_POST['f'], "w");
  43. fwrite($fd, $v_content);
  44. fclose($fd);
  45. $save_msg = "Saved ".$_POST['f'];
  46. }
  47. if ($_GET['a'] == "del" && permission_exists('sip_profiles_edit')) {
  48. if ($_GET['type'] == 'profile') {
  49. unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f']);
  50. header("Location: v_profiles.php");
  51. exit;
  52. }
  53. }
  54. require_once "resources/header.php";
  55. $c = 0;
  56. $row_style["0"] = "row_style0";
  57. $row_style["1"] = "row_style1";
  58. if (strlen($save_msg) > 0) {
  59. echo "<div align=\"center\">\n";
  60. echo " <table width=\"40%\">\n";
  61. echo " <tr>\n";
  62. echo " <th align=\"left\">Message</th>\n";
  63. echo " </tr>\n";
  64. echo " <tr>\n";
  65. echo " <td class=\"row_style1\">\n";
  66. echo " <strong>$save_msg</strong>\n";
  67. echo " </td>\n";
  68. echo " </tr>\n";
  69. echo " </table>\n";
  70. echo "</div>\n";
  71. }
  72. ?>
  73. <div align='center'>
  74. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  75. <tr>
  76. <td class="tabcont" align='left'>
  77. <form action="v_profiles.php" method="post" name="iform" id="iform">
  78. <table width="100%" border="0" cellpadding="6" cellspacing="0">
  79. <tr>
  80. <td align='left'><p><span class="vexpl"><span class="red"><strong>Profiles<br>
  81. </strong></span>
  82. Use this to configure your SIP profiles.
  83. </p></td>
  84. </tr>
  85. </table>
  86. <br />
  87. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  88. <tr>
  89. <th width="25%" class="">Name</th>
  90. <th width="70%" class="">Description</th>
  91. <td width="5%" class="list"></td>
  92. </th>
  93. </tr>
  94. <?php
  95. foreach (ListFiles($_SESSION['switch']['conf']['dir'].'/sip_profiles') as $key=>$file){
  96. if (substr($file, -4) == ".xml") {
  97. echo "<tr>\n";
  98. echo " <td class='".$row_style[$c]."' ondblclick=\"document.location='v_profile_edit.php?f=".$file."'\";\" valign='middle'>\n";
  99. echo $file;
  100. echo "&nbsp;\n";
  101. echo " </td>\n";
  102. echo " <td class='row_stylebg' ondblclick=\"document.location='v_profile_edit.php?f=".$file."\">\n";
  103. switch ($file) {
  104. case "internal.xml":
  105. echo "The Internal profile by default requires registration which is most often used for extensions. ";
  106. echo "By default the Internal profile binds to the WAN IP which is accessible to the internal network. ";
  107. echo "A rule can be set from PFSense -> Firewall -> Rules -> WAN to the the WAN IP for port 5060 which ";
  108. echo "enables phones register from outside the network.";
  109. echo "";
  110. echo "&nbsp;";
  111. break;
  112. case "internal-ipv6.xml":
  113. echo "The Internal IPV6 profile binds to the IP version 6 address and is similar to the Internal profile.\n";
  114. echo "&nbsp;";
  115. break;
  116. case "external.xml":
  117. echo "The External profile handles outbound registrations to a SIP provider or other SIP Server. The SIP provider sends calls to you, and you ";
  118. echo "send calls to your provider, through the external profile. The external profile allows anonymous calling, which is ";
  119. echo "required as your provider will never authenticate with you to send you a call. Calls can be sent using a SIP URL \"my.domain.com:5080\" ";
  120. echo "&nbsp;";
  121. break;
  122. case "lan.xml":
  123. echo "The LAN profile is the same as the Internal profile except that it is bound to the LAN IP.\n";
  124. echo "&nbsp;";
  125. break;
  126. default:
  127. //echo "<font color='#FFFFFF'>default</font>&nbsp;";
  128. }
  129. echo " </td>\n";
  130. echo " <td valign='middle' nowrap class='list' valign='top'>\n";
  131. echo " <table border='0' cellspacing='2' cellpadding='1'>\n";
  132. echo " <tr>\n";
  133. if (permission_exists('sip_profiles_edit')) {
  134. echo " <td valign='middle'><a href='v_profile_edit.php?type=profile&f=".$file."' alt='edit'>$v_link_label_edit</a></td>\n";
  135. }
  136. if (permission_exists('sip_profile_delete')) {
  137. echo " <td><a href='v_profiles.php?type=profile&a=del&f=".$file."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a></td>\n";
  138. }
  139. echo " </tr>\n";
  140. echo " </table>\n";
  141. echo " </td>\n";
  142. echo "</tr>\n";
  143. if ($c==0) { $c=1; } else { $c=0; }
  144. $i++;
  145. }
  146. }
  147. ?>
  148. </table>
  149. </form>
  150. <?php
  151. if ($v_path_show) {
  152. echo "<br />\n";
  153. echo $_SESSION['switch']['conf']['dir']."/sip_profiles\n";
  154. }
  155. ?>
  156. <br>
  157. <br>
  158. <br>
  159. <br>
  160. <br>
  161. <br>
  162. <br>
  163. <br>
  164. </td>
  165. </tr>
  166. </table>
  167. </div>
  168. <?php
  169. //show the footer
  170. require_once "resources/footer.php";
  171. ?>