function wplc_return_admin_chat_javascript($cid) { $ajax_nonce = wp_create_nonce("wplc"); if (function_exists("wplc_pro_get_admin_picture")) { $src = wplc_pro_get_admin_picture(); if ($src) { $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>"; } } $wplc_settings = get_option("WPLC_SETTINGS"); if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) { $display_name = 'display'; } else { $display_name = 'hide'; } if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) { $enable_ding = '1'; } else { $enable_ding = '0'; } if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") { $wplc_user_email_address = sanitize_text_field($_COOKIE['wplc_email']); } else { $wplc_user_email_address = ""; } ?> <script type="text/javascript"> /* var wplc_ajaxurl = '<?php echo plugins_url('/ajax.php', __FILE__); ?> '; */ var wplc_ajaxurl = ajaxurl; var chat_status = 3; var cid = <?php echo $cid; ?> ; var data = { action: 'wplc_admin_long_poll_chat', security: '<?php echo $ajax_nonce; ?> ', cid: cid, chat_status: chat_status }; var wplc_run = true; var wplc_display_name = '<?php echo $display_name; ?> '; var wplc_enable_ding = '<?php echo $enable_ding; ?> '; var wplc_user_email_address = '<?php echo $wplc_user_email_address; ?> '; function wplc_call_to_server_admin_chat(data) { jQuery.ajax({ url: wplc_ajaxurl, data: data, security: '<?php echo $ajax_nonce; ?> ', type: "POST", success: function (response) { if (response) { response = JSON.parse(response); if (response['action'] === "wplc_update_chat_status") { data['chat_status'] = response['chat_status']; wplc_display_chat_status_update(response['chat_status'], cid); } if (response['action'] === "wplc_new_chat_message") { current_len = jQuery("#admin_chat_box_area_" + cid).html().length; jQuery("#admin_chat_box_area_" + cid).append(response['chat_message']); new_length = jQuery("#admin_chat_box_area_" + cid).html().length; if (current_len < new_length) { if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") { document.getElementById("wplc_sound_update").innerHTML = "<embed src='<?php echo plugins_url('/ding.mp3', __FILE__); ?> ' hidden=true autostart=true loop=false>"; } } var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } if (response['action'] === "wplc_user_open_chat") { data['action_2'] = ""; <?php $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid); ?> window.location.replace('<?php echo $url; ?> '); } } }, error: function (jqXHR, exception) { if (jqXHR.status == 404) { console.log('Requested page not found. [404]'); wplc_run = false; } else if (jqXHR.status == 500) { console.log('Internal Server Error [500].'); wplc_run = false; } else if (exception === 'parsererror') { console.log('Requested JSON parse failed.'); wplc_run = false; } else if (exception === 'abort') { console.log('Ajax request aborted.'); wplc_run = false; } else { console.log('Uncaught Error.\n' + jqXHR.responseText); wplc_run = false; } }, complete: function (response) { //console.log(wplc_run); if (wplc_run) { wplc_call_to_server_admin_chat(data); } }, timeout: 120000 }); } ; function wplc_display_chat_status_update(new_chat_status, cid) { if (new_chat_status === "0") { } else { if (chat_status !== new_chat_status) { previous_chat_status = chat_status; //console.log("previous chat status: "+previous_chat_status); chat_status = new_chat_status; //console.log("chat status: "+chat_status); if ((previous_chat_status === "2" && chat_status === "3") || (previous_chat_status === "5" && chat_status === "3")) { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has opened the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status == "10" && previous_chat_status == "3") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has minimized the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status === "3" && previous_chat_status === "10") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has maximized the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status === "1" || chat_status === "8") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has closed and ended the chat", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); document.getElementById('wplc_admin_chatmsg').disabled = true; } } } } jQuery(document).ready(function () { var wplc_image = "<?php if (isset($image)) { echo $image; } else { echo ""; } ?> "; /* var wplc_ajaxurl = '<?php echo plugins_url('/ajax.php', __FILE__); ?> '; */ var wplc_ajaxurl = ajaxurl; jQuery("#wplc_admin_chatmsg").focus(); wplc_call_to_server_admin_chat(data); if (jQuery('#wplc_admin_cid').length) { var wplc_cid = jQuery("#wplc_admin_cid").val(); var height = jQuery('#admin_chat_box_area_' + wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + wplc_cid).scrollTop(height); } jQuery(".wplc_admin_accept").on("click", function () { wplc_title_alerts3 = setTimeout(function () { document.title = "WP Live Chat Support"; }, 2500); var cid = jQuery(this).attr("cid"); var data = { action: 'wplc_admin_accept_chat', cid: cid, security: '<?php echo $ajax_nonce; ?> ' }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_accept_chat"); wplc_refresh_chat_boxes[cid] = setInterval(function () { wpcl_admin_update_chat_box(cid); }, 3000); jQuery("#admin_chat_box_" + cid).show(); }); }); jQuery("#wplc_admin_chatmsg").keyup(function (event) { if (event.keyCode == 13) { jQuery("#wplc_admin_send_msg").click(); } }); jQuery("#wplc_admin_close_chat").on("click", function () { var wplc_cid = jQuery("#wplc_admin_cid").val(); var data = { action: 'wplc_admin_close_chat', security: '<?php echo $ajax_nonce; ?> ', cid: wplc_cid }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_close_chat"); //console.log(response); window.close(); }); }); function wplc_strip(str) { str=str.replace(/<br>/gi, "\n"); str=str.replace(/<p.*>/gi, "\n"); str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) "); str=str.replace(/<(?:.|\s)*?>/g, ""); str=str.replace('iframe', ""); str=str.replace('src', ""); str=str.replace('href', ""); str=str.replace('<', ""); str=str.replace('>', ""); return str; } jQuery("#wplc_admin_send_msg").on("click", function () { var wplc_cid = jQuery("#wplc_admin_cid").val(); var wplc_chat = wplc_strip(document.getElementById('wplc_admin_chatmsg').value); var wplc_name = "a" + "d" + "m" + "i" + "n"; jQuery("#wplc_admin_chatmsg").val(''); if (wplc_display_name == 'display') { jQuery("#admin_chat_box_area_" + wplc_cid).append("<span class='wplc-admin-message'>" + wplc_image + " <strong>" + wplc_name + "</strong>:<hr/ style='margin-bottom: 0px;'>" + wplc_chat + "</span><br /><div class='wplc-clear-float-message'></div>"); } else { jQuery("#admin_chat_box_area_" + wplc_cid).append("<span class='wplc-admin-message'>" + wplc_chat + "</span><br /><div class='wplc-clear-float-message'></div>"); } var height = jQuery('#admin_chat_box_area_' + wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + wplc_cid).scrollTop(height); var data = { action: 'wplc_admin_send_msg', security: '<?php echo $ajax_nonce; ?> ', cid: wplc_cid, msg: wplc_chat }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_send_msg"); /* do nothing jQuery("#admin_chat_box_area_"+wplc_cid).html(response); var height = jQuery('#admin_chat_box_area_'+wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_'+wplc_cid).scrollTop(height); */ }); }); }); </script> <?php }
function wplc_return_admin_chat_messages($cid) { if (current_user_can("wplc_ma_agent") || current_user_can("manage_options")) { $wplc_settings = get_option("WPLC_SETTINGS"); if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) { $display_name = 1; } else { $display_name = 0; } global $wpdb; global $wplc_tblname_msgs; $results = $wpdb->get_results("\n SELECT *\n FROM {$wplc_tblname_msgs}\n WHERE `chat_sess_id` = '{$cid}' AND `status` = '0' AND `originates` = '2'\n ORDER BY `timestamp` ASC\n\n "); $msg_hist = ""; foreach ($results as $result) { $id = $result->id; $from = $result->from; wplc_mark_as_read_admin_chat_messages($id); $msg = $result->msg; //$timestamp = strtotime($result->timestamp); //$timeshow = date("H:i",$timestamp); $image = ""; if ($result->originates == 1) { $class = "wplc-admin-message"; if (function_exists("wplc_pro_get_admin_picture")) { $src = wplc_pro_get_admin_picture(); if ($src) { $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>"; } } } else { $class = "wplc-user-message"; if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") { $wplc_user_gravatar = md5(strtolower(trim($_COOKIE['wplc_email']))); } else { $wplc_user_gravatar = ""; } if ($wplc_user_gravatar != "") { $image = "<img src='//www.gravatar.com/avatar/{$wplc_user_gravatar}?s=20' />"; } else { $image = ""; } } if (function_exists('wplc_decrypt_msg')) { $msg = wplc_decrypt_msg($msg); } if ($display_name) { $msg_hist .= "<span class='wplc-user-message'>" . $image . "<strong>{$from}</strong>: {$msg}</span><br /><div class='wplc-clear-float-message'></div>"; } else { $msg_hist .= "<span class='wplc-user-message'>{$msg}</span><br /><div class='wplc-clear-float-message'></div>"; } } return $msg_hist; } else { return "security issue"; } }
function wplc_return_admin_chat_javascript($cid) { $ajax_nonce = wp_create_nonce("wplc"); global $wplc_version; wp_register_script('wplc-admin-chat-js', plugins_url('js/wplc_u_admin_chat.js', __FILE__), false, $wplc_version, false); wp_enqueue_script('wplc-admin-chat-js'); if (function_exists("wplc_pro_get_admin_picture")) { $src = wplc_pro_get_admin_picture(); if ($src) { $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>"; } else { $image = ""; } } else { $image = ""; } $admin_pic = $image; wp_localize_script('wplc-admin-chat-js', 'wplc_ajax_nonce', $ajax_nonce); wp_localize_script('wplc-admin-chat-js', 'admin_pic', $admin_pic); $wplc_ding_file = plugins_url('/ding.mp3', __FILE__); wp_localize_script('wplc-admin-chat-js', 'wplc_ding_file', $wplc_ding_file); $extra_data = apply_filters("wplc_filter_admin_javascript", array()); wp_localize_script('wplc-admin-chat-js', 'wplc_extra_data', $extra_data); $wplc_settings = get_option("WPLC_SETTINGS"); if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) { $display_name = 'display'; } else { $display_name = 'hide'; } if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) { $enable_ding = '1'; } else { $enable_ding = '0'; } if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") { $wplc_user_email_address = sanitize_text_field($_COOKIE['wplc_email']); } else { $wplc_user_email_address = ""; } wp_localize_script('wplc-admin-chat-js', 'wplc_name', $display_name); wp_localize_script('wplc-admin-chat-js', 'wplc_enable_ding', $enable_ding); wp_localize_script('wplc-admin-chat-js', 'wplc_user_email', $wplc_user_email_address); $ajax_url = admin_url('admin-ajax.php'); $wplc_ajax_url = apply_filters("wplc_filter_ajax_url", $ajax_url); wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url); $wplc_url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid); wp_localize_script('wplc-admin-chat-js', 'wplc_url', $wplc_url); $wplc_string1 = __("User has opened the chat window", "wplivechat"); $wplc_string2 = __("User has minimized the chat window", "wplivechat"); $wplc_string3 = __("User has maximized the chat window", "wplivechat"); $wplc_string4 = __("The chat has been ended", "wplivechat"); wp_localize_script('wplc-admin-chat-js', 'wplc_string1', $wplc_string1); wp_localize_script('wplc-admin-chat-js', 'wplc_string2', $wplc_string2); wp_localize_script('wplc-admin-chat-js', 'wplc_string3', $wplc_string3); wp_localize_script('wplc-admin-chat-js', 'wplc_string4', $wplc_string4); wp_localize_script('wplc-admin-chat-js', 'wplc_cid', $cid); do_action("wplc_hook_admin_chatbox_javascript"); }
function wplc_return_pro_admin_chat_javascript($cid) { $ajax_nonce = wp_create_nonce("wplc"); if (function_exists("wplc_pro_get_admin_picture")) { $src = wplc_pro_get_admin_picture(); if ($src) { $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>"; } else { $image = ""; } } $wplc_settings = get_option("WPLC_SETTINGS"); if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) { $display_name = 'display'; } else { $display_name = 'hide'; } ?> <script type="text/javascript"> var wplc_ajaxurl = '<?php echo plugins_url('/ajax-pro.php', __FILE__); ?> '; var chat_status = 3; var cid = <?php echo $cid; ?> ; var aid = <?php echo $_GET['aid']; ?> ; var data = { action: 'wplc_admin_long_poll_chat', security: '<?php echo $ajax_nonce; ?> ', cid: cid, chat_status: chat_status, aid: aid }; var wplc_run = true; var wplc_display_name = '<?php echo $display_name; ?> '; function wplc_call_to_server_admin_chat(data) { jQuery.ajax({ url: wplc_ajaxurl, data: data, type: "POST", success: function (response) { if (response) { // console.log(response); response = JSON.parse(response); if (response['action'] === "wplc_ma_agant_already_answered") { jQuery('#wplc_admin_chat').empty().append("<h2><?php _e("This chat has already been answered. Please close the chat window", "wplivechat"); ?> </h2>"); wplc_run = false; //console.log("Chat Already Answered"); //console.log(aid); } if (response['action'] === "wplc_update_chat_status") { data['chat_status'] = response['chat_status']; wplc_display_chat_status_update(response['chat_status'], cid); } if (response['action'] === "wplc_new_chat_message") { current_len = jQuery("#admin_chat_box_area_" + cid).html().length; jQuery("#admin_chat_box_area_" + cid).append(response['chat_message']); new_length = jQuery("#admin_chat_box_area_" + cid).html().length; if (current_len < new_length) { document.getElementById("wplc_sound_update").innerHTML = "<embed src='<?php echo plugins_url('/ding.mp3', __FILE__); ?> ' hidden=true autostart=true loop=false>"; } var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } if (response['action'] === "wplc_user_open_chat") { data['action_2'] = ""; <?php $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid . '&aid=' . $_GET['aid']); ?> window.location.replace('<?php echo $url; ?> '); } } }, error: function (jqXHR, exception) { if (jqXHR.status == 404) { console.log('Requested page not found. [404]'); wplc_run = false; } else if (jqXHR.status == 500) { console.log('Internal Server Error [500].'); wplc_run = false; } else if (exception === 'parsererror') { console.log('Requested JSON parse failed.'); wplc_run = false; } else if (exception === 'abort') { console.log('Ajax request aborted.'); wplc_run = false; } else { console.log('Uncaught Error.\n' + jqXHR.responseText); wplc_run = false; } }, complete: function (response) { //console.log(wplc_run); if (wplc_run) { setTimeout(function () { wplc_call_to_server_admin_chat(data); }, 1500); } }, timeout: 120000 }); } ; function wplc_display_chat_status_update(new_chat_status, cid) { if (new_chat_status === "0") { } else { if (chat_status !== new_chat_status) { previous_chat_status = chat_status; //console.log("previous chat status: "+previous_chat_status); chat_status = new_chat_status; //("chat status: "+chat_status); if ((previous_chat_status === "2" && chat_status === "3") || (previous_chat_status === "5" && chat_status === "3")) { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has opened the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status == "10" && previous_chat_status == "3") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has minimized the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status === "3" && previous_chat_status === "10") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has maximized the chat window", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); } else if (chat_status === "1" || chat_status === "8") { jQuery("#admin_chat_box_area_" + cid).append("<em><?php _e("User has closed and ended the chat", "wplivechat"); ?> </em><br />"); var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + cid).scrollTop(height); document.getElementById('wplc_admin_chatmsg').disabled = true; } } } } jQuery(document).ready(function () { var wplc_image = "<?php echo $image; ?> "; var wplc_ajaxurl = '<?php echo plugins_url('/ajax-pro.php', __FILE__); ?> '; jQuery("#wplc_admin_chatmsg").focus(); jQuery(".wplc_macros_select").change(function () { var wplc_id = this.value; if (parseInt(wplc_id) === 0) { return; } var data = { action: 'wplc_macro', dataType: "json", postid: wplc_id, security: '<?php echo $ajax_nonce; ?> ' }; jQuery.post(ajaxurl, data, function (response) { var post_content = jQuery.parseJSON(response); jQuery("#wplc_admin_chatmsg").val(jQuery("#wplc_admin_chatmsg").val() + post_content); }); }); // console.log(data); <?php if ($_GET['action'] == 'rc') { ?> //this is to initiate a chat with a user from admin side data['action_2'] = "wplc_long_poll_check_user_opened_chat"; wplc_call_to_server_admin_chat(data); <?php } else { ?> wplc_call_to_server_admin_chat(data); if (jQuery('#wplc_admin_cid').length) { var wplc_cid = jQuery("#wplc_admin_cid").val(); var height = jQuery('#admin_chat_box_area_' + wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + wplc_cid).scrollTop(height); } jQuery(".wplc_admin_accept").on("click", function () { wplc_title_alerts3 = setTimeout(function () { document.title = "WP Live Chat Support"; }, 2500); var cid = jQuery(this).attr("cid"); var data = { action: 'wplc_admin_accept_chat', cid: cid, security: '<?php echo $ajax_nonce; ?> ' }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_accept_chat"); wplc_refresh_chat_boxes[cid] = setInterval(function () { wpcl_admin_update_chat_box(cid); }, 3000); jQuery("#admin_chat_box_" + cid).show(); }); }); jQuery("#wplc_admin_chatmsg").keyup(function (event) { if (event.keyCode == 13) { jQuery("#wplc_admin_send_msg").click(); } }); jQuery("#wplc_admin_close_chat").on("click", function () { var wplc_cid = jQuery("#wplc_admin_cid").val(); var data = { action: 'wplc_admin_close_chat', security: '<?php echo $ajax_nonce; ?> ', cid: wplc_cid }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_close_chat"); // console.log(response); window.close(); }); }); function wplc_strip(str) { str = str.replace(/<br>/gi, "\n\r"); str = str.replace(/<br\/>/gi, "\n\r"); str = str.replace(/<br \/>/gi, "\n\r"); str = str.replace(/<p.*>/gi, "\n\r"); str = str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) "); str = str.replace(/<(?:.|\s)*?>/g, ""); return str; } jQuery("#wplc_admin_send_msg").on("click", function () { var wplc_cid = jQuery("#wplc_admin_cid").val(); var wplc_chat = wplc_strip(document.getElementById('wplc_admin_chatmsg').value); var wplc_name = "<?php echo wplc_return_from_name(get_current_user_id()); ?> "; jQuery("#wplc_admin_chatmsg").val(''); if (wplc_display_name == 'display') { jQuery("#admin_chat_box_area_" + wplc_cid).append("<span class='wplc-admin-message'>" + wplc_image + " <strong>" + wplc_name + "</strong>: " + wplc_chat + "</span><br /><div class='wplc-clear-float-message'></div>"); } else { jQuery("#admin_chat_box_area_" + wplc_cid).append("<span class='wplc-admin-message'>" + wplc_chat + "</span><div class='wplc-clear-float-message'></div>"); } var height = jQuery('#admin_chat_box_area_' + wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_' + wplc_cid).scrollTop(height); var data = { action: 'wplc_admin_send_msg', security: '<?php echo $ajax_nonce; ?> ', cid: wplc_cid, msg: wplc_chat, admin_name: wplc_name }; jQuery.post(wplc_ajaxurl, data, function (response) { //console.log("wplc_admin_send_msg"); /* do nothing jQuery("#admin_chat_box_area_"+wplc_cid).html(response); var height = jQuery('#admin_chat_box_area_'+wplc_cid)[0].scrollHeight; jQuery('#admin_chat_box_area_'+wplc_cid).scrollTop(height); */ }); }); <?php } ?> }); </script> <?php }
function wplc_return_admin_chat_messages($cid) { $wplc_current_user = get_current_user_id(); if (get_user_meta($wplc_current_user, 'wplc_ma_agent', true)) { /* -- modified in in 6.0.04 -- if(current_user_can('wplc_ma_agent') || current_user_can('manage_options')){ */ $wplc_settings = get_option("WPLC_SETTINGS"); if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) { $display_name = 1; } else { $display_name = 0; } global $wpdb; global $wplc_tblname_msgs; /** * `Originates` - codes: * 0 - System notification to be delivered to users * 1 - Message from an agent * 2 - Message from a user * 3 - System notification to be delivered to agents * */ $results = $wpdb->get_results("\n SELECT *\n FROM {$wplc_tblname_msgs}\n WHERE `chat_sess_id` = '{$cid}' AND `status` = '0' AND (`originates` = '2' OR `originates` = '3')\n ORDER BY `timestamp` ASC\n\n "); $msg_hist = ""; foreach ($results as $result) { $system_notification = false; $id = $result->id; $from = $result->msgfrom; wplc_mark_as_read_admin_chat_messages($id); $msg = $result->msg; //$timestamp = strtotime($result->timestamp); //$timeshow = date("H:i",$timestamp); $image = ""; if ($result->originates == 2) { $class = "wplc-admin-message wplc-color-bg-4 wplc-color-2 wplc-color-border-4"; if (function_exists("wplc_pro_get_admin_picture")) { $src = wplc_pro_get_admin_picture(); if ($src) { $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>"; } } else { /* HERE */ $image = "<img src='//www.gravatar.com/avatar/{$wplc_user_gravatar}?s=20' class='wplc-admin-message-avatar' />"; } $from = apply_filters("wplc_filter_admin_from", $from, $cid); } else { if (intval($result->originates) == 3) { $system_notification = true; } } if (!$system_notification) { if (function_exists('wplc_decrypt_msg')) { $msg = wplc_decrypt_msg($msg); } $msg = apply_filters("wplc_filter_message_control_out", $msg); $msg = stripslashes($msg); if ($display_name) { $msg_hist .= "<span class='wplc-user-message wplc-color-bg-1 wplc-color-2 wplc-color-border-1'>" . $image . "<strong>{$from}</strong>: {$msg}</span><br /><div class='wplc-clear-float-message'></div>"; } else { $msg_hist .= "<span class='wplc-user-message wplc-color-bg-1 wplc-color-2 wplc-color-border-1'>{$msg}</span><br /><div class='wplc-clear-float-message'></div>"; } } else { $msg_hist .= "<span class='wplc_system_notification wplc-color-2'>" . $msg . "</span>"; } } return $msg_hist; } else { return "security issue"; } }