LICENSE: AGPLv2 # # CHANGES # 140916-1215 - Initial Build # 141114-1330 - formatting changes, code cleanup # 141229-1822 - Added code for on-the-fly language translations display # 150808-2042 - Added compatibility for custom fields data option # 161014-0842 - Added screen colors # 170409-1542 - Added IP List validation code # 170819-1001 - Added allow_manage_active_lists option # 190703-0925 - Added use of admin_web_directory system setting # 210427-1741 - Added more list count options # 220227-2204 - Added allow_web_debug system setting # $version = '2.14-10'; $build = '220227-2204'; 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']; $PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); $ip = getenv("REMOTE_ADDR"); $SQLdate = date("Y-m-d H:i:s"); $DB=0; $submit = ""; $confirm = ""; $orig_list = ""; $start_dest_list_id = ""; $num_leads = ""; if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["confirm"])) {$confirm=$_GET["confirm"];} elseif (isset($_POST["confirm"])) {$confirm=$_POST["confirm"];} if (isset($_GET["orig_list"])) {$orig_list=$_GET["orig_list"];} elseif (isset($_POST["orig_list"])) {$orig_list=$_POST["orig_list"];} if (isset($_GET["start_dest_list_id"])) {$start_dest_list_id=$_GET["start_dest_list_id"];} elseif (isset($_POST["start_dest_list_id"])) {$start_dest_list_id=$_POST["start_dest_list_id"];} if (isset($_GET["num_leads"])) {$num_leads=$_GET["num_leads"];} elseif (isset($_POST["num_leads"])) {$num_leads=$_POST["num_leads"];} $DB = preg_replace('/[^0-9]/','',$DB); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $sys_settings_stmt = "SELECT use_non_latin,outbound_autodial_active,sounds_central_control_active,enable_languages,language_method,active_modules,admin_screen_colors,allow_manage_active_lists,admin_web_directory,allow_web_debug 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]; $SSenable_languages = $sys_settings_row[3]; $SSlanguage_method = $sys_settings_row[4]; $SSactive_modules = $sys_settings_row[5]; $SSadmin_screen_colors = $sys_settings_row[6]; $SSallow_manage_active_lists = $sys_settings_row[7]; $SSadmin_web_directory = $sys_settings_row[8]; $SSallow_web_debug = $sys_settings_row[9]; } else { # there is something really weird if there are no system settings exit; } if ($SSallow_web_debug < 1) {$DB=0;} ##### END SETTINGS LOOKUP ##### ########################################### $submit = preg_replace('/[^-_0-9a-zA-Z]/','',$submit); $confirm = preg_replace('/[^-_0-9a-zA-Z]/','',$confirm); $orig_list = preg_replace('/[^0-9]/','',$orig_list); $start_dest_list_id = preg_replace('/[^0-9]/','',$start_dest_list_id); $num_leads = preg_replace('/[^0-9]/','',$num_leads); 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_USER = preg_replace('/[^-_0-9\p{L}]/u', '', $PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace('/[^-_0-9\p{L}]/u', '', $PHP_AUTH_PW); } $stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $sl_ct = mysqli_num_rows($rslt); if ($sl_ct > 0) { $row=mysqli_fetch_row($rslt); $VUselected_language = $row[0]; } $auth=0; $auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1,0); if ($auth_message == 'GOOD') {$auth=1;} if ($auth < 1) { $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); if ($auth_message == 'LOCK') { $VDdisplayMESSAGE = _QXZ("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; } if ($auth_message == 'IPBLOCK') { $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; 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 user_level, user_group, load_leads, 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); $user_level = $rights_row[0]; $user_group = $rights_row[1]; $load_leads = $rights_row[2]; $modify_leads = $rights_row[3]; $modify_lists = $rights_row[4]; # check their permissions if ( $user_level < 9 ) { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("You need to be a level 9 user to use this tool"); exit; } if ( $load_leads < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("You do not have permissions to load leads"); exit; } if ( $modify_leads < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("You do not have permissions to modify leads"); exit; } if ( $modify_lists < 1 ) { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("You do not have permissions to modify lists"); exit; } echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "| \n"; echo "\n"; echo ""._QXZ("List Split Tool")."\n"; echo "\n"; echo " | \n"; echo "\n"; echo " |
| \n";
if ($DB>0)
{
echo "DB: $DB \n"; echo "submit: $submit \n"; echo "confirm: $confirm \n"; echo "orig_list: $orig_list \n"; echo "start_dest_list_id: $start_dest_list_id \n"; echo "num_leads: $num_leads \n"; } # confirmation page if ($submit == _QXZ("submit") ) { # make sure the original list id is valid $id_chk_stmt = "SELECT list_id FROM vicidial_lists where list_id = $orig_list;"; if ($DB) { echo "|$id_chk_stmt|\n"; } $id_chk_rslt = mysql_to_mysqli($id_chk_stmt, $link); $id_chk_rows = mysqli_num_rows($id_chk_rslt); if ( $id_chk_rows < 1 ) { echo " $orig_list "._QXZ("is not a valid list id in the system.")." \n"; echo ""._QXZ("Click here to start over.")." \n"; echo "\n\n"; exit; } # figure out the highest list id in the system $max_id_stmt = "SELECT MAX(list_id) FROM vicidial_lists;"; if ($DB) { echo "|$max_id_stmt|\n"; } $max_id_rslt = mysql_to_mysqli($max_id_stmt, $link); $max_id_row = mysqli_fetch_row($max_id_rslt); $max_list_id = $max_id_row[0] + 1; # make sure the start destination list id is >= to max_list_id and an integer if ( ( is_int( $start_dest_list_id ) ) && ($start_dest_list_id < $max_list_id ) ) { echo ""._QXZ("The Start Destination List must be greater than or equal to")." $max_list_id. "._QXZ("This is to ensure that new lists will not interfere with the existing ones.")." \n"; echo "\n"; echo " | |