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 # require("dbconnect_mysqli.php"); require("functions.php"); $MT[0]=''; $chat_group_ids=$MT; if (isset($_GET["email"])) {$email=$_GET["email"];} elseif (isset($_POST["email"])) {$email=$_POST["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"];} if (isset($_GET["chat_id"])) {$chat_id=$_GET["chat_id"];} elseif (isset($_POST["chat_id"])) {$chat_id=$_POST["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"];} 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"];} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} if (isset($_GET["child_window"])) {$child_window=$_GET["child_window"];} elseif (isset($_POST["child_window"])) {$child_window=$_POST["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"];} if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} elseif (isset($_POST["last_name"])) {$last_name=$_POST["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"];} ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $VUselected_language = ''; $stmt = "SELECT use_non_latin,enable_languages,language_method,default_language,allow_chats 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]; } $VUselected_language = $SSdefault_language; ##### END SETTINGS LOOKUP ##### ########################################### 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 ($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); $chat_group_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$chat_group_id); $server_ip = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$server_ip); $email = preg_replace("/\'|\"|\\\\|;/","",$email); $campaign = preg_replace('/[^-\_0-9a-zA-Z]/','',$campaign); $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); 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); $chat_creator = preg_replace('/[^- \_0-9a-zA-Z]/','',$chat_creator); $phone_number = preg_replace("/[^0-9]/","",$phone_number); $first_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$first_name); $last_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$last_name); } else { $user = preg_replace("/\'|\"|\\\\|;/","",$user); $pass=preg_replace("/\'|\"|\\\\|;| /","",$pass); $outside_user_name = preg_replace("/\'|\"|\\\\|;/","",$user); } 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,0,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; } } 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 ' '; ?>