Merge pull request #10 from fusionpbx/master

7
This commit is contained in:
blackc2004 2016-01-12 12:18:57 -08:00
commit 9617bcd201
17 changed files with 347 additions and 234 deletions

View File

@ -553,7 +553,7 @@ require_once "resources/require.php";
else {
$domain_name = $_SESSION['domain_name'];
}
echo " window.location = 'https://".$domain_name."/app/provision?mac=$device_mac_address&file=' + d + '&content_type=application/octet-stream';\n";
echo " window.location = 'https://".$domain_name."/app/provision?mac=".$device_mac_address."&file=' + d + '&content_type=application/octet-stream';\n";
echo " }\n";
echo "\n";
@ -602,8 +602,11 @@ require_once "resources/require.php";
echo " <select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
echo " <option value=''>".$text['label-download']."</option>\n";
foreach ($files as $file) {
//format the mac address and
$format = new provision();
$mac = $format->format_mac($device_mac_address, $device_vendor);
//render the file name
$file_name = str_replace("{\$mac}",$device_mac_address,basename($file));
$file_name = str_replace("{\$mac}", $mac, basename($file));
//add the select option
echo " <option value='".basename($file)."'>".$file_name."</option>\n";
}

View File

@ -53,18 +53,6 @@ include "root.php";
case "00085d":
$device_vendor = "aastra";
break;
case "000e08":
$device_vendor = "linksys";
break;
case "0004f2":
$device_vendor = "polycom";
break;
case "00907a":
$device_vendor = "polycom";
break;
case "0080f0":
$device_vendor = "panasonic";
break;
case "001873":
$device_vendor = "cisco";
break;
@ -83,23 +71,38 @@ include "root.php";
case "68efbd":
$device_vendor = "cisco";
break;
case "000b82":
$device_vendor = "grandstream";
break;
case "00177d":
$device_vendor = "konftel";
break;
case "00045a":
$device_vendor = "linksys";
break;
case "000625":
$device_vendor = "linksys";
break;
case "001565":
$device_vendor = "yealink";
case "000e08":
$device_vendor = "linksys";
break;
case "08000f":
$device_vendor = "mitel";
break;
case "0080f0":
$device_vendor = "panasonic";
break;
case "0004f2":
$device_vendor = "polycom";
break;
case "00907a":
$device_vendor = "polycom";
break;
case "000413":
$device_vendor = "snom";
break;
case "000b82":
$device_vendor = "grandstream";
break;
case "00177d":
$device_vendor = "konftel";
case "001565":
$device_vendor = "yealink";
break;
default:
$device_vendor = "";

View File

@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="cidlookup" number="" continue="true" app_uuid="a0cb498c-6e09-441f-83ea-a7684565c44e" enabled="false">
<condition field="${user_exists}" expression="^true$"/>
<condition field="${call_direction}" expression="^(inbound)$" break="never">
<action application="set" data="effective_caller_id_name=${cidlookup(${caller_id_number})}"/>
</condition>
</extension>
</context>

View File

@ -298,7 +298,13 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0);
//deliver the customized config over HTTP/HTTPS
//need to make sure content-type is correct
if ($_REQUEST['content_type'] == 'application/octet-stream') {
//format the mac address and
$mac = $prov->format_mac($mac, $device_vendor);
//replace the variable name with the value
$file_name = str_replace("{\$mac}", $mac, $file);
//set the headers
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file_name).'"');

View File

