Example #1
0
function session_full_html(PDO &$connection, Client &$_local_client)
{
    if (!$connection) {
        throw new Exception('Unable to render full session due to invalid PDO arg');
    } else {
        if (!$_local_client->status()) {
            ?>
        <section class="main">
            <header>
                Your session has expired!
            </header>
        </section>
        <?php 
        } else {
            if ($_local_client->getSessionNc() == 0) {
                ?>
        <section class="main">
            <header>
                Your session isn't ready yet!
            </header>
        </section>
        <?php 
            }
        }
    }
    $req = 'SELECT client_id, client_psn, leaderboard_score, acs_level, acs_prestige, leaderboard_score, ' . 'leaderboard_kills, leaderboard_deaths, pub_report ' . 'FROM CLIENTS JOIN SESSIONS ON client_session=session_token ' . 'WHERE client_status = true ' . 'AND client_session = ? ' . 'AND session_status = true ' . 'ORDER BY leaderboard_score DESC';
    $stmt = $connection->prepare($req);
    $cSession = $_local_client->getSessionToken();
    $stmt->bindParam(1, $cSession, PDO::PARAM_STR, 64);
    ?>
<div id="fSession"><?php 
    if ($stmt->execute()) {
        while ($data = $stmt->fetch()) {
            ?>
            <!-- Main -->
            <section id="client<?php 
            echo $data['client_id'];
            ?>
" class="main">
                <header>
                    <span class="avatar"><?php 
            level_image_associated_html($data['acs_level'], $data['acs_prestige']);
            ?>
</span>
                    <h1><?php 
            echo $data['client_psn'];
            ?>
</h1>

                    <table>
                        <thead>
                            <tr>
                                <td>Score</td>
                                <td>Kills</td>
                                <td>Deaths</td>
                                <td>Report</td>
                            </tr>
                        </thead>

                        <tbody>
                            <tr>
                                <td><?php 
            echo $data['leaderboard_score'];
            ?>
</td>
                                <td><?php 
            echo $data['leaderboard_kills'];
            ?>
</td>
                                <td><?php 
            echo $data['leaderboard_deaths'];
            ?>
</td>
                                <td><?php 
            echo $data['pub_report'];
            ?>
</td>
                            </tr>
                        </tbody>
                    </table>

                </header>
                <footer>
                    <button onclick="createReport('<?php 
            echo $_local_client->getToken();
            ?>
', <?php 
            echo $data['client_id'];
            ?>
)">Report</button>
                    <?php 
            if ($_local_client->isSU()) {
                ?>
<button onclick="createKick('<?php 
                echo $_local_client->getToken();
                ?>
', <?php 
                echo $data['client_id'];
                ?>
)">Kick</button><?php 
            }
            ?>
                </footer>
            </section>
        <?php 
        }
        ?>
</div><?php 
    } else {
        throw new Exception('Cannot render full session #session_full_html');
    }
}