Ejemplo n.º 1
0
    ?>
            <div class="right floated">
                <div class="user item" data-timestamp="<?php 
    echo time();
    ?>
" data-user-id="<?php 
    echo $user['id'];
    ?>
">
                    <div class="name"><?php 
    echo $user['name'];
    ?>
</div>
                    <div class="balance">Баланс: <span
                            class="cash"><?php 
    echo number_format(getCashById($user['id']) / 100, 2, '.', '');
    ?>
</span>
                        руб
                    </div>
                </div>

                <?php 
    renderFormStart($form = createPayForm(), ['class' => 'item pay']);
    ?>
                <?php 
    renderFormField($form['fields']['pay'], ['id' => 'pay', 'autocomplete' => 'off', 'style' => 'display: none;']);
    ?>
                <button class="button label" type="submit">Пополнить</button>
                <?php 
    renderFormField($form['fields']['_token']);
Ejemplo n.º 2
0
        if (time() - $timer >= 5) {
            return [];
        }
    }
    return $events;
}
return function (array $request) {
    $query = $request['query'];
    if (array_key_exists('t', $query)) {
        $id = (int) $query['t'];
        if (!eventExists($id)) {
            return createResponse('', 400);
        }
    } else {
        $id = getLastId();
    }
    session_write_close();
    $events = waitForEvent($id);
    session_start();
    if (0 === count($events)) {
        $response = ['t' => $id];
    } else {
        $currentUser = currentUser();
        if ($currentUser) {
            $response = ['events' => $events, 'cash' => getCashById(currentUser()['id']) / 100, 't' => $events[0]['id']];
        } else {
            return createResponse('', 401);
        }
    }
    return createResponse(json_encode($response), 200, ['content-type' => 'application/json']);
};