@ -126,7 +126,29 @@ include "root.php";
}
}
function render() {
//set the mac address in the correct format for the specific vendor
public function format_mac($mac, $vendor) {
switch (strtolower($vendor)) {
case "aastra":
$mac = strtoupper($mac);
break;
case "mitel":
$mac = strtoupper($mac);
break;
case "polycom":
$mac = strtolower($mac);
break;
case "snom":
$mac = strtolower($mac);
break;
default:
$mac = strtolower($mac);
$mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2);
}
return $mac;
}
public function render() {
//debug
$debug = $_REQUEST['debug']; // array
@ -473,7 +495,7 @@ include "root.php";
unset ($prep_statement);
}
//get the extensions array and add to the template engine
//get the contact extensions array and add to the template engine
if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['directory_extensions']['boolean'] == "true") {
//get contacts from the database
$sql = "select c.contact_organization, c.contact_name_given, c.contact_name_family, e.extension ";
@ -489,9 +511,27 @@ include "root.php";
$sql .= "order by c.contact_organization desc, c.contact_name_given asc, c.contact_name_family asc ";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$contact_extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//assign the contacts array
$view->assign("contact_extensions", $contact_extensions);
}
//get the extensions array and add to the template engine
if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['directory_extensions']['boolean'] == "true") {
//get contacts from the database
$sql = "select directory_full_name, description ";
$sql .= "effective_caller_id_name, effective_caller_id_number ";
$sql .= "from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and enabled = 'true' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
}
//assign the contacts array
$view->assign("extensions", $extensions);
}
@ -703,20 +743,7 @@ include "root.php";
unset ($prep_statement);
//set the mac address in the correct format
switch (strtolower($device_vendor)) {
case "aastra":
$mac = strtoupper($mac);
break;
case "snom":
$mac = strtolower($mac);
break;
case "polycom":
$mac = strtolower($mac);
break;
default:
$mac = strtolower($mac);
$mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2);
}
$mac = $this->format_mac($mac, $device_vendor);
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$view->assign("mac" , $mac);
@ -882,15 +909,11 @@ include "root.php";
$this->file = $file_name;
$file_contents = $this->render();
//format the mac address
$mac = $this->format_mac($device_mac_address, $device_vendor);
//replace {$mac} in the file name
if ($device_vendor == "aastra" || $device_vendor == "cisco") {
//upper case the mac address for aastra phones
$file_name = str_replace("{\$mac}", strtoupper($device_mac_address), $file_name);
}
else {
//all other phones
$file_name = str_replace("{\$mac}", $device_mac_address, $file_name);
}
$file_name = str_replace("{\$mac}", $mac, $file_name);
//write the file
//echo $directory.'/'.$file_name."\n";

View File

