function wplc_draw_chat_area($cid)
{
    global $wpdb;
    global $wplc_tblname_chats;
    $results = $wpdb->get_results("\n        SELECT *\n        FROM {$wplc_tblname_chats}\n        WHERE `id` = '{$cid}'\n        LIMIT 1\n        ");
    ?>
    <style>

        .wplc-clear-float-message{
            clear: both;
        }


    </style>
    <?php 
    foreach ($results as $result) {
        $user_data = maybe_unserialize($result->ip);
        $user_ip = $user_data['ip'];
        $browser = wplc_return_browser_string($user_data['user_agent']);
        $browser_image = wplc_return_browser_image($browser, "16");
        global $wplc_basic_plugin_url;
        if ($result->status == 1) {
            $status = __("Previous", "wplivechat");
        } else {
            $status = __("Active", "wplivechat");
        }
        if ($user_ip == "") {
            $user_ip = __('IP Address not recorded', 'wplivechat');
        } else {
            $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "'>" . $user_ip . "</a>";
        }
        echo "<h2>{$status} " . __('Chat with', 'wplivechat') . " " . $result->name . "</h2>";
        echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
        echo "<div class=\"end_chat_div\"><a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">" . __("End chat", "wplivechat") . "</a></div>";
        echo "<div id='admin_chat_box'>";
        echo "<div class='admin_chat_box'><div class='admin_chat_box_inner' id='admin_chat_box_area_" . $result->id . "'>" . wplc_return_chat_messages($cid) . "</div><div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid) . "</div></div>";
        echo "<div class='admin_visitor_info'>";
        do_action("wplc_hook_admin_visitor_info_display_before", $cid);
        echo "  <div style='float:left; width:100px;'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "\" class=\"admin_chat_img\" /></div>";
        echo "  <div style='float:left;'>";
        echo "      <div class='admin_visitor_info_box1'>";
        echo "          <span class='admin_chat_name'>" . $result->name . "</span>";
        echo "          <span class='admin_chat_email'>" . $result->email . "</span>";
        echo "      </div>";
        echo "  </div>";
        echo "  <div class='admin_visitor_advanced_info'>";
        echo "      <strong>" . __("Site Info", "wplivechat") . "</strong>";
        echo "      <hr />";
        echo "      <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . $result->url . "</span>";
        echo "  </div>";
        echo "  <div class='admin_visitor_advanced_info'>";
        echo "      <strong>" . __("Advanced Info", "wplivechat") . "</strong>";
        echo "      <hr />";
        echo "      <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> {$browser} <img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /><br />";
        echo "      <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> " . $user_ip;
        echo "  </div>";
        echo "  <div id=\"wplc_sound_update\"></div>";
        do_action("wplc_hook_admin_visitor_info_display_after", $cid);
        echo "</div>";
        if ($result->status != 1) {
            echo "<div class='admin_chat_quick_controls'>";
            echo "  <p style=\"text-align:left; font-size:11px;\">" . __('Press ENTER to send your message', 'wplivechat') . "</p>";
            echo "  " . __("Assign Quick Response", "wplivechat") . " <select name='wplc_macros_select' class='wplc_macros_select' disabled><option>" . __('Select', 'wplivechat') . "</option></select> <a href='http://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=quick_resposnes' title='" . __('Add Quick Responses to your Live Chat', 'wplivechat') . "' target='_BLANK'>" . __("Pro version only", "wplivechat") . "</a>";
            echo "  </div>";
            echo "</div>";
            //echo wplc_return_admin_chat_javascript($_GET['cid']);
        }
    }
}
function wplc_list_chats_pro($agent_id)
{
    global $wpdb;
    global $wplc_tblname_chats;
    $wplc_c = 0;
    $results = $wpdb->get_results("\n\tSELECT *\n\tFROM {$wplc_tblname_chats}\n        WHERE `status` = 3 OR `status` = 2 OR `status` = 10\n        ORDER BY `timestamp` ASC\n\n\t");
    //    $results = $wpdb->get_results(
    //        "
    //	SELECT *
    //	FROM $wplc_tblname_chats
    //        WHERE `status` = 7
    //        ORDER BY `timestamp` ASC
    //
    //	"
    //    );
    $table = "<div class='wplc_chats_container'>";
    if (!$results) {
        $table .= "<p>" . __("No chat sessions available at the moment", "wplivechat") . "</p>";
    } else {
        $table .= "<h2>" . __('Active Chats', 'wplivechat') . "</h2>";
        foreach ($results as $result) {
            // youre working here
            unset($trstyle);
            unset($actions);
            unset($icon);
            global $wplc_basic_plugin_url;
            $user_data = maybe_unserialize($result->ip);
            $user_ip = $user_data['ip'];
            if (function_exists("wplc_return_browser_string")) {
                $browser = wplc_return_browser_string($user_data['user_agent']);
            } else {
                $browser = "";
                $user_ip = "<em>Please <a href='./update-core.php'>udpate your pro version</a></em>";
            }
            if (function_exists("wplc_return_browser_image")) {
                $browser_image = wplc_return_browser_image($browser, "16");
            } else {
                $browser_image = "";
            }
            $wplc_c++;
            $aid = "";
            if (is_numeric($agent_id)) {
                $aid = "&aid=" . $agent_id;
            }
            if ($user_ip == "") {
                $user_ip = __('IP Address not recorded', 'wplivechat');
            } else {
                $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "'>" . $user_ip . "</a>";
            }
            if ($result->status == 2) {
                if (is_numeric($agent_id) or $agent_id === true) {
                    $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id . $aid);
                    $actions = "<p><a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Accept Chat", "wplivechat") . "</a></p>";
                    $trstyle = "style='background-color:#FFFBE4; height:30px;'";
                    $icon = "<i class=\"fa fa-phone wplc_pending\" title='" . __('Incoming Chat', 'wplivechat') . "' alt='" . __('Incoming Chat', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('You have an incoming chat.', 'wplivechat') . "</div>";
                } else {
                    $actions = "<p></p>";
                    $trstyle = "style='background-color:#FFFBE4; height:30px;'";
                    $icon = "<i class=\"fa fa-times-circle wplc_closed\" title='" . __('You must be a chat agent to answer chats', 'wplivechat') . "' alt='" . __('You must be a chat agent to answer chats', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('You must be a chat agent to answer chats', 'wplivechat') . "</div>";
                }
            }
            if ($result->status == 3) {
                if (is_numeric($agent_id) or $agent_id === true) {
                    $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id . $aid);
                    $actions = "<p><a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Open Chat Window", "wplivechat") . "</a></p>";
                    $trstyle = "style='background-color:#F7FCFE; height:30px;'";
                    $icon = "<i class=\"fa fa-check-circle wplc_active\" title='" . __('Chat Active', 'wplivechat') . "' alt='" . __('Chat Active', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('This chat is active', 'wplivechat') . "</div>";
                    if (isset($result->agent_id) && is_numeric($agent_id) && $result->agent_id != $agent_id && $result->agent_id != 0) {
                        $actions = "<p>" . __("Chat has been answered by another agent", "wplivechat") . "</p>";
                        $icon = "<i class=\"fa fa-times-circle wplc_closed\" title='" . __('Chat answered by another agent', 'wplivechat') . "' alt='" . __('Chat answered by another agent', 'wplivechat') . "'></i>";
                    }
                } else {
                    //                    $actions = "<a class=\"wplc_open_chat\" window-title=\"WP_Live_Chat_".$result->id."\">".__("Chat has been Accepted By Chat Agent ", "wplivechat")."</a>";
                    $actions = "";
                    $agent_details = "There is a chat agent (Another guy)";
                    $trstyle = "style='background-color:#F7FCFE; height:30px;'";
                }
            }
            $trstyle = "";
            $table .= "\n                <div class='wplc_single_chat' id='record_'" . $result->id . " {$trstyle}> \n                    <div class='wplc_chat_section section_1'>\n                        <div class='wplc_user_image' id='chat_image_" . $result->id . "'>\n                            <img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=60&d=mm\" />\n                        </div>\n                        <div class='wplc_user_meta_data'>\n                            <div class='wplc_user_name' id='chat_name_" . $result->id . "'>\n                                <h3>" . $result->name . $icon . "</h3>\n                                <a href='mailto:" . $result->email . "' target='_BLANK'>" . $result->email . "</a>\n                            </div>                                \n                        </div>    \n                    </div>\n                    <div class='wplc_chat_section section_2'>\n                        <div class='admin_visitor_advanced_info'>\n                            <strong>" . __("Site Info", "wplivechat") . "</strong>\n                            <hr />\n                            <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'> <a href='" . $result->url . "' target='_BLANK'>" . $result->url . "</a></span>\n                        </div>\n\n                        <div class='admin_visitor_advanced_info'>\n                            <strong>" . __("Advanced Info", "wplivechat") . "</strong>\n                            <hr />\n                            <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> {$browser} <img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /><br />\n                            <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> " . $user_ip . " \n                        </div>\n                    </div>\n                    <div class='wplc_chat_section section_3'>\n                        <div class='wplc_agent_actions'>\n                            {$actions}\n                        </div>\n                    </div>\n                </div>\n                    ";
        }
    }
    $table .= "</div>";
    return $table;
}
function wplc_list_chats_new()
{
    global $wpdb;
    global $wplc_tblname_chats;
    $status = 3;
    $wplc_c = 0;
    $results = $wpdb->get_results("SELECT * FROM {$wplc_tblname_chats} WHERE `status` = 3 OR `status` = 2 OR `status` = 10 OR `status` = 5 or `status` = 8 or `status` = 9 ORDER BY `timestamp` ASC");
    $data_array = array();
    $id_list = array();
    if (!$results) {
        $data_array = false;
    } else {
        foreach ($results as $result) {
            unset($trstyle);
            unset($actions);
            global $wplc_basic_plugin_url;
            $user_data = maybe_unserialize($result->ip);
            $user_ip = $user_data['ip'];
            $browser = wplc_return_browser_string($user_data['user_agent']);
            $browser_image = wplc_return_browser_image($browser, "16");
            if ($user_ip == "") {
                $user_ip = __('IP Address not recorded', 'wplivechat');
            } else {
                $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "'>" . $user_ip . "</a>";
            }
            if (intval($result->status) == 2) {
                $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id);
                $actions = "<a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Accept Chat", "wplivechat") . "</a>";
                $trstyle = "style='background-color:#FFFBE4; height:30px;'";
                $icon = "<i class=\"fa fa-phone wplc_pending\" title='" . __('Incoming Chat', 'wplivechat') . "' alt='" . __('Incoming Chat', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('You have an incoming chat.', 'wplivechat') . "</div>";
                $wplc_c++;
            } else {
                if (intval($result->status) == 3) {
                    $wplc_c++;
                    $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id);
                    $actions = "<a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Open Chat", "wplivechat") . "</a>";
                    $trstyle = "style='background-color:#F7FCFE; height:30px;'";
                    $icon = "<i class=\"fa fa-check-circle wplc_active\" title='" . __('Chat Active', 'wplivechat') . "' alt='" . __('Chat Active', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('This chat is active', 'wplivechat') . "</div>";
                } else {
                    if (intval($result->status) == 5) {
                        $actions = "<a href=\"javascript:void(0);\" id=\"wplc_initiate_chat\" class=\"wplc_initiate_chat button button-secondary\">" . __("Initiate Chat", "wplivechat") . "</a>";
                    } else {
                        $actions = "";
                    }
                }
            }
            if ($wplc_c > 1) {
                $actions = wplc_get_msg();
            }
            $trstyle = "";
            $id_list[intval($result->id)] = true;
            $data_array[$result->id]['name'] = $result->name;
            $data_array[$result->id]['email'] = $result->email;
            $data_array[$result->id]['status'] = $result->status;
            $data_array[$result->id]['action'] = $actions;
            $data_array[$result->id]['timestamp'] = wplc_time_ago($result->timestamp);
            if (current_time('timestamp') - strtotime($result->timestamp) < 3600) {
                $data_array[$result->id]['type'] = __("New", "wplivechat");
            } else {
                $data_array[$result->id]['type'] = __("Returning", "wplivechat");
            }
            $data_array[$result->id]['image'] = "<img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=20&d=mm\" />";
            $data_array[$result->id]['data']['browsing'] = $result->url;
            $path = parse_url($result->url, PHP_URL_PATH);
            if (strlen($path) > 20) {
                $data_array[$result->id]['data']['browsing_nice_url'] = substr($path, 0, 20) . '...';
            } else {
                $data_array[$result->id]['data']['browsing_nice_url'] = $path;
            }
            $data_array[$result->id]['data']['browser'] = "<img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /> ";
            $data_array[$result->id]['data']['ip'] = $user_ip;
        }
        $data_array['ids'] = $id_list;
    }
    return json_encode($data_array);
}
function wplc_api_return_sessions()
{
    global $wpdb;
    global $wplc_tblname_chats;
    $results = $wpdb->get_results("SELECT * FROM {$wplc_tblname_chats} WHERE `status` = 3 OR `status` = 2 OR `status` = 10 OR `status` = 5 or `status` = 8 or `status` = 9 ORDER BY `timestamp` ASC");
    $session_array = array();
    if ($results) {
        foreach ($results as $result) {
            global $wplc_basic_plugin_url;
            $ip_info = maybe_unserialize($result->ip);
            $user_ip = $ip_info['ip'];
            if ($user_ip == "") {
                $user_ip = __('IP Address not recorded', 'wplivechat');
            }
            $browser = wplc_return_browser_string($user_data['user_agent']);
            $browser_image = wplc_return_browser_image($browser, "16");
            $session_array[$result->id] = array();
            $session_array[$result->id]['name'] = $result->name;
            $session_array[$result->id]['email'] = $result->email;
            $session_array[$result->id]['status'] = $result->status;
            $session_array[$result->id]['timestamp'] = wplc_time_ago($result->timestamp);
            if (current_time('timestamp') - strtotime($result->timestamp) < 3600) {
                $session_array[$result->id]['type'] = __("New", "wplivechat");
            } else {
                $session_array[$result->id]['type'] = __("Returning", "wplivechat");
            }
            $session_array[$result->id]['image'] = "//www.gravatar.com/avatar/" . md5($result->email) . "?s=30";
            $session_array[$result->id]['data']['browsing'] = $result->url;
            $path = parse_url($result->url, PHP_URL_PATH);
            if (strlen($path) > 20) {
                $session_array[$result->id]['data']['browsing_nice_url'] = substr($path, 0, 20) . '...';
            } else {
                $session_array[$result->id]['data']['browsing_nice_url'] = $path;
            }
            $session_array[$result->id]['data']['browser'] = $wplc_basic_plugin_url . "/images/{$browser_image}";
            $session_array[$result->id]['data']['ip'] = $user_ip;
        }
    }
    return $session_array;
}
function wplc_pro_draw_chat_area($cid)
{
    global $wpdb;
    global $wplc_tblname_chats;
    $results = $wpdb->get_results("\n        SELECT *\n        FROM {$wplc_tblname_chats}\n        WHERE `id` = '{$cid}'\n        LIMIT 1\n        ");
    foreach ($results as $result) {
        $status = "";
        if ($result->status == 1 || $result->status == 8) {
            $status = "Previous";
        } else {
            if ($result->status == 3) {
                $status = "Active";
            } else {
                if ($result->status == 6) {
                    $status = "Awaiting";
                }
            }
        }
        ?>
        <style>

            .wplc-clear-float-message{
                clear: both;
            }

        </style>
        <?php 
        $user_data = maybe_unserialize($result->ip);
        if (is_array($user_data)) {
            $user_ip = $user_data['ip'];
            $browser = wplc_return_browser_string($user_data['user_agent']);
            $browser_image = wplc_return_browser_image($browser, "16");
        } else {
            $user_ip = $user_data;
            $browser = __("Unknown", "wplivechat");
            $browser_image = wplc_return_browser_image($browser, "16");
        }
        if ($user_ip == "") {
            $user_ip = __('IP Address not recorded', 'wplivechat');
        } else {
            $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "'>" . $user_ip . "</a>";
        }
        global $wplc_basic_plugin_url;
        echo "<h2>{$status} Chat with " . $result->name . "</h2>";
        echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
        echo "<div class=\"end_chat_div\"><a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">" . __("End chat", "wplivechat") . "</a></div>";
        echo "<div id='admin_chat_box'>";
        if ($result->status == 6) {
            echo "<strong>" . __("Attempting to open the chat window... Please be patient.", "wplivechat") . "</strong>";
            return;
        }
        if ($result->status != 6) {
            echo "<div class='admin_chat_box'>";
            echo "  <div class='admin_chat_box_inner' id='admin_chat_box_area_" . $result->id . "'>" . wplc_return_chat_messages($cid) . "</div>";
            if ($result->status == 3) {
                echo "  <div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid) . "</div>";
            }
            echo "</div>";
            echo "<div class='admin_visitor_info'>";
            echo "  <div style='float:left; width:100px;'><img src=\"http://www.gravatar.com/avatar/" . md5($result->email) . "\" class=\"admin_chat_img\" /></div>";
            echo "  <div style='float:left;'>";
            echo "      <div class='admin_visitor_info_box1'>";
            echo "          <span class='admin_chat_name'>" . $result->name . "</span>";
            echo "          <span class='admin_chat_email'>" . $result->email . "</span>";
            echo "      </div>";
            echo "  </div>";
            echo "<div class='admin_visitor_advanced_info'>";
            echo "      <strong>" . __("Site Info", "wplivechat") . "</strong>";
            echo "      <hr />";
            echo "      <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . $result->url . "</span>";
            echo "</div>";
            echo "<div class='admin_visitor_advanced_info'>";
            echo "      <strong>" . __("Advanced Info", "wplivechat") . "</strong>";
            echo "      <hr />";
            echo "      <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> {$browser} <img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /><br />";
            echo "      <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> " . $user_ip;
            echo "</div>";
            echo "  <div id=\"wplc_sound_update\"></div>";
            echo "</div>";
        }
        if ($result->status == 3) {
            echo "<div class='admin_chat_quick_controls'>";
            echo "  <p style=\"text-align:left; font-size:11px;\">Press ENTER to send your message</p>";
            echo wplc_return_macros();
            echo "  </div>";
            echo "</div>";
        }
        echo "</div>";
    }
}
function wplc_draw_chat_area($cid)
{
    global $wpdb;
    global $wplc_tblname_chats;
    $results = $wpdb->get_results("\r\n        SELECT *\r\n        FROM {$wplc_tblname_chats}\r\n        WHERE `id` = '{$cid}'\r\n        LIMIT 1\r\n        ");
    if ($results) {
    } else {
        $results[0] = null;
    }
    /* if chat ID doesnt exist, create the variable anyway to avoid an error. Hopefully the Chat ID exists on the server..! */
    $result = apply_filters("wplc_filter_chat_area_data", $results[0], $cid);
    ?>
    <style>

        .wplc-clear-float-message{
            clear: both;
        }


    </style>
    <?php 
    $user_data = maybe_unserialize($result->ip);
    $user_ip = $user_data['ip'];
    $browser = wplc_return_browser_string($user_data['user_agent']);
    $browser_image = wplc_return_browser_image($browser, "16");
    global $wplc_basic_plugin_url;
    if ($result->status == 1) {
        $status = __("Previous", "wplivechat");
    } else {
        $status = __("Active", "wplivechat");
    }
    if ($user_ip == "") {
        $user_ip = __('IP Address not recorded', 'wplivechat');
    } else {
        $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "' target='_BLANK'>" . $user_ip . "</a>";
    }
    echo "<h2>{$status} " . __('Chat with', 'wplivechat') . " " . $result->name . "</h2>";
    echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
    echo "<div class=\"end_chat_div\"><a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">" . __("End chat", "wplivechat") . "</a></div>";
    echo "<div id='admin_chat_box'>";
    $result->continue = true;
    do_action("wplc_hook_wplc_draw_chat_area", $result);
    if (!$result->continue) {
        return;
    }
    echo "<div class='admin_chat_box'><div class='admin_chat_box_inner' id='admin_chat_box_area_" . $result->id . "'>" . wplc_return_chat_messages($cid) . "</div><div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid) . "</div></div>";
    echo "<div class='admin_visitor_info'>";
    do_action("wplc_hook_admin_visitor_info_display_before", $cid);
    echo "  <div style='float:left; width:100px;'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "\" class=\"admin_chat_img\" /></div>";
    echo "  <div style='float:left;'>";
    echo "      <div class='admin_visitor_info_box1'>";
    echo "          <span class='admin_chat_name'>" . $result->name . "</span>";
    echo "          <span class='admin_chat_email'>" . $result->email . "</span>";
    echo "      </div>";
    echo "  </div>";
    echo "  <div class='admin_visitor_advanced_info'>";
    echo "      <strong>" . __("Site Info", "wplivechat") . "</strong>";
    echo "      <hr />";
    echo "      <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . $result->url . "</span>";
    echo "  </div>";
    echo "  <div class='admin_visitor_advanced_info'>";
    echo "      <strong>" . __("Advanced Info", "wplivechat") . "</strong>";
    echo "      <hr />";
    echo "      <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> {$browser} <img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /><br />";
    echo "      <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> " . $user_ip;
    echo "  </div>";
    echo "  <div id=\"wplc_sound_update\"></div>";
    echo "<hr />";
    echo "<h3>" . __("Add-ons", "wplivechat") . "</h3>";
    do_action("wplc_hook_admin_visitor_info_display_after", $cid);
    echo "<a href='" . admin_url('admin.php?page=wplivechat-menu-extensions-page') . "' class='button button-primary' target='_BLANK'>" . __("Get more add-ons", "wplivechat") . "</a>";
    echo "</div>";
    if ($result->status != 1) {
        do_action("wplc_hook_admin_below_chat_box", $result);
        //echo wplc_return_admin_chat_javascript($_GET['cid']);
    }
}
function wplc_list_chats_new($post_data)
{
    global $wpdb;
    global $wplc_tblname_chats;
    $status = 3;
    $wplc_c = 0;
    $results = $wpdb->get_results("SELECT * FROM {$wplc_tblname_chats} WHERE `status` = 3 OR `status` = 2 OR `status` = 10 OR `status` = 5 or `status` = 8 or `status` = 9 ORDER BY `timestamp` ASC");
    $data_array = array();
    $id_list = array();
    if (!$results) {
        $data_array = false;
    } else {
        foreach ($results as $result) {
            unset($trstyle);
            unset($actions);
            global $wplc_basic_plugin_url;
            $user_data = maybe_unserialize($result->ip);
            $user_ip = $user_data['ip'];
            $browser = wplc_return_browser_string($user_data['user_agent']);
            $browser_image = wplc_return_browser_image($browser, "16");
            if ($user_ip == "") {
                $user_ip = __('IP Address not recorded', 'wplivechat');
            } else {
                $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "' target='_BLANK'>" . $user_ip . "</a>";
            }
            $actions = apply_filters("wplc_filter_list_chats_actions", "", $result, $post_data);
            $other_data = maybe_unserialize($result->other);
            $trstyle = "";
            $id_list[intval($result->id)] = true;
            $data_array[$result->id]['name'] = $result->name;
            $data_array[$result->id]['email'] = $result->email;
            $data_array[$result->id]['status'] = $result->status;
            $data_array[$result->id]['action'] = $actions;
            $data_array[$result->id]['timestamp'] = wplc_time_ago($result->timestamp);
            if (current_time('timestamp') - strtotime($result->timestamp) < 3600) {
                $data_array[$result->id]['type'] = __("New", "wplivechat");
            } else {
                $data_array[$result->id]['type'] = __("Returning", "wplivechat");
            }
            $data_array[$result->id]['image'] = "<img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=30&d=mm\"  class='wplc-user-message-avatar' />";
            $data_array[$result->id]['data']['browsing'] = $result->url;
            $path = parse_url($result->url, PHP_URL_PATH);
            if (strlen($path) > 20) {
                $data_array[$result->id]['data']['browsing_nice_url'] = substr($path, 0, 20) . '...';
            } else {
                $data_array[$result->id]['data']['browsing_nice_url'] = $path;
            }
            $data_array[$result->id]['data']['browser'] = "<img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /> ";
            $data_array[$result->id]['data']['ip'] = $user_ip;
            $data_array[$result->id]['other'] = $other_data;
        }
        $data_array['ids'] = $id_list;
    }
    return json_encode($data_array);
}
Exemple #8
0
function wplc_list_chats()
{
    global $wpdb;
    global $wplc_tblname_chats;
    $status = 3;
    $wplc_c = 0;
    $results = $wpdb->get_results("\n\tSELECT *\n\tFROM {$wplc_tblname_chats}\n        WHERE `status` = 3 OR `status` = 2\n        ORDER BY `timestamp` ASC\n\n\t");
    $table = "<div class='wplc_chats_container'>";
    if (!$results) {
        $table .= "<p>" . __("No chat sessions available at the moment", "wplivechat") . "</p>";
    } else {
        $table .= "<h2>" . __('Active Chats', 'wplivechat') . "</h2>";
        foreach ($results as $result) {
            unset($trstyle);
            unset($actions);
            $wplc_c++;
            global $wplc_basic_plugin_url;
            $user_data = maybe_unserialize($result->ip);
            $user_ip = $user_data['ip'];
            $browser = wplc_return_browser_string($user_data['user_agent']);
            $browser_image = wplc_return_browser_image($browser, "16");
            if ($user_ip == "") {
                $user_ip = __('IP Address not recorded', 'wplivechat');
            } else {
                $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='" . __('Whois for', 'wplivechat') . " " . $user_ip . "'>" . $user_ip . "</a>";
            }
            if ($result->status == 2) {
                $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id);
                $actions = "<a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Accept Chat", "wplivechat") . "</a>";
                $trstyle = "style='background-color:#FFFBE4; height:30px;'";
                $icon = "<i class=\"fa fa-phone wplc_pending\" title='" . __('Incoming Chat', 'wplivechat') . "' alt='" . __('Incoming Chat', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('You have an incoming chat.', 'wplivechat') . "</div>";
            }
            if ($result->status == 3) {
                $url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $result->id);
                $actions = "<a href=\"" . $url . "\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_" . $result->id . "\">" . __("Open Chat Window", "wplivechat") . "</a>";
                $trstyle = "style='background-color:#F7FCFE; height:30px;'";
                $icon = "<i class=\"fa fa-check-circle wplc_active\" title='" . __('Chat Active', 'wplivechat') . "' alt='" . __('Chat Active', 'wplivechat') . "'></i><div class='wplc_icon_message'>" . __('This chat is active', 'wplivechat') . "</div>";
            }
            if ($wplc_c > 1) {
                $actions = wplc_get_msg();
            }
            $trstyle = "";
            $table .= "\n                <div class='wplc_single_chat' id='record_'" . $result->id . " {$trstyle}> \n                    <div class='wplc_chat_section'>\n                        <div class='wplc_user_image' id='chat_image_" . $result->id . "'>\n                            <img src=\"http://www.gravatar.com/avatar/" . md5($result->email) . "?s=100&d=mm\" />\n                        </div>\n                        <div class='wplc_user_meta_data'>\n                            <div class='wplc_user_name' id='chat_name_" . $result->id . "'>\n                                <h3>" . $result->name . $icon . "</h3>\n                                " . $result->email . "\n                            </div>                                \n                        </div>    \n                    </div>\n                    <div class='wplc_chat_section'>\n                        <div class='admin_visitor_advanced_info'>\n                            <strong>" . __("Site Info", "wplivechat") . "</strong>\n                            <hr />\n                            <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . $result->url . "</span>\n                        </div>\n\n                        <div class='admin_visitor_advanced_info'>\n                            <strong>" . __("Advanced Info", "wplivechat") . "</strong>\n                            <hr />\n                            <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> {$browser} <img src='" . $wplc_basic_plugin_url . "/images/{$browser_image}' alt='{$browser}' title='{$browser}' /><br />\n                            <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> " . $user_ip . "\n                        </div>\n                    </div>\n                    <div class='wplc_chat_section'>\n                        <div class='wplc_agent_actions'>\n                            {$actions}\n                        </div>\n                    </div>\n                </div>\n                    ";
        }
    }
    $table .= "</div>";
    return $table;
}