function wplc_pro_admin_menu_layout_display() { if (!isset($_GET['action'])) { $wplc_current_user_id = get_current_user_id(); ?> <div class='wplc_page_title'> <h1><?php _e("Chat sessions", "wplivechat"); ?> </h1> <p><?php _e("Please note: This window must be open in order to receive new chat notifications.", "wplivechat"); ?> </p> <?php $is_agent = get_user_meta($wplc_current_user_id, 'wplc_ma_agent', true); if (!$is_agent) { $warning = "<p style='color: red;'><b>" . __('You are not a chat agent. Please make yourself a chat agent before trying to chat to visitors', 'wplivechat') . "</b></p>"; echo $warning; } ?> </div> <?php wplc_pro_version_check(); ?> <?php //if(function_exists("wplc_ma_register")){ $agent_id = wplc_ma_check_if_user_is_agent(); //} else { //$agent_id = true; //} ?> <div class="wplc_admin_dashboard_container"> <?php $wplc_pro_settings = get_option("WPLC_PRO_SETTINGS"); if (isset($wplc_pro_settings['wplc_auto_online']) && $wplc_pro_settings['wplc_auto_online'] == 1) { ?> <div style="padding: 10px 0;"><input type="checkbox" class="wplc_switchery" name="wplc_agent_status" id="wplc_agent_status" <?php if (get_user_meta($wplc_current_user_id, "wplc_chat_agent_online", true)) { echo 'checked'; } ?> /><div id="wplc_agent_status_text" style="display: inline-block; padding-left: 10px;"></div></div> <?php } ?> <div id="wplc_sound"></div> <div id="wplc_admin_chat_area"> <?php echo wplc_list_chats_pro($agent_id); ?> </div> <div id="wplc_admin_visitor_area"> <?php echo wplc_list_visitors($agent_id); ?> </div> </div> <?php } else { if (isset($_GET['aid'])) { //if(function_exists("wplc_ma_register")){ wplc_ma_update_agent_id($_GET['cid'], $_GET['aid']); //} } if ($_GET['action'] == 'ac') { wplc_change_chat_status($_GET['cid'], 3); wplc_pro_draw_chat_area($_GET['cid']); } else { if ($_GET['action'] == 'history' && function_exists("wplc_register_pro_version")) { wplc_admin_pro_view_chat_history($_GET['cid']); } else { if ($_GET['action'] == 'rc' && function_exists("wplc_register_pro_version")) { wplc_admin_pro_request_chat($_GET['cid']); } } } } }
//wplc_error_log("[".__LINE__."] NEW ADMIN LONG POLL LOOP"); if (defined('WPLC_TIMEOUT')) { set_time_limit(WPLC_TIMEOUT); } else { set_time_limit(120); } $i = 1; while ($i <= $iterations) { ////wplc_error_log("[".__LINE__."] ADMIN LOOP $i"); session_write_close(); // update chats if they have timed out every x iterations if ($i % 15 == 0) { //wplc_error_log("[".__LINE__."] Updating chat statuses $i"); wplc_update_chat_statuses(); } $new_visitor_data = wplc_list_visitors($_POST['wplc_agent_id']); if ($_POST['wplc_list_visitors_data'] == 'false') { $old_visitors = false; } else { $old_visitors = stripslashes($_POST['wplc_list_visitors_data']); } if ($_POST['wplc_update_admin_chat_table'] == 'false') { $old_chat_data = false; } else { $old_chat_data = stripslashes($_POST['wplc_update_admin_chat_table']); } if (stripslashes($old_visitors) !== stripslashes($new_visitor_data)) { //wplc_error_log("[".__LINE__."] Visitor data updated $i"); //$visitor_table = wplc_list_visitors($_POST['wplc_agent_id']); $visitor_table = $new_visitor_data; $array = array("action" => "wplc_list_visitors", "wplc_list_visitors_data" => $visitor_table, "chat_data" => $old_chat_data, "wplc_update_admin_chat_table" => $old_chat_data);