@ -290,7 +290,7 @@
case "inbound":
$callee_number = check_str(urldecode($row->caller_profile->destination_number));
$callee_number_serie = number_series($callee_number);
$sql_user_rate = "SELECT v_lcr.currency, v_lcr.rate, v_lcr.connect_increment, v_lcr.talk_increment FROM v_lcr JOIN v_billings ON v_billings.type_value='$accountcode' WHERE v_lcr.carrier_uuid IS NULL AND v_lcr.lcr_direction = '".check_str(urldecode($xml->variables->call_direction))."' AND v_lcr.lcr_profile=v_billings.lcr_profile AND NOW() >= v_lcr.date_start AND NOW() < v_lcr.date_end AND digits IN ($destination_number_serie) ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1";
$sql_user_rate = "SELECT v_lcr.currency, v_lcr.rate, v_lcr.connect_increment, v_lcr.talk_increment FROM v_lcr JOIN v_billings ON v_billings.type_value='$accountcode' WHERE v_lcr.carrier_uuid IS NULL AND v_lcr.lcr_direction = '".check_str(urldecode($xml->variables->call_direction))."' AND v_lcr.lcr_profile=v_billings.lcr_profile AND NOW() >= v_lcr.date_start AND NOW() < v_lcr.date_end AND digits IN ($callee_number_serie) ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1";
if ($debug) {
echo "sql_user_rate: $sql_user_rate\n";

View File

@ -44,6 +44,7 @@
--get the variables
dsn = trim(api:execute("global_getvar", "dsn"));
dsn_callcenter = trim(api:execute("global_getvar", "dsn_callcenter"));
--start the xml array
local xml = {}
@ -52,9 +53,13 @@
table.insert(xml, [[ <section name="configuration">]]);
table.insert(xml, [[ <configuration name="callcenter.conf" description="Call Center">]]);
table.insert(xml, [[ <settings>]]);
if (dsn_callcenter) then
table.insert(xml, [[ <param name="odbc-dsn" value="]]..dsn_callcenter..[["/>]]);
else
if (string.len(dsn) > 0) then
table.insert(xml, [[ <param name="odbc-dsn" value="]]..database["switch"]..[["/>]]);
end
end
--table.insert(xml, [[ <param name="dbname" value="/usr/local/freeswitch/db/call_center.db"/>]]);
table.insert(xml, [[ </settings>]]);

View File

@ -457,8 +457,8 @@
freeswitch.consoleLog("INFO", "[FAX] RETRY_STATS FAILURE BAD NUMBER: GATEWAY[".. fax_uri .."]");
email_message_fail = email_message_fail.."We tried sending, but the number entered was not a working phone number "
email_address = email_address:gsub("\\,", ",");
freeswitch.email("",
"",
freeswitch.email(email_address,
email_address,
"To: "..email_address.."\nFrom: "..from_address.."\nSubject: Fax to: "..number_dialed.." was INVALID",
email_message_fail ,
fax_file
@ -470,8 +470,8 @@
freeswitch.consoleLog("INFO", "[FAX] RETRY STATS FAILURE BUSY: GATEWAY[".. fax_uri .."], BUSY NUMBER");
email_message_fail = email_message_fail.." We tried sending, but the call was busy "..fax_busy_attempts.." of those times."
email_address = email_address:gsub("\\,", ",");
freeswitch.email("",
"",
freeswitch.email(email_address,
email_address,
"To: "..email_address.."\nFrom: "..from_address.."\nSubject: Fax to: "..number_dialed.." was BUSY",
email_message_fail ,
fax_file
@ -485,8 +485,8 @@
email_message_fail = email_message_fail.." We tried sending 5 times ways. You may also want to know that the call was busy "..fax_busy_attempts.." of those times."
email_address = email_address:gsub("\\,", ",");
freeswitch.email("",
"",
freeswitch.email(email_address,
email_address,
"To: "..email_address.."\nFrom: "..from_address.."\nSubject: Fax to: "..number_dialed.." FAILED",
email_message_fail ,
fax_file
@ -521,8 +521,8 @@
freeswitch.consoleLog("INFO", "[FAX] RETRY STATS SUCCESS: GATEWAY[".. fax_uri .."] VARS[" .. fax_trial .. "]");
email_address = email_address:gsub("\\,", ",");
freeswitch.email("",
"",
freeswitch.email(email_address,
email_address,
"To: "..email_address.."\nFrom: "..from_address.."\nSubject: Fax to: "..number_dialed.." SENT",
email_message_success ,
fax_file

View File

@ -1,15 +1,11 @@
<configuration name="cidlookup.conf" description="cidlookup Configuration">
<settings>
<!-- comment out url to not setup a url based lookup -->
<param name="url" value="http://query.voipcnam.com/query.php?api_key=MYAPIKEY&number=${caller_id_number}"/>
<!-- comment out url to not setup a url based lookup -->
<!-- contact support@to-call.me for more details -->
<!-- <param name="url" value="http://cnam.to-call.me/lookup/${caller_id_number}?api_key=MYAPIKEY"/> -->
<!--<param name="url" value="http://query.voipcnam.com/query.php?api_key=MYAPIKEY&number=${caller_id_number}"/>-->
<!-- comment out whitepages-apikey to not use whitepages.com, you must
get an API key from http://developer.whitepages.com/ -->
<!--<param name="whitepages-apikey" value="MYAPIKEY"/>-->
<param name="whitepages-apikey" value="MYAPIKEY"/>-->
<!-- set to false to not cache (in memcache) results from the url query -->
<param name="cache" value="true"/>
@ -21,11 +17,12 @@
<!-- comment out sql to not setup a database (directory) lookup -->
<param name="sql" value="
SELECT v_contacts.contact_name_given || ' ' || v_contacts.contact_name_family ||' ('||v_contact_phones.phone_type||')' AS name, v_contact_phones.phone_number AS number
SELECT trim(v_contacts.contact_name_given || ' ' || v_contacts.contact_name_family || ' (' || v_contacts.contact_organization || ')') AS name, v_contact_phones.phone_number AS number
FROM v_contacts, v_contact_phones
WHERE v_contact_phones.contact_uuid = v_contacts.contact_uuid AND v_contact_phones.phone_number = '${caller_id_number}'
WHERE v_contact_phones.contact_uuid = v_contacts.contact_uuid AND (v_contact_phones.phone_number = '${caller_id_number}' OR v_contact_phones.phone_number = '1${caller_id_number}')
LIMIT 1
"/>
<!-- comment out citystate-sql to not setup a database (city/state)
lookup -->
<!--

View File

@ -11,8 +11,9 @@ preferred_codec: g711ulaw
enable_vad: 0
dial_template: "dialplan"
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}"
#registration information
# Registration information
{foreach $lines as $row}
reg.{$row.line_number}.displayName="{$row.display_name}"
proxy{$row.line_number}_address: "{$row.server_address}"
proxy{$row.line_number}_port:"{$row.sip_port}"
line{$row.line_number}_name: "{$row.user_id}"
@ -111,8 +112,11 @@ dst_stop_time: "2"
dst_auto_adjust: "1"
# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control)
{if isset($cisco_dnd_control)}
dnd_control: "{$cisco_dnd_control}" ; Default 0 (Do Not Disturb feature is off)
{else}
dnd_control: "2" ; Default 0 (Do Not Disturb feature is off)
{/if}
# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous)

View File

@ -0,0 +1,25 @@
<CiscoIPPhoneDirectory>
<Title>Our Phones</Title>
<Prompt>Please choose...</Prompt>
{assign var=x value=1}
{foreach $extensions as $row}{
<DirectoryEntry>
{if $row.directory_full_name != ""}
<Name>{$row.directory_full_name}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.extension}</Telephone>
{/if}
</DirectoryEntry>
{/if}
{assign var=x value=$x+1}
{/foreach}
</CiscoIPPhoneDirectory>

View File

@ -1,13 +1,18 @@
<CiscoIPPhoneMenu>
<Title>Contacts</Title>
<Prompt>Please choose...</Prompt>
<MenuItem>
<Name>Our Phones</Name>
<URL>http://{$domain_name}/app/provision/file/directory-extensions.xml</URL>
</MenuItem>
<!--
<MenuItem>
<Name>Personal</Name>
<URL>http://{$domain_name}/app/provision/file/directory-personal.xml</URL>
</MenuItem>
--> <MenuItem> <Name>Enterprise</Name>
-->
<MenuItem>
<Name>Enterprise</Name>
<URL>http://{$domain_name}/app/provision/file/directory-enterprise.xml?mac={$mac}</URL>
</MenuItem>
<MenuItem>

View File

@ -11,8 +11,9 @@ preferred_codec: g711ulaw
enable_vad: 0
dial_template: "dialplan"
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}"
#registration information
# Registration information
{foreach $lines as $row}
reg.{$row.line_number}.displayName="{$row.display_name}"
proxy{$row.line_number}_address: "{$row.server_address}"
proxy{$row.line_number}_port:"{$row.sip_port}"
line{$row.line_number}_name: "{$row.user_id}"
@ -111,8 +112,11 @@ dst_stop_time: "2"
dst_auto_adjust: "1"
# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control)
{if isset($cisco_dnd_control)}
dnd_control: "{$cisco_dnd_control}" ; Default 0 (Do Not Disturb feature is off)
{else}
dnd_control: "2" ; Default 0 (Do Not Disturb feature is off)
{/if}
# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous)

View File

@ -0,0 +1,25 @@
<CiscoIPPhoneDirectory>
<Title>Our Phones</Title>
<Prompt>Please choose...</Prompt>
{assign var=x value=1}
{foreach $extensions as $row}{
<DirectoryEntry>
{if $row.directory_full_name != ""}
<Name>{$row.directory_full_name}</Name>
{else}
<Name>{$row.effective_caller_id_name}</Name>
{/if}
{if $row.number_alias != ""}
<Telephone>{$row.number_alias}</Telephone>
{else}
<Telephone>{$row.extension}</Telephone>
{/if}
</DirectoryEntry>
{/if}
{assign var=x value=$x+1}
{/foreach}
</CiscoIPPhoneDirectory>

View File

@ -1,13 +1,18 @@
<CiscoIPPhoneMenu>
<Title>Contacts</Title>
<Prompt>Please choose...</Prompt>
<MenuItem>
<Name>Our Phones</Name>
<URL>http://{$domain_name}/app/provision/file/directory-extensions.xml</URL>
</MenuItem>
<!--
<MenuItem>
<Name>Personal</Name>
<URL>http://{$domain_name}/app/provision/file/directory-personal.xml</URL>
</MenuItem>
--> <MenuItem> <Name>Enterprise</Name>
-->
<MenuItem>
<Name>Enterprise</Name>
<URL>http://{$domain_name}/app/provision/file/directory-enterprise.xml?mac={$mac}</URL>
</MenuItem>
<MenuItem>