From 7f31c2b3b37621dfce4652b0822a6656b0c8c2c2 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 23 Jul 2009 05:56:24 +0000 Subject: [PATCH] renamed classific.phh --- web/briskin5/Obj/placing.phh | 154 +++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 web/briskin5/Obj/placing.phh diff --git a/web/briskin5/Obj/placing.phh b/web/briskin5/Obj/placing.phh new file mode 100644 index 0000000..69e2758 --- /dev/null +++ b/web/briskin5/Obj/placing.phh @@ -0,0 +1,154 @@ +username = $username; + $this->pts = $pts; + $this->gam = $gam; + } + + function &clone() + { + $ret = new Ptsgam($this->username, $this->pts, $this->gam); + + return ($ret); + } + + function add($pts) + { + $this->pts += $pts; + $this->gam++; + } + + function snormpts() + { + $ret = sprintf ("%.3f", $this->normpts()); + if (strchr($ret, ".")) { + $ret = rtrim(rtrim($ret, "0"), "."); + } + return ($ret); + } + + function normpts() + { + if ($this->gam == 0) + return (0); + else + return ($this->pts / $this->gam); + } +} + +function ptsgam_cmp($a, $b) +{ + $norma = $a->normpts(); + $normb = $b->normpts(); + + if ($norma == $normb) { + if ($a->gam == $b->gam) + return (0); + else + return ($a->gam < $b->gam ? 1 : -1); + } + else + return (($norma < $normb) ? 1 : -1); +} + +function placings_show(&$user) +{ + $ret = sprintf("
"); + $ret .= sprintf("", WEE_FEW_GAMES, placing_show($user, "wee_hi") ); + $ret .= sprintf("\n", WEE_FEW_GAMES, placing_show($user, "wee_lo") ); + + $ret .= sprintf("", MON_FEW_GAMES, placing_show($user, "mon_hi") ); + $ret .= sprintf("\n", MON_FEW_GAMES, placing_show($user, "mon_lo") ); + + $ret .= sprintf("", TRI_FEW_GAMES, placing_show($user, "tri_hi")); + $ret .= sprintf("", TRI_FEW_GAMES, placing_show($user, "tri_lo")); + + + $ret .= sprintf("

Settimanale
(non meno di %d partite)

%s

Settimanale
(meno di %d partite)

%s

Mensile
(non meno di %d partite)

%s

Mensile
(meno di %d partite)

%s

Trimestrale
(non meno di %d partite)

%s

Trimestrale
(meno di %d partite)

%s
"); + return ($ret); +} + +function placing_show(&$user, $suff) +{ + $tail = FALSE; + + if (($fp = @fopen(LEGAL_PATH."/class_".$suff.".log", 'r')) == FALSE) { + return (FALSE); + } + + // MLANG + $ret = sprintf(""); + for ($i = 0 ; !feof($fp) ; $i++) { + $bf = fgets($fp, 4096); + $ar = csplitter($bf, '|'); + + $pg = new Ptsgam($ar[0], $ar[1], $ar[2]); + + if ($pg->username == "") + continue; + + if ($i < 5) { + $ret .= sprintf("", $i+1, + ($pg->username == $user->name ? "" : ""), $pg->username, ($pg->username == $user->name ? "" : ""), $pg->snormpts(), $pg->pts, $pg->gam); + } + if ($user != FALSE) { + if ($pg->username == $user->name && $i >= 5) { + $tail = sprintf(""); + $tail .= sprintf("", $i+1, + ($pg->username == $user->name ? "" : ""), $pg->username, ($pg->username == $user->name ? "" : ""), $pg->snormpts(), $pg->pts, $pg->gam); + } + } + } + + if ($tail != FALSE) { + $ret .= $tail; + } + $ret .= "
Pos.UtenteScore(Punti/Partite)
%d%s%s%s%s(%d/%d)
. . . . . . . . . .
%d%s%s%s%s(%d/%d)
"; + + fclose($fp); + + return ($ret); +} \ No newline at end of file -- 2.17.1