Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
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;
}