0) { // Brand new chat, user is HOST } else { // Existing chat, user is NOT host } */ $datetime_now = date("Y-m-d"); $datetime_now .= "|".date("H:i:s"); // GENERATE New Chat Message $sql = "INSERT INTO chrm_user_chat (id, username, user_type_host_or_user, user_status_voice, user_status_chat, channel, channel_type_text_or_voice, peerjs_id, datetime, metamask_id, email, message, extra_data) VALUES (null,'".aes_encrypt($username_in)."', '".aes_encrypt("user")."', null, '".aes_encrypt("normal")."', '".aes_encrypt($channel_in)."', '".aes_encrypt("text")."',null, '".aes_encrypt($datetime_now)."',null, null, '".aes_encrypt($message_in)."',null)"; $result = mysqli_query($con, $sql); $sql = "SELECT * FROM chrm_user_chat WHERE channel = '".aes_encrypt($channel_in)."' OR channel = '".aes_encrypt("global")."' ORDER BY id DESC, datetime DESC LIMIT 20"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); $total_rows_chat = mysqli_num_rows( $result ); if ($total_rows_chat > 0) { $return_value = ""; foreach ( $result as $row ) { $return_value = $return_value.aes_decrypt("{$row['channel']}")."|".aes_decrypt("{$row['username']}")."|".aes_decrypt("{$row['datetime']}")."|".aes_decrypt("{$row['message']}")."~"; } } } else if ($user_block_status == "blocked") { $return_value = "BLOCKED"; } } else if ($action_in == "text_chat_getmessagelist") { // Make sure username is NOT banned in system $sql = "SELECT * FROM chrm_user_chat where channel_type_text_or_voice = '".aes_encrypt("text")."' AND channel = '".aes_encrypt($channel_in)."' LIMIT 0, 1"; $result = mysqli_query($con, $sql); $total_rows_channel = mysqli_num_rows( $result ); // Go through ENTIRE text chat history to see if this username has ever been blocked $sql = "SELECT * FROM chrm_user_chat where channel_type_text_or_voice = '".aes_encrypt("text")."' AND username = '".aes_encrypt($username_in)."'"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); $user_block_status = "normal"; foreach ( $result as $row ) { if (aes_decrypt("{$row['user_status_chat']}") == "blocked") { // All messages from this user are blocked and will return as **** SYSTEM_BLOCKED_USER **** // Messages are IGNORED and user cannot write any more messages to the system. If they login, they cannot use text or voice and must reach out to the galaxy owner // ONLY Galaxy owners in the backend (or admins) can unblock a username once it has been blocked. $user_block_status = "blocked"; } else { // User is NOT blocked, we can continue } } if ($user_block_status == "normal") { /* // FOR VOICE CHAT ONLY if ($total_rows_channel > 0) { // Brand new chat, user is HOST } else { // Existing chat, user is NOT host } */ $sql = "SELECT * FROM chrm_user_chat WHERE channel = '".aes_encrypt($channel_in)."' OR channel = '".aes_encrypt("global")."' ORDER BY id DESC, datetime DESC LIMIT 20"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); $total_rows_chat = mysqli_num_rows( $result ); if ($total_rows_chat > 0) { $return_value = ""; foreach ( $result as $row ) { $return_value = $return_value.aes_decrypt("{$row['channel']}")."|".aes_decrypt("{$row['username']}")."|".aes_decrypt("{$row['datetime']}")."|".aes_decrypt("{$row['message']}")."~"; } } } else if ($user_block_status == "blocked") { $return_value = "BLOCKED"; } } else if ($action_in == "text_chat_getchannelslist") { // Make sure username is NOT banned in system // Go through ENTIRE text chat history to see if this username has ever been blocked $sql = "SELECT * FROM chrm_user_chat where channel_type_text_or_voice = '".aes_encrypt("text")."' AND username = '".aes_encrypt($username_in)."'"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); $user_block_status = "normal"; foreach ( $result as $row ) { if (aes_decrypt("{$row['user_status_chat']}") == "blocked") { // All messages from this user are blocked and will return as **** SYSTEM_BLOCKED_USER **** // Messages are IGNORED and user cannot write any more messages to the system. If they login, they cannot use text or voice and must reach out to the galaxy owner // ONLY Galaxy owners in the backend (or admins) can unblock a username once it has been blocked. $user_block_status = "blocked"; } else { // User is NOT blocked, we can continue } } if ($user_block_status == "normal") { /* // FOR VOICE CHAT ONLY if ($total_rows_channel > 0) { // Brand new chat, user is HOST } else { // Existing chat, user is NOT host } */ $sql = "SELECT * FROM chrm_user_chat"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); $total_rows_chat = mysqli_num_rows( $result ); if ($total_rows_chat > 0) { $return_value = ""; $array_of_channels = array(); foreach ( $result as $row ) { $channel_name = aes_decrypt("{$row['channel']}"); $found_channel = "false"; for($i = 0; $i < count($array_of_channels); $i++) { if ($channel_name == $array_of_channels[$i]) { $found_channel = "true"; } } if ($found_channel == "false") { array_push($array_of_channels, $channel_name); } } // Generate list of channels delimited by | for ($i = 0; $i < count($array_of_channels); $i++) { $return_value = $return_value.$array_of_channels[$i]."|"; } } } else if ($user_block_status == "blocked") { $return_value = "BLOCKED"; } } else if ($action_in == "text_chat_blocktextchatuser") { // Block a text chat user // This function will have to be done in backend admin section ONLY. Should not happen here. } else if ($action_in == "text_chat_unblocktextchatuser") { // Unblock a text chat user // This function will have to be done in backend admin section ONLY. Should not happen here. } else if ($action_in == "text_chat_clearallchats") { // Clear all text chats in system // This function will have to be done in backend admin section ONLY. Should not happen here. } // FINAL RETURN VALUE echo $return_value; // This file will handle all text and voice chat system functionality ?>