+//
+//
+
+function placing_show_pgsql($user, $ty, $subty)
+{
+ GLOBAL $G_dbpfx;
+
+ if (($bdb = BriskDB::create()) == FALSE) {
+ log_crit("placing: database connection failed");
+ return ("");
+ }
+
+ if ($user != FALSE) {
+ $pla_sql = sprintf("SELECT * from %sbin5_places where type = %d AND (rank <= %d OR ucode = '%s');",
+ $G_dbpfx, ($ty * 2) + $subty, TOP_NUM, escsql($user->code));
+ }
+ else {
+ $pla_sql = sprintf("SELECT * from %sbin5_places where type = %d AND rank <= %d;",
+ $G_dbpfx, ($ty * 2) + $subty, TOP_NUM);
+ }
+
+ if (($pla_pg = pg_query($bdb->dbconn->db(), $pla_sql)) == FALSE || pg_numrows($pla_pg) == 0) {
+ // no point found, abort
+ log_crit("placing: get placing list failed [$pla_sql]");
+ return ("");
+ }
+
+ // MLANG
+ $ret = sprintf("<table class='placing'><tr><th>Pos.</th><th>Utente</th><th>Score</th><th>(Punti/Partite)</th>");
+
+ for ($i = 0 ; $i < pg_numrows($pla_pg) ; $i++) {
+ $pla_obj = pg_fetch_object($pla_pg,$i);
+
+ $ein = "";
+ $eou = "";
+ if ($user != FALSE) {
+ if ($user->code == $pla_obj->ucode) {
+ $ein = "<b>";
+ $eou = "</b>";
+ }
+ }
+
+ /* when the user is far from the top-ten we place a ... separator before it */
+ if ($pla_obj->rank > TOP_NUM) {
+ $ret .= sprintf("<tr><td colspan=4 style='text-align: center'> . . . . . . . . . . </td></tr>");
+ }
+ $ret .= sprintf("<tr><td>%d</td><td>%s%s%s</td><td>%s%12.3f%s</td><td>%s(%d/%d)%s</td></tr>", $pla_obj->rank,
+ $ein, xcape($pla_obj->login), $eou,
+ $ein, $pla_obj->score, $eou,
+ $ein, $pla_obj->pts, $pla_obj->games, $eou);
+ }
+ $ret .= "</table>";
+
+ return ($ret);
+}
+
+function placing_show($user, $ty, $subty)
+{
+ GLOBAL $G_dbasetype;
+
+ $fun_name = "placing_show_${G_dbasetype}";
+
+ return ($fun_name($user, $ty, $subty));
+}
+
+?>
\ No newline at end of file