From 3266980a56c46a06f4e1df3f9fd73925b8818d85 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 19 Dec 2015 22:16:43 +0000 Subject: [PATCH] Added dynamic language ability to chat functions Fixed several security issues with Chat functions Added new options to ADMIN_www_languages.pl script git-svn-id: svn://192.168.202.10@2435 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/ADMIN_www_languages.pl | 140 +++-- agc_2-X/trunk/docs/CHAT_MESSAGING.txt | 11 +- .../agc/agc_agent_manager_chat_interface.php | 503 ++++++++++++++++-- agc_2-X/trunk/www/agc/chat_db_query.php | 115 ++-- agc_2-X/trunk/www/agc/vdc_chat_display.php | 157 ++++-- agc_2-X/trunk/www/agc/vicidial.php | 11 +- agc_2-X/trunk/www/agc/vicidial_chat_agent.js | 388 +------------- .../www/chat_customer/customer_chat_code.php | 33 +- .../chat_customer/customer_chat_functions.php | 116 ++-- .../vicidial_chat_customer_side.php | 162 ++++-- .../trunk/www/vicidial/AST_CLOSERstats_v2.php | 47 +- .../www/vicidial/manager_chat_actions.php | 40 +- .../www/vicidial/manager_chat_interface.php | 442 +++++++++++++-- .../www/vicidial/new_manager_chat_form.php | 43 +- agc_2-X/trunk/www/vicidial/vicidial_chat.js | 282 +--------- 15 files changed, 1449 insertions(+), 1041 deletions(-) diff --git a/agc_2-X/trunk/bin/ADMIN_www_languages.pl b/agc_2-X/trunk/bin/ADMIN_www_languages.pl index fb513dff..cd899a30 100644 --- a/agc_2-X/trunk/bin/ADMIN_www_languages.pl +++ b/agc_2-X/trunk/bin/ADMIN_www_languages.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# ADMIN_www_languages.pl version 2.10 +# ADMIN_www_languages.pl version 2.12 # # This script is designed to traverse the vicidial and agc web directories and # generate a list of phrases that are output from the QXZ PHP functions so that @@ -13,11 +13,12 @@ # and alter them if necessary: # ALTER TABLE audio_store_details CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; # -# Copyright (C) 2014 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # CHANGES # 141128-0024 - First build # 141211-2123 - Added --wipe-www-phrases-table CLI option and insert_date field +# 151219-0756 - Added --chat-only option for chat_customer and --one-file-only option # $secX = time(); @@ -69,7 +70,9 @@ if (length($ARGV[0])>1) print " [--debug] = verbose debug messages\n"; print " [--debugX] = extra verbose debug messages\n"; print " [--agc-only] = only parse the agc directory\n"; + print " [--chat-only] = only parse the chat_customer directory\n"; print " [--vicidial-only] = only parse the vicidial directory\n"; + print " [--one-file-only=/path/from/root] = process one php file only\n"; print " [--QXZlines] = print full lines that include QXZ functions\n"; print " [--QXZvalues] = print only QXZ function values\n"; print " [--QXZvaronly] = print only QXZ function values with PHP variables in them\n"; @@ -89,6 +92,8 @@ if (length($ARGV[0])>1) {$DBX=1;} if ($args =~ /--agc-only/i) # agc flag {$agc_only=1;} + if ($args =~ /--chat-only/i) # agc flag + {$chat_only=1;} if ($args =~ /--vicidial-only/i) # vicidial flag {$vicidial_only=1;} if ($args =~ /--QXZlines/i) # QXZlines flag @@ -103,6 +108,17 @@ if (length($ARGV[0])>1) {$QXZplaceonly=1;} if ($args =~ /--wipe-www-phrases-table/i) # wipewwwphrasestable flag {$wipewwwphrasestable=1;} + if ($args =~ /--one-file-only=/i) # CLI defined file path for one file only + { + @CLIonefileARY = split(/--one-file-only=/,$args); + @CLIonefileARX = split(/ /,$CLIonefileARY[1]); + if (length($CLIonefileARX[0])>2) + { + $PATHone = $CLIonefileARX[0]; + $PATHone =~ s/\/$| |\r|\n|\t//gi; + print " CLI defined one-file-only path: $PATHone\n"; + } + } if ($args =~ /--conffile=/i) # CLI defined file path { @CLIconffileARY = split(/--conffile=/,$args); @@ -195,51 +211,97 @@ if ($wipewwwphrasestable > 0) $i=0; $f=0; -if ($vicidial_only < 1) +if (length($PATHone) > 2) { - opendir(FILE, "$PATHweb/agc/"); - @agcFILES = readdir(FILE); - ### Loop through files first to gather list - foreach(@agcFILES) + $FILEparseDIR[$f] = "$PATHweb/temp/"; + $FILEparseNAME[$f] = ''; + $FILEparse[$f] = ''; + if ( (length($PATHone) > 2) && (!-d "$PATHone") ) { - $FILEparseDIR[$f] = "$PATHweb/agc/"; - $FILEparseNAME[$f] = ''; - $FILEparse[$f] = ''; - if ( (length($agcFILES[$i]) > 2) && (!-d "$PATHweb/agc/$agcFILES[$i]") ) - { - $FILEparse[$f] = "$PATHweb/agc/$agcFILES[$i]"; - $FILEparseNAME[$f] = $agcFILES[$i]; - $event_string = "$PATHweb/agc/$agcFILES[$i] $FILEparseNAME[$f]"; - if ($DBX > 0) {print "$event_string\n";} - &event_logger; - $f++; - } - $i++; + $FILEparse[$f] = "$PATHone"; + @oneARY = split("/", $PATHone); + $FILEparseNAME[$f] = $oneARY[-1]; + $event_string = "$PATHone $FILEparseNAME[$f]"; + if ($DBX > 0) {print "$event_string\n";} + &event_logger; + $f++; } + $i++; } - -$i=0; -if ($agc_only < 1) +else { - opendir(FILE, "$PATHweb/vicidial/"); - @vicidialFILES = readdir(FILE); - - ### Loop through files first to gather list - foreach(@vicidialFILES) + $i=0; + if ( ($vicidial_only < 1) && ($chat_only < 1) ) { - $FILEparseDIR[$f] = "$PATHweb/vicidial/"; - $FILEparseNAME[$f] = ''; - $FILEparse[$f] = ''; - if ( (length($vicidialFILES[$i]) > 2) && (!-d "$PATHweb/vicidial/$vicidialFILES[$i]") ) + opendir(FILE, "$PATHweb/agc/"); + @agcFILES = readdir(FILE); + ### Loop through files first to gather list + foreach(@agcFILES) { - $FILEparse[$f] = "$PATHweb/vicidial/$vicidialFILES[$i]"; - $FILEparseNAME[$f] = $vicidialFILES[$i]; - $event_string = "$PATHweb/vicidial/$vicidialFILES[$i] $FILEparseNAME[$f]"; - if ($DBX > 0) {print "$event_string\n";} - &event_logger; - $f++; + $FILEparseDIR[$f] = "$PATHweb/agc/"; + $FILEparseNAME[$f] = ''; + $FILEparse[$f] = ''; + if ( (length($agcFILES[$i]) > 2) && (!-d "$PATHweb/agc/$agcFILES[$i]") ) + { + $FILEparse[$f] = "$PATHweb/agc/$agcFILES[$i]"; + $FILEparseNAME[$f] = $agcFILES[$i]; + $event_string = "$PATHweb/agc/$agcFILES[$i] $FILEparseNAME[$f]"; + if ($DBX > 0) {print "$event_string\n";} + &event_logger; + $f++; + } + $i++; + } + } + + $i=0; + if ( ($agc_only < 1) && ($chat_only < 1) ) + { + opendir(FILE, "$PATHweb/vicidial/"); + @vicidialFILES = readdir(FILE); + + ### Loop through files first to gather list + foreach(@vicidialFILES) + { + $FILEparseDIR[$f] = "$PATHweb/vicidial/"; + $FILEparseNAME[$f] = ''; + $FILEparse[$f] = ''; + if ( (length($vicidialFILES[$i]) > 2) && (!-d "$PATHweb/vicidial/$vicidialFILES[$i]") ) + { + $FILEparse[$f] = "$PATHweb/vicidial/$vicidialFILES[$i]"; + $FILEparseNAME[$f] = $vicidialFILES[$i]; + $event_string = "$PATHweb/vicidial/$vicidialFILES[$i] $FILEparseNAME[$f]"; + if ($DBX > 0) {print "$event_string\n";} + &event_logger; + $f++; + } + $i++; + } + } + + $i=0; + if ( ($vicidial_only < 1) && ($agc_only < 1) ) + { + opendir(FILE, "$PATHweb/chat_customer/"); + @chat_customerFILES = readdir(FILE); + + ### Loop through files first to gather list + foreach(@chat_customerFILES) + { + $FILEparseDIR[$f] = "$PATHweb/chat_customer/"; + $FILEparseNAME[$f] = ''; + $FILEparse[$f] = ''; + if ( (length($chat_customerFILES[$i]) > 2) && (!-d "$PATHweb/chat_customer/$chat_customerFILES[$i]") ) + { + $FILEparse[$f] = "$PATHweb/chat_customer/$chat_customerFILES[$i]"; + $FILEparseNAME[$f] = $chat_customerFILES[$i]; + $event_string = "$PATHweb/chat_customer/$chat_customerFILES[$i] $FILEparseNAME[$f]"; + if ($DBX > 0) {print "$event_string\n";} + &event_logger; + $f++; + } + $i++; } - $i++; } } diff --git a/agc_2-X/trunk/docs/CHAT_MESSAGING.txt b/agc_2-X/trunk/docs/CHAT_MESSAGING.txt index d78a52ad..7e237cfe 100644 --- a/agc_2-X/trunk/docs/CHAT_MESSAGING.txt +++ b/agc_2-X/trunk/docs/CHAT_MESSAGING.txt @@ -1,4 +1,4 @@ -CHAT MESSAGING Started 2014-05-01 Updated 2015-12-17 +CHAT MESSAGING Started 2014-05-01 Updated 2015-12-19 After over 18 months of development, the Chat Messaging system for Vicidial was added to svn/trunk on December 13th, 2015(svn revision 2428). Our Chat messaging allows for customers to chat with agents from websites, as well as allowing managers to chat with agents and agents to chat with other agents all within their existing agent screen. @@ -6,6 +6,8 @@ After over 18 months of development, the Chat Messaging system for Vicidial was The Chat Messaging built into Vicidial is entirely web-based and uses it's own protocol. Also, all messages are logged and searchable though the Agent-Manager Chat Log accessible through the Admin Utilities webpage. +UPDATE 2015-12-19: We added several security enhancements related to the chat functionality. We strongly recommend that you update your system to svn/trunk revision 2435 or higher if you are running revision between 2428 and 2434. We also added dynamic language capability throughout the chat screens. + AGENT CHAT INTERFACE INSTRUCTIONS: @@ -54,6 +56,13 @@ If you want to put a chat page within your own IFRAME and use a specific in-grou http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?group_id=TESTCHAT +If you want to link to chat with a specific in-group and language ID in the system, you can use a link like this, +http://192.168.1.2/chat_customer/customer_chat_code.php?group_id=TESTCHAT&language=new_spanish + +If you want to put a chat page within your own IFRAME and use a specific in-group and language ID in the system, you can use a URL like this, +http://192.168.1.2/chat_customer/vicidial_chat_customer_side.php?group_id=TESTCHAT&language=new_spanish + + Chat settings in System Settings: diff --git a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php index 0fa498b7..55970426 100644 --- a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php +++ b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php @@ -8,36 +8,17 @@ # changes: # 141212-2245 - First Build # 151213-1108 - Added variable filtering +# 151218-1141 - Added missing translation code and user auth, merged js code into file # -$admin_version = '2.12-2'; -$build = '151213-1108'; +$admin_version = '2.12-3'; +$build = '151218-1141'; $sh="managerchats"; require("dbconnect_mysqli.php"); require("functions.php"); -############################################# -##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_languages,language_method 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]; - } -##### END SETTINGS LOOKUP ##### -########################################### - -$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; -$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; -$PHP_SELF=$_SERVER['PHP_SELF']; if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["action"])) {$action=$_GET["action"];} @@ -65,6 +46,56 @@ else $manager_chat_id = preg_replace("/\'|\"|\\\\|;/","",$user); } +############################################# +##### 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 ##### +########################################### + +$auth=0; +$auth_message = user_authorization($user,$pass,'',0,0,0); +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|$sh|\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 ($SSallow_chats < 1) + { + header ("Content-type: text/html; charset=utf-8"); + echo _QXZ("Error, chat disabled on this system"); + exit; + } + + # Get a count on unread messages where the user is involved but not the chat manager/initiator in order to create the ChatReloadIDNumber variable $chat_reload_id_number_array=array(); $unread_stmt="select manager_chat_id, manager_chat_subid, sum(if(message_viewed_date is not null, 0, 1)) as unread_count from vicidial_manager_chat_log where vicidial_manager_chat_log.user='$user' group by manager_chat_id, manager_chat_subid order by manager_chat_id, manager_chat_subid"; @@ -137,6 +168,13 @@ while (list($key, $id_number) = each($chat_reload_id_number_array)) { $ChatReloadIDNumber.="$id_number."; } $ChatReloadIDNumber=substr($ChatReloadIDNumber,0,-1); + +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 ' + +'; ?> @@ -144,31 +182,424 @@ $ChatReloadIDNumber=substr($ChatReloadIDNumber,0,-1); - + <?php echo _QXZ("ADMINISTRATION: Agent/Manager Chat Interface"); ?> - + "; echo ""; echo "\n"; -echo ""; -echo ""; -echo ""; +echo ""; +echo ""; +echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; @@ -204,7 +635,7 @@ echo ""; \n"; echo "\n"; -echo "\n"; -echo "\n"; echo "\n"; -echo "\n"; -echo "\n"; +echo "\n"; +echo "\n"; echo "
Chatting with:
".$chat_managers_array[$priority_chat]."
Chat started:
".$chat_start_date_array[$priority_chat]."
Your active chats:"._QXZ("Chatting with").":
".$chat_managers_array[$priority_chat]."
"._QXZ("Chat started").":
".$chat_start_date_array[$priority_chat]."
"._QXZ("Your active chats").":
\n"; echo "\t

