Added several more options to add_phone and update_phone functions in the Non-Agent API

git-svn-id: svn://192.168.202.10@3258 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2020-06-23 21:00:14 +00:00
parent 3189091387
commit 1b7c75b86a
3 changed files with 109 additions and 7 deletions
@@ -140,6 +140,7 @@ if (!$VARDB_port) {$VARDB_port='3306';}
if ($run_check > 0) if ($run_check > 0)
{ {
my $grepout = `/bin/ps ax | grep timeclock | grep -v grep | grep -v '/bin/sh' | grep -v 'Timeclock'`; my $grepout = `/bin/ps ax | grep timeclock | grep -v grep | grep -v '/bin/sh' | grep -v 'Timeclock'`;
# my $grepout = `/bin/ps ax | grep timeclock | grep -v grep | grep -v '/bin/sh' | grep -v 'SCREEN' | grep -v 'screen'`;
my $grepnum=0; my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g); $grepnum++ while ($grepout =~ m/\n/g);
if ($DBX) {print "CONCURRENCY CHECK: |$grepnum|\n$grepout\n";} if ($DBX) {print "CONCURRENCY CHECK: |$grepnum|\n$grepout\n";}
+14 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-06-10 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-06-22
This document describes the functions of an API(Application Programming This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -158,6 +158,7 @@ Changes:
200418-0837 - Added custom_copy_method option for the add_list function 200418-0837 - Added custom_copy_method option for the add_list function
200606-0938 - Added more settings to add_list & update_list 200606-0938 - Added more settings to add_list & update_list
200610-1447 - Added duration option to recording_lookup function 200610-1447 - Added duration option to recording_lookup function
200622-1609 - Added more options to add_phone and update_phone functions
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -1291,6 +1292,11 @@ OPTIONAL FIELDS-
phone_context - a phone context, default is 'default' phone_context - a phone context, default is 'default'
email - 1-100 characters email - 1-100 characters
admin_user_group - a valid user group or '---ALL---' admin_user_group - a valid user group or '---ALL---'
is_webphone - Y, N or Y_API_LAUNCH: whether this phone should be treated as a webphone, default is N.
webphone_auto_answer - Y or N: whether this phone should answer as soon as the call to the agent is placed, default is N.
use_external_server_ip - Y or N: whether this phone should use the server's external IP for registration, default is N.
template_id - 1-15 characters, if defined it must be a valid template in the system
on_hook_agent - Y or N: should this phone be treated as on-hook when an agent logs in with it, default is N.
Example URL strings for API calls: Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=add_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP&registration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212 http://server/vicidial/non_agent_api.php?source=test&function=add_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP&registration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212
@@ -1303,6 +1309,7 @@ ERROR: add_phone SERVER DOES NOT EXIST - 6666|10.0.9.9
ERROR: add_phone PHONE ALREADY EXISTS ON THIS SERVER - 6666|10.0.9.8|cc101 ERROR: add_phone PHONE ALREADY EXISTS ON THIS SERVER - 6666|10.0.9.8|cc101
ERROR: add_phone PHONE LOGIN ALREADY EXISTS - 6666|cc100 ERROR: add_phone PHONE LOGIN ALREADY EXISTS - 6666|cc100
ERROR: add_phone YOU MUST USE A VALID TIMEZONE - 6666|-5 ERROR: add_phone YOU MUST USE A VALID TIMEZONE - 6666|-5
ERROR: add_phone TEMPLATE ID DOES NOT EXIST, THIS IS AN OPTIONAL FIELD - 6666|cc100|batch
SUCCESS: add_phone PHONE HAS BEEN ADDED - 6666|cc100|10.0.9.8|SIP|100 SUCCESS: add_phone PHONE HAS BEEN ADDED - 6666|cc100|10.0.9.8|SIP|100
@@ -1337,6 +1344,11 @@ email - 5-100 characters, email address for voicemail, to clear this field sen
admin_user_group - a valid user group or '---ALL---' admin_user_group - a valid user group or '---ALL---'
phone_ring_timeout - 1-3 digits, default '60' phone_ring_timeout - 1-3 digits, default '60'
delete_vm_after_email - Y or N, default 'N' delete_vm_after_email - Y or N, default 'N'
is_webphone - Y, N or Y_API_LAUNCH: whether this phone should be treated as a webphone, default is N.
webphone_auto_answer - Y or N: whether this phone should answer as soon as the call to the agent is placed, default is N.
use_external_server_ip - Y or N: whether this phone should use the server's external IP for registration, default is N.
template_id - 1-15 characters, if defined it must be a valid template in the system
on_hook_agent - Y or N: should this phone be treated as on-hook when an agent logs in with it, default is N.
Example URL strings for API calls: Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP&registration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212 http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP&registration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212
@@ -1365,6 +1377,7 @@ ERROR: update_phone OUTBOUND ALT CID MUST BE FROM 6 TO 18 DIGITS, THIS IS AN OPT
ERROR: update_phone USER GROUP MUST BE FROM 2 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|0 ERROR: update_phone USER GROUP MUST BE FROM 2 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone PHONE RING TIMEOUT MUST BE FROM 2 TO 180 SECONDS, THIS IS AN OPTIONAL FIELD - 6666|0 ERROR: update_phone PHONE RING TIMEOUT MUST BE FROM 2 TO 180 SECONDS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone DELETE VOICEMAIL AFTER EMAIL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|0 ERROR: update_phone DELETE VOICEMAIL AFTER EMAIL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone TEMPLATE ID DOES NOT EXIST, THIS IS AN OPTIONAL FIELD - 6666|cc100|batch
SUCCESS: update_phone PHONE HAS BEEN UPDATED - 6666|cc100|10.0.9.8|SIP|100 SUCCESS: update_phone PHONE HAS BEEN UPDATED - 6666|cc100|10.0.9.8|SIP|100
SUCCESS: update_phone PHONE HAS BEEN DELETED - 6666|cc100|10.0.9.8| SUCCESS: update_phone PHONE HAS BEEN DELETED - 6666|cc100|10.0.9.8|
NOTICE: update_phone USER DOES NOT HAVE PERMISSION TO DELETE PHONES - 6666|7878 NOTICE: update_phone USER DOES NOT HAVE PERMISSION TO DELETE PHONES - 6666|7878
+94 -6
View File
@@ -150,10 +150,11 @@
# 200525-0118 - Fix for middle_initial --BLANK-- # 200525-0118 - Fix for middle_initial --BLANK--
# 200606-0938 - Added more settings to add_list & update_list # 200606-0938 - Added more settings to add_list & update_list
# 200610-1447 - Added duration option to recording_lookup function # 200610-1447 - Added duration option to recording_lookup function
# 200622-1609 - Added more options to add_phone and update_phone functions
# #
$version = '2.14-127'; $version = '2.14-128';
$build = '200610-1447'; $build = '200622-1609';
$api_url_log = 0; $api_url_log = 0;
$startMS = microtime(); $startMS = microtime();
@@ -536,6 +537,16 @@ if (isset($_GET["custom_copy_method"])) {$custom_copy_method=$_GET["custom_co
elseif (isset($_POST["custom_copy_method"])) {$custom_copy_method=$_POST["custom_copy_method"];} elseif (isset($_POST["custom_copy_method"])) {$custom_copy_method=$_POST["custom_copy_method"];}
if (isset($_GET["duration"])) {$duration=$_GET["duration"];} if (isset($_GET["duration"])) {$duration=$_GET["duration"];}
elseif (isset($_POST["duration"])) {$duration=$_POST["duration"];} elseif (isset($_POST["duration"])) {$duration=$_POST["duration"];}
if (isset($_GET["is_webphone"])) {$is_webphone=$_GET["is_webphone"];}
elseif (isset($_POST["is_webphone"])) {$is_webphone=$_POST["is_webphone"];}
if (isset($_GET["webphone_auto_answer"])) {$webphone_auto_answer=$_GET["webphone_auto_answer"];}
elseif (isset($_POST["webphone_auto_answer"])) {$webphone_auto_answer=$_POST["webphone_auto_answer"];}
if (isset($_GET["use_external_server_ip"])) {$use_external_server_ip=$_GET["use_external_server_ip"];}
elseif (isset($_POST["use_external_server_ip"])) {$use_external_server_ip=$_POST["use_external_server_ip"];}
if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];}
elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];}
if (isset($_GET["on_hook_agent"])) {$on_hook_agent=$_GET["on_hook_agent"];}
elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];}
header ("Content-type: text/html; charset=utf-8"); header ("Content-type: text/html; charset=utf-8");
@@ -765,6 +776,11 @@ if ($non_latin < 1)
$custom_order = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_order); $custom_order = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_order);
$custom_copy_method = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_copy_method); $custom_copy_method = preg_replace('/[^-_0-9a-zA-Z]/','',$custom_copy_method);
$duration = preg_replace('/[^-_0-9a-zA-Z]/','',$duration); $duration = preg_replace('/[^-_0-9a-zA-Z]/','',$duration);
$is_webphone = preg_replace('/[^-_0-9a-zA-Z]/','',$is_webphone);
$webphone_auto_answer = preg_replace('/[^-_0-9a-zA-Z]/','',$webphone_auto_answer);
$use_external_server_ip = preg_replace('/[^-_0-9a-zA-Z]/','',$use_external_server_ip);
$template_id = preg_replace('/[^-_0-9a-zA-Z]/','',$template_id);
$on_hook_agent = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_agent);
} }
else else
{ {
@@ -3428,10 +3444,47 @@ if ($function == 'add_phone')
} }
else else
{ {
$is_webphone_SQL='';
$webphone_auto_answer_SQL='';
$use_external_server_ip_SQL='';
$template_id_SQL='';
$on_hook_agent_SQL='';
if (preg_match("/^Y$|^N$|^Y_API_LAUNCH$/i",$is_webphone))
{$is_webphone_SQL = ",is_webphone='$is_webphone'";}
if (preg_match("/^Y$|^N$/i",$webphone_auto_answer))
{$webphone_auto_answer_SQL = ",webphone_auto_answer='$webphone_auto_answer'";}
if (preg_match("/^Y$|^N$/i",$use_external_server_ip))
{$use_external_server_ip_SQL = ",use_external_server_ip='$use_external_server_ip'";}
if (preg_match("/^Y$|^N$/i",$on_hook_agent))
{$on_hook_agent_SQL = ",on_hook_agent='$on_hook_agent'";}
if (strlen($template_id) > 1)
{
if (preg_match("/^--BLANK--$/i",$template_id))
{$template_id_SQL = ",template_id=''";}
else
{
$stmt="SELECT count(*) from vicidial_conf_templates where template_id='$template_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$template_id_exists=$row[0];
if ($template_id_exists > 0)
{$template_id_SQL = ",template_id='$template_id'";}
else
{
$result = 'ERROR';
$result_reason = "add_phone TEMPLATE ID DOES NOT EXIST, THIS IS AN OPTIONAL FIELD";
$data = "$phone_login|$template_id";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
}
if (strlen($phone_context)<1) {$phone_context='default';} if (strlen($phone_context)<1) {$phone_context='default';}
if (strlen($admin_user_group)<1) {$admin_user_group='---ALL---';} if (strlen($admin_user_group)<1) {$admin_user_group='---ALL---';}
$stmt="INSERT INTO phones SET extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', login='$phone_login', pass='$phone_pass', server_ip='$server_ip', protocol='$protocol', conf_secret='$registration_password', fullname='$phone_full_name', local_gmt='$local_gmt', outbound_cid='$outbound_cid', phone_context='$phone_context', email='$email', active='Y', status='ACTIVE', user_group='$admin_user_group';"; $stmt="INSERT INTO phones SET extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', login='$phone_login', pass='$phone_pass', server_ip='$server_ip', protocol='$protocol', conf_secret='$registration_password', fullname='$phone_full_name', local_gmt='$local_gmt', outbound_cid='$outbound_cid', phone_context='$phone_context', email='$email', active='Y', status='ACTIVE', user_group='$admin_user_group' $is_webphone_SQL $webphone_auto_answer_SQL $use_external_server_ip_SQL $template_id_SQL $on_hook_agent_SQL;";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
### LOG INSERTION Admin Log Table ### ### LOG INSERTION Admin Log Table ###
@@ -3624,6 +3677,11 @@ if ($function == 'update_phone')
$outbound_alt_cidSQL=''; $outbound_alt_cidSQL='';
$phone_ring_timeoutSQL=''; $phone_ring_timeoutSQL='';
$delete_vm_after_emailSQL=''; $delete_vm_after_emailSQL='';
$is_webphone_SQL='';
$webphone_auto_answer_SQL='';
$use_external_server_ip_SQL='';
$template_id_SQL='';
$on_hook_agent_SQL='';
if (strlen($local_gmt) > 0) if (strlen($local_gmt) > 0)
{ {
@@ -3883,9 +3941,39 @@ if ($function == 'update_phone')
else else
{$delete_vm_after_emailSQL = " ,delete_vm_after_email='$delete_vm_after_email'";} {$delete_vm_after_emailSQL = " ,delete_vm_after_email='$delete_vm_after_email'";}
} }
if (preg_match("/^Y$|^N$|^Y_API_LAUNCH$/i",$is_webphone))
{$is_webphone_SQL = ",is_webphone='$is_webphone'";}
$updateSQL = "$dialplan_numberSQL$activeSQL$outboundcidSQL$voicemail_idSQL$phone_loginSQL$phone_passSQL$protocolSQL$registration_passwordSQL$phone_full_nameSQL$phone_contextSQL$emailSQL$local_gmtSQL$admin_user_groupSQL$outbound_alt_cidSQL$phone_ring_timeoutSQL$delete_vm_after_emailSQL"; if (preg_match("/^Y$|^N$/i",$webphone_auto_answer))
{$webphone_auto_answer_SQL = ",webphone_auto_answer='$webphone_auto_answer'";}
if (preg_match("/^Y$|^N$/i",$use_external_server_ip))
{$use_external_server_ip_SQL = ",use_external_server_ip='$use_external_server_ip'";}
if (preg_match("/^Y$|^N$/i",$on_hook_agent))
{$on_hook_agent_SQL = ",on_hook_agent='$on_hook_agent'";}
if (strlen($template_id) > 1)
{
if (preg_match("/^--BLANK--$/i",$template_id))
{$template_id_SQL = ",template_id=''";}
else
{
$stmt="SELECT count(*) from vicidial_conf_templates where template_id='$template_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$template_id_exists=$row[0];
if ($template_id_exists > 0)
{$template_id_SQL = ",template_id='$template_id'";}
else
{
$result = 'ERROR';
$result_reason = "update_phone TEMPLATE ID DOES NOT EXIST, THIS IS AN OPTIONAL FIELD";
$data = "$phone_login|$template_id";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
}
$updateSQL = "$dialplan_numberSQL$activeSQL$outboundcidSQL$voicemail_idSQL$phone_loginSQL$phone_passSQL$protocolSQL$registration_passwordSQL$phone_full_nameSQL$phone_contextSQL$emailSQL$local_gmtSQL$admin_user_groupSQL$outbound_alt_cidSQL$phone_ring_timeoutSQL$delete_vm_after_emailSQL $is_webphone_SQL $webphone_auto_answer_SQL $use_external_server_ip_SQL $template_id_SQL $on_hook_agent_SQL";
if (strlen($updateSQL)< 3) if (strlen($updateSQL)< 3)