From 27285a69795ed5b84c5b2c9b13c87c0fc99dc276 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 10 Feb 2021 01:44:48 +0000 Subject: [PATCH] Added 'add_did' function to the Non-Agent API. git-svn-id: svn://192.168.202.10@3349 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 2 + agc_2-X/trunk/docs/NON-AGENT_API.txt | 52 ++- .../trunk/www/agc/images/arrow_green_down.png | Bin 0 -> 235 bytes .../trunk/www/agc/images/arrow_green_up.png | Bin 0 -> 245 bytes .../trunk/www/agc/images/arrow_red_down.png | Bin 0 -> 234 bytes agc_2-X/trunk/www/agc/images/arrow_red_up.png | Bin 0 -> 240 bytes .../www/agc/images/arrow_yellow_down.png | Bin 0 -> 233 bytes .../trunk/www/agc/images/arrow_yellow_up.png | Bin 0 -> 239 bytes agc_2-X/trunk/www/agc/images/email_icon.png | Bin 0 -> 400 bytes .../trunk/www/agc/images/email_icon_white.png | Bin 0 -> 428 bytes agc_2-X/trunk/www/agc/images/fax_icon.png | Bin 0 -> 483 bytes .../trunk/www/agc/images/fax_icon_white.png | Bin 0 -> 520 bytes agc_2-X/trunk/www/agc/images/search.png | Bin 0 -> 686 bytes agc_2-X/trunk/www/vicidial/non_agent_api.php | 301 +++++++++++++++++- 14 files changed, 352 insertions(+), 3 deletions(-) create mode 100644 agc_2-X/trunk/www/agc/images/arrow_green_down.png create mode 100644 agc_2-X/trunk/www/agc/images/arrow_green_up.png create mode 100644 agc_2-X/trunk/www/agc/images/arrow_red_down.png create mode 100644 agc_2-X/trunk/www/agc/images/arrow_red_up.png create mode 100644 agc_2-X/trunk/www/agc/images/arrow_yellow_down.png create mode 100644 agc_2-X/trunk/www/agc/images/arrow_yellow_up.png create mode 100644 agc_2-X/trunk/www/agc/images/email_icon.png create mode 100644 agc_2-X/trunk/www/agc/images/email_icon_white.png create mode 100644 agc_2-X/trunk/www/agc/images/fax_icon.png create mode 100644 agc_2-X/trunk/www/agc/images/fax_icon_white.png create mode 100644 agc_2-X/trunk/www/agc/images/search.png diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 71a3ec79..e0097a8f 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -564,6 +564,8 @@ OTHER CHANGES: 160. Added 'copy_user' function to the Non-Agent API. +161. Added 'add_did' function to the Non-Agent API. + diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index 3d512403..975ebe3a 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-01-13 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-02-09 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -45,6 +45,7 @@ server_refresh - forces a conf file refresh on all telco servers in the cluster check_phone_number - allows you to check if a phone number is valid and dialable logged_in_agents - list of agents that are logged in to the system update_campaign - updates campaign settings in the system +add_did - adds new Inbound DID entries to the system update_did - updates Inbound DID information in the system phone_number_log - exports list of calls placed to one of more phone numbers ccc_lead_info - outputs lead data for cross-cluster-communication call @@ -169,6 +170,7 @@ Changes: 201113-0713 - Added delete_did option to update_did function 201201-1625 - Added group_by_campaign option to agent_stats_export function 210113-1714 - Added copy_user function +210209-2014 - Added add_did function API Functions use the 'function' variable @@ -2020,6 +2022,54 @@ SUCCESS: update_campaign CAMPAIGN HAS BEEN UPDATED - 6666|1101 +-------------------------------------------------------------------------------- +add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table + +NOTE: api user for this function must have user_level set to 8 or higher and "Modify DIDs" enabled + +REQUIRED FIELDS- +did_pattern - 2-50 characters, must be a valid DID in the system + NOTE: special characters in the did_pattern need to be URL encoded, for example the plus sign '+' must be sent as '%2B' +source - description of what originated the API call (maximum 20 characters) + +EDITABLE FIELDS- +did_description - 6-50 characters +active - Must be one of these: 'Y','N' +did_route - must be one of these: 'EXTEN','VOICEMAIL','AGENT','PHONE','IN_GROUP','CALLMENU','VMAIL_NO_INST' +record_call - must be one of these: 'Y','N','Y_QUEUESTOP' +extension - 1-50 digits +exten_context - 1-50 characters +voicemail_ext - 1-10 digits +phone_extension - 1-100 characters +server_ip - must be all numbers and dots, max 15 characters +group - a valid in-group group_id +filter_clean_cid_number - 1-20 characters + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=add_did&did_pattern=%2B1727555112&did_description=Updated+test+API+DID&active=Y +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=add_did&did_pattern=7275553331&did_description=Testing+DID&active=N&did_route=EXTEN&record_call=Y_QUEUESTOP&extension=8300&exten_context=notdefault&voicemail_ext=8301&phone_extension=55000&server_ip=192.168.198.5&group=TEST_IN2&filter_clean_cid_number=R10 + +Example responses: +ERROR: add_did USER DOES NOT HAVE PERMISSION TO ADD DIDS - 6666 +ERROR: add_did YOU MUST USE ALL REQUIRED FIELDS - 6666|1 +ERROR: add_did NOT AN ALLOWED DID - 98762 +ERROR: add_did DID ALREADY EXISTS - 6666|1000 +ERROR: add_did DID DESCRIPTION MUST BE FROM 6 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|012 +ERROR: add_did ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|U +ERROR: add_did DID ROUTE IS NOT VALID, THIS IS AN OPTIONAL FIELD - 6666|12 +ERROR: add_did RECORD CALL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did EXTENSION MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did EXTENSION CONTEXT MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did VOICEMAIL EXTENSION MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did PHONE EXTENSION MUST BE FROM 1 TO 100 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|0.0.0.0 +ERROR: add_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test +ERROR: add_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +SUCCESS: add_did DID HAS BEEN ADDED - 6666|1101 + + + + -------------------------------------------------------------------------------- update_did - updates Inbound DID information in the vicidial_inbound_dids table diff --git a/agc_2-X/trunk/www/agc/images/arrow_green_down.png b/agc_2-X/trunk/www/agc/images/arrow_green_down.png new file mode 100644 index 0000000000000000000000000000000000000000..1dde0b9f6b8d4bbbd20a97aee7ee566cc43b4a62 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4TDTK8UU*Z>r&@N{tuk+^*J>_*N*4h*di^|w2A z={#bYdGMFoMgjE=zJixn*RT{aYG0qQI%nMuqu!=a2d1po+5h?F{_kHUH=FyG{5!b< zmtRdn+Zbj2f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4TD)?1<`I01#4JY5_^Brab)YskkKDAIN@IZecB zeZ|bMrBgFmdKI;Vst0E?biumAu6 literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/arrow_red_down.png b/agc_2-X/trunk/www/agc/images/arrow_red_down.png new file mode 100644 index 0000000000000000000000000000000000000000..585858f4e2c0b5c6fe19bf49c40ee576c9cb41d3 GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4Rt{5@Yow*iI9JzX3_BrcylyOHyd14HXWeRJ0? zX(fwBV~f7l6sFrElWutlh;P`mpYutVKwh&6R~RGbinZ(i+E@JfziQ#i^%4IIk`HkH zf0=I3XZW>a|i^_yzqEiL$1$L#;d>2U$~+zW0)u$yz~59 Z)?!J;NamBaX+S41c)I$ztaD0e0sty|PkI0V literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/arrow_red_up.png b/agc_2-X/trunk/www/agc/images/arrow_red_up.png new file mode 100644 index 0000000000000000000000000000000000000000..20e6c812b3b42af791c793375ea7ffc2feb81ab7 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4SY7V@c!tAIkao-U3d5|^)@RTOdzlxTbSJZ^i( zBw-fMul=hc8V$E4v_!9U*u;I)DCZ#85@WZCp-*R7vfPc{pZ;vM$WssFIUkNxmF$ea zA04|uv1~>{S8|`pj|R&idFeCV&4%ABgP2SEt{i5(ou~6~Q}x9KM_+MI-EnrJTxeg( gu|x0k{w)yq-7aqRQ2hI4phFluUHx3vIVCg!05bAeC;$Ke literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/arrow_yellow_down.png b/agc_2-X/trunk/www/agc/images/arrow_yellow_down.png new file mode 100644 index 0000000000000000000000000000000000000000..9b10de1c6b403b144246e24100b09abdbf0aaa3a GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4Rtx{*^wKt`2$x;TbNTt0htBj+IphSrDr=B{0{ z4{_$KKWicOh-I6m%GRj@IYCi7+hPQtn0YKt5S`F)>({OS&By<*mummj^p(Gy-$Jq8 zQSx?!*kATJ7mtPP5(utLYCg=AK4)V)gW*(8*>&7Ix>wpPsQNG2Ue&6sW@0$?_MJG3 X3Gzp@yQ->yE@1F<^>bP0l+XkK3OY~5 literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/arrow_yellow_up.png b/agc_2-X/trunk/www/agc/images/arrow_yellow_up.png new file mode 100644 index 0000000000000000000000000000000000000000..97598aa996654d6c1ff8d6780e3ee6ca97e35467 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! zGca%qgD@k*tT_@uLG}_)Usv|0Ow4TDQa_9vWPn07o-U3d5|^)@HRN-2lxV$}yvJ>& zQLEF^sTpe>ln)8He2mf-XpLQ=n^?B^7k6*e>dHxq8yU9$^((4g<$AI>=HrpHJ$vro z(+$mNVO}=lp^z%SeZmx*1AN`D5}J~y+;Qld^xGo&{!yuQyTo~;*6a`Hy{++c;)cJC eSv8;7s~J1GB{J%tiFY)wsWq-=V%xuYD7y2oefq_xh)5S5w;`Gxi`@Ieoim-m@4+`K9 za9ix8V0BgKN|1@jIa{Y*wzsZpot%TevTVI7vbW)?j)|3tOJaRSM#1l`cMcr6Qu4(o z{@wREhxgw3{MV?+V_}P}5AVybU57>DCL9#ZV>7vZKyRMnLCskj{0ZBHZ%zI%X+cM- zNkLzyU5{GxZI0ZHcLj5;Ks0 zUUTQ_2GLo4%IA+7%~N`_H-Ib8bj$v2F$dN43_thtoO__PWop>ry4|m?=1%H*UL?3v sip~3mPa-dS?Y_RejHLQ6|HALP%y#j3(ti9fFzgsSUHx3vIVCg!0BN$Op8x;= literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/email_icon_white.png b/agc_2-X/trunk/www/agc/images/email_icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..c4fc9c7adc5814a767b1b55181d41bfc7cafba21 GIT binary patch literal 428 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 zP{(x;W^~e+T>%tiFY)wsWq-=V%))KG{ho^s0|TR_r;B5V#p$P0_Ioh}h_vt5=KRL6 z)IyDAQLwI)uB-FIJIYrwF2r5YGBKIz9}w+(kvrq8Q?j$O#NWjW55CQQA*K~JYjOIn zIlq6`evdh~Q~a1-QxscS!%D$O{{wXa@(m^h3^D(Nx3T3g>;CCU-nurdO?74T#p)%$ zSanu)zgk?iXc-%WuiM+?FJikJ0;dG$U)g2#ms@A8*&;LXV%MuK;q6X4SiKHt7pxWg zb%5)D=m(xDiWa&GV09sP&@g-<^n7~OwwonH7= z^RGTmdKI;Vst0O?4pG9{EDs6#6eG=j=)E)=2MxN;|oh`5PX{to|w8^K@T zMi7z~sg+h1E@-3+ioESkRjGz*2Dc6`pmcjwN z#X347-otUkr-^Y~o|+EjPR&qqQ9`8|U+@OYvC&^Mj9iRh8wT+?vGW7G$G1%TudW>o ZTmVb2Xz1M|1jqmY002ovPDHLkV1j>5&sP8d literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/fax_icon_white.png b/agc_2-X/trunk/www/agc/images/fax_icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..ac914dda11a4adef29a085e9b4f52a18bb904cac GIT binary patch literal 520 zcmV+j0{8uiP)UoR8bJcf0NxtMKpztBnn0mG>er8Q3Q>x7Lh=-v9c3IL~O*$&*4|F5%v?< z1O!70HJbP*$`-*uAS6h#`?GKYm&Hxq%Ynx`cV^zX=P`3H41juC?N|-V>IguS!Ds=S zz!-buEpQ(Axtm}BTM@COJ^-#}d6MR zFamr4&Sk7uL9hWF2cDw-R&N#~FrLFYNe!sC)K&81@gi|BW2bW6+&Kkms3(frQFW*^ zGE`yn=fJXh5x56@SEto$zz^U_ztz1QHq;}9!{MU#=zbjD1={La;70N*>II+;Ox2yk zcfc#418gK;1pXwSD~qc*?B+v`(00D<%T;zb0o(y*fs@I<0&B@Pi;Dx)USCrVl})KJ zhb^_&1ik<>>g&v1+G&Q`uAw;vd_ujfelD)_j`~9VW<4yZ6Mq53(rp1_mfNQQ0000< KMNUMnLSTZpY}HHv literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/agc/images/search.png b/agc_2-X/trunk/www/agc/images/search.png new file mode 100644 index 0000000000000000000000000000000000000000..4d8381759a7b346bde0e0b0104b68cb88c8d34a6 GIT binary patch literal 686 zcmV;f0#W^mP)35m%E~nn zxdNO94g+6+HzG3Uy6#LEhN`_^{)YL!f5J4)N5DvH=_{}U^Z35`>go&NjELNK zUHA6h-}<8+cSYnD@XGVNvza6?lgUho$W5T?dER6a22iO~^wiW;IgaBza6XRXcZoMF z6bkbqG7bb$6h-?zTo42Wt#t%EP3)nFIKWP$(O9N~YBrn8z<0n&dz53qR;^ZRb^=x^ zl^?(s(4Pi2fC0yGtWH4R_f22`*iHjq0zI~Ek97iCmNf?S0=2Xr&i+b9XzVvhTI)Nl z&zZ!{eSLiofjZz;tJQmHXgh~Mww1%##2gL|4tl^v;5aa{v9XaG9v*)0IL>ChUe{q5 z8kS{^#&P^WL?(a_N~zNH^z>zQmHh)7c&ea-wg&J zrBW%clzIXj1h#=<6h*J;vP`AaOdC^51&fP|U1I>5p`jt$FpOT{>cYape_;SW0pD-n UBu#FN!vFvP07*qoM6N<$f-mtgu>b%7 literal 0 HcmV?d00001 diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 6de178e8..2ad44363 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -159,10 +159,11 @@ # 201201-1625 - Added group_by_campaign option to agent_stats_export function # 201214-1547 - Fixes for PHP8 compatibility # 210113-1714 - Added copy_user function +# 210209-2014 - Added add_did function # -$version = '2.14-136'; -$build = '210113-1714'; +$version = '2.14-137'; +$build = '210209-2014'; $api_url_log = 0; $startMS = microtime(); @@ -6739,6 +6740,302 @@ if ($function == 'update_campaign') +################################################################################ +### add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table +################################################################################ +if ($function == 'add_did') + { + 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); + echo "ERROR: Invalid Source: |$source|\n"; + 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 modify_inbound_dids='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 = "add_did USER DOES NOT HAVE PERMISSION TO ADD DIDS"; + $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($did_pattern)<2) or (strlen($did_pattern)>50) ) + { + $result = 'ERROR'; + $result_reason = "add_did YOU MUST USE ALL REQUIRED FIELDS"; + $data = "$did_pattern"; + 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 allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGadmin_viewable_groups = $row[1]; + + $admin_viewable_groupsSQL=''; + $WHEREadmin_viewable_groupsSQL=''; + if (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $admin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $WHEREadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $did_exists=$row[0]; + if ($did_exists > 0) + { + $result = 'ERROR'; + $result_reason = "add_did DID ALREADY EXISTS"; + $data = "$did_pattern"; + 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 + { + $did_patternSQL = "did_pattern='$did_pattern'"; + $did_descriptionSQL=''; + $activeSQL=''; + $did_routeSQL=''; + $record_callSQL=''; + $extensionSQL=''; + $exten_contextSQL=''; + $voicemail_extSQL=''; + $phone_extensionSQL=''; + $server_ipSQL=''; + $groupSQL=''; + $filter_clean_cid_numberSQL=''; + + if (strlen($did_description) > 0) + { + if ( (strlen($did_description) > 50) or (strlen($did_description) < 6) ) + { + $result = 'ERROR'; + $result_reason = "add_did DID DESCRIPTION MUST BE FROM 6 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$did_description"; + 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 + {$did_descriptionSQL = " ,did_description='$did_description'";} + } + if (strlen($active) > 0) + { + if ( ($active != 'Y') and ($active != 'N') ) + { + $result = 'ERROR'; + $result_reason = "add_did ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD"; + $data = "$active"; + 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 + {$activeSQL = " ,did_active='$active'";} + } + if (strlen($did_route) > 0) + { + if (preg_match("/^EXTEN$|^VOICEMAIL$|^AGENT$|^PHONE$|^IN_GROUP$|^CALLMENU$|^VMAIL_NO_INST$/",$did_route)) + {$did_routeSQL = " ,did_route='$did_route'";} + else + { + $result = 'ERROR'; + $result_reason = "add_did DID ROUTE IS NOT VALID, THIS IS AN OPTIONAL FIELD"; + $data = "$did_route"; + 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($record_call) > 0) + { + if ( ($record_call != 'Y') and ($record_call != 'N') and ($record_call != 'Y_QUEUESTOP') ) + { + $result = 'ERROR'; + $result_reason = "add_did RECORD CALL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD"; + $data = "$record_call"; + 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 + {$record_callSQL = " ,record_call='$record_call'";} + } + if (strlen($extension) > 0) + { + if (strlen($extension) > 50) + { + $result = 'ERROR'; + $result_reason = "add_did EXTENSION MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$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 + {$extensionSQL = " ,extension='$extension'";} + } + if (strlen($exten_context) > 0) + { + if (strlen($exten_context) > 50) + { + $result = 'ERROR'; + $result_reason = "add_did EXTENSION CONTEXT MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$exten_context"; + 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 + {$exten_contextSQL = " ,exten_context='$exten_context'";} + } + if (strlen($voicemail_ext) > 0) + { + if ( (strlen($voicemail_ext) > 10) or (strlen($voicemail_ext) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did VOICEMAIL EXTENSION MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$voicemail_ext"; + 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 + {$voicemail_extSQL = " ,voicemail_ext='$voicemail_ext'";} + } + if (strlen($phone_extension) > 0) + { + if ( (strlen($phone_extension) > 100) or (strlen($phone_extension) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did PHONE EXTENSION MUST BE FROM 1 TO 100 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$phone_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 + {$phone_extensionSQL = " ,phone='$phone_extension'";} + } + if (strlen($server_ip) > 0) + { + $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 = "add_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD"; + $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; + } + $server_ipSQL = " ,server_ip='$server_ip'"; + } + if (strlen($group) > 0) + { + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $group_exists=$row[0]; + + if ($group_exists < 1) + { + $result = 'ERROR'; + $result_reason = "add_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD"; + $data = "$group"; + 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; + } + $groupSQL = " ,group_id='$group'"; + } + if (strlen($filter_clean_cid_number) > 0) + { + if ( (strlen($filter_clean_cid_number) > 20) or (strlen($filter_clean_cid_number) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$filter_clean_cid_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; + } + else + {$filter_clean_cid_numberSQL = " ,filter_clean_cid_number='$filter_clean_cid_number'";} + } + + $addSQL = "$did_patternSQL$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$filter_clean_cid_numberSQL"; + + $addSQL = preg_replace("/^ ,/",'',$addSQL); + $stmt="INSERT INTO vicidial_inbound_dids SET $addSQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + $add_count = mysqli_affected_rows($link); + $did_id = mysqli_insert_id($link); + if ($DB) {echo "$add_count|$did_id|$stmt|\n";} + + ### 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='DIDS', event_type='ADD', record_id='$did_id', event_code='ADMIN API ADD DID', event_sql=\"$SQL_log\", event_notes='did: $did_pattern did_id: $did_id inserted: $add_count';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + $result = 'SUCCESS'; + $result_reason = "add_did DID HAS BEEN ADDED"; + $data = "$did_pattern"; + 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 add_did +################################################################################ + + + + + ################################################################################ ### update_did - updates Inbound DID information in the vicidial_inbound_dids table ################################################################################