Browse Source

move to apps

Mark Crane 13 years ago
parent
commit
6fbf91f246
3 changed files with 358 additions and 0 deletions
  1. 50 0
      soft_phone/root.php
  2. 31 0
      soft_phone/v_config.php
  3. 277 0
      soft_phone/v_softphone.php

+ 50 - 0
soft_phone/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-2010
+	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')){
+		define('PROJECT_PATH', '/fusionpbx');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		define('PROJECT_PATH', '');
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 31 - 0
soft_phone/v_config.php

@@ -0,0 +1,31 @@
+<?php
+	/*
+	//application details
+		$apps[$x]['name'] = "Soft Phone";
+		$apps[$x]['guid'] = 'D49D1E25-2240-DCB3-8A40-643232472A2D';
+		$apps[$x]['category'] = 'PBX';
+		$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'] = 'Used with PortAudio.';
+	
+	//menu details	
+		$apps[$x]['menu'][0]['title']['en'] = 'Soft Phone';
+		$apps[$x]['menu'][0]['guid'] = '0875598D-BF25-D348-2E87-8D05AEF3CF78';
+		$apps[$x]['menu'][0]['parent_guid'] = 'FD29E39C-C936-F5FC-8E2B-611681B266B5';
+		$apps[$x]['menu'][0]['category'] = 'internal';
+		$apps[$x]['menu'][0]['path'] = '/mod/soft_phone/v_softphone.php';
+		$apps[$x]['menu'][0]['groups'][] = 'admin';
+		$apps[$x]['menu'][0]['groups'][] = 'superadmin';
+
+	//permission details
+		$apps[$x]['permissions'][0]['name'] = 'soft_phone_view';
+		$apps[$x]['permissions'][0]['groups'][] = 'admin';
+		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][1]['name'] = 'soft_phone_dial';
+		$apps[$x]['permissions'][1]['groups'][] = 'admin';
+		$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
+	*/
+?>

+ 277 - 0
soft_phone/v_softphone.php

