Exemplo n.º 1
0
 * Time: 1:16 AM
 */
// THIS FILE IS MEANT TO RESPOND TO AJAX REQUESTS
require_once "handlers/SessionsHandler.php";
SessionsHandler::startSession();
SessionsHandler::checkAccess("operations.php");
require_once "handlers/UserHandler.php";
require_once "handlers/ChatHandler.php";
$action = $_GET["action"];
if ($action == "get_active_users") {
    // get users that have been active in the last 30 seconds
    $data = UserHandler::getActiveUsers();
} else {
    if ($action == "logout") {
        SessionsHandler::destroySession();
        SessionsHandler::redirect("login.php");
    } else {
        if ($action == "post") {
            if (isset($_GET["chat_id"]) && isset($_GET["msg"])) {
                $chat_id = $_GET["chat_id"];
                $message = $_GET["msg"];
                $data = ChatHandler::insertMessage(UserHandler::getCurrentUserId(), $chat_id, $message);
            }
        } else {
            if ($action == "get") {
                if (isset($_GET["chat_id"]) && isset($_GET["reload"])) {
                    $chat_id = $_GET["chat_id"];
                    $reload = $_GET["reload"];
                    $data = ChatHandler::getLatestMessages(UserHandler::getCurrentUserId(), $chat_id, $reload);
                }
            } else {
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Kristaps
 * Date: 11/27/2015
 * Time: 12:01 AM
 */
require_once "handlers/UserHandler.php";
if (isset($_POST['username']) && $_POST['username'] != "") {
    UserHandler::login($_POST['username']);
    SessionsHandler::redirect('chatroom.php');
}
require_once "header.php";
?>

<div class="login-card">
    <h1>Log-in</h1><br>
    <form id="login_form" action="login.php" method="post">
        <input type="text" name="username" placeholder="Username">
        <input type="submit" name="login" class="login button" value="login">
    </form>

    <div class="login-help">
        There is no password
    </div>
</div>

<?php 
require_once "footer.php";
Exemplo n.º 3
0
<?php

/**
 * Created by PhpStorm.
 * User: Kristaps
 * Date: 11/26/2015
 * Time: 11:39 PM
 */
require_once "handlers/SessionsHandler.php";
SessionsHandler::startSession();
require_once "header.php";
SessionsHandler::redirect("chatroom.php");
require_once "footer.php";