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> <b><big>" . $i . ".</big></b> </td><td> <b><big>" . $name . "</big></b> </td><td> <b><big>(" . $points . " points)</big></b> </td></tr>\n"; } else { echo "<tr class=" . $cls . "><td> " . $i . ". </td><td> " . $name . " </td><td> (" . $points . " points) </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> 1. </td><td> " . $name . " </td><td> (" . $points . " points) </td>"; if ($rank == score_get_first_rank()) { $ranktable['2'][$table] = "<td> </td><td> </td><td> </td>"; } else { list($uid, $name, $points) = score_get_rank($table, $rank - 1); $ranktable['2'][$table] = "<td> " . ($rank - 1) . ". </td><td> " . $name . " </td><td> (" . $points . " points) </td>"; } list($uid, $name, $points) = score_get_rank($table, $rank); $ranktable['3'][$table] = "<td> <b>" . $rank . ".</b> </td><td> <b>" . $name . "</b> </td><td> <b>(" . $points . " points)</b> </td>"; if ($rank == score_get_last_rank()) { $ranktable['4'][$table] = "<td> </td><td> </td><td> </td>"; } else { list($uid, $name, $points) = score_get_rank($table, $rank + 1); $ranktable['4'][$table] = "<td> " . ($rank + 1) . ". </td><td> " . $name . " </td><td> (" . $points . " points) </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>"; }