X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fbriskin5%2Fstat-day.php;h=a895d7c00cf6914d53762b1e0dbf7655f143e977;hb=bef452514e4c78f5f13ad096b6643cd6d7d081f5;hp=7218905773092cdc12279bcd4d57b5e73a983c62;hpb=5c967dabf5b7bef5b0471e61c9ada4a51d887cb6;p=brisk.git
diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php
index 7218905..a895d7c 100644
--- a/web/briskin5/stat-day.php
+++ b/web/briskin5/stat-day.php
@@ -1,9 +1,9 @@
array( 'it' => 'Partite normali',
+ 'en' => 'Normal matches' ),
+ 'special match' => array( 'it' => 'Partite speciali',
+ 'en' => 'Special matches'),
+
+ 'info_total'=> array( 'it' => 'totali',
+ 'en' => 'En totali')
+ );
+
+
ini_set("max_execution_time", "240");
require_once("../Obj/brisk.phh");
@@ -41,17 +61,17 @@ require_once("Obj/placing.phh");
function main_file($curtime)
{
- GLOBAL $G_alarm_passwd;
+ GLOBAL $G_lang, $G_alarm_passwd;
$tri = array();
$mon = array();
$wee = array();
-
+
if (($fp = @fopen(LEGAL_PATH."/points.log", 'r')) == FALSE) {
echo "Open data file error";
exit;
}
echo "prima
";
-
+
if (($fp_start = @fopen(LEGAL_PATH."/points.start", 'r')) != FALSE) {
$skip = intval(fgets($fp_start));
if ($skip > 0)
@@ -63,7 +83,7 @@ function main_file($curtime)
echo "database connection failed";
exit;
}
-
+
$bdb->users_load();
for ($i = 0 ; $i < $bdb->count() ; $i++) {
@@ -82,7 +102,7 @@ function main_file($curtime)
// if not auth table, continue
if (count($ar) < 15)
continue;
-
+
// echo $p++."
";
if ($ar[7] >= TABLES_AUTH_N)
continue;
@@ -98,11 +118,11 @@ function main_file($curtime)
fwrite($fp_start, sprintf("%d\n", $curpos));
fclose($fp_start);
}
-
+
continue;
}
// echo $p++." ".BIN5_PLAYERS_N."
";
-
+
$found = FALSE;
$mult = 1;
for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
@@ -125,22 +145,22 @@ function main_file($curtime)
echo "WARNING: the user [".$username."] NOT EXISTS!
";
continue;
}
-
+
// echo $item->login." id)".$id." ".$ar[10+($i*2)]." mult: ".$mult."
";
$tri[$id]->add($ar[10+($i*2)] / $mult);
- if ($ar[0] >= $curtime - MON_LIMIT)
+ if ($ar[0] >= $curtime - MON_LIMIT)
$mon[$id]->add($ar[10+($i*2)] / $mult);
- if ($ar[0] >= $curtime - WEE_LIMIT)
+ if ($ar[0] >= $curtime - WEE_LIMIT)
$wee[$id]->add($ar[10+($i*2)] / $mult);
}
// $p++; echo $p++."
";
}
fclose($fp);
-
+
usort($tri, ptsgam_cmp);
usort($mon, ptsgam_cmp);
usort($wee, ptsgam_cmp);
-
+
echo "
TRI
\n";
if (($fplo = @fopen(LEGAL_PATH."/class_tri_lo.log", 'w')) == FALSE) {
@@ -156,9 +176,9 @@ function main_file($curtime)
if ($tri[$i]->gam == 0.0)
continue;
printf("%s: %s (%d)
\n", $tri[$i]->username, $tri[$i]->snormpts(), $tri[$i]->gam);
- if ($tri[$i]->gam >= TRI_MAX_GAMES)
+ if ($tri[$i]->gam >= TRI_MAX_GAMES)
fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($tri[$i]->username), $tri[$i]->pts, $tri[$i]->gam));
- else if ($tri[$i]->gam > TRI_MIN_GAMES)
+ else if ($tri[$i]->gam > TRI_MIN_GAMES)
fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($tri[$i]->username), $tri[$i]->pts, $tri[$i]->gam));
}
fclose($fphi);
@@ -179,9 +199,9 @@ function main_file($curtime)
if ($mon[$i]->gam == 0.0)
continue;
printf("%s: %s (%d)
\n", $mon[$i]->username, $mon[$i]->snormpts(), $mon[$i]->gam);
- if ($mon[$i]->gam >= MON_MAX_GAMES)
+ if ($mon[$i]->gam >= MON_MAX_GAMES)
fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($mon[$i]->username), $mon[$i]->pts, $mon[$i]->gam));
- else if ($mon[$i]->gam > MON_MIN_GAMES)
+ else if ($mon[$i]->gam > MON_MIN_GAMES)
fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($mon[$i]->username), $mon[$i]->pts, $mon[$i]->gam));
}
fclose($fphi);
@@ -198,12 +218,12 @@ function main_file($curtime)
}
for ($i = 0 ; $i < count($wee) ; $i++) {
- if ($wee[$i]->gam == 0.0)
+ if ($wee[$i]->gam == 0.0)
continue;
printf("%s: %s (%d)
\n", $wee[$i]->username, $wee[$i]->snormpts(), $wee[$i]->gam);
- if ($wee[$i]->gam >= WEE_MAX_GAMES)
+ if ($wee[$i]->gam >= WEE_MAX_GAMES)
fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($wee[$i]->username), $wee[$i]->pts, $wee[$i]->gam));
- else if ($wee[$i]->gam > WEE_MIN_GAMES)
+ else if ($wee[$i]->gam > WEE_MIN_GAMES)
fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($wee[$i]->username), $wee[$i]->pts, $wee[$i]->gam));
}
fclose($fphi);
@@ -213,60 +233,117 @@ function main_file($curtime)
function main_pgsql($from, $to)
{
- GLOBAL $G_dbpfx;
+ GLOBAL $G_lang, $G_dbpfx, $mlang_stat_day;
- if (($fpexp = @fopen(LEGAL_PATH."/explain.log", 'w')) == FALSE) {
- echo "Open explain failed
";
- exit;
- }
- fprintf($fpexp, "
%s | ", $usr_obj->login); + } + fprintf($fpexp, "%s | ", $users[$u]['login']); + // note: we are looping on users, order on them not needed $pts_sql = sprintf(" -select p.pts as pts from %sbin5_matches as m, %sbin5_games as g, %sbin5_points as p, %susers as u WHERE m.code = g.mcode AND g.code = p.gcode AND u.code = p.ucode AND m.code = %d AND u.code = %d ORDER BY g.code", $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, - $tmt_obj->code, $usr_obj->code); +SELECT p.pts AS pts + FROM %sbin5_games AS g, %sbin5_points AS p + WHERE g.code = p.gcode AND g.mcode = %d AND p.ucode = %d + ORDER BY g.code", + $G_dbpfx, $G_dbpfx, + $tmt_obj->code, $users[$u]['code']); - if (($pts_pg[$u] = pg_query($bdb->dbconn->db(), $pts_sql)) == FALSE) { + // points of the match for each user + if (($pts_pg[$u] = pg_query($bdb->dbconn->db(), $pts_sql)) == FALSE) { + log_crit("stat-day: pts_sql failed"); break; } if ($u == 0) { @@ -274,74 +351,158 @@ select p.pts as pts from %sbin5_matches as m, %sbin5_games as g, %sbin5_points a } else { if ($num_games != pg_numrows($pts_pg[$u])) { + log_crit("stat-day: num_games != pg_numrows"); break; } } } - if ($u != 5) { + if ($u != BIN5_PLAYERS_N) { + log_crit("stat-day: u != BIN5_PLAYERS_N"); break; - } - fprintf($fpexp, "mazzo | descrizione | \n"); + } // LISTA DELLE VARIE PARTITE + $pts_obj = array(); for ($g = 0 ; $g < $num_games ; $g++) { + $gam_obj = pg_fetch_object($gam_pg, $g); fprintf($fpexp, "
---|---|---|
%d | ", $pts_obj->pts); + $pt_min = 1000; + $pt_min_n = 0; + $pt_max = -1000; + $pt_max_n = 0; + for ($u = 0 ; $u < BIN5_PLAYERS_N ; $u++) { + $pts_obj[$u] = pg_fetch_object($pts_pg[$u], $g); + + if ($pt_min > $pts_obj[$u]->pts) { + $pt_min = $pts_obj[$u]->pts; + $pt_min_n = 1; + } + else if ($pt_min == $pts_obj[$u]->pts) { + $pt_min_n++; + } + + if ($pt_max < $pts_obj[$u]->pts) { + $pt_max = $pts_obj[$u]->pts; + $pt_max_n = 1; + } + else if ($pt_max == $pts_obj[$u]->pts) { + $pt_max_n++; + } + } + if ($pt_min_n > 1) { + $pt_min = 1000; + } + if ($pt_max_n > 1) { + $pt_max = -1000; + } + + /* cases: + pts = 0 -> white + pts == pt_min -> red + pts == pt_max -> green + pts < 0 -> light red + pts > 0 -> light green + */ + for ($u = 0 ; $u < BIN5_PLAYERS_N ; $u++) { + $pts = $pts_obj[$u]->pts; + + if ($pts == 0) + $cla_nam = 'bg_white'; + else if ($pts == $pt_min) + $cla_nam = 'bg_red'; + else if ($pts == $pt_max) + $cla_nam = 'bg_green'; + else if ($pts < 0) + $cla_nam = 'bg_lired'; + else if ($pts > 0) + $cla_nam = 'bg_ligre'; + + fprintf($fpexp, "<%s class='%s'>%d%s>", + ($tmt_obj->minus_one_is_old == -1 ? "td" : "th"), + $cla_nam, pow(2,$gam_obj->mult) * $pts, + ($tmt_obj->minus_one_is_old == -1 ? "td" : "th")); + } + if ($tmt_obj->minus_one_is_old != -1) { + fprintf($fpexp, "%s | %s | ", $users[$gam_obj->mazzo]['login'], + xcape( game_description($gam_obj->act, 'plain', $gam_obj->mult, + $gam_obj->asta_win, + ($gam_obj->asta_win != -1 ? + $users[$gam_obj->asta_win]['login'] : ""), + $gam_obj->friend, + ($gam_obj->friend != -1 ? + $users[$gam_obj->friend]['login'] : ""), + $gam_obj->pnt, $gam_obj->asta_pnt) ) + ); } fprintf($fpexp, "
%d | ", $tot_obj->pts); } - fprintf($fpexp, "%s | \n", $mlang_stat_day['info_total'][$G_lang]); + } fprintf($fpexp, "