@@ -0,0 +1,277 @@
+<?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-2010
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "includes/config.php";
+require_once "includes/checkauth.php";
+if (ifgroup("admin") || ifgroup("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+
+
+//notes
+	// http://wiki.freeswitch.org/wiki/Mod_portaudio
+	// http://wiki.freeswitch.org/wiki/Freeswitch_softphone
+	// 
+
+
+//echo "<form method='post' name='frm' action=''>\n";
+//echo "</form>";
+
+echo "<div align='center'>\n";
+
+echo "<div id='ajax_response'>\n";
+
+echo "</div>\n";
+
+echo "<table border='0'>\n";
+echo "<tr>\n";
+echo "<td>\n";
+
+	echo "<table border='0' width='225'>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center' colspan='3'>\n";
+	echo "<input style='width: 100%' class='formfld' type='text' id='dial' name='dial' maxlength='10' value=\"\">\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '1';\" value='1'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '2';\" value='2'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '3';\" value='3'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '4';\" value='4'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '5';\" value='5'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '6';\" value='6'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '7';\" value='7'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '8';\" value='8'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '9';\" value='9'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '*';\" value='*'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '0';\" value='0'>\n";
+	echo "</td>\n";
+	echo "<td align='center'>\n";
+	echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"document.getElementById('dial').value += '#';\" value='#'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align='center' colspan='3'>\n";
+	echo "<input style='width: 100%' class='formfld' type='text' id='api_cmd' name='api_cmd' value=\"\">\n";
+	//echo "<br \>\n";
+	echo "<input style='width: 100%' class='formfld' type='hidden' id='uid' name='uid' value=\"\">\n";
+	echo "<input style='width: 100%' class='formfld' type='hidden' id='rec' name='rec' value=\"\">\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>\n";
+
+echo "</td>\n";
+echo "<td width='50'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"backspace();\" value='<'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"clear();\" value='clear'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_call();\" value='call'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' disabled class='btn' name='xfer' id = 'xfer' alt='view' onclick=\"xfer();\" value='xfer'>\n";
+//echo "	<input type='button' style='width: 100%; height: 100%;' class='btn' name='' alt='view' onclick=\"rec();\" value='rec'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch();\" value='switch'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_switch_none();\" value='hold'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"cmd();\" value='cmd'>\n";
+echo "	<input type='button' style='width: 100%; height: 20px;' class='btn' name='' alt='view' onclick=\"pa_hangup();\" value='end'>\n";
+echo "</td>\n";
+echo "</tr>\n";
+echo "</table>\n";
+
+echo "</div>\n";
+
+?>
+
+<script type="text/javascript">
+function ajaxFunction()
+{
+	var xmlhttp;
+	if (window.XMLHttpRequest)
+	{
+		// code for IE7+, Firefox, Chrome, Opera, Safari
+		xmlhttp=new XMLHttpRequest();
+	}
+	else if (window.ActiveXObject)
+	{
+		// code for IE6, IE5
+		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+	}
+	else
+	{
+		alert("Your browser does not support XMLHTTP!");
+	}
+	xmlhttp.onreadystatechange=function()
+	{
+	if(xmlhttp.readyState==4)
+		{
+			var dial = document.getElementById('dial').value;
+			//alert('dial:'+dial);
+			var response = xmlhttp.responseText;
+			document.getElementById('ajax_response').innerHTML = '<pre>\n'+response+'</pre>\n';
+			//alert('response: '+response);
+			//response = response.replace('SUCCESS:', '');
+			var response_array = response.split(':');
+			if (response_array.length > 1) {
+				document.getElementById('uid').value = response_array[2];
+				document.getElementById('xfer').disabled = false;
+			}
+			//document.myForm.time.value=xmlhttp.responseText;
+		}
+	}
+
+	var api_cmd = document.getElementById('api_cmd').value;
+	//alert('cmd:'. api_cmd);
+	xmlhttp.open("GET","<?php echo PROJECT_PATH; ?>/includes/v_cmd.php?cmd="+escape(api_cmd)+"&rdr=false",true);
+	xmlhttp.send(null);
+}
+
+function backspace() {
+	document.getElementById('api_cmd').value = '';
+	var dial = document.getElementById('dial').value;
+	document.getElementById('dial').value = dial.substr(0, (dial.length -1));
+}
+
+function clear() {
+	document.getElementById('uid').value = '';
+	document.getElementById('api_cmd').value = '';
+	document.getElementById('dial').value = '';
+}
+
+function pa_call() {
+	document.getElementById('api_cmd').value = 'api pa call '+document.getElementById('dial').value;
+	var uid = document.getElementById('uid').value;
+	var dial = document.getElementById('dial').value;
+	if (dial.length == 0) {
+		document.getElementById('api_cmd').value = 'api pa answer';
+		document.getElementById('xfer').disabled = false;
+	}
+	else {
+		if (uid.length > 0) {
+			document.getElementById('api_cmd').value = 'api pa dtmf '+document.getElementById('dial').value;
+		}
+	}
+	ajaxFunction();
+	document.getElementById('dial').value = '';
+}
+
+function xfer() {
+	//uuid_transfer,<uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>],Transfer a session,mod_commands
+	var uid = document.getElementById('uid').value;
+	var dial = document.getElementById('dial').value;
+	if (uid.length > 0) {
+		document.getElementById('api_cmd').value = 'api uuid_transfer '+uid+' '+dial+' XML default';
+	}
+	ajaxFunction();
+	//document.getElementById('dial').value = '';
+}
+
+function rec() {
+	//this function is making the recording but freeswitch crashes after hanging up the call. So it is currently disabled.
+	//uuid_record,<uuid> [start|stop] <path> [<limit>],session record,mod_commands
+	var uid = document.getElementById('uid').value;
+	var rec = document.getElementById('rec').value;
+	if (uid.length > 0) {
+		if (rec.length > 0) {
+			//stop
+			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
+			document.getElementById('rec').value = '';
+		}
+		else {
+			//start
+			document.getElementById('api_cmd').value = 'api uuid_record '+uid+' start C:/PortableWebAp4.0.pro/Program/FreeSWITCH/recordings/portaudio.wav';
+			document.getElementById('rec').value = 'true';
+		}
+	}
+	ajaxFunction();
+	//document.getElementById('dial').value = '';
+}
+
+function pa_switch() {
+	document.getElementById('api_cmd').value = 'api pa switch';
+	ajaxFunction();
+}
+
+function pa_switch_none() {
+	document.getElementById('api_cmd').value = 'api pa switch none';
+	ajaxFunction();
+}
+
+function cmd() {
+	ajaxFunction();
+}
+
+function pa_hangup () {
+	//uid = document.getElementById('uid').value;
+	//document.getElementById('api_cmd').value = 'api uuid_record '+uid+' stop';
+	document.getElementById('uid').value = '';
+	document.getElementById('api_cmd').value = 'api pa hangup';
+	document.getElementById('dial').value = '';
+	ajaxFunction();
+
+}
+
+
+</script>
+<?php
+
+require_once "includes/footer.php";
+?>