コード例 #1
0
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";
    }
}
コード例 #2
0
function wplc_api_return_messages($cid, $limit, $offset)
{
    global $wpdb;
    global $wplc_tblname_msgs;
    $cid = intval($cid);
    $limit = intval($limit);
    $offset = intval($offset);
    $cdata = wplc_get_chat_data($cid);
    $wplc_settings = get_option("WPLC_SETTINGS");
    if ($limit > 50) {
        $limit = 50;
    }
    $results = $wpdb->get_results("\n        SELECT * \n        FROM {$wplc_tblname_msgs} \n        WHERE `chat_sess_id` = '{$cid}' \n        ORDER BY `timestamp` ASC \n        LIMIT {$limit} OFFSET {$offset} \n        ");
    $messages = array();
    //The message array
    if ($results) {
        foreach ($results as $result) {
            $messages[$result->id] = array();
            //Message object
            $messages[$result->id]['from'] = $result->msgfrom;
            $messages[$result->id]['message'] = stripslashes($result->msg);
            $messages[$result->id]['timestamp'] = strtotime($result->timestamp);
            $messages[$result->id]['is_admin'] = $result->originates == 1 ? true : false;
            $gravatar = "";
            if ($messages[$result->id]['is_admin']) {
                if (isset($cdata->other)) {
                    $other = maybe_unserialize($cdata->other);
                    if (isset($other['aid'])) {
                        $user_info = get_userdata(intval($other['aid']));
                        $gravatar = "//www.gravatar.com/avatar/" . md5($user_info->user_email) . "?s=30";
                    }
                }
            } else {
                if (isset($cdata->email)) {
                    $gravatar = "//www.gravatar.com/avatar/" . md5($cdata->email) . "?s=30";
                }
            }
            if (function_exists('wplc_decrypt_msg')) {
                $messages[$result->id]['message'] = wplc_decrypt_msg($messages[$result->id]['message']);
            }
            $messages[$result->id]['message'] = stripslashes($messages[$result->id]['message']);
        }
    }
    return $messages;
}
コード例 #3
0
function wplc_admin_pro_download_history($type, $cid)
{
    global $wpdb;
    global $wplc_tblname_msgs;
    $results = $wpdb->get_results("\n        SELECT *\n        FROM {$wplc_tblname_msgs}\n        WHERE `chat_sess_id` = '{$cid}'\n        ORDER BY `timestamp` ASC\n        LIMIT 0, 100\n        ");
    $fields[] = array('id' => __('Chat ID', 'wplivechat'), 'from' => __('From', 'wplivechat'), 'msg' => __('Message', 'wplivechat'), 'time' => __('Timestamp', 'wplivechat'), 'orig' => __('Origin', 'wplivechat'));
    foreach ($results as $result => $key) {
        if ($key->originates == 2) {
            $user = __('user', 'wplivechat');
        } else {
            $user = __('agent', 'wplivechat');
        }
        $fields[] = array('id' => $key->chat_sess_id, 'from' => $key->from, 'msg' => wplc_decrypt_msg($key->msg), 'time' => $key->timestamp, 'orig' => $user);
    }
    ob_end_clean();
    wplc_convert_to_csv($fields, 'live_chat_history_' . $cid . '.csv', ',');
    exit;
}
コード例 #4
0
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";
    }
}