/** * eventScoresUpdate - Re-calculate the scores and players of an event */ function eventScoresUpdate($current_match) { global $sql; global $time; //echo "dbg: current_match $current_match<br>"; $numMatchsPerUpdate = 10; $q = "SELECT " . TBL_MATCHS . ".*" . " FROM " . TBL_MATCHS . " WHERE (" . TBL_MATCHS . ".Event = '" . $this->fields['EventID'] . "')" . " AND (" . TBL_MATCHS . ".Status = 'active')" . " ORDER BY TimeReported"; $result = $sql->db_Query($q); $num_matches = mysql_numrows($result); if ($current_match > $num_matches) { switch ($this->fields['Type']) { case "One Player Ladder": updateStats($this->fields['EventID'], $time, true); break; case "Team Ladder": updateStats($this->fields['EventID'], $time, true); updateTeamStats($this->fields['EventID'], $time, true); break; case "Clan Ladder": updateTeamStats($this->fields['EventID'], $time, true); break; case "One Player Tournament": case "Clan Tournament": break; default: } echo "Done."; echo '<META HTTP-EQUIV="Refresh" Content="0; URL=eventmanage.php?eventid=' . $this->fields['EventID'] . '">'; } else { $next_match = 1; if ($current_match == 0) { // Reset players stats $this->resetPlayers(); $this->resetTeams(); switch ($this->fields['Type']) { case "One Player Ladder": updateStats($this->fields['EventID'], $this->fields['StartDateTime'], false); break; case "Team Ladder": updateStats($this->fields['EventID'], $this->fields['StartDateTime'], false); updateTeamStats($this->fields['EventID'], $this->fields['StartDateTime'], false); break; case "Clan Ladder": updateTeamStats($this->fields['EventID'], $this->fields['getStartDateTime'], false); break; case "One Player Tournament": case "Clan Tournament": break; default: } } else { if (ob_get_level() == 0) { ob_start(); } // Output a 'waiting message' echo str_pad('Please wait while this task completes... ', 4096) . "<br />\n"; // Update matchs scores for ($j = $current_match - 1; $j < min($current_match + $numMatchsPerUpdate - 1, $num_matches); $j++) { set_time_limit(10); $next_match = $j + 2; $match_id = mysql_result($result, $j, TBL_MATCHS . ".MatchID"); $match = new Match($match_id); $time_reported = mysql_result($result, $j, TBL_MATCHS . ".TimeReported"); //echo "dbg: match: $match_id<br>"; //echo "dbg: etype: $this->fields['Type']<br>"; $match->match_scores_update(); switch ($this->fields['Type']) { case "One Player Ladder": $match->match_players_update(); updateStats($this->fields['EventID'], $this->fields['StartDateTime'], false); break; case "Team Ladder": $match->match_players_update(); updateStats($this->fields['EventID'], $this->fields['StartDateTime'], false); updateTeamStats($this->fields['EventID'], $this->fields['StartDateTime'], false); break; case "Clan Ladder": $match->match_teams_update(); updateTeamStats($this->fields['EventID'], $this->fields['StartDateTime'], false); break; case "One Player Tournament": case "Clan Tournament": break; default: } //echo 'match '.$j.': '.$match_id.'<br>'; //echo '<div class="percents">match '.$j.': '.$match_id.'</div>'; echo '<div class="percents">' . number_format(100 * ($j + 1) / $num_matches, 0, '.', '') . '% complete</div>'; echo str_pad('', 4096) . "\n"; ob_flush(); flush(); } } echo '<form name="updateform" action="' . e_PLUGIN . 'ebattles/eventprocess.php?eventid=' . $this->fields['EventID'] . '" method="post">'; echo '<input type="hidden" name="match" value="' . $next_match . '"/>'; echo '<input type="hidden" name="eventupdatescores" value="1"/>'; echo '</form>'; echo '<script language="javascript">document.updateform.submit()</script>'; ob_end_flush(); } exit; }
*/ /* Update */ if ($eneedupdate == 1) { $new_nextupdate = $time + 60 * $pref['eb_events_update_delay']; $event->setFieldDB('NextUpdate_timestamp', $new_nextupdate); $event->setFieldDB('IsChanged', 0); $eventIsChanged = 0; switch ($event->getField('Type')) { case "One Player Ladder": updateStats($event_id, $time, TRUE); break; case "Team Ladder": updateStats($event_id, $time, TRUE); updateTeamStats($event_id, $time, TRUE); case "Clan Ladder": updateTeamStats($event_id, $time, TRUE); break; default: } } $nextupdate_timestamp = $event->getField('NextUpdate_timestamp'); $nextupdate_timestamp_local = $nextupdate_timestamp + TIMEOFFSET; $date_nextupdate = date("d M Y, h:i A", $nextupdate_timestamp_local); // Put nbrMatches pending in tab header $q = "SELECT COUNT(DISTINCT " . TBL_MATCHS . ".MatchID) as NbrMatches" . " FROM " . TBL_MATCHS . ", " . TBL_SCORES . " WHERE (" . TBL_MATCHS . ".Event = '{$event_id}')" . " AND (" . TBL_SCORES . ".MatchID = " . TBL_MATCHS . ".MatchID)" . " AND (" . TBL_MATCHS . ".Status = 'pending')"; $result = $sql->db_Query($q); $row = mysql_fetch_array($result); $nbrMatchesPending = $row['NbrMatches']; if ($nbrMatchesPending == 0) { $can_approve = 0; }