X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2Fstatadm.php;h=2e702c79bb3f141d4b8ec0202ca8903e87733e3d;hb=a222ac87c9aa8297cc7dd4ede7c9b92089d52238;hp=bbde8eb144fa5a374179901047f445be7be2ee5d;hpb=e469882b494df00aab18f2e38d18c5faa214c740;p=brisk.git diff --git a/web/briskin5/statadm.php b/web/briskin5/statadm.php index bbde8eb..2e702c7 100644 --- a/web/briskin5/statadm.php +++ b/web/briskin5/statadm.php @@ -2,7 +2,7 @@ /* * brisk - statadm.php * - * Copyright (C) 2009-2011 Matteo Nastasi + * Copyright (C) 2009-2012 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -33,6 +33,7 @@ $G_base = "../"; ini_set("max_execution_time", "240"); require_once("../Obj/brisk.phh"); +require_once("../Obj/user.phh"); require_once("../Obj/auth.phh"); require_once("../Obj/dbase_${G_dbasetype}.phh"); require_once("Obj/briskin5.phh"); @@ -224,15 +225,15 @@ function main_pgsql($curtime) $maxg = array( TRI_MAX_GAMES, MON_MAX_GAMES, WEE_MAX_GAMES ); do { - if (pg_query($bdb->dbconn->db(), "BEGIN") == FALSE) { + if ($bdb->transaction("BEGIN") == FALSE) { log_crit("statadm: begin failed"); break; } $mtc_sql = sprintf("CREATE TEMPORARY TABLE %sbin5_temp_matches ON COMMIT DROP AS SELECT m.code, max(g.tstamp) AS tstamp FROM %sbin5_matches as m, %sbin5_games as g - WHERE g.mcode = m.code GROUP BY m.code, m.ttok", - $G_dbpfx, $G_dbpfx, $G_dbpfx); + WHERE (m.tcode = %d OR m.tcode = %d) AND m.code = g.mcode GROUP BY m.code, m.ttok", + $G_dbpfx, $G_dbpfx, $G_dbpfx, BIN5_TOURNAMENT_OLDRULES, BIN5_TOURNAMENT_NO_DRAW); if (pg_query($bdb->dbconn->db(), $mtc_sql) == FALSE) { log_crit("statadm: temporary matches table creation [$mtc_sql] failed"); break; @@ -266,7 +267,8 @@ function main_pgsql($curtime) } $mtc_obj = pg_fetch_object($mtc_pg, 0); - if (fwrite($fp, sprintf("M|%d|%s|%d|\n", $mtc_obj->code, xcapelt($mtc_obj->ttok), $mtc_obj->tidx)) == FALSE) { + if (fwrite($fp, sprintf("M|%d|%s|%d|%d|\n", $mtc_obj->code, xcapelt($mtc_obj->ttok), + $mtc_obj->tidx, $mtc_obj->tcode)) == FALSE) { log_crit("statadm: log file [$fname] write match failed"); break; } @@ -332,15 +334,21 @@ function main_pgsql($curtime) $old_score = array( 1000000000, 1000000000); $old_gam = array( -1, -1); $rank = array( 0, 0); - + + // TAG: POINTS_MANAGEMENT $pla_sql = sprintf("SELECT (float4(sum(p.pts)) * 100.0 ) / float4(count(p.pts)) as score, sum(p.pts) as points, count(p.pts) as games, u.code as ucode, u.login as login FROM %sbin5_points as p, %sbin5_games as g, %sbin5_matches as m, %susers as u - WHERE p.ucode = u.code AND p.gcode = g.code AND g.mcode = m.code AND - g.tstamp > to_timestamp(%d) AND g.tstamp <= to_timestamp(%d) + WHERE (m.tcode = %d OR m.tcode = %d) AND m.code = g.mcode AND + ( (u.type & (CAST (X'ff0000' as integer))) <> (CAST (X'800000' as integer)) ) AND + g.tstamp > to_timestamp(%d) AND g.tstamp <= to_timestamp(%d) AND + p.ucode = u.code AND p.gcode = g.code AND + p.pts != 0 GROUP BY u.code, u.login ORDER BY (float4(sum(p.pts)) * 100.0 ) / float4(count(p.pts)) DESC, count(p.pts) DESC", - $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, $curtime - $limi[$dtime], $curtime); + $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, + BIN5_TOURNAMENT_OLDRULES, BIN5_TOURNAMENT_NO_DRAW, + $curtime - $limi[$dtime], $curtime); // log_crit("statadm: INFO: [$pla_sql]"); @@ -394,13 +402,13 @@ function main_pgsql($curtime) break; } - if (pg_query($bdb->dbconn->db(), "COMMIT") == FALSE) { + if ($bdb->transaction("COMMIT") == FALSE) { break; } return (TRUE); } while (0); - pg_query($bdb->dbconn->db(), "ROLLBACK"); + $bdb->transaction("ROLLBACK"); return (FALSE); } @@ -410,10 +418,10 @@ function main() GLOBAL $G_dbasetype, $G_alarm_passwd, $pazz; echo "Inizio.
"; - flush(); + mop_flush(); if ($pazz != $G_alarm_passwd) { echo "Wrong password
"; - flush(); + mop_flush(); exit; } @@ -421,14 +429,17 @@ function main() $ctime = time(); - $curtime = ((int)($ctime / (24 * 3600))) * 24 * 3600 - (((int)substr(date("O", $ctime), 0, -2)) * 3600); + if (BIN5_PLAYERS_N != 5) + $curtime = $ctime; + else + $curtime = ((int)($ctime / (24 * 3600))) * 24 * 3600 - (((int)substr(date("O", $ctime), 0, -2)) * 3600); if ($ret = $fun_name($curtime)) echo "Success.
\n"; else echo "Failed.
\n"; echo "Fine.\n"; - flush(); + mop_flush(); } main();