Added apinewlead options for system settings and lists
git-svn-id: svn://192.168.202.10@3927 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -223,10 +223,11 @@
|
||||
# 250105-1001 - Added enhanced_agent_monitoring option compatibility
|
||||
# 250130-1130 - Changed vicidial_daily_rt_monitor_log to vicidial_daily_rt_monitorING_log to match SQL file
|
||||
# 250516-1047 - Changed ksort to uksort so array sorting by key is alphabetic, case-INsensitive
|
||||
# 250620-1007 - Added apinewlead_url requests for add_lead when new leads are inserted
|
||||
#
|
||||
|
||||
$version = '2.14-200';
|
||||
$build = '250516-1047';
|
||||
$version = '2.14-201';
|
||||
$build = '250620-1007';
|
||||
$php_script='non_agent_api.php';
|
||||
$api_url_log = 0;
|
||||
$camp_lead_order_random=1;
|
||||
@@ -16150,6 +16151,7 @@ if ($function == 'add_lead')
|
||||
}
|
||||
|
||||
### BEGIN custom fields insert section ###
|
||||
$FORMcustom_field_names='';
|
||||
if ($custom_fields == 'Y')
|
||||
{
|
||||
if ($custom_fields_enabled > 0)
|
||||
@@ -16219,6 +16221,7 @@ if ($function == 'add_lead')
|
||||
{$A_field_valueSQL[$o] = $A_field_value[$o];}
|
||||
|
||||
$CFinsert_SQL .= "$A_field_label[$o]=\"$A_field_valueSQL[$o]\",";
|
||||
$FORMcustom_field_names .= "$A_field_label[$o]|";
|
||||
}
|
||||
}
|
||||
$o++;
|
||||
@@ -16416,6 +16419,273 @@ if ($function == 'add_lead')
|
||||
}
|
||||
}
|
||||
### END scheduled callback section ###
|
||||
|
||||
### BEGIN apinewlead section ###
|
||||
$apinewlead_url='';
|
||||
$apinewlead_url_LIST='';
|
||||
$apinewlead_url_STSTEM='';
|
||||
$stmt="SELECT url_address from vicidial_url_multi where campaign_id='-SYSTEM-API-NEWLEAD-' and entry_type='system' and url_type='apinewlead';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$urls_to_print = mysqli_num_rows($rslt);
|
||||
if ($urls_to_print > 0)
|
||||
{
|
||||
$rowx=mysqli_fetch_row($rslt);
|
||||
$apinewlead_url_STSTEM = $rowx[0];
|
||||
}
|
||||
$stmt="SELECT url_address from vicidial_url_multi where campaign_id='$list_id' and entry_type='list' and url_type='apinewlead';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$urls_to_print = mysqli_num_rows($rslt);
|
||||
if ($urls_to_print > 0)
|
||||
{
|
||||
$rowx=mysqli_fetch_row($rslt);
|
||||
$apinewlead_url_LIST = $rowx[0];
|
||||
}
|
||||
if ( (strlen($apinewlead_url_STSTEM) > 0) and (strlen($apinewlead_url_LIST) < 1) )
|
||||
{$apinewlead_url = $apinewlead_url_STSTEM;}
|
||||
if ( (strlen($apinewlead_url_LIST) > 0) and ($apinewlead_url_LIST != '---DISABLED---') )
|
||||
{$apinewlead_url = $apinewlead_url_LIST;}
|
||||
|
||||
# request apinewlead_url URL
|
||||
if (strlen($apinewlead_url) > 10)
|
||||
{
|
||||
##### grab the data from vicidial_list for the lead_id
|
||||
$stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id FROM vicidial_list where lead_id='$lead_id' LIMIT 1;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$list_lead_ct = mysqli_num_rows($rslt);
|
||||
if ($list_lead_ct > 0)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$entry_date = urlencode(trim($row[1]));
|
||||
$status = urlencode(trim($row[3]));
|
||||
$tsr = urlencode(trim($row[4]));
|
||||
$vendor_id = urlencode(trim($row[5]));
|
||||
$vendor_lead_code = urlencode(trim($row[5]));
|
||||
$source_id = urlencode(trim($row[6]));
|
||||
$list_id = urlencode(trim($row[7]));
|
||||
$gmt_offset_now = urlencode(trim($row[8]));
|
||||
$phone_code = urlencode(trim($row[10]));
|
||||
$phone_number = urlencode(trim($row[11]));
|
||||
$title = urlencode(trim($row[12]));
|
||||
$first_name = urlencode(trim($row[13]));
|
||||
$middle_initial = urlencode(trim($row[14]));
|
||||
$last_name = urlencode(trim($row[15]));
|
||||
$address1 = urlencode(trim($row[16]));
|
||||
$address2 = urlencode(trim($row[17]));
|
||||
$address3 = urlencode(trim($row[18]));
|
||||
$city = urlencode(trim($row[19]));
|
||||
$state = urlencode(trim($row[20]));
|
||||
$province = urlencode(trim($row[21]));
|
||||
$postal_code = urlencode(trim($row[22]));
|
||||
$country_code = urlencode(trim($row[23]));
|
||||
$gender = urlencode(trim($row[24]));
|
||||
$date_of_birth = urlencode(trim($row[25]));
|
||||
$alt_phone = urlencode(trim($row[26]));
|
||||
$email = urlencode(trim($row[27]));
|
||||
$security_phrase = urlencode(trim($row[28]));
|
||||
$comments = urlencode(trim($row[29]));
|
||||
$called_count = urlencode(trim($row[30]));
|
||||
$call_date = urlencode(trim($row[31]));
|
||||
$rank = urlencode(trim($row[32]));
|
||||
$owner = urlencode(trim($row[33]));
|
||||
$entry_list_id = urlencode(trim($row[34]));
|
||||
}
|
||||
|
||||
if (preg_match('/list_name--B--|list_description--B--|campaign--B--/i',$apinewlead_url))
|
||||
{
|
||||
$stmt = "SELECT list_name,list_description,campaign_id from vicidial_lists where list_id='$list_id' limit 1;";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$VL_ln_ct = mysqli_num_rows($rslt);
|
||||
if ($VL_ln_ct > 0)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$list_name = urlencode(trim($row[0]));
|
||||
$list_description = urlencode(trim($row[1]));
|
||||
$list_campaign = urlencode(trim($row[2]));
|
||||
}
|
||||
}
|
||||
|
||||
$apinewlead_url = preg_replace('/^VAR/','',$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--lead_id--B--/i',"$lead_id",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--list_id--B--/i',"$list_id",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--list_name--B--/i',"$list_name",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--list_description--B--/i',"$list_description",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--phone_code--B--/i',"$phone_code",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--phone_number--B--/i',"$phone_number",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--title--B--/i',"$title",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--first_name--B--/i',"$first_name",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--last_name--B--/i',"$last_name",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--address1--B--/i',"$address1",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--address2--B--/i',"$address2",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--address3--B--/i',"$address3",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--city--B--/i',"$city",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--state--B--/i',"$state",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--province--B--/i',"$province",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--postal_code--B--/i',"$postal_code",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--country_code--B--/i',"$country_code",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--gender--B--/i',"$gender",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--email--B--/i',"$email",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--comments--B--/i',"$comments",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--user--B--/i',"$tsr",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--campaign--B--/i',"$list_campaign",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--SQLdate--B--/i',urlencode(trim($SQLdate)),$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--epoch--B--/i',"$epoch",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--phone--B--/i',"$phone_number",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--source_id--B--/i',"$source_id",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--status--B--/i',"$status",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--rank--B--/i',"$rank",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--owner--B--/i',"$owner",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--entry_date--B--/i',"$entry_date",$apinewlead_url);
|
||||
$apinewlead_url = preg_replace('/--A--called_count--B--/i',"$called_count",$apinewlead_url);
|
||||
|
||||
if ($custom_insert_count > 0)
|
||||
{
|
||||
$custom_field_names = preg_replace("/^\||\|$/",'',$FORMcustom_field_names);
|
||||
$custom_field_names = preg_replace("/\|.*_DUPLICATE_.*\|/",'|',$custom_field_names);
|
||||
$custom_field_names = preg_replace("/\|/",",",$custom_field_names);
|
||||
$custom_field_names_ARY = explode(',',$custom_field_names);
|
||||
$custom_field_names_ct = count($custom_field_names_ARY);
|
||||
$custom_field_names_SQL = $custom_field_names;
|
||||
|
||||
if (preg_match("/cf_encrypt/",$active_modules))
|
||||
{
|
||||
$enc_fields=0;
|
||||
$stmt = "SELECT count(*) from vicidial_lists_fields where field_encrypt='Y' and list_id='$entry_list_id';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$enc_field_ct = mysqli_num_rows($rslt);
|
||||
if ($enc_field_ct > 0)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$enc_fields = $row[0];
|
||||
}
|
||||
if ($enc_fields > 0)
|
||||
{
|
||||
$stmt = "SELECT field_label from vicidial_lists_fields where field_encrypt='Y' and list_id='$entry_list_id';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$enc_field_ct = mysqli_num_rows($rslt);
|
||||
$r=0;
|
||||
while ($enc_field_ct > $r)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$encrypt_list .= "$row[0],";
|
||||
$r++;
|
||||
}
|
||||
$encrypt_list = ",$encrypt_list";
|
||||
}
|
||||
}
|
||||
|
||||
##### BEGIN grab the data from custom table for the lead_id
|
||||
if ($entry_list_id > 0)
|
||||
{
|
||||
$stmt="SELECT $custom_field_names_SQL FROM custom_$entry_list_id where lead_id='$lead_id' LIMIT 1;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00753',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$list_lead_ct = mysqli_num_rows($rslt);
|
||||
if ($list_lead_ct > 0)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$o=0;
|
||||
while ($custom_field_names_ct > $o)
|
||||
{
|
||||
$field_name_id = $custom_field_names_ARY[$o];
|
||||
$field_name_tag = "--A--" . $field_name_id . "--B--";
|
||||
if ($enc_fields > 0)
|
||||
{
|
||||
$field_enc=''; $field_enc_all='';
|
||||
if ($DB) {echo "|$column_list|$encrypt_list|\n";}
|
||||
if ( (preg_match("/,$field_name_id,/",$encrypt_list)) and (strlen($row[$o]) > 0) )
|
||||
{
|
||||
exec("../agc/aes.pl --decrypt --text=$row[$o]", $field_enc);
|
||||
$field_enc_ct = count($field_enc);
|
||||
$k=0;
|
||||
while ($field_enc_ct > $k)
|
||||
{
|
||||
$field_enc_all .= $field_enc[$k];
|
||||
$k++;
|
||||
}
|
||||
$field_enc_all = preg_replace("/CRYPT: |\n|\r|\t/",'',$field_enc_all);
|
||||
$row[$o] = base64_decode($field_enc_all);
|
||||
}
|
||||
}
|
||||
$form_field_value = urlencode(trim("$row[$o]"));
|
||||
|
||||
### Check for dispo filter, run if enabled and field matches
|
||||
if ( ($dispo_filter_enabled > 0) and (preg_match("/\|$field_name_id\|/",$df_fields)) )
|
||||
{
|
||||
$dct=0;
|
||||
while ($dispo_filters_ct > $dct)
|
||||
{
|
||||
$temp_df = explode(',',$dispo_filters[$dct]);
|
||||
$lm=0;
|
||||
|
||||
if ( (preg_match("/^$field_name_id$/i",$temp_df[0])) and ($form_field_value == $temp_df[1]) ) {$form_field_value = $temp_df[2]; $lm++;}
|
||||
|
||||
if ($DB) {echo "DF-Debug 3: $dct|$lm|$temp_df[0]($field_name_id)|$temp_df[1]($form_field_value)|$temp_df[2]|\n";}
|
||||
$dct++;
|
||||
}
|
||||
}
|
||||
$apinewlead_url = preg_replace("/$field_name_tag/i","$form_field_value",$apinewlead_url);
|
||||
$o++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### insert a new url log entry
|
||||
$stmt = "INSERT INTO vicidial_url_log SET uniqueid='$lead_id',url_date=NOW(),url_type='apinewlead',url='" . mysqli_real_escape_string($link, $apinewlead_url) . "',url_response='';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$affected_rows = mysqli_affected_rows($link);
|
||||
$url_id = mysqli_insert_id($link);
|
||||
|
||||
$URLstart_sec = date("U");
|
||||
|
||||
### send dispo_call_url ###
|
||||
if ($DB > 0) {echo "$apinewlead_url<BR>\n";}
|
||||
|
||||
$SCUfile = file("$apinewlead_url");
|
||||
if ( !($SCUfile) )
|
||||
{
|
||||
$error_array = error_get_last();
|
||||
$error_type = $error_array["type"];
|
||||
$error_message = $error_array["message"];
|
||||
$error_line = $error_array["line"];
|
||||
$error_file = $error_array["file"];
|
||||
}
|
||||
|
||||
if ($DB > 0) {echo "$SCUfile[0]<BR>\n";}
|
||||
|
||||
### update url log entry
|
||||
$URLend_sec = date("U");
|
||||
$URLdiff_sec = ($URLend_sec - $URLstart_sec);
|
||||
if ($SCUfile)
|
||||
{
|
||||
$SCUfile_contents = implode("", $SCUfile);
|
||||
$SCUfile_contents = preg_replace('/;/','',$SCUfile_contents);
|
||||
$SCUfile_contents = addslashes($SCUfile_contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
$SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file";
|
||||
}
|
||||
$stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$affected_rows = mysqli_affected_rows($link);
|
||||
}
|
||||
### END apinewlead section ###
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user