5 * Copyright (C) 2009 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. You should have received a
19 * copy of the GNU General Public License along with this program; if
20 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 * Suite 330, Boston, MA 02111-1307, USA.
29 1246428948|492e4e9e856b0|N|tre|172.22.1.90|STAT:BRISKIN5:FINISH_GAME|4a4afd4983039|6|3|tre|1|due|2|uno|-1|
32 - update the STAT file with differential
38 require_once("../Obj/brisk.phh");
39 require_once("../Obj/auth.phh");
40 require_once("Obj/briskin5.phh");
41 require_once("Obj/placing.phh");
45 GLOBAL $pazz, $G_alarm_passwd;
50 if ($pazz != $G_alarm_passwd)
53 if (($fp = @fopen(LEGAL_PATH."/points.log", 'r')) == FALSE) {
54 echo "Open data file error";
58 $userdb = new LoginDB();
60 for ($i = 0 ; $i < $userdb->count() ; $i++) {
61 $login = $userdb->getlogin_byidx($i);
62 $tri[$i] = new Ptsgam($login);
63 $mon[$i] = new Ptsgam($login);
64 $wee[$i] = new Ptsgam($login);
67 // recalculate all the placings
69 // 1246428948|492e4e9e856b0|N|tre|172.22.1.90|STAT:BRISKIN5:FINISH_GAME|4a4afd4983039|6|3|tre|1|due|2|uno|-1|
72 $bf = fgets($fp, 4096);
73 $ar = csplitter($bf, '|');
74 // if not auth table, continue
79 if ($ar[7] >= TABLES_AUTH_N)
81 // echo $p++." ".$ar[5]."<br>";
82 // if not FINISH_GAME line, continue
83 if ($ar[5] != "STAT:BRISKIN5:FINISH_GAME")
86 // if to much old points, continue
87 if ($ar[0] < $curtime - TRI_LIMIT)
89 // echo $p++." ".BRISKIN5_PLAYERS_N."<br>";
91 for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
92 // echo $p." i) ".$i."<br>";
93 $username = $ar[9+($i*2)];
94 if (($item = $userdb->getitem_bylogin($username, &$id)) == FALSE) {
95 echo "WARNING: the user [".$username."] NOT EXISTS!<br>";
99 // echo $item->login." id)".$id." ".$ar[10+($i*2)]."<br>";
100 $tri[$id]->add($ar[10+($i*2)]);
101 if ($ar[0] >= $curtime - MON_LIMIT)
102 $mon[$id]->add($ar[10+($i*2)]);
103 if ($ar[0] >= $curtime - WEE_LIMIT)
104 $wee[$id]->add($ar[10+($i*2)]);
106 // $p++; echo $p++."<br>";
110 usort($tri, ptsgam_cmp);
111 usort($mon, ptsgam_cmp);
112 usort($wee, ptsgam_cmp);
114 echo "<br><br>TRI<br>\n";
116 if (($fplo = @fopen(LEGAL_PATH."/class_tri_lo.log", 'w')) == FALSE) {
117 echo "Open tri_lo failed<br>";
120 if (($fphi = @fopen(LEGAL_PATH."/class_tri_hi.log", 'w')) == FALSE) {
121 echo "Open tri_hi failed<br>";
125 for ($i = 0 ; $i < count($tri) ; $i++) {
126 if ($tri[$i]->gam == 0.0)
128 printf("%s: %s (%d) <br>\n", $tri[$i]->username, $tri[$i]->snormpts(), $tri[$i]->gam);
129 if ($tri[$i]->gam >= TRI_MAX_GAMES)
130 fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($tri[$i]->username), $tri[$i]->pts, $tri[$i]->gam));
131 else if ($tri[$i]->gam > TRI_MIN_GAMES)
132 fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($tri[$i]->username), $tri[$i]->pts, $tri[$i]->gam));
137 echo "<br><br>MON<br>\n";
139 if (($fplo = @fopen(LEGAL_PATH."/class_mon_lo.log", 'w')) == FALSE) {
140 echo "Open tri_lo failed<br>";
143 if (($fphi = @fopen(LEGAL_PATH."/class_mon_hi.log", 'w')) == FALSE) {
144 echo "Open tri_hi failed<br>";
148 for ($i = 0 ; $i < count($mon) ; $i++) {
149 if ($mon[$i]->gam == 0.0)
151 printf("%s: %s (%d) <br>\n", $mon[$i]->username, $mon[$i]->snormpts(), $mon[$i]->gam);
152 if ($mon[$i]->gam >= MON_MAX_GAMES)
153 fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($mon[$i]->username), $mon[$i]->pts, $mon[$i]->gam));
154 else if ($mon[$i]->gam > MON_MIN_GAMES)
155 fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($mon[$i]->username), $mon[$i]->pts, $mon[$i]->gam));
160 echo "<br><br>WEE<br>\n";
161 if (($fplo = @fopen(LEGAL_PATH."/class_wee_lo.log", 'w')) == FALSE) {
162 echo "Open wee_lo failed<br>";
165 if (($fphi = @fopen(LEGAL_PATH."/class_wee_hi.log", 'w')) == FALSE) {
166 echo "Open wee_hi failed<br>";
170 for ($i = 0 ; $i < count($wee) ; $i++) {
171 if ($wee[$i]->gam == 0.0)
173 printf("%s: %s (%d) <br>\n", $wee[$i]->username, $wee[$i]->snormpts(), $wee[$i]->gam);
174 if ($wee[$i]->gam >= WEE_MAX_GAMES)
175 fwrite($fphi, sprintf("%s|%d|%d|\n", xcapelt($wee[$i]->username), $wee[$i]->pts, $wee[$i]->gam));
176 else if ($wee[$i]->gam > WEE_MIN_GAMES)
177 fwrite($fplo, sprintf("%s|%d|%d|\n", xcapelt($wee[$i]->username), $wee[$i]->pts, $wee[$i]->gam));