LICENSE: AGPLv2 # # This is the interface for agents to chat with customers and each other. It's separate from the manager-to-agent # chat interface out of necessity and calls the chat_db_query.php page to send information and display it. It will # display any open chat the agent has, and of those open chats the full conversation of the current active chat # will be displayed. It will also show when an agent has a new unread message in any of his conversations and # allow the agent to toggle between them. They can also initiate chats with any agent currently logged into a # campaign through the agent interface. # # Builds: # 150903-2349 - First build # 151213-1107 - Added variable filtering # 151218-0913 - Added missing translation code and user auth # 160303-0051 - Added code for chat transfers # 160818-1235 - Added line colors and scrolling # 170528-1001 - Added variable filtering # 190902-0914 - Fix for PHP 7.2 # 201117-2207 - Changes for better compatibility with non-latin data input # 210616-2040 - Added optional CORS support, see options.php for details # 220220-0928 - Added allow_web_debug system setting # 220518-2211 - Small fix for encrypted auth # 230518-2002 - Added customer_chat_refresh_seconds options.php setting, and message display # 260302-1156 - Code updates for PHP8 compatibility # require("dbconnect_mysqli.php"); require("functions.php"); $php_script = 'vdc_chat_display.php'; $MT[0]=''; $chat_group_ids=$MT; $customer_chat_refresh_seconds=1; if (isset($_GET["email"])) {$email=$_GET["email"];} elseif (isset($_POST["email"])) {$email=$_POST["email"];} else {$email="";} if (isset($_GET["email_invite_lead_id"])) {$email_invite_lead_id=$_GET["email_invite_lead_id"];} elseif (isset($_POST["email_invite_lead_id"])) {$email_invite_lead_id=$_POST["email_invite_lead_id"];} else {$email_invite_lead_id="";} if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];} elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["chat_id"];} else {$chat_id="";} if (isset($_GET["chat_group_id"])) {$chat_group_id=$_GET["chat_group_id"];} elseif (isset($_POST["chat_group_id"])) {$chat_group_id=$_POST["chat_group_id"];} else {$chat_group_id="";} if (isset($_GET["chat_group_ids"])) {$chat_group_ids=$_GET["chat_group_ids"];} elseif (isset($_POST["chat_group_ids"])) {$chat_group_ids=$_POST["chat_group_ids"];} if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} else {$lead_id=0;} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} else {$user="";} if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} else {$campaign="";} if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} else {$dial_method="";} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} else {$pass="";} if (isset($_GET["child_window"])) {$child_window=$_GET["child_window"];} elseif (isset($_POST["child_window"])) {$child_window=$_POST["child_window"];} else {$child_window="";} if (isset($_GET["outside_user_name"])) {$outside_user_name=$_GET["outside_user_name"];} elseif (isset($_POST["outside_user_name"])) {$outside_user_name=$_POST["outside_user_name"];} if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} else {$first_name="";} if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} else {$last_name="";} if (isset($_GET["clickmute"])) {$clickmute=$_GET["clickmute"];} elseif (isset($_POST["clickmute"])) {$clickmute=$_POST["clickmute"];} if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} else {$stage="";} $PHP_SELF=$_SERVER['PHP_SELF']; $PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); $user=preg_replace("/\'|\"|\\\\|;| /","",$user); $pass=preg_replace("/\'|\"|\\\\|;| /","",$pass); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $VUselected_language = ''; $stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats,allow_web_debug FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} #if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { $row=mysqli_fetch_row($rslt); $non_latin = $row[0]; $SSenable_languages = $row[1]; $SSlanguage_method = $row[2]; $SSdefault_language = $row[3]; $SSallow_chats = $row[4]; $SSallow_web_debug = $row[5]; } $VUselected_language = $SSdefault_language; if ($SSallow_web_debug < 1 || !isset($DB)) {$DB=0;} $DB=preg_replace("/[^0-9]/","",$DB); ##### END SETTINGS LOOKUP ##### ########################################### # if options file exists, use the override values for the above variables # see the options-example.php file for more information if (file_exists('options.php')) { require('options.php'); } 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 if (!isset($clickmute) || $clickmute!="1") {$clickmute="0";} // Prevents annoying quirk of playing the audio cue every time you click the tab to view this $lead_id = preg_replace("/[^0-9]/","",$lead_id); # $chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id); # $server_ip = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$server_ip); $email = preg_replace("/\'|\"|\\\\|;/","",$email); # $dial_method = preg_replace('/[^-\_0-9a-zA-Z]/','',$dial_method); $clickmute = preg_replace("/\'|\"|\\\\|;/","",$clickmute); # $stage = preg_replace('/[^-\_0-9a-zA-Z]/','',$stage); $email_invite_lead_id = preg_replace("/\'|\"|\\\\|;/","",$email_invite_lead_id); # $child_window = preg_replace('/[^-\_0-9a-zA-Z]/','',$child_window); $chat_group_ids = preg_replace("/\"|\\\\|;/","",$chat_group_ids); $customer_chat_refresh_seconds=preg_replace("/[^0-9\.]/", "", $customer_chat_refresh_seconds); if (!$customer_chat_refresh_seconds) {$customer_chat_refresh_seconds=1;} $customer_chat_refresh_milliseconds = $customer_chat_refresh_seconds*1000; if ($non_latin < 1) { $user = preg_replace('/[^-\_0-9a-zA-Z]/','',$user); $pass=preg_replace("/[^-\.\+\/\=_0-9a-zA-Z]/","",$pass); $outside_user_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$user); $first_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$first_name); $last_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$last_name); $campaign = preg_replace('/[^-\_0-9a-zA-Z]/','',$campaign); $chat_group_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_group_id); $chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_id); $server_ip = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$server_ip); $dial_method = preg_replace('/[^-\_0-9a-zA-Z]/','',$dial_method); $stage = preg_replace('/[^-\_0-9a-zA-Z]/','',$stage); $child_window = preg_replace('/[^-\_0-9a-zA-Z]/','',$child_window); } else { $user = preg_replace('/[^-_0-9\p{L}]/u','',$user); $pass = preg_replace('/[^-\.\+\/\=_0-9\p{L}]/u','',$pass); $outside_user_name = preg_replace("/\'|\"|\\\\|;/","",$user); $first_name = preg_replace('/[^- \_\.0-9\p{L}]/u','',$first_name); $last_name = preg_replace('/[^- \_\.0-9\p{L}]/u','',$last_name); $campaign = preg_replace('/[^-\_0-9\p{L}]/u','',$campaign); $chat_group_id = preg_replace('/[^- \_\.0-9\p{L}]/u','',$chat_group_id); $chat_id = preg_replace('/[^- \_\.0-9\p{L}]/u','',$chat_id); $server_ip = preg_replace('/[^- \_\.0-9\p{L}]/u','',$server_ip); $dial_method = preg_replace('/[^-\_0-9\p{L}]/u','',$dial_method); $stage = preg_replace('/[^-\_0-9\p{L}]/u','',$stage); $child_window = preg_replace('/[^-\_0-9\p{L}]/u','',$child_window); } if( (strlen($stage) > 0) and ($stage == 'WELCOME') ) { echo _QXZ("Customer Chat Frame"); exit; } if ($SSallow_chats < 1) { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("Error, chat disabled on this system"); exit; } $auth=0; $auth_message = user_authorization($user,$pass,'',0,1,0,0,'vdc_chat_display'); if ($auth_message == 'GOOD') {$auth=1;} if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) { echo _QXZ("Invalid Username/Password:")." |$user|$pass|$auth_message|vdc_chat_display|\n"; exit; } $user_stmt="SELECT full_name,user_level,selected_language from vicidial_users where user='$user';"; $user_level=0; $user_rslt=mysql_to_mysqli($user_stmt, $link); if (mysqli_num_rows($user_rslt)>0) { $user_row=mysqli_fetch_row($user_rslt); $full_name = $user_row[0]; $user_level = $user_row[1]; $VUselected_language = $user_row[2]; if ($chat_id) { $chat_stmt="SELECT * from vicidial_live_chats where chat_creator='$user' and chat_id='$chat_id';"; # echo "\n"; } else { # echo "Waiting for chat request..."; exit; $chat_stmt=""; # Defined for $DB, prevents warnings } } else { unset($pass); ## Since user is not a vicidial user, check to see if they belong to another chat and use that as the default chat variable. $chat_stmt="SELECT chat_id from vicidial_chat_participants where chat_member='$user';"; $chat_rslt=mysql_to_mysqli($chat_stmt, $link); if (mysqli_num_rows($chat_rslt)>0) { $chat_row=mysqli_fetch_row($chat_rslt); $chat_id=$chat_row[0]; } } $stmt="SELECT * from vicidial_list where lead_id='$lead_id';"; $rslt=mysql_to_mysqli($stmt, $link); if (mysqli_num_rows($rslt)>0) { $row=mysqli_fetch_array($rslt); $first_name=$row["first_name"]; $last_name=$row["last_name"]; if (!$full_name) {$full_name=trim("$first_name $last_name");} if (!$email) {$email=$row["email"];} } 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 echo ' '; ?>