$_GET["mp" . $pc] = $postar[0]; $_GET["mi" . $pc] = base64UrlEncode($id); $_GET["mrid" . $pc] = $id; $_GET["mc" . $pc++] = $postar[1]; queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `id`='" . DBManager::RealEscape($id) . "' LIMIT 1;"); } $pc = 0; $USER->Browsers[0]->QueuedPosts = array(); } } if (!empty($_GET["mi" . $pc]) || $USER->Browsers[0]->Waiting || !empty($USER->Browsers[0]->InitChatWith) || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) { if ($USER->Browsers[0]->Waiting && $BOTMODE && !empty($USER->Browsers[0]->QueuedPosts)) { $USER->Browsers[0]->QueuedPosts = array(); } else { if (!$openChatExternal) { initChat(); } } if (!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) { $USER->Browsers[0]->Forward->Save(true, true); $ACTIVE_OVLC = !$USER->Browsers[0]->Declined; } } if (!empty($USER->Browsers[0]->ChatId)) { $USER->AddFunctionCall("lz_chat_id='" . $USER->Browsers[0]->ChatId . "';", false); } $HTML = ""; $USER->Browsers[0]->VisitId = $USER->VisitId; while (!empty($_GET["mi" . $pc])) { $id = !empty($_GET["mrid" . $pc]) ? $_GET["mrid" . $pc] : md5($USER->Browsers[0]->SystemId . $USER->Browsers[0]->ChatId . $_GET["mi" . $pc]); $senderName = !empty($USER->Browsers[0]->Fullname) ? $USER->Browsers[0]->Fullname : $LZLANG["client_guest"] . " " . getNoName($USER->UserId . getIP());
<?php require 'init_database.php'; header('content-type: application/json; charset=utf-8'); header("access-control-allow-origin: *"); define("INIT_CHAT", "init_chat"); $conn = TalentMeDB::getConnection(); if (array_key_exists(INIT_CHAT, $_GET)) { $request = json_decode(str_rot13($_GET[INIT_CHAT])); initChat($request->host_email, $request->user_email); } TalentMeDB::close(); function initChat($host_email, $user_email) { global $conn; // check for existence of host $result = $conn->query("SELECT * FROM UserTable WHERE user_email='{$host_email}'"); if ($result->num_rows < 1) { echo '{"error" : "$host_email does not exist in UserTable"}'; return null; } // check for existence of user $result = $conn->query("SELECT * FROM UserTable WHERE user_email='{$user_email}'"); if ($result->num_rows < 1) { echo '{"error" : "$user_email does not exist in UserTable"}'; return null; } // create chat session with checking existence of chat session mechanism /* // Way 1 $sql = "SELECT * FROM ChatLineTable as t1 WHERE user_email = $host_email AND group_id IS NULL AND ".