\n"; echo "\t\n"; echo "
\n"; echo "
\n"; echo "
    "; if (empty($chat_managers_array)) { - echo "\t
  • NO OPEN CHATS
  • \n"; + echo "\t
  • "._QXZ("NO OPEN CHATS")."
  • \n"; } else { while (list($manager_chat_id, $text) = each($chat_managers_array)) { $manager_chat_subid=$chat_subid_array[$manager_chat_id]; @@ -180,9 +611,9 @@ echo "
    \n"; } echo "
\n"; echo "\t
\n"; -echo "(bolded chats = unread messages)
Mute alert sound
\n"; -echo "\t

\n"; -echo "\t

"; +echo "(bolded chats = unread messages)
"._QXZ("Mute alert sound")."
\n"; +echo "\t

\n"; +echo "\t

"; echo "
Select a live agent:
\n"; +echo "
"._QXZ("Select a live agent").":
\n"; $stmt="SELECT user_group from vicidial_users where user='$user';"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} @@ -255,13 +686,13 @@ echo "
Select a live agent:
\n"; echo ""; echo "
Message:
\n"; +echo "
"._QXZ("Message").":
\n"; echo ""; echo "


\n


\n
"; ?>
diff --git a/agc_2-X/trunk/www/agc/chat_db_query.php b/agc_2-X/trunk/www/agc/chat_db_query.php index 8c6c16c9..06e4e7c6 100644 --- a/agc_2-X/trunk/www/agc/chat_db_query.php +++ b/agc_2-X/trunk/www/agc/chat_db_query.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2015 Joe Johnson, Matt Florell LICENSE: AGPLv2 # # Called by vdc_chat_display.php and vicidial_chat_agent.js. This contains all actions taken by the # agent's interface when chatting with customers, other agents, and managers, through @@ -11,6 +11,7 @@ # # Builds: # 150901-2348 - First build +# 151218-1052 - Added missing translation code and user auth # require("dbconnect_mysqli.php"); @@ -79,6 +80,56 @@ if (isset($_GET["ChatReloadIDNumber"])) {$ChatReloadIDNumber=$_GET["ChatRelo $chat_member_name = preg_replace('/[^- \.\,\_0-9a-zA-Z]/',"",$chat_member_name); if (!$user) {echo "No user, no using."; exit;} +############################################# +##### 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 ##### +########################################### + +$auth=0; +$auth_message = user_authorization($user,$pass,'',0,0,0); +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|chat_db_query|\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 ($SSallow_chats < 1) + { + header ("Content-type: text/html; charset=utf-8"); + echo _QXZ("Error, chat disabled on this system"); + exit; + } + + ###### AGENT/MANAGER CHAT FUNCTIONS ####### if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manager_message) { @@ -86,7 +137,7 @@ if ($action=="CreateAgentToAgentChat" && $agent_manager && $agent_user && $manag $dupe_chat_stmt="select * from vicidial_manager_chats where (manager='$agent_manager' and selected_agents like '%|$agent_user|%') or (manager='$agent_user' and selected_agents like '%|$agent_manager|%')"; $dupe_chat_rslt=mysqli_query($link, $dupe_chat_stmt); if (mysqli_num_rows($dupe_chat_rslt)>0) { - echo "Error: You already have an open chat with this agent"; + echo _QXZ("Error: You already have an open chat with this agent"); } else { # This is slightly different from the manager-to-agent chat because it's only one agent you're chatting to so for reporting all that agent's specific information is grabbed and used to make the vicidial_manager_chats entry. Since the query should only return one result there's no while loop to insert subid chat info. @@ -166,7 +217,7 @@ if ($action=="DisplayMgrAgentChat" && $manager_chat_id && $manager_chat_subid && echo $allow_replies."\n".$chat_output_text."\n".$chat_start_date."\n".$display_name."\n".$new_messages; } else { - echo "N\nCHAT ENDED\n\n"; + echo "N\n"._QXZ("CHAT ENDED")."\n\n"; } } @@ -255,7 +306,7 @@ if ($action=="RefreshActiveChatView" && $user) { echo "$new_ChatReloadIDNumber|"; echo "
    "; if (empty($chat_managers_array)) { - echo "\t
  • NO OPEN CHATS
  • \n"; + echo "\t
  • "._QXZ("NO OPEN CHATS")."
  • \n"; } else { while (list($manager_chat_id, $text) = each($chat_managers_array)) { $manager_chat_subid=$chat_subid_array[$manager_chat_id]; @@ -270,7 +321,7 @@ if ($action=="RefreshActiveChatView" && $user) { if ($action=="ReloadAgentNewChatSpan" && $user) { echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "
    Select a live agent:
    \n"; + echo "
    "._QXZ("Select a live agent").":
    \n"; $stmt="SELECT user_group from vicidial_users where user='$user';"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} @@ -311,7 +362,7 @@ if ($action=="ReloadAgentNewChatSpan" && $user) { if ($rslt) {$agents_count = mysqli_num_rows($rslt);} $loop_count=0; echo ""; echo "
    Message:
    \n"; + echo "
    "._QXZ("Message").":
    \n"; echo ""; echo "


    \n


    \n
    "; } @@ -351,10 +402,10 @@ if ($action=="SendMgrChatMessage" && $manager_chat_id && $manager_chat_subid) { if (mysqli_insert_id($link)>0) { $reload_chat_span=1; } else { - echo "Error sending message."; + echo _QXZ("Error sending message."); } } else { - echo "Error sending message."; + echo _QXZ("Error sending message."); } } ###################################### @@ -461,20 +512,20 @@ if ($action=="agent_send_message" && $chat_id) { $live_row=mysqli_fetch_row($live_rslt); $status=$live_row[0]; if ($status=="WAITING") { - echo "Chat $chat_id is waiting for an agent"; + echo _QXZ("Chat is waiting for an agent").": $chat_id"; } else { if ($status=="LIVE") { $ins_stmt="insert ignore into vicidial_chat_log(chat_id, message, poster, chat_member_name, chat_level) VALUES('$chat_id', '".mysqli_real_escape_string($link, $chat_message)."', '$user', '".mysqli_real_escape_string($link, $chat_member_name)."', '$chat_level')"; $ins_rslt=mysql_to_mysqli($ins_stmt, $link); if (mysqli_affected_rows($link)<1) { - echo "SYSTEM ERROR
    \n"; + echo ""._QXZ("SYSTEM ERROR")."
    \n"; } } else { - echo "SYSTEM ERROR
    \n"; + echo ""._QXZ("SYSTEM ERROR")."
    \n"; } } } else if (mysqli_num_rows($rslt)==0) { - echo "Chat $chat_id has been closed"; + echo _QXZ("Chat has been closed").": $chat_id"; } } @@ -506,7 +557,7 @@ if ($action=="update_agent_chat_window" && $chat_id) { $status_stmt="select status, chat_creator from vicidial_live_chats where chat_id='$chat_id'"; $status_rslt=mysql_to_mysqli($status_stmt, $link); if (mysqli_num_rows($status_rslt)==0) { - echo "Chat $chat_id does not exist or has been closed
    \n"; + echo ""._QXZ("Chat does not exist or has been closed").": $chat_id
    \n"; } else { $status_row=mysqli_fetch_row($status_rslt); @@ -521,7 +572,7 @@ if ($action=="update_agent_chat_window" && $chat_id) { $live_stmt="select * from vicidial_live_chats vlc, vicidial_chat_participants vcp where vlc.chat_id='$chat_id' and status='LIVE' and vlc.chat_id=vcp.chat_id and vcp.chat_member='$user'"; $live_rslt=mysql_to_mysqli($live_stmt, $link); if (mysqli_num_rows($live_rslt)>0) { - echo "Current chat: $chat_id
    \n"; + echo ""._QXZ("Current chat").": $chat_id
    \n"; # Create color-coding for chat $stmt="select * from vicidial_chat_log where chat_id='$chat_id' order by message_time asc"; @@ -550,16 +601,16 @@ if ($action=="update_agent_chat_window" && $chat_id) { $current_messages=mysqli_num_rows($rslt); echo "\n"; } else { - echo "Click on a live chat at right to join it.
    \n"; + echo ""._QXZ("Click on a live chat at right to join it.")."
    \n"; } } else { if ($status_row[1]=="NONE") { - echo "Waiting for next available agent....
    \n"; + echo ""._QXZ("Waiting for next available agent...")."
    \n"; # 8/28 - Added in case agent starts chat but hasn't invited someone or they haven't shown up yet } else if ($status_row[1]==$user || $status_row[0]=="WAITING") { - echo "Please send an invite to the customer to begin...
    \n"; + echo ""._QXZ("Please send an invite to the customer to begin...")."
    \n"; } else { - echo "SYSTEM ERROR
    \n"; + echo ""._QXZ("SYSTEM ERROR")."
    \n"; } } } @@ -661,7 +712,7 @@ if ($action=="send_invite" && $chat_id && $email && $chat_group_id) { if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) { if ($user!=$chat_creator) { - echo "You cannot end this chat unless you are the one who started it."; + echo _QXZ("You cannot end this chat unless you are the one who started it."); exit; } @@ -674,9 +725,9 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) { $del_stmt="delete from vicidial_live_chats where chat_id='$chat_id' and chat_creator='$chat_creator'"; $del_rslt=mysql_to_mysqli($del_stmt, $link); if (mysqli_affected_rows($link)==0) { - echo "Warning: chat ID not found. Deleting any remaining participants...

    "; + echo _QXZ("Warning: chat ID not found. Deleting any remaining participants...")."

    "; } else { - echo "Chat ended

    "; + echo _QXZ("Chat ended")."

    "; } $del_log_stmt="delete from vicidial_chat_log where chat_id='$chat_id'"; $del_log_rslt=mysql_to_mysqli($del_log_stmt, $link); @@ -685,7 +736,7 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) { $del_rslt2=mysql_to_mysqli($del_stmt2, $link); $deleted_participants=mysqli_affected_rows($link); - echo "$deleted_participants removed from chat."; + echo "$deleted_participants "._QXZ("removed from chat."); # HTML to display after ending chat - will only display again if no lead_id, i.e. no customer involved and no dispositioning needed. echo "|"; @@ -695,9 +746,9 @@ if ($action=="end_chat" && $chat_id && $chat_creator && $user && $server_ip) { $vla_stmt="select closer_campaigns from vicidial_live_agents where user='$user'"; $vla_rslt=mysql_to_mysqli($vla_stmt, $link); - echo "

    "; + echo "

    "; echo "

    "; + echo ""; } } diff --git a/agc_2-X/trunk/www/agc/vdc_chat_display.php b/agc_2-X/trunk/www/agc/vdc_chat_display.php index 5dfcf75f..be972429 100644 --- a/agc_2-X/trunk/www/agc/vdc_chat_display.php +++ b/agc_2-X/trunk/www/agc/vdc_chat_display.php @@ -13,28 +13,12 @@ # Builds: # 150903-2349 - First build # 151213-1107 - Added variable filtering +# 151218-0913 - Added missing translation code and user auth # require("dbconnect_mysqli.php"); require("functions.php"); -############################################# -##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_languages,language_method 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]; - } -##### END SETTINGS LOOKUP ##### -########################################### - 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"];} @@ -67,6 +51,29 @@ 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 @@ -82,6 +89,7 @@ $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); if ($non_latin < 1) { @@ -100,24 +108,47 @@ else $outside_user_name = preg_replace("/\'|\"|\\\\|;/","",$user); } -$user_stmt="select full_name, user_level from vicidial_users where user='$user'"; -echo "\n"; +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); +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]; + $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"; + # echo "\\-->\n"; } else { # echo "Waiting for chat request..."; exit; } @@ -141,10 +172,16 @@ if (mysqli_num_rows($rslt)>0) { 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 ' + +'; ?> -Vicidial Chat Interface +<?php echo _QXZ("Agent Chat Interface"); ?> + <?php echo _QXZ("ADMINISTRATION: Manager Chat Interface"); ?> \"HELP\""; echo "\n"; - echo "CURRENT CHAT #$manager_chat_id\n"; - echo "[END ALL CHATS]"; + echo ""._QXZ("CURRENT CHAT")." #$manager_chat_id\n"; + echo "["._QXZ("END ALL CHATS")."]"; echo ""; echo "\n"; - echo "\tAgent\n"; - echo "\tTranscript\n"; - echo "\tMessage\n"; + echo "\t"._QXZ("Agent")."\n"; + echo "\t"._QXZ("Transcript")."\n"; + echo "\t"._QXZ("Message")."\n"; echo ""; $stmt="select vm.message_posted_by, vm.message, vm.message_date, vu.full_name, vm.manager, vm.manager_chat_subid, vm.user from vicidial_manager_chats vmc, vicidial_manager_chat_log vm, vicidial_users vu where vmc.manager_chat_id='$manager_chat_id' and vmc.manager_chat_id=vm.manager_chat_id and vm.user=vu.user order by vm.manager_chat_subid asc, message_date desc"; $rslt=mysqli_query($link, $stmt); - if (mysqli_num_rows($rslt)>0) { + if (mysqli_num_rows($rslt)>0) + { $prev_chat_subid=""; $backlog_limit=20; $chat_output_header=array(); $chat_output_text=array(); $chat_output_footer=array(); $chat_subids_array="["; - while($row=mysqli_fetch_row($rslt)) { + while($row=mysqli_fetch_row($rslt)) + { $full_name=$row[3]; $chat_subid=$row[5]; $chat_subids_array.="'$chat_subid',"; - if ($backlog_limit>0) { + if ($backlog_limit>0) + { if ($row[0]==$row[4]) {$fc="#990000";} else {$fc="#000099";} $chat_output_text[$chat_subid]="$row[1]
    ".$chat_output_text[$chat_subid]; $backlog_limit--; - } - if ($prev_chat_subid!=$chat_subid) { + } + if ($prev_chat_subid!=$chat_subid) + { $agent_id=$row[6]; if ($bgcolor=="#E6E6E6") {$bgcolor="#FFFFFF";} else {$bgcolor="#E6E6E6";} $chat_output_header[$chat_subid]= "\n"; @@ -449,30 +778,33 @@ $NWE = "')\">\"HELP\""; - $chat_output_footer[$chat_subid].="\t

    "; + $chat_output_footer[$chat_subid].="\t

    "; $chat_output_footer[$chat_subid].=""; $backlog_limit=20; $prev_chat_subid=$chat_subid; + } } - } $chat_subids_array=preg_replace("/,$/", "", $chat_subids_array); $chat_subids_array.="]"; - while (list($chat_subid, $text) = each($chat_output_header)) { + while (list($chat_subid, $text) = each($chat_output_header)) + { echo $chat_output_header[$chat_subid]; echo $chat_output_text[$chat_subid]; echo $chat_output_footer[$chat_subid]; - } + } # $reload_function="setInterval(\"CheckNewMessages($manager_chat_id, $chat_subids_array)\", 3000);\n"; $reload_function="setInterval(\"CheckNewMessages($manager_chat_id)\", 2000);\n"; - } else { + } + else + { $reload_function="setInterval(\"RefreshChatDisplay()\", 30000);\n"; - } + } echo ""; echo "\n"; - } + } echo ""; diff --git a/agc_2-X/trunk/www/vicidial/new_manager_chat_form.php b/agc_2-X/trunk/www/vicidial/new_manager_chat_form.php index 07116736..7f3a403d 100644 --- a/agc_2-X/trunk/www/vicidial/new_manager_chat_form.php +++ b/agc_2-X/trunk/www/vicidial/new_manager_chat_form.php @@ -1,19 +1,34 @@ LICENSE: AGPLv2 +# +# This page is for managers (level 8 or higher) to chat with live agents +# +# changes: +# 150608-2041 - First Build +# 151219-0718 - Added translation code where missing +# + require("dbconnect_mysqli.php"); require("functions.php"); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,allow_chats FROM system_settings;"; +$stmt = "SELECT use_non_latin,allow_chats,enable_languages,language_method,default_language FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); 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]; - $SSallow_chats = $row[1]; + $non_latin = $row[0]; + $SSallow_chats = $row[1]; + $SSenable_languages = $row[2]; + $SSlanguage_method = $row[3]; + $SSdefault_language = $row[4]; } +$VUselected_language = $SSdefault_language; ##### END SETTINGS LOOKUP ##### ########################################### @@ -51,6 +66,24 @@ if ($auth < 1) exit; } +$user_stmt="select full_name,user_level,selected_language from vicidial_users where user='$PHP_AUTH_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 ($SSallow_chats < 1) + { + header ("Content-type: text/html; charset=utf-8"); + echo _QXZ("Error, chat disabled on this system"); + exit; + } + + $stmt="select vla.user, vu.full_name, vu.user_group, vla.campaign_id, vc.campaign_name, vug.group_name from vicidial_users vu, vicidial_live_agents vla, vicidial_campaigns vc, vicidial_user_groups vug where vla.user=vu.user and vla.campaign_id=vc.campaign_id and vu.user_group=vug.user_group"; $rslt=mysql_to_mysqli($stmt, $link); $user_array=array(); @@ -121,8 +154,8 @@ echo "