/** * Take in a chat and record it to the database. * **/ public function receive() { $char_id = self_char_id(); $message = in('message', null, 'no filter'); // Essentially no filtering. $error = null; if (!empty($message)) { if ($char_id) { send_chat($char_id, $message); } else { $error = 'You must be logged in to chat.'; } } return new RedirectResponse('/village.php' . ($error ? '?error=' . url($error) : '')); }
$filename = "chat.json"; $fopen = fopen($filename, "r"); $fgets = fgets($fopen); fclose($fopen); $decode = json_decode($fgets, true); $val .= "<table class=\"table table-condensed\">"; foreach ($decode as $post) { $val .= "<tr><td><b style=\"color:#{$post[0]}\">{$post[0]}</b>: {$post[1]}</td></tr>"; } $val .= "</table>"; return $val; } if (isset($_POST["chat"]) && $_POST["chat"] != "") { $nick = $_SESSION["id"]; $chat = $_POST["chat"]; send_chat($nick, $chat); } if (isset($_GET["chat"]) && $_GET["chat"] != "") { echo show_chat(); exit; } ?> <!DOCTYPE html> <html lang="id"> <head> <title>MY CHAT</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
function json_send_chat($msg) { if (is_logged_in()) { require_once LIB_ROOT . "control/lib_chat.php"; $msg = trim($msg); $user_id = (int) self_char_id(); $info = self_char_info(); $success = send_chat($user_id, $msg); if (!$success) { return false; } else { return '{"message":"' . $msg . '","sender_id":"' . $user_id . '","uname":"' . $info['uname'] . '"}'; } } }
$rewards_string .= ' ' . $reward_block_count . ' blocks'; $message = '[HERALD] Gave you ' . $reward_block_count . ' Blocks'; send_pm($data['name'], $message); $claimed = true; } // Were they able to claim a reward of some value? if ($claimed == true) { $message = 'Vote again tomorrow for even better rewards!'; send_pm($data['name'], $message); echo " * Gave player c:{$reward_credits} fp:{$reward_faction_points} b:{$reward_block_count}"; echo " rewards ok: claiming.\n"; echo " * Broadcasting the transaction.\n"; $message = '[HERALD] Gave ' . $data['name'] . ' ' . $rewards_string; $message .= ' for voting for us ' . $user_new_data[$data['name']]['consecutive_votes']; $message .= ' days in a row on starmade-servers.com'; send_chat($message); } else { echo " * Player had no rewards: vote NOT claimed.\n"; unset($user_new_data[$data['name']]); } } else { echo " * Error claiming vote: vote NOT claimed.\n"; unset($user_new_data[$data['name']]); } } else { echo " * Player was not online: vote NOT claimed.\n"; unset($user_new_data[$data['name']]); } } } }
include SERVER_ROOT . "interface/header.php"; echo "<h1>Chat Board</h1>"; echo "<p><a href=\"" . $_SERVER['PHP_SELF'] . "?chatlength=50\">Refresh</a><p>"; $default_limit = 360; $chatlength = in('chatlength', $default_limit, 'toInt'); $message = in('message', null, 'forChat'); // Essentially no filtering. $command = in('command'); $sentMessage = in('message'); $sent = false; $username = get_username(); $user_id = get_user_id(); $input_form = $username ? render_chat_input($_SERVER['PHP_SELF'], $field_size = 40) : ''; $channel = 1; // Take in a chat and record it to the database. if ($user_id) { if ($command == "postnow" && $message) { send_chat($user_id, $message); } } // Output section. echo render_chat_refresh($not_mini = true); // Write out the js to refresh to refresh page to full chat. echo "<div id='full-chat'>"; echo $input_form; echo render_active_members($sql); echo render_chat_messages($chatlength); echo "</div>"; // End of full_chat div. echo render_footer(); // Don't skip the quickstat.
private function jsonSendChat($msg) { if (is_logged_in()) { require_once LIB_ROOT . "control/lib_chat.php"; $msg = trim($msg); $user_id = (int) self_char_id(); $player = new Player($user_id); $info = $player->dataWithClan(); $success = send_chat($user_id, $msg); if (!$success) { return false; } else { return ['message' => $msg, 'sender_id' => $user_id, 'uname' => $info['uname']]; } } }