Pārlūkot izejas kodu

Move the old profiles (sip profiles) to trunk/apps.

Mark Crane 13 gadi atpakaļ
vecāks
revīzija
30f29af903
4 mainītis faili ar 405 papildinājumiem un 0 dzēšanām
  1. 32 0
      profiles/app_config.php
  2. 50 0
      profiles/root.php
  3. 129 0
      profiles/v_profile_edit.php
  4. 194 0
      profiles/v_profiles.php

+ 32 - 0
profiles/app_config.php

@@ -0,0 +1,32 @@
+<?php
+	//application details
+		$apps[$x]['name'] = "SIP Profiles";
+		$apps[$x]['uuid'] = '5414b2d9-fd7c-f4fa-3c31-eecc387bd1e4';
+		$apps[$x]['category'] = 'Switch';;
+		$apps[$x]['subcategory'] = '';
+		$apps[$x]['version'] = '';
+		$apps[$x]['license'] = 'Mozilla Public License 1.1';
+		$apps[$x]['url'] = 'http://www.fusionpbx.com';
+		$apps[$x]['description']['en'] = 'Use this to configure your SIP profiles.';
+
+	//menu details
+		$apps[$x]['menu'][0]['title']['en'] = 'SIP Profiles';
+		$apps[$x]['menu'][0]['uuid'] = '3fe562d4-b9d2-74d2-7def-bff4707831e2';
+		$apps[$x]['menu'][0]['parent_uuid'] = '594d99c5-6128-9c88-ca35-4b33392cec0f';
+		$apps[$x]['menu'][0]['category'] = 'internal';
+		$apps[$x]['menu'][0]['path'] = '/app/profiles/v_profiles.php';
+		$apps[$x]['menu'][0]['groups'][] = 'superadmin';
+
+	//permission details
+		$apps[$x]['permissions'][0]['name'] = 'sip_profiles_view';
+		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][1]['name'] = 'sip_profiles_add';
+		$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][2]['name'] = 'sip_profiles_edit';
+		$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][3]['name'] = 'sip_profiles_delete';
+		$apps[$x]['permissions'][3]['groups'][] = 'superadmin';
+?>

+ 50 - 0
profiles/root.php

@@ -0,0 +1,50 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 129 - 0
profiles/v_profile_edit.php

