Added copy_phone API function

git-svn-id: svn://192.168.202.10@4024 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2026-09-07 22:19:06 +00:00
parent bd5f94ae68
commit 12a518040a
3 changed files with 229 additions and 16 deletions
+49 -10
View File
@@ -238,6 +238,7 @@ Changes:
260519-1647 - Code updates for PHP8 compatibility, and json output format 260519-1647 - Code updates for PHP8 compatibility, and json output format
260822-0841 - Added agent_ingroup_availability function 260822-0841 - Added agent_ingroup_availability function
260907-1702 - Added PJSIP option for add_phone & update_phone 260907-1702 - Added PJSIP option for add_phone & update_phone
260907-1808 - Added copy_phone function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -1733,7 +1734,7 @@ SUCCESS: update_remote_agent USER HAS BEEN UPDATED - 6666|7878
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
add_group_alias - adds group alias to the system add_group_alias - adds group alias to the system
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
caller_id_number - 6-20 characters caller_id_number - 6-20 characters
@@ -1853,17 +1854,17 @@ SUCCESS: delete_fpg_phone FILTER PHONE GROUP NUMBER HAS BEEN DELETED - 6666|7275
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
add_phone - adds a phone to the system add_phone - adds a phone to the system
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
extension - 2-100 characters extension - 2-100 characters
dialplan_number - 1-20 digits dialplan_number - 1-20 digits
voicemail_id - 1-10 digits voicemail_id - 1-10 digits
phone_login - 1-20 characters phone_login - 1-20 characters
phone_pass - 1-20 characters phone_pass - 1-100 characters
server_ip - 7-15 characters, must be a valid server_ip server_ip - 7-15 characters, must be a valid server_ip
protocol - Must be one of these: 'IAX2','SIP','PJSIP','Zap','EXTERNAL' protocol - Must be one of these: 'IAX2','SIP','PJSIP','Zap','EXTERNAL'
registration_password - 1-20 characters registration_password - 1-100 characters
phone_full_name - 1-50 characters phone_full_name - 1-50 characters
local_gmt - timezone setting, not adjusting for DST, default: '-5.00' local_gmt - timezone setting, not adjusting for DST, default: '-5.00'
outbound_cid - 1-20 digits outbound_cid - 1-20 digits
@@ -1896,10 +1897,48 @@ SUCCESS: add_phone PHONE HAS BEEN ADDED - 6666|cc100|10.0.9.8|SIP|100
--------------------------------------------------------------------------------
copy_phone - copies a phone in the system
NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS-
extension - 2-100 characters
dialplan_number - 1-20 digits
voicemail_id - 1-10 digits
phone_login - 1-20 characters
server_ip - 7-15 characters, must be a valid server_ip
phone_full_name - 1-50 characters
outbound_cid - 1-20 digits
source_extension - Must be an existing phone extension-server_ip combination in the system
source_server_ip - Must be an existing phone extension-server_ip combination in the system
OPTIONAL FIELDS-
phone_pass - 1-100 characters (if not populated, then default system phone pass is used)
registration_password - 1-100 characters (if not populated, then default system registration pass is used)
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=copy_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&registration_password=test&phone_full_name=Extension+55000&outbound_cid=7275551212&source_extension=cc100&source_server_ip=10.0.9.8
http://server/vicidial/non_agent_api.php?source=test&function=copy_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&server_ip=192.168.198.5&phone_full_name=Extension+55000&outbound_cid=7275551212&source_extension=cc100&source_server_ip=10.0.9.8
Example responses:
ERROR: copy_phone USER DOES NOT HAVE PERMISSION TO COPY PHONES - 6666|0
ERROR: copy_phone YOU MUST USE ALL REQUIRED FIELDS - 6666|1000|||||||||||
ERROR: copy_phone SOURCE SERVER DOES NOT EXIST - 6666|10.0.9.8
ERROR: copy_phone SOURCE PHONE DOES NOT EXIST ON THIS SERVER - 6666|10.0.9.8|cc100
ERROR: copy_phone SERVER DOES NOT EXIST - 6666|10.0.9.9
ERROR: copy_phone PHONE ALREADY EXISTS ON THIS SERVER - 6666|10.0.9.8|cc101
ERROR: copy_phone PHONE LOGIN ALREADY EXISTS - 6666|cc100
SUCCESS: copy_phone PHONE HAS BEEN COPIED - 6666|cc100|10.0.9.8|SIP|100
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
update_phone - updates or deletes a phone entry already in the system update_phone - updates or deletes a phone entry already in the system
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
extension - 2-100 characters extension - 2-100 characters
@@ -1912,9 +1951,9 @@ EDITABLE FIELDS-
dialplan_number - 1-20 digits dialplan_number - 1-20 digits
voicemail_id - 1-10 digits voicemail_id - 1-10 digits
phone_login - 1-20 characters phone_login - 1-20 characters
phone_pass - 1-20 characters phone_pass - 1-100 characters
protocol - Must be one of these: 'IAX2','SIP','PJSIP','Zap','EXTERNAL' protocol - Must be one of these: 'IAX2','SIP','PJSIP','Zap','EXTERNAL'
registration_password - 1-20 characters registration_password - 1-100 characters
phone_full_name - 1-50 characters phone_full_name - 1-50 characters
local_gmt - timezone setting, not adjusting for DST, default: '-5.00' local_gmt - timezone setting, not adjusting for DST, default: '-5.00'
outbound_cid - 6-18 digits outbound_cid - 6-18 digits
@@ -1969,7 +2008,7 @@ NOTICE: update_phone USER DOES NOT HAVE PERMISSION TO DELETE PHONES - 6666|7878
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
add_phone_alias - adds a phone alias entry to the system add_phone_alias - adds a phone alias entry to the system
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
alias_id - 2-20 characters alias_id - 2-20 characters
@@ -1993,7 +2032,7 @@ SUCCESS: add_phone_alias PHONE ALIAS HAS BEEN ADDED - 6666|x100|testing_x100|cc1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
update_phone_alias - updates or deletes a phone alias entry already in the system update_phone_alias - updates or deletes a phone alias entry already in the system
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
alias_id - 2-20 characters alias_id - 2-20 characters
@@ -2023,7 +2062,7 @@ SUCCESS: update_phone_alias PHONE ALIAS HAS BEEN DELETED - 6666|x100|
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
server_refresh - forces a conf file refresh on all telco servers in the cluster server_refresh - forces a conf file refresh on all telco servers in the cluster
NOTE: api user for this function must have user_level set to 8 or higher and "ast admin access" enabled NOTE: api user for this function must have user_level set to 8 or higher and "AGC Admin Access" enabled
REQUIRED FIELDS- REQUIRED FIELDS-
stage - "REFRESH" stage - "REFRESH"
+4 -3
View File
@@ -130,7 +130,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa
$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information';
$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_ingroup_availability agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list hopper_bulk_insert call_dispo_report agent_campaigns park_call pause_code preview_dial_action ra_call_control recording stereo_recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did copy_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent user_details'; $APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_ingroup_availability agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number copy_user copy_phone did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list hopper_bulk_insert call_dispo_report agent_campaigns park_call pause_code preview_dial_action ra_call_control recording stereo_recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did copy_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent user_details';
$browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone'; $browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone';
@@ -7776,12 +7776,13 @@ if ($SSscript_remove_js > 0)
# 260620-1447 - Added amd_status_map system setting and campaign setting # 260620-1447 - Added amd_status_map system setting and campaign setting
# 260822-0855 - Added many input variable declarations, added agent_ingroup_availability API function # 260822-0855 - Added many input variable declarations, added agent_ingroup_availability API function
# 260902-1656 - Fix for PJSIP # 260902-1656 - Fix for PJSIP
# 260907-1810 - Added copy_phone API function
# #
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time
$admin_version = '2.14-963a'; $admin_version = '2.14-964a';
$build = '260902-1656'; $build = '260907-1810';
$STARTtime = date("U"); $STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s"); $SQLdate = date("Y-m-d H:i:s");
+176 -3
View File
@@ -233,10 +233,11 @@
# 260822-0841 - Added agent_ingroup_availability function # 260822-0841 - Added agent_ingroup_availability function
# 260902-1709 - Fix for PJSIP # 260902-1709 - Fix for PJSIP
# 260907-1702 - Added PJSIP option for add_phone & update_phone # 260907-1702 - Added PJSIP option for add_phone & update_phone
# 260907-1808 - Added copy_phone function
# #
$version = '2.14-208'; $version = '2.14-209';
$build = '260907-1702'; $build = '260907-1808';
$php_script='non_agent_api.php'; $php_script='non_agent_api.php';
$api_url_log = 0; $api_url_log = 0;
$camp_lead_order_random=1; $camp_lead_order_random=1;
@@ -1034,6 +1035,13 @@ if (isset($_GET["ingroup_set_name"])) {$ingroup_set_name=$_GET["ingroup_set_na
else {$ingroup_set_name="";} else {$ingroup_set_name="";}
if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];} if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];}
elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];} elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];}
if (isset($_GET["source_extension"])) {$source_extension=$_GET["source_extension"];}
elseif (isset($_POST["source_extension"])) {$source_extension=$_POST["source_extension"];}
else {$source_extension="";}
if (isset($_GET["source_server_ip"])) {$source_server_ip=$_GET["source_server_ip"];}
elseif (isset($_POST["source_server_ip"])) {$source_server_ip=$_POST["source_server_ip"];}
else {$source_server_ip="";}
if (file_exists('options.php')) if (file_exists('options.php'))
{require('options.php');} {require('options.php');}
@@ -1044,7 +1052,7 @@ header ("Pragma: no-cache"); // HTTP/1.0
############################################# #############################################
##### START SYSTEM_SETTINGS LOOKUP ##### ##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,custom_fields_enabled,pass_hash_enabled,agent_whisper_enabled,active_modules,auto_dial_limit,enable_languages,language_method,admin_web_directory,sounds_web_server,allow_web_debug,enhanced_agent_monitoring FROM system_settings;"; $stmt = "SELECT use_non_latin,custom_fields_enabled,pass_hash_enabled,agent_whisper_enabled,active_modules,auto_dial_limit,enable_languages,language_method,admin_web_directory,sounds_web_server,allow_web_debug,enhanced_agent_monitoring,default_phone_registration_password,default_phone_login_password FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$qm_conf_ct = mysqli_num_rows($rslt); $qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0) if ($qm_conf_ct > 0)
@@ -1064,6 +1072,8 @@ if ($qm_conf_ct > 0)
$SSsounds_web_server = $row[9]; $SSsounds_web_server = $row[9];
$SSallow_web_debug = $row[10]; $SSallow_web_debug = $row[10];
$SSenhanced_agent_monitoring = $row[11]; $SSenhanced_agent_monitoring = $row[11];
$SSdefault_phone_registration_password = $row[12];
$SSdefault_phone_login_password = $row[13];
} }
if ($SSallow_web_debug < 1 || !isset($DB)) {$DB=0;} if ($SSallow_web_debug < 1 || !isset($DB)) {$DB=0;}
if ($SSallow_web_debug < 1 || !isset($DBX)) {$DBX=0;} if ($SSallow_web_debug < 1 || !isset($DBX)) {$DBX=0;}
@@ -1098,6 +1108,7 @@ $function = preg_replace('/[^-_0-9a-zA-Z]/', '',$function);
$format = preg_replace('/[^0-9a-zA-Z]/','',$format); $format = preg_replace('/[^0-9a-zA-Z]/','',$format);
$session_id = preg_replace('/[^0-9]/','',$session_id); $session_id = preg_replace('/[^0-9]/','',$session_id);
$server_ip = preg_replace('/[^-\.\:\_0-9a-zA-Z]/','',$server_ip); $server_ip = preg_replace('/[^-\.\:\_0-9a-zA-Z]/','',$server_ip);
$source_server_ip = preg_replace('/[^-\.\:\_0-9a-zA-Z]/','',$source_server_ip);
$stage = preg_replace('/[^-_0-9a-zA-Z]/','',$stage); $stage = preg_replace('/[^-_0-9a-zA-Z]/','',$stage);
$rank = preg_replace('/[^0-9]/','',$rank); $rank = preg_replace('/[^0-9]/','',$rank);
$did_ids=preg_replace('/[^\,\+0-9a-zA-Z]/','',$did_ids); $did_ids=preg_replace('/[^\,\+0-9a-zA-Z]/','',$did_ids);
@@ -1261,6 +1272,7 @@ if ($non_latin < 1)
$custom_four=preg_replace('/[^- \+\.\:\/\@\_0-9a-zA-Z]/','',$custom_four); $custom_four=preg_replace('/[^- \+\.\:\/\@\_0-9a-zA-Z]/','',$custom_four);
$custom_five=preg_replace('/[^- \+\.\:\/\@\_0-9a-zA-Z]/','',$custom_five); $custom_five=preg_replace('/[^- \+\.\:\/\@\_0-9a-zA-Z]/','',$custom_five);
$extension=preg_replace('/[^-_0-9a-zA-Z]/','',$extension); $extension=preg_replace('/[^-_0-9a-zA-Z]/','',$extension);
$source_extension = preg_replace('/[^-_0-9a-zA-Z]/','',$source_extension);
$dialplan_number=preg_replace('/[^\*\#0-9a-zA-Z]/','',$dialplan_number); $dialplan_number=preg_replace('/[^\*\#0-9a-zA-Z]/','',$dialplan_number);
$registration_password=preg_replace('/[^-_0-9a-zA-Z]/','',$registration_password); $registration_password=preg_replace('/[^-_0-9a-zA-Z]/','',$registration_password);
$phone_full_name=preg_replace('/[^- \+\.\_0-9a-zA-Z]/','',$phone_full_name); $phone_full_name=preg_replace('/[^- \+\.\_0-9a-zA-Z]/','',$phone_full_name);
@@ -1424,6 +1436,7 @@ else
$custom_four=preg_replace('/[^- \+\.\:\/\@\_0-9\p{L}]/u','',$custom_four); $custom_four=preg_replace('/[^- \+\.\:\/\@\_0-9\p{L}]/u','',$custom_four);
$custom_five=preg_replace('/[^- \+\.\:\/\@\_0-9\p{L}]/u','',$custom_five); $custom_five=preg_replace('/[^- \+\.\:\/\@\_0-9\p{L}]/u','',$custom_five);
$extension=preg_replace('/[^-_0-9\p{L}]/u','',$extension); $extension=preg_replace('/[^-_0-9\p{L}]/u','',$extension);
$source_extension=preg_replace('/[^-_0-9\p{L}]/u','',$source_extension);
$dialplan_number=preg_replace('/[^\*\#0-9\p{L}]/u','',$dialplan_number); $dialplan_number=preg_replace('/[^\*\#0-9\p{L}]/u','',$dialplan_number);
$registration_password=preg_replace('/[^-_0-9\p{L}]/u','',$registration_password); $registration_password=preg_replace('/[^-_0-9\p{L}]/u','',$registration_password);
$phone_full_name=preg_replace('/[^- \+\.\_0-9\p{L}]/u','',$phone_full_name); $phone_full_name=preg_replace('/[^- \+\.\_0-9\p{L}]/u','',$phone_full_name);
@@ -6273,6 +6286,166 @@ if ($function == 'add_phone')
################################################################################
### copy_phone - adds phone to the phones table
################################################################################
if ($function == 'copy_phone')
{
if(strlen($source)<2)
{
$result = 'ERROR';
$result_reason = "Invalid Source";
echo "$result: $result_reason: |$source|\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
else
{
if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) )
{
$result = 'ERROR';
$result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION";
echo "$result: $result_reason: |$user|$function|\n";
$data = "$allowed_user";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
$stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and ast_admin_access='1' and user_level >= 8 and active='Y';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$allowed_user=$row[0];
if ($allowed_user < 1)
{
$result = 'ERROR';
$result_reason = "copy_phone USER DOES NOT HAVE PERMISSION TO COPY PHONES";
$data = "$allowed_user";
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;
}
else
{
if ( (strlen($extension)<2) or (strlen($dialplan_number)<2) or (strlen($voicemail_id)<1) or (strlen($phone_login)<1) or (strlen($server_ip)<1) or (strlen($phone_full_name)<1) or (strlen($outbound_cid)<1) or (strlen($source_extension)<1) or (strlen($source_server_ip)<1) )
{
$result = 'ERROR';
$result_reason = "copy_phone YOU MUST USE ALL REQUIRED FIELDS";
$data = "$extension|$dialplan_number|$voicemail_id|$phone_login|$server_ip|$phone_full_name|$outbound_cid";
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;
}
else
{
$stmt="SELECT count(*) from servers where server_ip='$source_server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$source_server_exists=$row[0];
if ($source_server_exists < 1)
{
$result = 'ERROR';
$result_reason = "copy_phone SOURCE SERVER DOES NOT EXIST";
$data = "$source_server_ip";
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;
}
$stmt="SELECT count(*) from phones where extension='$source_extension' and server_ip='$source_server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$source_phone_exists=$row[0];
if ($source_phone_exists < 1)
{
$result = 'ERROR';
$result_reason = "copy_phone SOURCE PHONE DOES NOT EXIST ON THIS SERVER";
$data = "$source_server_ip|$source_extension";
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;
}
$stmt="SELECT count(*) from servers where server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$server_exists=$row[0];
if ($server_exists < 1)
{
$result = 'ERROR';
$result_reason = "copy_phone SERVER DOES NOT EXIST";
$data = "$server_ip";
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;
}
else
{
$stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$phone_exists=$row[0];
if ($phone_exists > 0)
{
$result = 'ERROR';
$result_reason = "copy_phone PHONE ALREADY EXISTS ON THIS SERVER";
$data = "$server_ip|$extension";
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;
}
else
{
$stmt="SELECT count(*) from phones where login='$phone_login';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$phone_exists=$row[0];
if ($phone_exists > 0)
{
$result = 'ERROR';
$result_reason = "copy_phone PHONE LOGIN ALREADY EXISTS";
$data = "$phone_login";
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;
}
else
{
if (strlen($phone_pass)<1) {$phone_pass = $SSdefault_phone_login_password;}
if (strlen($registration_password)<1) {$registration_password = $SSdefault_phone_registration_password;}
$stmt="INSERT INTO phones(extension, dialplan_number, voicemail_id, phone_ip, computer_ip, server_ip, login, pass, status, active, phone_type, fullname, company, picture, messages, old_messages, protocol, local_gmt, ASTmgrUSERNAME, ASTmgrSECRET, login_user, login_pass, login_campaign, park_on_extension, conf_on_extension, VICIDIAL_park_on_extension, VICIDIAL_park_on_filename, monitor_prefix, recording_exten, voicemail_exten, voicemail_dump_exten, ext_context, dtmf_send_extension, call_out_number_group, client_browser, install_directory, local_web_callerID_URL, VICIDIAL_web_URL, AGI_call_logging_enabled, user_switching_enabled, conferencing_enabled, admin_hangup_enabled, admin_hijack_enabled, admin_monitor_enabled, call_parking_enabled, updater_check_enabled, AFLogging_enabled, QUEUE_ACTION_enabled, CallerID_popup_enabled, voicemail_button_enabled, enable_fast_refresh, fast_refresh_rate, enable_persistant_mysql, auto_dial_next_number, VDstop_rec_after_each_call, DBX_server, DBX_database, DBX_user, DBX_pass, DBX_port, DBY_server, DBY_database, DBY_user, DBY_pass, DBY_port, outbound_cid, enable_sipsak_messages, email, template_id, conf_override, phone_context, phone_ring_timeout, conf_secret, delete_vm_after_email, is_webphone, use_external_server_ip, codecs_list, codecs_with_template, webphone_dialpad, on_hook_agent, webphone_auto_answer, voicemail_timezone, voicemail_options, user_group, voicemail_greeting, voicemail_dump_exten_no_inst, voicemail_instructions, on_login_report, unavail_dialplan_fwd_exten, unavail_dialplan_fwd_context, nva_call_url, nva_search_method, nva_error_filename, nva_new_list_id, nva_new_phone_code, nva_new_status, webphone_dialbox, webphone_mute, webphone_volume, webphone_debug, outbound_alt_cid, conf_qualify, webphone_layout, mohsuggest, webphone_settings) SELECT '$extension', '$dialplan_number', '$voicemail_id', phone_ip, computer_ip, '$server_ip', '$phone_login', '$phone_pass', status, active, phone_type, '$phone_full_name', company, picture, messages, old_messages, protocol, local_gmt, ASTmgrUSERNAME, ASTmgrSECRET, login_user, login_pass, login_campaign, park_on_extension, conf_on_extension, VICIDIAL_park_on_extension, VICIDIAL_park_on_filename, monitor_prefix, recording_exten, voicemail_exten, voicemail_dump_exten, ext_context, dtmf_send_extension, call_out_number_group, client_browser, install_directory, local_web_callerID_URL, VICIDIAL_web_URL, AGI_call_logging_enabled, user_switching_enabled, conferencing_enabled, admin_hangup_enabled, admin_hijack_enabled, admin_monitor_enabled, call_parking_enabled, updater_check_enabled, AFLogging_enabled, QUEUE_ACTION_enabled, CallerID_popup_enabled, voicemail_button_enabled, enable_fast_refresh, fast_refresh_rate, enable_persistant_mysql, auto_dial_next_number, VDstop_rec_after_each_call, DBX_server, DBX_database, DBX_user, DBX_pass, DBX_port, DBY_server, DBY_database, DBY_user, DBY_pass, DBY_port, '$outbound_cid', enable_sipsak_messages, email, template_id, conf_override, phone_context, phone_ring_timeout, '$registration_password', delete_vm_after_email, is_webphone, use_external_server_ip, codecs_list, codecs_with_template, webphone_dialpad, on_hook_agent, webphone_auto_answer, voicemail_timezone, voicemail_options, user_group, voicemail_greeting, voicemail_dump_exten_no_inst, voicemail_instructions, on_login_report, unavail_dialplan_fwd_exten, unavail_dialplan_fwd_context, nva_call_url, nva_search_method, nva_error_filename, nva_new_list_id, nva_new_phone_code, nva_new_status, webphone_dialbox, webphone_mute, webphone_volume, webphone_debug, outbound_alt_cid, conf_qualify, webphone_layout, mohsuggest, webphone_settings from phones where extension='$source_extension' and server_ip='$source_server_ip'";
$rslt=mysql_to_mysqli($stmt, $link);
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = preg_replace('/;/', '', $SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='PHONES', event_type='COPY', record_id='$extension', event_code='ADMIN API COPY PHONE', event_sql=\"$SQL_log\", event_notes='phone: $extension|$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmtA, $link);
$result = 'SUCCESS';
$result_reason = "copy_phone PHONE HAS BEEN COPIED";
$data = "$extension|$server_ip|$protocol|$dialplan_number";
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;
}
################################################################################
### END copy_phone
################################################################################
################################################################################ ################################################################################
### update_phone - updates phone entry already in the system ### update_phone - updates phone entry already in the system