function activeListen($runs = 1, $isPost = false) { global $CONFIG, $GROUPS, $INTERNAL, $USER; $start = time(); $USER->Browsers[0]->Typing = isset($_POST[POST_EXTERN_TYPING]); if (!(!empty($USER->Browsers[0]->InternalUser) && $USER->Browsers[0]->InternalUser->LastActive > time() - $CONFIG["timeout_clients"])) { $USER->Browsers[0]->CloseChat(4); } while ($runs == 1) { processForward(); if ($USER->Browsers[0]->Declined) { displayDeclined(); return $USER; } else { if ($USER->Browsers[0]->Closed) { displayQuit(); return $USER; } else { if ($USER->Browsers[0]->Activated == CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { beginnConversation(); } } } if ($USER->Browsers[0]->Activated >= CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { refreshPicture(); processTyping(); } if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && !isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR]) && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { $USER = $USER->Browsers[0]->RequestFileUpload($USER, AJAXDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])); } else { if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR])) { $USER = $USER->Browsers[0]->AbortFileUpload($USER, namebase(AJAXDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])), AJAXDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR])); } } if ($runs++ == 1 && isset($_POST[POST_GLOBAL_SHOUT])) { processPosts(); } if ($USER->Browsers[0]->Activated == CHAT_STATUS_ACTIVE) { $isPost = getNewPosts(); $USER->Browsers[0]->SetStatus(CHAT_STATUS_ACTIVE); } if (isset($_POST[POST_GLOBAL_SHOUT]) || isset($_POST[POST_GLOBAL_NO_LONG_POLL]) || $isPost || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed) { break; } else { if (md5($USER->Response) != AJAXDecode($_POST[POST_GLOBAL_XMLCLIP_HASH_ALL])) { $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] = md5($USER->Response); $USER->AddFunctionCall("lz_chat_listen_hash('" . md5($USER->Response) . "','" . getId(5) . "');", false); break; } else { $USER->Response = ""; break; } } } }
function activeListen($runs = 1, $isPost = false) { global $CONFIG, $USER, $VOUCHER; $USER->Browsers[0]->Typing = isset($_POST[POST_EXTERN_TYPING]); if (isset($_POST["p_tc_declined"])) { $USER->Browsers[0]->UpdateArchive(""); } else { if (isset($_POST["p_tc_email"])) { $USER->Browsers[0]->UpdateArchive(base64UrlDecode($_POST["p_tc_email"])); } } if ($USER->Browsers[0]->InternalUser->Status == USER_STATUS_OFFLINE) { $USER->Browsers[0]->CloseChat(4); } else { foreach ($USER->Browsers[0]->Members as $sid => $member) { if ($USER->Browsers[0]->InternalUser->Status == USER_STATUS_OFFLINE) { $USER->Browsers[0]->LeaveChat($sid); } } if ($USER->Browsers[0]->InternalUser->SystemId != $USER->Browsers[0]->DesiredChatPartner) { $USER->Browsers[0]->DesiredChatPartner = $USER->Browsers[0]->InternalUser->SystemId; } } processForward(); if (!empty($USER->Browsers[0]->Declined)) { if ($USER->Browsers[0]->Declined < time() - $CONFIG["poll_frequency_clients"] * 2) { displayDeclined(); } return $USER; } else { if ($USER->Browsers[0]->Closed || empty($USER->Browsers[0]->InternalUser)) { displayQuit(); return $USER; } else { if ($USER->Browsers[0]->Activated == CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { beginnConversation(); } } } if ($USER->Browsers[0]->Activated >= CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { refreshPicture(); processTyping(); } if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && !isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR]) && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { $USER = $USER->Browsers[0]->RequestFileUpload($USER, base64UrlDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])); } else { if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR])) { $USER = $USER->Browsers[0]->AbortFileUpload($USER, namebase(base64UrlDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])), base64UrlDecode($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR])); } } if (isset($_POST[POST_GLOBAL_SHOUT])) { processPosts(); } if ($USER->Browsers[0]->Activated == CHAT_STATUS_ACTIVE) { $isPost = getNewPosts(); $USER->Browsers[0]->SetStatus(CHAT_STATUS_ACTIVE); if (!empty($VOUCHER)) { if (time() - $USER->Browsers[0]->LastActive > 0) { $VOUCHER->UpdateVoucherChatTime(time() - $USER->Browsers[0]->LastActive); } if (!(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { $VOUCHER->UpdateVoucherChatSessions($USER->Browsers[0]->ChatId); } $vouchers = VisitorChat::GetRelatedChatVouchers(base64UrlDecode($_POST[POST_EXTERN_USER_GROUP]), $VOUCHER); $USER->AddFunctionCall("lz_chat_add_update_vouchers_init('" . base64_encode(getChangeVoucherHTML($vouchers)) . "');", false); foreach ($vouchers as $tonlist) { $USER->AddFunctionCall("lz_chat_add_available_voucher('" . $tonlist->Id . "'," . $tonlist->ChatTime . "," . $tonlist->ChatTimeMax . "," . $tonlist->ChatSessions . "," . $tonlist->ChatSessionsMax . "," . $tonlist->VoucherAutoExpire . "," . parseBool($tonlist->VoucherAutoExpire < time()) . ");", false); } } else { $USER->AddFunctionCall("lz_chat_add_update_vouchers_init('" . base64_encode("") . "');", false); } } if ($USER->Browsers[0]->TranslationSettings != null) { $USER->AddFunctionCall("lz_chat_set_translation(" . $USER->Browsers[0]->TranslationSettings[0] . ",'" . base64_encode($USER->Browsers[0]->TranslationSettings[1]) . "','" . base64_encode($USER->Browsers[0]->TranslationSettings[2]) . "');", false); } if (isset($_POST[POST_GLOBAL_SHOUT]) || isset($_POST[POST_GLOBAL_NO_LONG_POLL]) || $isPost || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed) { //break; } else { if (md5($USER->Response) != base64UrlDecode($_POST[POST_GLOBAL_XMLCLIP_HASH_ALL])) { $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] = md5($USER->Response); $USER->AddFunctionCall("lz_chat_listen_hash('" . md5($USER->Response) . "','" . getId(5) . "');", false); //break; } else { $USER->Response = ""; //break; } } }
function activeListen($runs = 1, $isPost = false) { global $USER, $VOUCHER; $USER->Browsers[0]->Typing = isset($_POST[POST_EXTERN_TYPING]); if (isset($_POST["p_tc_declined"])) { $USER->Browsers[0]->UpdateArchive(""); } else { if (isset($_POST["p_tc_email"])) { $USER->Browsers[0]->UpdateArchive(Encoding::Base64UrlDecode($_POST["p_tc_email"])); } } $USER->Browsers[0]->ValidateOperator(); processForward(); if (!empty($USER->Browsers[0]->Declined)) { if ($USER->Browsers[0]->Declined < time() - Server::$Configuration->File["poll_frequency_clients"] * 2) { displayDeclined(); } return $USER; } else { if ($USER->Browsers[0]->Closed || empty($USER->Browsers[0]->OperatorId)) { displayQuit(); return $USER; } else { if ($USER->Browsers[0]->Activated == CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { $USER->Browsers[0]->ExternalWindowActivate(); } } } if ($USER->Browsers[0]->Activated >= CHAT_STATUS_WAITING && !(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { refreshPicture(); updateMembers(); } if (isset($_POST[POST_GLOBAL_SHOUT])) { processPosts(); } else { if (!empty($USER->Browsers[0]->OperatorId)) { $autoReply = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies("", $USER->Browsers[0]); if (!empty($autoReply)) { ChatAutoReply::SendAutoReply($autoReply, $USER, $USER->Browsers[0]->OperatorId); } } } if ($USER->Browsers[0]->Activated == CHAT_STATUS_ACTIVE) { $isPost = receivePosts(); $USER->Browsers[0]->SetStatus(CHAT_STATUS_ACTIVE); if (!empty($VOUCHER)) { if (time() - $USER->Browsers[0]->LastActive > 0) { $VOUCHER->UpdateVoucherChatTime(time() - $USER->Browsers[0]->LastActive); } if (!(!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed)) { $VOUCHER->UpdateVoucherChatSessions($USER->Browsers[0]->ChatId); } $vouchers = VisitorChat::GetRelatedChatVouchers(Encoding::Base64UrlDecode($_POST[POST_EXTERN_USER_GROUP]), $VOUCHER); $USER->AddFunctionCall("lz_chat_add_update_vouchers_init('" . base64_encode(getChangeVoucherHTML($vouchers)) . "');", false); foreach ($vouchers as $tonlist) { $USER->AddFunctionCall("lz_chat_add_available_voucher('" . $tonlist->Id . "'," . $tonlist->ChatTime . "," . $tonlist->ChatTimeMax . "," . $tonlist->ChatSessions . "," . $tonlist->ChatSessionsMax . "," . $tonlist->VoucherAutoExpire . "," . To::BoolString($tonlist->VoucherAutoExpire < time()) . ");", false); } } else { $USER->AddFunctionCall("lz_chat_add_update_vouchers_init('" . base64_encode("") . "');", false); } } if ($USER->Browsers[0]->TranslationSettings != null) { $USER->AddFunctionCall("lz_chat_set_translation(" . $USER->Browsers[0]->TranslationSettings[0] . ",'" . base64_encode($USER->Browsers[0]->TranslationSettings[1]) . "','" . base64_encode($USER->Browsers[0]->TranslationSettings[2]) . "');", false); } if (isset($_POST[POST_GLOBAL_SHOUT]) || isset($_POST[POST_GLOBAL_NO_LONG_POLL]) || $isPost || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Processed) { $USER->AddFunctionCall("lz_chat_listen_hash('','" . getId(5) . "');", false); } else { if (md5($USER->Response) != Encoding::Base64UrlDecode($_POST[POST_GLOBAL_XMLCLIP_HASH_ALL])) { $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] = md5($USER->Response); $USER->AddFunctionCall("lz_chat_listen_hash('" . md5($USER->Response) . "','" . getId(5) . "');", false); } else { $USER->Response = ""; } } }
function activeListen($runs = 1, $picUpdate = false, $isPost = false) { global $CONFIG, $GROUPS, $INTERNAL, $USER, $ISFORWARD; $start = time(); $USER->Browsers[0]->Typing = isset($_POST[POST_EXTERN_TYPING]); while ($runs == 1) { isForward(); processForward(); if ($runs > 1) { getDataSets(); getData(false, false, false, true); $USER->Browsers[0]->LoadChat($CONFIG, null); if (isnull($USER->Browsers[0]->Chat)) { break; } } if ($USER->Browsers[0]->Chat->Closed) { displayQuit(); return $USER; } else { if ($USER->Browsers[0]->Chat->Declined) { displayDeclined(); return $USER; } else { if ($USER->Browsers[0]->Chat->Activated == CHAT_STATUS_WAITING && !$ISFORWARD) { beginnConversation(); } } } if ($USER->Browsers[0]->Chat->Activated >= CHAT_STATUS_WAITING && !$ISFORWARD) { $picUpdate = refreshPicture(); processTyping(); } if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && !isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR]) && !$ISFORWARD) { $USER = $USER->Browsers[0]->RequestFileUpload($USER, $_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]); } else { if ($runs == 1 && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]) && isset($_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR])) { $USER->Browsers[0]->AbortFileUpload($USER, namebase($_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]), $_POST[POST_EXTERN_USER_FILE_UPLOAD_ERROR]); } } if ($runs++ == 1 && isset($_POST[POST_GLOBAL_SHOUT])) { processPosts(); } if ($USER->Browsers[0]->Chat->Activated == CHAT_STATUS_ACTIVE) { $isPost = getNewPosts(); updateRoom($USER->Browsers[0]->Chat->Id, CHAT_STATUS_ACTIVE); } else { updateRoom($USER->Browsers[0]->Chat->Id, CHAT_STATUS_WAITING); } if (isset($_POST[POST_GLOBAL_SHOUT]) || isset($_POST[POST_GLOBAL_NO_LONG_POLL]) || $isPost || $ISFORWARD) { break; } else { if (md5($USER->Response) != $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] || $picUpdate) { $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] = md5($USER->Response); $USER->AddFunctionCall("lz_chat_listen_hash('" . md5($USER->Response) . "','" . getId(5) . "');", false); break; } else { $USER->Response = ""; $wait = max($CONFIG["poll_frequency_clients"] - 1, 1); if (time() + $wait < $start + getLongPollRuntime()) { sleep($wait); } else { break; } } } } }