@@ -0,0 +1,129 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('sip_profiles_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+$fd = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f'], "r");
+$v_content = fread($fd, filesize($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f']));
+fclose($fd);
+
+require_once "includes/header.php";
+
+?>
+
+<script language="Javascript">
+function sf() { document.forms[0].savetopath.focus(); }
+</script>
+<script language="Javascript" type="text/javascript" src="<?php echo PROJECT_PATH; ?>/includes/edit_area/edit_area_full.js"></script>
+<script language="Javascript" type="text/javascript">
+	// initialisation
+	editAreaLoader.init({
+		id: "code"	// id of the textarea to transform
+		,start_highlight: true
+		,allow_toggle: false
+		,language: "en"
+		,syntax: "html"	
+		,toolbar: "search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
+		,syntax_selection_allow: "css,html,js,php,xml,c,cpp,sql"
+		,show_line_colors: true
+	});	
+</script>
+
+<div align='center'>
+	<table width="100%" border="0" cellpadding="0" cellspacing="0">
+		<tr>
+			<td class="tabcont" >
+
+				<form action="v_profiles.php" method="post" name="iform" id="iform">
+					<table width="100%" border="0" cellpadding="0" cellspacing="0">
+					<tr>
+						<td align='left'><p><span class="vexpl"><span class="red"><strong>Edit Profile<br>
+							</strong></span>
+							Use this to configure your SIP profiles.
+							<br />
+							<br />
+						</td>
+						<td align='right' valign='top'>Filename: <input type="text" name="f" value="<?php echo $_GET['f']; ?>" /><input type="submit" class='btn' value="save" /></td>
+					</tr>
+
+					<tr>
+					<td colspan='2' class='' valign='top' align='left' nowrap>
+						<textarea style="width:100%;" id="code" name="code" rows="35" class='txt'><?php echo htmlentities($v_content); ?></textarea>
+					<br />
+					<br />
+					</td>
+					</tr>
+
+					<tr>
+						<td align='left'>
+						<?php
+						if ($v_path_show) {
+							echo "<b>location:</b> ".$_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f']."</td>";
+						}
+						?>
+						<td align='right'>
+							<input type="hidden" name="a" value="save" />
+							<?php
+							echo "<input type='button' class='btn' value='Restore Default' onclick=\"document.location.href='v_profiles.php?a=default&f=".$_GET['f']."';\" />";
+							?>
+						</td>
+					</tr>
+
+					<tr>
+					<td colspan='2'>
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+						<br /><br /><br />
+					</td>
+					</tr>
+
+					</table>
+				</form>
+
+			</td>
+		</tr>
+	</table>
+</div>
+
+<?php
+//show the footer
+	require_once "includes/footer.php";
+?>

+ 194 - 0
profiles/v_profiles.php

@@ -0,0 +1,194 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (permission_exists('sip_profiles_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if ($_GET['a'] == "default" && permission_exists('sip_profiles_edit')) {
+
+	//get the contents of the sip profile
+	$sip_profile = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/templates/conf/sip_profiles/'.$_GET['f']);
+
+	//write the default config fget
+	$fd = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f'], "w");
+	fwrite($fd, $sip_profile);
+	fclose($fd);
+
+	$save_msg = "Restored ".$_GET['f'];
+}
+
+if ($_POST['a'] == "save" && permission_exists('sip_profiles_edit')) {
+	$v_content = $_POST['code'];
+	$fd = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_POST['f'], "w");
+	fwrite($fd, $v_content);
+	fclose($fd);
+	$save_msg = "Saved ".$_POST['f'];
+}
+
+if ($_GET['a'] == "del" && permission_exists('sip_profiles_edit')) {
+	if ($_GET['type'] == 'profile') {
+		unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$_GET['f']);
+		header("Location: v_profiles.php");
+		exit;
+	}
+}
+
+require_once "includes/header.php";
+
+$c = 0;
+$row_style["0"] = "row_style0";
+$row_style["1"] = "row_style1";
+
+if (strlen($save_msg) > 0) {
+	echo "<div align=\"center\">\n";
+	echo "	<table width=\"40%\">\n";
+	echo "		<tr>\n";
+	echo "			<th align=\"left\">Message</th>\n";
+	echo "		</tr>\n";
+	echo "		<tr>\n";
+	echo "			<td class=\"row_style1\">\n";
+	echo "				<strong>$save_msg</strong>\n";
+	echo "			</td>\n";
+	echo "		</tr>\n";
+	echo "	</table>\n";
+	echo "</div>\n";
+}
+
+?>
+
+<div align='center'>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+	<tr>
+	 <td class="tabcont" align='left'>
+
+<form action="v_profiles.php" method="post" name="iform" id="iform">
+	<table width="100%" border="0" cellpadding="6" cellspacing="0">
+		<tr>
+		<td align='left'><p><span class="vexpl"><span class="red"><strong>Profiles<br>
+			</strong></span>
+			Use this to configure your SIP profiles.
+			</p></td>
+		</tr>
+	</table>
+	<br />
+	<table width="100%" border="0" cellpadding="0" cellspacing="0">
+	<tr>
+		<th width="25%" class="">Name</th>
+		<th width="70%" class="">Description</th>
+		<td width="5%" class="list"></td>
+		</th>
+	</tr>
+
+<?php
+	foreach (ListFiles($_SESSION['switch']['conf']['dir'].'/sip_profiles') as $key=>$file){
+		if (substr($file, -4) == ".xml") {
+			echo "<tr>\n";
+			echo "	<td class='".$row_style[$c]."' ondblclick=\"document.location='v_profile_edit.php?f=".$file."'\";\" valign='middle'>\n";
+			echo $file;
+			echo "&nbsp;\n";
+			echo "	</td>\n";
+			echo "	<td class='row_stylebg' ondblclick=\"document.location='v_profile_edit.php?f=".$file."\">\n";
+			switch ($file) {
+			case "internal.xml":
+				echo "The Internal profile by default requires registration which is most often used for extensions. ";
+				echo "By default the Internal profile binds to the WAN IP which is accessible to the internal network. ";
+				echo "A rule can be set from PFSense -> Firewall -> Rules -> WAN to the the WAN IP for port 5060 which ";
+				echo "enables phones register from outside the network.";
+				echo "";
+				echo "&nbsp;";
+				break; 
+			case "internal-ipv6.xml":
+				echo "The Internal IPV6 profile binds to the IP version 6 address and is similar to the Internal profile.\n";
+				echo "&nbsp;";
+				break;
+			case "external.xml":
+				echo "The External profile handles outbound registrations to a SIP provider or other SIP Server. The SIP provider sends calls to you, and you ";
+				echo "send calls to your provider, through the external profile. The external profile allows anonymous calling, which is ";
+				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\" ";
+				echo "&nbsp;";
+				break;
+			case "lan.xml":
+				echo "The LAN profile is the same as the Internal profile except that it is bound to the LAN IP.\n";
+				echo "&nbsp;";
+				break;
+			default:
+				//echo "<font color='#FFFFFF'>default</font>&nbsp;";
+			}
+			echo "	</td>\n";
+			echo "	<td valign='middle' nowrap class='list' valign='top'>\n";
+			echo "	  <table border='0' cellspacing='2' cellpadding='1'>\n";
+			echo "		<tr>\n";
+			if (permission_exists('sip_profiles_edit')) {
+				echo "		  <td valign='middle'><a href='v_profile_edit.php?type=profile&f=".$file."' alt='edit'>$v_link_label_edit</a></td>\n";
+			}
+			if (permission_exists('sip_profiles_delete')) {
+				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";
+			}
+			echo "		</tr>\n";
+			echo "	 </table>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+			$i++;
+		}
+	}
+?>
+	</table>
+</form>
+
+<?php
+if ($v_path_show) {
+	echo "<br />\n";
+	echo $_SESSION['switch']['conf']['dir']."/sip_profiles\n";
+}
+?>
+
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+<?php 
+//show the footer
+	require_once "includes/footer.php";
+?>