function render_active($limit = 5, $alive_only = true)
{
    $where_cond = $alive_only ? 'and health>0' : '';
    $sel = "select uname, player_id from players where confirmed=1 {$where_cond} order by last_started_attack desc limit {$limit}";
    $sql = new DBAccess();
    $res = $sql->QueryAssoc($sel);
    $out = "\n    <div class='active-players'>\n      <ul>\n        <li><span>Lurking ninja: </span></li>\n\t";
    foreach ($res as $ninja) {
        $out .= "        <li class='active-ninja'><a href='player.php?target_id=" . $ninja['player_id'] . "'>" . $ninja['uname'] . "</a></li>";
    }
    $out .= "\n      </ul>\n    </div>\n    ";
    return $out;
}
Exemple #2
0
/**
 * Just do a check whether the input username and password is valid
 * @return boolean
**/
function is_authentic($user, $pass)
{
    $filter = new Filter();
    $user = $filter->toUsername($user);
    $pass = $filter->toPassword($pass);
    $res = false;
    if ($user != '' && $pass != '') {
        $sql = new DBAccess();
        $q = "select uname, player_id from players where lower(uname) =\n\t\t\tlower('" . $user . "') and pname = '" . $pass . "' and confirmed = 1 limit 1";
        $results = $sql->QueryAssoc($q);
        $rows = $sql->getRowCount();
        if (1 == $rows) {
            $res = true;
        }
    }
    return $res;
}
Exemple #3
0
function render_clan_members($clan = null, $limit = 30)
{
    ob_start();
    if ($clan) {
        $where = "where clan = '{$clan}' and confirmed=1";
        $sel = "select uname, player_id, health from players {$where} order by health desc, level desc limit {$limit}";
        $sql = new DBAccess();
        $ninjas = $sql->QueryAssoc($sel);
        ?>
        <div class='clan-members'>
            <div class='subtitle'>Clan members</div>
                <?php 
        if (!empty($ninjas)) {
            $display_ul = true;
        }
        if ($display_ul) {
            echo "<ul>";
        }
        foreach ($ninjas as $ninja) {
            $added_class = '';
            if ($ninja['health'] < 1) {
                $added_class = ' injured';
            }
            echo "<li class='clan-member{$added_class}'>\n                            <a href='player.php?target_id=" . $ninja['player_id'] . "'>\n                                " . $ninja['uname'] . "\n                            </a>\n                          </li>";
        }
        if ($display_ul) {
            echo "</ul>";
        }
        ?>
        </div>
        <?php 
    }
    $res = ob_get_contents();
    ob_end_clean();
    return $res;
}