Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'functions.php';
- if (!isset($_SESSION['is_logged'])) {
- if (!isset($_REQUEST['log_in'])) {
- echo '<html>
- <link rel = "stylesheet" type = "text/css" href = "style.css">
- <body>
- <div class = "log_in_window">
- <form action = "'.$_SERVER['SCRIPT_NAME'].'" method = "POST">
- <input class = "input_nick" type = "text" name="nick" value = ""><br>
- <input class = "log_in" type = "submit" name = "log_in" value = "Войти">
- </form>
- </div>
- </body>
- </html>';
- } else {
- db_connect();
- $_SESSION['is_logged'] = 1;
- $_SESSION['nick'] = $_REQUEST['nick'];
- db_user_status($_SESSION['nick'], "online");
- db_close();
- exit("<meta http-equiv = 'refresh' content ='0; url = $_SERVER[PHP_SELF]'>");
- }
- } else {
- db_connect();
- $message = db_read_message();
- $online = db_user_online();
- header('refresh: 30;url = '.$_SERVER['SCRIPT_NAME'].'');
- echo '<html>
- <link rel = "stylesheet" type = "text/css" href = "style.css">
- <body>
- <div>
- <form action = "'.$_SERVER['SCRIPT_NAME'].'" method = "POST">
- <div class="chat_field">';
- for ($i = 0; $i < db_get_post_count(); $i++) {
- echo $message[$i].'<br>';
- }
- echo ' </div>
- <div class="users_field">';
- for ($i = 0; $i < db_get_post_count(); $i++) {
- echo $online[$i].'<br>';
- }
- echo ' </div><br>
- <input class = "message_field" type="text" name="message_field" value="">
- <input class = "post_message" type="submit" name="post_message" value="ОК">
- <input class = "log_out" type="submit" name="log_out" value="Выйти">
- </form>
- </div>
- </body>
- </html>';
- if (isset($_REQUEST['log_out'])) {
- db_user_status($_SESSION['nick'], "offline");
- session_destroy();
- db_close();
- exit("<meta http-equiv = 'refresh' content = '0; url = $_SERVER[PHP_SELF]'>");
- }
- if (isset($_REQUEST['post_message'])) {
- if ($_REQUEST['message_field']) {
- db_post_message($_SESSION['nick'], $_REQUEST['message_field']);
- exit("<meta http-equiv = 'refresh' content = '0; url = $_SERVER[PHP_SELF]'>");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement