LICENSE: AGPLv2 # # CHANGES # 131016-1948 - Initial Build based upon lead_tools.php # 140113-0853 - Added USERONLY to ANYONE callback switcher # $version = '2.8-1'; $build = '140113-0853'; # This limit is to prevent data inconsistancies. # If there are too many leads in a list this # script might not finish before the php execution limit. $list_lead_limit = 100000; # maximum call count the script will work with $max_count = 20; require("dbconnect_mysqli.php"); require("functions.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $ip = getenv("REMOTE_ADDR"); $SQLdate = date("Y-m-d H:i:s"); $DB=0; $move_submit=""; $update_submit=""; $delete_submit=""; $callback_submit=""; $confirm_move=""; $confirm_update=""; $confirm_delete=""; $confirm_callback=""; if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["move_submit"])) {$move_submit=$_GET["move_submit"];} elseif (isset($_POST["move_submit"])) {$move_submit=$_POST["move_submit"];} if (isset($_GET["update_submit"])) {$update_submit=$_GET["update_submit"];} elseif (isset($_POST["update_submit"])) {$update_submit=$_POST["update_submit"];} if (isset($_GET["delete_submit"])) {$delete_submit=$_GET["delete_submit"];} elseif (isset($_POST["delete_submit"])) {$delete_submit=$_POST["delete_submit"];} if (isset($_GET["callback_submit"])) {$callback_submit=$_GET["callback_submit"];} elseif (isset($_POST["callback_submit"])) {$callback_submit=$_POST["callback_submit"];} if (isset($_GET["confirm_move"])) {$confirm_move=$_GET["confirm_move"];} elseif (isset($_POST["confirm_move"])) {$confirm_move=$_POST["confirm_move"];} if (isset($_GET["confirm_update"])) {$confirm_move=$_GET["confirm_update"];} elseif (isset($_POST["confirm_update"])) {$confirm_update=$_POST["confirm_update"];} if (isset($_GET["confirm_delete"])) {$confirm_delete=$_GET["confirm_delete"];} elseif (isset($_POST["confirm_delete"])) {$confirm_delete=$_POST["confirm_delete"];} if (isset($_GET["confirm_callback"])) {$confirm_callback=$_GET["confirm_callback"];} elseif (isset($_POST["confirm_callback"])) {$confirm_callback=$_POST["confirm_callback"];} $DB = preg_replace('/[^0-9]/','',$DB); $move_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$move_submit); $update_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$update_submit); $delete_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$delete_submit); $callback_submit = preg_replace('/[^-_0-9a-zA-Z]/','',$callback_submit); $confirm_move = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_move); $confirm_update = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_update); $confirm_delete = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_delete); $confirm_callback = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm_callback); $delete_status = preg_replace('/[^-_0-9a-zA-Z]/','',$delete_status); if ($DB) { echo "
DB = $DB | $move_submit = $move_submit | update_submit = $update_submit | delete_submit = $delete_submit | callback_submit = $callback_submit | confirm_move = $confirm_move | confirm_update = $confirm_update | confirm_delete = $confirm_delete | confirm_callback = $confirm_callback
"; } ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $sys_settings_stmt = "SELECT use_non_latin, outbound_autodial_active, sounds_central_control_active FROM system_settings;"; $sys_settings_rslt=mysql_to_mysqli($sys_settings_stmt, $link); if ($DB) {echo "$sys_settings_stmt\n";} $num_rows = mysqli_num_rows($sys_settings_rslt); if ($num_rows > 0) { $sys_settings_row=mysqli_fetch_row($sys_settings_rslt); $non_latin = $sys_settings_row[0]; $SSoutbound_autodial_active = $sys_settings_row[1]; $sounds_central_control_active = $sys_settings_row[2]; } else { # there is something really weird if there are no system settings exit; } ##### END SETTINGS LOOKUP ##### ########################################### if ($non_latin < 1) { $PHP_AUTH_USER = preg_replace('/[^0-9a-zA-Z]/', '', $PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace('/[^0-9a-zA-Z]/', '', $PHP_AUTH_PW); } else { $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); } $list_id_override = preg_replace('/[^0-9]/','',$list_id_override); $auth=0; $auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1); if ($auth_message == 'GOOD') {$auth=1;} if ($auth < 1) { $VDdisplayMESSAGE = "Login incorrect, please try again"; if ($auth_message == 'LOCK') { $VDdisplayMESSAGE = "Too many login attempts, try again in 15 minutes"; Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); Header("HTTP/1.0 401 Unauthorized"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; exit; } header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 # valid user $rights_stmt = "SELECT load_leads,user_group, delete_lists, modify_leads, modify_lists from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {echo "|$stmt|\n";} $rights_rslt=mysql_to_mysqli($rights_stmt, $link); $rights_row=mysqli_fetch_row($rights_rslt); $load_leads = $rights_row[0]; $user_group = $rights_row[1]; $delete_lists = $rights_row[2]; $modify_leads = $rights_row[3]; $modify_lists = $rights_row[4]; # check their permissions if ( $load_leads < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo "You do not have permissions to load leads\n"; exit; } if ( $modify_leads < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo "You do not have permissions to modify leads\n"; exit; } if ( $modify_lists < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo "You do not have permissions to modify lists\n"; exit; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; ?> ADMINISTRATION: Lead Tools\n"; ##### BEGIN Set variables to make header show properly ##### $ADD = '999998'; $hh = 'admin'; $LOGast_admin_access = '1'; $SSoutbound_autodial_active = '1'; $ADMIN = 'admin.php'; $page_width='770'; $section_width='750'; $header_font_size='3'; $subheader_font_size='2'; $subcamp_font_size='2'; $header_selected_bold=''; $header_nonselected_bold=''; $admin_color = '#FFFF99'; $admin_font = 'BLACK'; $admin_color = '#E6E6E6'; $subcamp_color = '#C6C6C6'; ##### END Set variables to make header show properly ##### require("admin_header.php"); echo "| \n"; echo "\n"; echo " Basic Lead Tools | Advanced Lead Tools\n"; echo "\n"; echo " | \n"; echo "\n"; echo " |
| \n";
# move confirmation page
if ($move_submit == "move" )
{
# get the variables
$enable_move_status="";
$enable_move_country_code="";
$enable_move_vendor_lead_code="";
$enable_move_source_id="";
$enable_move_owner="";
$enable_move_entry_date="";
$enable_move_modify_date="";
$enable_move_security_phrase="";
$enable_move_count="";
$move_country_code="";
$move_vendor_lead_code="";
$move_source_id="";
$move_owner="";
$move_entry_date="";
$move_modify_date="";
$move_security_phrase="";
$move_from_list="";
$move_to_list="";
$move_status="";
$move_count_op="";
$move_count_num="";
# check the get / post data for the variables
if (isset($_GET["enable_move_status"])) {$enable_move_status=$_GET["enable_move_status"];}
elseif (isset($_POST["enable_move_status"])) {$enable_move_status=$_POST["enable_move_status"];}
if (isset($_GET["enable_move_country_code"])) {$enable_move_country_code=$_GET["enable_move_country_code"];}
elseif (isset($_POST["enable_move_country_code"])) {$enable_move_country_code=$_POST["enable_move_country_code"];}
if (isset($_GET["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_GET["enable_move_vendor_lead_code"];}
elseif (isset($_POST["enable_move_vendor_lead_code"])) {$enable_move_vendor_lead_code=$_POST["enable_move_vendor_lead_code"];}
if (isset($_GET["enable_move_source_id"])) {$enable_move_source_id=$_GET["enable_move_source_id"];}
elseif (isset($_POST["enable_move_source_id"])) {$enable_move_source_id=$_POST["enable_move_source_id"];}
if (isset($_GET["enable_move_owner"])) {$enable_move_owner=$_GET["enable_move_owner"];}
elseif (isset($_POST["enable_move_owner"])) {$enable_move_owner=$_POST["enable_move_owner"];}
if (isset($_GET["enable_move_entry_date"])) {$enable_move_entry_date=$_GET["enable_move_entry_date"];}
elseif (isset($_POST["enable_move_entry_date"])) {$enable_move_entry_date=$_POST["enable_move_entry_date"];}
if (isset($_GET["enable_move_modify_date"])) {$enable_move_modify_date=$_GET["enable_move_modify_date"];}
elseif (isset($_POST["enable_move_modify_date"])) {$enable_move_modify_date=$_POST["enable_move_modify_date"];}
if (isset($_GET["enable_move_security_phrase"])) {$enable_move_security_phrase=$_GET["enable_move_security_phrase"];}
elseif (isset($_POST["enable_move_security_phrase"])) {$enable_move_security_phrase=$_POST["enable_move_security_phrase"];}
if (isset($_GET["enable_move_count"])) {$enable_move_count=$_GET["enable_move_count"];}
elseif (isset($_POST["enable_move_count"])) {$enable_move_count=$_POST["enable_move_count"];}
if (isset($_GET["move_country_code"])) {$move_country_code=$_GET["move_country_code"];}
elseif (isset($_POST["move_country_code"])) {$move_country_code=$_POST["move_country_code"];}
if (isset($_GET["move_vendor_lead_code"])) {$move_vendor_lead_code=$_GET["move_vendor_lead_code"];}
elseif (isset($_POST["move_vendor_lead_code"])) {$move_vendor_lead_code=$_POST["move_vendor_lead_code"];}
if (isset($_GET["move_source_id"])) {$move_source_id=$_GET["move_source_id"];}
elseif (isset($_POST["move_source_id"])) {$move_source_id=$_POST["move_source_id"];}
if (isset($_GET["move_owner"])) {$move_owner=$_GET["move_owner"];}
elseif (isset($_POST["move_owner"])) {$move_owner=$_POST["move_owner"];}
if (isset($_GET["move_entry_date"])) {$move_entry_date=$_GET["move_entry_date"];}
elseif (isset($_POST["move_entry_date"])) {$move_entry_date=$_POST["move_entry_date"];}
if (isset($_GET["move_modify_date"])) {$move_modify_date=$_GET["move_modify_date"];}
elseif (isset($_POST["move_modify_date"])) {$move_modify_date=$_POST["move_modify_date"];}
if (isset($_GET["move_security_phrase"])) {$move_security_phrase=$_GET["move_security_phrase"];}
elseif (isset($_POST["move_security_phrase"])) {$move_security_phrase=$_POST["move_security_phrase"];}
if (isset($_GET["move_from_list"])) {$move_from_list=$_GET["move_from_list"];}
elseif (isset($_POST["move_from_list"])) {$move_from_list=$_POST["move_from_list"];}
if (isset($_GET["move_to_list"])) {$move_to_list=$_GET["move_to_list"];}
elseif (isset($_POST["move_to_list"])) {$move_to_list=$_POST["move_to_list"];}
if (isset($_GET["move_status"])) {$move_status=$_GET["move_status"];}
elseif (isset($_POST["move_status"])) {$move_status=$_POST["move_status"];}
if (isset($_GET["move_count_op"])) {$move_count_op=$_GET["move_count_op"];}
elseif (isset($_POST["move_count_op"])) {$move_count_op=$_POST["move_count_op"];}
if (isset($_GET["move_count_num"])) {$move_count_num=$_GET["move_count_num"];}
elseif (isset($_POST["move_count_num"])) {$move_count_num=$_POST["move_count_num"];}
if ($DB)
{
echo " enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num "; } # filter out anything bad $enable_move_status = preg_replace('/[^a-zA-Z]/','',$enable_move_status); $enable_move_country_code = preg_replace('/[^a-zA-Z]/','',$enable_move_country_code); $enable_move_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_move_vendor_lead_code); $enable_move_source_id = preg_replace('/[^a-zA-Z]/','',$enable_move_source_id); $enable_move_owner = preg_replace('/[^a-zA-Z]/','',$enable_move_owner); $enable_move_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_move_entry_date); $enable_move_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_move_modify_date); $enable_move_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_move_security_phrase); $enable_move_count = preg_replace('/[^a-zA-Z]/','',$enable_move_count); $move_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$move_country_code); $move_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_vendor_lead_code); $move_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_source_id); $move_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_owner); $move_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_entry_date); $move_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_modify_date); $move_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_security_phrase); $move_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_status); $move_from_list = preg_replace('/[^0-9]/','',$move_from_list); $move_to_list = preg_replace('/[^0-9]/','',$move_to_list); $move_count_num = preg_replace('/[^0-9]/','',$move_count_num); $move_count_op = preg_replace('/[^<>=]/','',$move_count_op); if ($DB) { echo "enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num "; } # build the count operation phrase $move_count_op_phrase=""; if ( $move_count_op == "<" ) { $move_count_op_phrase= "less than "; } elseif ( $move_count_op == "<=" ) { $move_count_op_phrase= "less than or equal to "; } elseif ( $move_count_op == ">" ) { $move_count_op_phrase= "greater than "; } elseif ( $move_count_op == ">=" ) { $move_count_op_phrase= "greater than or equal to "; } # make sure the required fields are set if ($move_from_list == '') { missing_required_field('From List'); } if ($move_to_list == '') { missing_required_field('To List'); } # build the sql query's where phrase and the move phrase $sql_where = ""; $move_parm = ""; if (($enable_move_status == "enabled") && ($move_status != '')) { if ($move_status == '---BLANK---') {$move_status = '';} $sql_where = $sql_where . " and status like '$move_status' "; $move_parm = $move_parm . " status is like $move_status"; if ($move_status == '') {$move_status = '---BLANK---';} } elseif ($enable_move_status == "enabled") { blank_field('Status',true); } if (($enable_move_country_code == "enabled") && ($move_country_code != '')) { if ($move_country_code == '---BLANK---') {$move_country_code = '';} $sql_where = $sql_where . " and country_code like '$move_country_code' "; $move_parm = $move_parm . " country code is like $move_country_code "; if ($move_country_code == '') {$move_country_code = '---BLANK---';} } elseif ($enable_move_country_code == "enabled") { blank_field('Country Code',true); } if (($enable_move_vendor_lead_code == "enabled") && ($move_vendor_lead_code != '')) { if ($move_vendor_lead_code == '---BLANK---') {$move_vendor_lead_code = '';} $sql_where = $sql_where . " and vendor_lead_code like '$move_vendor_lead_code' "; $move_parm = $move_parm . " vendor lead code is like $move_vendor_lead_code "; if ($move_vendor_lead_code == '') {$move_vendor_lead_code = '---BLANK---';} } elseif ($enable_move_vendor_lead_code == "enabled") { blank_field('Vendor Lead Code',true); } if (($enable_move_source_id == "enabled") && ( $move_source_id != '')) { if ($move_source_id == '---BLANK---') {$move_source_id = '';} $sql_where = $sql_where . " and source_id like '$move_source_id' "; $move_parm = $move_parm . " source id is like $move_source_id "; if ($move_source_id == '') {$move_source_id = '---BLANK---';} } elseif ($enable_move_source_id == "enabled") { blank_field('Source ID',true); } if (($enable_move_owner == "enabled") && ($move_owner != '')) { if ($move_owner == '---BLANK---') {$move_owner = '';} $sql_where = $sql_where . " and owner like '$move_owner' "; $move_parm = $move_parm . " owner is like $move_owner "; if ($move_owner == '') {$move_owner = '---BLANK---';} } elseif ($enable_move_owner == "enabled") { blank_field('Owner',true); } if (($enable_move_security_phrase == "enabled") && ($move_security_phrase != '')) { if ($move_security_phrase == '---BLANK---') {$move_security_phrase = '';} $sql_where = $sql_where . " and security_phrase like '$move_security_phrase' "; $move_parm = $move_parm . " secuirty_phrase is like $move_security_phrase "; if ($move_security_phrase == '') {$move_security_phrase = '---BLANK---';} } elseif ($enable_move_security_phrase == "enabled") { blank_field('Security Phrase',true); } if (($enable_move_entry_date == "enabled") && ($move_entry_date != '')) { if ($move_entry_date == '---BLANK---') { $sql_where = $sql_where . " and entry_date == '' "; $move_parm = $move_parm . " entry date is blank "; } else { $sql_where = $sql_where . " and entry_date >= '$move_entry_date 00:00:00' and entry_date <= '$move_entry_date 23:59:59' "; $move_parm = $move_parm . " entry date was on $move_entry_date "; } } elseif ($enable_move_entry_date == "enabled") { blank_field('Entry Date',true); } if (($enable_move_modify_date == "enabled") && ($move_modify_date != '')) { if ($move_modify_date == '---BLANK---') { $sql_where = $sql_where . " and modify_date == '' "; $move_parm = $move_parm . " modify date is blank "; } else { $sql_where = $sql_where . " and modify_date >= '$move_modify_date 00:00:00' and modify_date <= '$move_modify_date 23:59:59' "; $move_parm = $move_parm . " last modify date was on $move_modify_date "; } } elseif ($enable_move_modify_date == "enabled") { blank_field('Modify Date',true); } if (($enable_move_count == "enabled") && ($move_count_op != '') && ($move_count_num != '')) { if ($move_count_op == '---BLANK---') {$move_count_op = '';} if ($move_count_num == '---BLANK---') {$move_count_num = '';} $sql_where = $sql_where . " and called_count $move_count_op $move_count_num"; $move_parm = $move_parm . " called count is $move_count_op_phrase $move_count_num "; if ($move_count_op == '') {$move_count_op = '---BLANK---';} if ($move_count_num == '') {$move_count_num = '---BLANK---';} } elseif ($enable_move_count == "enabled") { blank_field('Move Count',true); } # get the number of leads this action will move $move_lead_count=0; $move_lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$move_from_list' $sql_where"; if ($DB) { echo "|$move_lead_count_stmt|\n"; } $move_lead_count_rslt = mysql_to_mysqli($move_lead_count_stmt, $link); $move_lead_count_row = mysqli_fetch_row($move_lead_count_rslt); $move_lead_count = $move_lead_count_row[0]; # get the number of leads in the list this action will move to $to_list_lead_count=0; $to_list_lead_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$move_to_list'"; if ($DB) { echo "|$to_list_lead_stmt|\n"; } $to_list_lead_rslt = mysql_to_mysqli($to_list_lead_stmt, $link); $to_list_lead_row = mysqli_fetch_row($to_list_lead_rslt); $to_list_lead_count = $to_list_lead_row[0]; # check to see if we will exceed list_lead_limit in the move to list if ( $to_list_lead_count + $move_lead_count > $list_lead_limit ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " Sorry. This operation will cause list $move_to_list to exceed $list_lead_limit leads which is not allowed. \n"; echo "\n"; echo "\n\n"; } else { echo "You are about to move $move_lead_count leads from list $move_from_list to $move_to_list with the following parameters: enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num "; } # filter out anything bad $enable_move_status = preg_replace('/[^a-zA-Z]/','',$enable_move_status); $enable_move_country_code = preg_replace('/[^a-zA-Z]/','',$enable_move_country_code); $enable_move_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_move_vendor_lead_code); $enable_move_source_id = preg_replace('/[^a-zA-Z]/','',$enable_move_source_id); $enable_move_owner = preg_replace('/[^a-zA-Z]/','',$enable_move_owner); $enable_move_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_move_entry_date); $enable_move_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_move_modify_date); $enable_move_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_move_security_phrase); $enable_move_count = preg_replace('/[^a-zA-Z]/','',$enable_move_count); $move_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$move_country_code); $move_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_vendor_lead_code); $move_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_source_id); $move_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_owner); $move_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_entry_date); $move_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_modify_date); $move_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_security_phrase); $move_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$move_status); $move_from_list = preg_replace('/[^0-9]/','',$move_from_list); $move_to_list = preg_replace('/[^0-9]/','',$move_to_list); $move_count_num = preg_replace('/[^0-9]/','',$move_count_num); $move_count_op = preg_replace('/[^<>=]/','',$move_count_op); if ($DB) { echo "enable_move_status = $enable_move_status | enable_move_country_code = $enable_move_country_code | enable_move_vendor_lead_code = $enable_move_vendor_lead_code | enable_move_source_id = $enable_move_source_id | enable_move_owner = $enable_move_owner | enable_move_entry_date = $enable_move_entry_date | enable_move_modify_date = $enable_move_modify_date | enable_move_security_phrase = $enable_move_security_phrase | enable_move_count = $enable_move_count | move_country_code = $move_country_code | move_vendor_lead_code = $move_vendor_lead_code | move_source_id = $move_source_id | move_owner = $move_owner | move_owner = $move_entry_date | move_modify_date = $move_modify_date | move_security_phrase = $move_security_phrase | move_from_list = $move_from_list | move_to_list = $move_to_list | move_status = $move_status | move_count_op = $move_count_op | move_count_num = $move_count_num "; } $move_count_op_phrase=""; if ( $move_count_op == "<" ) { $move_count_op_phrase= "less than "; } elseif ( $move_count_op == "<=" ) { $move_count_op_phrase= "less than or equal to "; } elseif ( $move_count_op == ">" ) { $move_count_op_phrase= "greater than "; } elseif ( $move_count_op == ">=" ) { $move_count_op_phrase= "greater than or equal to "; } # make sure the required fields are set if ($move_from_list == '') { missing_required_field('From List'); } if ($move_to_list == '') { missing_required_field('To List'); } # build the sql query's where phrase and the move phrase $sql_where = ""; $move_parm = ""; if (($enable_move_status == "enabled") && ($move_status != '')) { if ($move_status == '---BLANK---') {$move_status = '';} $sql_where = $sql_where . " and status like '$move_status' "; $move_parm = $move_parm . " status is like $move_status"; if ($move_status == '') {$move_status = '---BLANK---';} } elseif ($enable_move_status == "enabled") { blank_field('Status',true); } if (($enable_move_country_code == "enabled") && ($move_country_code != '')) { if ($move_country_code == '---BLANK---') {$move_country_code = '';} $sql_where = $sql_where . " and country_code like '$move_country_code' "; $move_parm = $move_parm . " country code is like $move_country_code "; if ($move_country_code == '') {$move_country_code = '---BLANK---';} } elseif ($enable_move_country_code == "enabled") { blank_field('Country Code',true); } if (($enable_move_vendor_lead_code == "enabled") && ($move_vendor_lead_code != '')) { if ($move_vendor_lead_code == '---BLANK---') {$move_vendor_lead_code = '';} $sql_where = $sql_where . " and vendor_lead_code like '$move_vendor_lead_code' "; $move_parm = $move_parm . " vendor lead code is like $move_vendor_lead_code "; if ($move_vendor_lead_code == '') {$move_vendor_lead_code = '---BLANK---';} } elseif ($enable_move_vendor_lead_code == "enabled") { blank_field('Vendor Lead Code',true); } if (($enable_move_source_id == "enabled") && ( $move_source_id != '')) { if ($move_source_id == '---BLANK---') {$move_source_id = '';} $sql_where = $sql_where . " and source_id like '$move_source_id' "; $move_parm = $move_parm . " source id is like $move_source_id "; if ($move_source_id == '') {$move_source_id = '---BLANK---';} } elseif($enable_move_source_id == "enabled") { blank_field('Source ID',true); } if (($enable_move_owner == "enabled") && ($move_owner != '')) { if ($move_owner == '---BLANK---') {$move_owner = '';} $sql_where = $sql_where . " and owner like '$move_owner' "; $move_parm = $move_parm . " owner is like $move_owner "; if ($move_owner == '') {$move_owner = '---BLANK---';} } elseif ($enable_move_owner == "enabled") { blank_field('Owner',true); } if (($enable_move_security_phrase == "enabled") && ($move_security_phrase != '')) { if ($move_security_phrase == '---BLANK---') {$move_security_phrase = '';} $sql_where = $sql_where . " and security_phrase like '$move_security_phrase' "; $move_parm = $move_parm . " secuirty_phrase is like $move_security_phrase "; if ($move_security_phrase == '') {$move_security_phrase = '---BLANK---';} } elseif ($enable_move_security_phrase == "enabled") { blank_field('Security Phrase',true); } if (($enable_move_entry_date == "enabled") && ($move_entry_date != '')) { if ($move_entry_date == '---BLANK---') { $sql_where = $sql_where . " and entry_date == '' "; $move_parm = $move_parm . " entry date is blank "; } else { $sql_where = $sql_where . " and entry_date >= '$move_entry_date 00:00:00' and entry_date <= '$move_entry_date 23:59:59' "; $move_parm = $move_parm . " entry date was on $move_entry_date "; } } elseif ($enable_move_entry_date == "enabled") { blank_field('Entry Date',true); } if (($enable_move_modify_date == "enabled") && ($move_modify_date != '')) { if ($move_modify_date == '---BLANK---') { $sql_where = $sql_where . " and modify_date == '' "; $move_parm = $move_parm . " modify date is blank "; } else { $sql_where = $sql_where . " and modify_date >= '$move_modify_date 00:00:00' and modify_date <= '$move_modify_date 23:59:59' "; $move_parm = $move_parm . " last modify date was on $move_modify_date "; } } elseif ($enable_move_modify_date == "enabled") { blank_field('Modify Date',true); } if (($enable_move_count == "enabled") && ($move_count_op != '') && ($move_count_num != '')) { if ($move_count_op == '---BLANK---') {$move_count_op = '';} if ($move_count_num == '---BLANK---') {$move_count_num = '';} $sql_where = $sql_where . " and called_count $move_count_op $move_count_num"; $move_parm = $move_parm . " called count is $move_count_op_phrase $move_count_num "; if ($move_count_op == '') {$move_count_op = '---BLANK---';} if ($move_count_num == '') {$move_count_num = '---BLANK---';} } elseif ($enable_move_count == "enabled") { blank_field('Move Count',true); } $move_lead_stmt = "UPDATE vicidial_list SET list_id = '$move_to_list' WHERE list_id = '$move_from_list' $sql_where"; if ($DB) { echo "|$move_lead_stmt|\n"; } $move_lead_rslt = mysql_to_mysqli($move_lead_stmt, $link); $move_lead_count = mysqli_affected_rows($link); $move_sentence = "$move_lead_count leads have been moved from list $move_from_list to $move_to_list with the following parameters: $move_parm "; $SQL_log = "$move_lead_stmt|"; $SQL_log = preg_replace('/;/', '', $SQL_log); $SQL_log = addslashes($SQL_log); $admin_log_stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='OTHER', record_id='$move_from_list', event_code='ADMIN MOVE LEADS', event_sql=\"$SQL_log\", event_notes='$move_sentence';"; if ($DB) {echo "|$admin_log_stmt|\n";} $admin_log_rslt=mysql_to_mysqli($admin_log_stmt, $link); echo " $move_sentence "; echo "\n"; } # update confirmation page if ($update_submit == "update" ) { # get the variables $enable_update_from_status=""; $enable_update_country_code=""; $enable_update_vendor_lead_code=""; $enable_update_source_id=""; $enable_update_owner=""; $enable_update_entry_date=""; $enable_update_modify_date=""; $enable_update_security_phrase=""; $enable_update_count=""; $update_country_code=""; $update_vendor_lead_code=""; $update_source_id=""; $update_owner=""; $update_entry_date=""; $update_modify_date=""; $update_security_phrase=""; $update_list=""; $update_to_status=""; $update_from_status=""; $update_count_op=""; $update_count_num=""; # check the get / post data for the variables if (isset($_GET["enable_update_from_status"])) {$enable_update_from_status=$_GET["enable_update_from_status"];} elseif (isset($_POST["enable_update_from_status"])) {$enable_update_from_status=$_POST["enable_update_from_status"];} if (isset($_GET["enable_update_country_code"])) {$enable_update_country_code=$_GET["enable_update_country_code"];} elseif (isset($_POST["enable_update_country_code"])) {$enable_update_country_code=$_POST["enable_update_country_code"];} if (isset($_GET["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_GET["enable_update_vendor_lead_code"];} elseif (isset($_POST["enable_update_vendor_lead_code"])) {$enable_update_vendor_lead_code=$_POST["enable_update_vendor_lead_code"];} if (isset($_GET["enable_update_source_id"])) {$enable_update_source_id=$_GET["enable_update_source_id"];} elseif (isset($_POST["enable_update_source_id"])) {$enable_update_source_id=$_POST["enable_update_source_id"];} if (isset($_GET["enable_update_owner"])) {$enable_update_owner=$_GET["enable_update_owner"];} elseif (isset($_POST["enable_update_owner"])) {$enable_update_owner=$_POST["enable_update_owner"];} if (isset($_GET["enable_update_entry_date"])) {$enable_update_entry_date=$_GET["enable_update_entry_date"];} elseif (isset($_POST["enable_update_entry_date"])) {$enable_update_entry_date=$_POST["enable_update_entry_date"];} if (isset($_GET["enable_update_modify_date"])) {$enable_update_modify_date=$_GET["enable_update_modify_date"];} elseif (isset($_POST["enable_update_modify_date"])) {$enable_update_modify_date=$_POST["enable_update_modify_date"];} if (isset($_GET["enable_update_security_phrase"])) {$enable_update_security_phrase=$_GET["enable_update_security_phrase"];} elseif (isset($_POST["enable_update_security_phrase"])) {$enable_update_security_phrase=$_POST["enable_update_security_phrase"];} if (isset($_GET["enable_update_count"])) {$enable_update_count=$_GET["enable_update_count"];} elseif (isset($_POST["enable_update_count"])) {$enable_update_count=$_POST["enable_update_count"];} if (isset($_GET["update_country_code"])) {$update_country_code=$_GET["update_country_code"];} elseif (isset($_POST["update_country_code"])) {$update_country_code=$_POST["update_country_code"];} if (isset($_GET["update_vendor_lead_code"])) {$update_vendor_lead_code=$_GET["update_vendor_lead_code"];} elseif (isset($_POST["update_vendor_lead_code"])) {$update_vendor_lead_code=$_POST["update_vendor_lead_code"];} if (isset($_GET["update_source_id"])) {$update_source_id=$_GET["update_source_id"];} elseif (isset($_POST["update_source_id"])) {$update_source_id=$_POST["update_source_id"];} if (isset($_GET["update_owner"])) {$update_owner=$_GET["update_owner"];} elseif (isset($_POST["update_owner"])) {$update_owner=$_POST["update_owner"];} if (isset($_GET["update_entry_date"])) {$update_entry_date=$_GET["update_entry_date"];} elseif (isset($_POST["update_entry_date"])) {$update_entry_date=$_POST["update_entry_date"];} if (isset($_GET["update_modify_date"])) {$update_modify_date=$_GET["update_modify_date"];} elseif (isset($_POST["update_modify_date"])) {$update_modify_date=$_POST["update_modify_date"];} if (isset($_GET["update_security_phrase"])) {$update_security_phrase=$_GET["update_security_phrase"];} elseif (isset($_POST["update_security_phrase"])) {$update_security_phrase=$_POST["update_security_phrase"];} if (isset($_GET["update_list"])) {$update_list=$_GET["update_list"];} elseif (isset($_POST["update_list"])) {$update_list=$_POST["update_list"];} if (isset($_GET["update_from_status"])) {$update_from_status=$_GET["update_from_status"];} elseif (isset($_POST["update_from_status"])) {$update_from_status=$_POST["update_from_status"];} if (isset($_GET["update_to_status"])) {$update_to_status=$_GET["update_to_status"];} elseif (isset($_POST["update_to_status"])) {$update_to_status=$_POST["update_to_status"];} if (isset($_GET["update_count_op"])) {$update_count_op=$_GET["update_count_op"];} elseif (isset($_POST["update_count_op"])) {$update_count_op=$_POST["update_count_op"];} if (isset($_GET["update_count_num"])) {$update_count_num=$_GET["update_count_num"];} elseif (isset($_POST["update_count_num"])) {$update_count_num=$_POST["update_count_num"];} if ($DB) { echo "enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num "; } # filter out anything bad $enable_update_from_status = preg_replace('/[^a-zA-Z]/','',$enable_update_from_status); $enable_update_country_code = preg_replace('/[^a-zA-Z]/','',$enable_update_country_code); $enable_update_vendor_lead_code = preg_replace('/[^a-zA-Z]/','',$enable_update_vendor_lead_code); $enable_update_source_id = preg_replace('/[^a-zA-Z]/','',$enable_update_source_id); $enable_update_owner = preg_replace('/[^a-zA-Z]/','',$enable_update_owner); $enable_update_entry_date = preg_replace('/[^a-zA-Z]/','',$enable_update_entry_date); $enable_update_modify_date = preg_replace('/[^a-zA-Z]/','',$enable_update_modify_date); $enable_update_security_phrase = preg_replace('/[^a-zA-Z]/','',$enable_update_security_phrase); $enable_update_count = preg_replace('/[^a-zA-Z]/','',$enable_update_count); $update_country_code = preg_replace('/[^-_%a-zA-Z0-9]/','',$update_country_code); $update_vendor_lead_code = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_vendor_lead_code); $update_source_id = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_source_id); $update_owner = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_owner); $update_entry_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_entry_date); $update_modify_date = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_modify_date); $update_security_phrase = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_security_phrase); $update_to_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_to_status); $update_from_status = preg_replace('/[^-_%0-9a-zA-Z]/','',$update_from_status); $update_list = preg_replace('/[^0-9]/','',$update_list); $update_count_num = preg_replace('/[^0-9]/','',$update_count_num); $update_count_op = preg_replace('/[^<>=]/','',$update_count_op); if ($DB) { echo "enable_update_from_status = $enable_update_from_status | enable_update_country_code = $enable_update_country_code | enable_update_vendor_lead_code = $enable_update_vendor_lead_code | enable_update_source_id = $enable_update_source_id | enable_update_owner = $enable_update_owner | enable_update_entry_date = $enable_update_entry_date | enable_update_modify_date = $enable_update_modify_date | enable_update_security_phrase = $enable_update_security_phrase | enable_update_count = $enable_update_count | update_country_code = $update_country_code | update_vendor_lead_code = $update_vendor_lead_code | update_source_id = $update_source_id | update_owner = $update_owner | update_owner = $update_entry_date | update_modify_date = $update_modify_date | update_security_phrase = $update_security_phrase | update_list = $update_list | update_to_status = $ update_to_status | update_from_status = $update_from_status | update_count_op = $update_count_op | update_count_num = $update_count_num "; } $update_count_op_phrase=""; if ( $update_count_op == "<" ) { $update_count_op_phrase= "less than "; } elseif ( $update_count_op == "<=" ) { $update_count_op_phrase= "less than or equal to "; } elseif ( $update_count_op == ">" ) { $update_count_op_phrase= "greater than "; } elseif ( $update_count_op == ">=" ) { $update_count_op_phrase= "greater than or equal to "; } # make sure the required fields are set if ($update_to_status == '') { missing_required_field('To Status'); } if ($update_list == '') { missing_required_field('List ID'); } # build the sql query's where phrase and the move phrase $sql_where = ""; $update_parm = ""; if (($enable_update_from_status == "enabled") && ($update_from_status != '')) { if ($update_from_status == '---BLANK---') {$update_from_status = '';} $sql_where = $sql_where . " and status like '$update_from_status' "; $update_parm = $update_parm . " status is like $update_from_status"; if ($update_from_status == '') {$update_from_status = '---BLANK---';} } elseif ($enable_update_from_status == "enabled") { blank_field('Status',true); } if (($enable_update_country_code == "enabled") && ($update_country_code != '')) { if ($update_country_code == '---BLANK---') {$update_country_code = '';} $sql_where = $sql_where . " and country_code like '$update_country_code' "; $update_parm = $update_parm . " country code is like $update_country_code "; if ($update_country_code == '') {$update_country_code = '---BLANK---';} } elseif ($enable_update_country_code == "enabled") { blank_field('Country Code',true); } if (($enable_update_vendor_lead_code == "enabled") && ($update_vendor_lead_code != '')) { if ($update_vendor_lead_code == '---BLANK---') {$update_vendor_lead_code = '';} $sql_where = $sql_where . " and vendor_lead_code like '$update_vendor_lead_code' "; $update_parm = $update_parm . " vendor lead code is like $update_vendor_lead_code "; if ($update_vendor_lead_code == '') {$update_vendor_lead_code = '---BLANK---';} } elseif ($enable_update_vendor_lead_code == "enabled") { blank_field('Vendor Lead Code',true); } if (($enable_update_source_id == "enabled") && ( $update_source_id != '')) { if ($update_source_id == '---BLANK---') {$update_source_id = '';} $sql_where = $sql_where . " and source_id like '$update_source_id' "; $update_parm = $update_parm . " source id is like $update_source_id "; if ($update_source_id == '') {$update_source_id = '---BLANK---';} } elseif ($enable_update_source_id == "enabled") { blank_field('Source ID',true); } if (($enable_update_owner == "enabled") && ($update_owner != '')) { if ($update_owner == '---BLANK---') {$update_owner = '';} $sql_where = $sql_where . " and owner like '$update_owner' "; $update_parm = $update_parm . " owner is like $update_owner "; if ($update_owner == '') {$update_owner = '---BLANK---';} } elseif ($enable_update_owner == "enabled") { blank_field('Owner',true); } if (($enable_update_security_phrase == "enabled") && ($update_security_phrase != '')) { if ($update_security_phrase == '---BLANK---') {$update_security_phrase = '';} $sql_where = $sql_where . " and security_phrase like '$update_security_phrase' "; $update_parm = $update_parm . " secuirty_phrase is like $update_security_phrase "; if ($update_security_phrase == '') {$update_security_phrase = '---BLANK---';} } elseif ($enable_update_security_phrase == "enabled") { blank_field('Security Phrase',true); } if (($enable_update_entry_date == "enabled") && ($update_entry_date != '')) { if ($update_entry_date == '---BLANK---') { $sql_where = $sql_where . " and entry_date == '' "; $update_parm = $update_parm . " entry date is blank "; } else { $sql_where = $sql_where . " and entry_date >= '$update_entry_date 00:00:00' and entry_date <= '$update_entry_date 23:59:59' "; $update_parm = $update_parm . " entry date was on $update_entry_date "; } } elseif ($enable_update_entry_date == "enabled") { blank_field('Entry Date',true); } if (($enable_update_modify_date == "enabled") && ($update_modify_date != '')) { if ($update_modify_date == '---BLANK---') { $sql_where = $sql_where . " and modify_date == '' "; $update_parm = $update_parm . " modify date is blank "; } else { $sql_where = $sql_where . " and modify_date >= '$update_modify_date 00:00:00' and modify_date <= '$update_modify_date 23:59:59' "; $update_parm = $update_parm . " last modify date was on $update_modify_date "; } } elseif ($enable_update_modify_date == "enabled") { blank_field('Modify Date',true); } if (($enable_update_count == "enabled") && ($update_count_op != '') && ($update_count_num != '')) { if ($update_count_op == '---BLANK---') {$update_count_op = '';} if ($update_count_num == '---BLANK---') {$update_count_num = '';} $sql_where = $sql_where . " and called_count $update_count_op $update_count_num"; $update_parm = $update_parm . " called count is $update_count_op_phrase $update_count_num "; if ($update_count_op == '') {$update_count_op = '---BLANK---';} if ($update_count_num == '') {$update_count_num = '---BLANK---';} } elseif ($enable_update_count == "enabled") { blank_field('Move Count'); } # get the number of leads this action will move $update_lead_count=0; $update_lead_count_stmt = "SELECT count(1) FROM vicidial_list WHERE list_id = '$update_list' $sql_where"; if ($DB) { echo "|$update_lead_count_stmt|\n"; } $update_lead_count_rslt = mysql_to_mysqli($update_lead_count_stmt, $link); $update_lead_count_row = mysqli_fetch_row($update_lead_count_rslt); $update_lead_count = $update_lead_count_row[0]; echo " You are about to update $update_lead_count leads in list $update_list to the status $update_to_status with the following parameters: | |