use transaction method instead of direct BEGIN/COMMIT/ROLLBACK queries
[brisk.git] / web / briskin5 / statadm.php
index 4eb267b..e88a9f9 100644 (file)
@@ -30,8 +30,6 @@
 
 $G_base = "../";
 
-define('BIN5_TOURNAMENT_NORMAL', 1);
-
 ini_set("max_execution_time",  "240");
 
 require_once("../Obj/brisk.phh");
@@ -227,7 +225,7 @@ 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;
         }
@@ -335,7 +333,8 @@ 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 m.tcode = %d AND m.code = g.mcode AND
@@ -401,13 +400,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);
 }
@@ -428,7 +427,10 @@ 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.<br>\n";
     else