Beispiel #1
0
function show_score($table, $offset, $user_id)
{
    assert(is_string($table));
    assert(is_string($offset));
    assert(is_numeric($user_id));
    global $_CONFIG;
    // Define minimum and maximum ranking for this page
    if ($offset == "") {
        $offset = 1;
    }
    $min = $offset;
    $max = $offset + $_CONFIG['SCORE_VIEWSIZE'];
    if ($max > score_get_last_rank()) {
        $max = score_get_last_rank();
    }
    // Print nice title
    if ($table == "overall") {
        $str = "Overall Ranking";
    }
    if ($table == "resource") {
        $str = "Resource Ranking";
    }
    if ($table == "strategic") {
        $str = "Strategic Ranking";
    }
    if ($table == "exploration") {
        $str = "Exploration Ranking";
    }
    print_subtitle($str);
    // Create sub menu
    create_submenu(array("Resource Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("resource"), "Exploration Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("exploration"), "Strategic Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("strategic"), "Overall Ranking" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall")));
    $pagecount = round((score_get_last_rank() - score_get_first_rank()) / $_CONFIG['SCORE_VIEWSIZE'] + 0.5);
    $pages = array();
    for ($i = 1; $i != $pagecount + 1; $i++) {
        $a = array("P{$i}" => "score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars($table) . "&ofs=" . encrypt_get_vars(($i - 1) * $_CONFIG['SCORE_VIEWSIZE'] + 1));
        $pages = array_merge($pages, $a);
    }
    create_submenu($pages);
    // Print the table
    $cls = "bl";
    echo "<table border=0 align=center width=75%>\n";
    echo "  <tr class=wb><th colspan=3>" . $str . "</th><tr>\n";
    for ($i = $min; $i != $max + 1; $i++) {
        list($uid, $name, $points) = score_get_rank($table, $i);
        if ($uid == $user_id) {
            echo "<tr class=" . $cls . "><td>&nbsp;<b><big>" . $i . ".</big></b>&nbsp;</td><td>&nbsp;<b><big>" . $name . "</big></b>&nbsp;</td><td>&nbsp;<b><big>(" . $points . " points)</big></b>&nbsp</td></tr>\n";
        } else {
            echo "<tr class=" . $cls . "><td>&nbsp;" . $i . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td></tr>\n";
        }
        if ($cls == "bl") {
            $cls = "lbl";
        } else {
            $cls = "bl";
        }
    }
    echo "</table>";
    echo "<br><br>";
}
function score_showuser($user_id)
{
    assert(is_numeric($user_id));
    $tables = array("resource", "exploration", "strategic", "overall");
    foreach ($tables as $table) {
        // Get the current ranking of the user
        $rank = score_get_user_rank($table, $user_id);
        // Get the first rank
        list($uid, $name, $points) = score_get_rank($table, 1);
        $ranktable['1'][$table] = "<td>&nbsp;1.&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        if ($rank == score_get_first_rank()) {
            $ranktable['2'][$table] = "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
        } else {
            list($uid, $name, $points) = score_get_rank($table, $rank - 1);
            $ranktable['2'][$table] = "<td>&nbsp;" . ($rank - 1) . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        }
        list($uid, $name, $points) = score_get_rank($table, $rank);
        $ranktable['3'][$table] = "<td>&nbsp;<b>" . $rank . ".</b>&nbsp;</td><td>&nbsp;<b>" . $name . "</b>&nbsp;</td><td>&nbsp;<b>(" . $points . " points)</b>&nbsp</td>";
        if ($rank == score_get_last_rank()) {
            $ranktable['4'][$table] = "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
        } else {
            list($uid, $name, $points) = score_get_rank($table, $rank + 1);
            $ranktable['4'][$table] = "<td>&nbsp;" . ($rank + 1) . ".&nbsp;</td><td>&nbsp;" . $name . "&nbsp;</td><td>&nbsp;(" . $points . " points)&nbsp</td>";
        }
    }
    echo "<table border=0 width=75% align=center>";
    echo "  <tr class=wb><th colspan=2>Rankings</th></tr>";
    echo "  <tr><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("resource") . ">Resource Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['resource'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['resource'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['resource'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['resource'] . "</tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("exploration") . ">Exploration Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['exploration'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['exploration'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['exploration'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['exploration'] . "</tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "<tr><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("strategic") . ">Strategic Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['strategic'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['strategic'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['strategic'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['strategic'] . "</tr>";
    echo "</table>";
    echo "</td><td>";
    echo "<table width=100% border=0>";
    echo "  <tr class=bl><th colspan=4><a href=score.php?cmd=" . encrypt_get_vars("show") . "&tbl=" . encrypt_get_vars("overall") . ">Overall Ranking:</a></th></tr>";
    echo "  <tr class=bl>" . $ranktable['1']['overall'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['2']['overall'] . "</tr>";
    echo "  <tr class=bl>" . $ranktable['3']['overall'] . "</tr>";
    echo "  <tr class=lbl>" . $ranktable['4']['overall'] . "</tr>";
    echo "</table>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br><br>";
}