$q = "INSERT INTO " . TBL_SCORES . "(MatchID,Player,Player_MatchTeam,Player_Score,Player_Rank,Faction,Color,sColor,APM)\r\n\t\t\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t{$match_id},\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player_MatchTeam'] . "',\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Player_Rank'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Faction'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['Color'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['sColor'] . "',\r\n\t\t\t\t\t\t\t'" . $scores[$i]['APM'] . "'\r\n\t\t\t\t\t\t\t)"; break; case 'Teams': break; default: $q = ''; } $result = $sql->db_Query($q); } // Update scores stats $match->match_scores_update(); // Automatically Update Players stats only if Match Approval is Disabled if ($event->getField('MatchesApproval') == eb_UC_NONE) { switch ($event->getMatchPlayersType()) { case 'Players': $match->match_players_update(); break; case 'Teams': $match->match_teams_update(); break; default: } } $event->setFieldDB('IsChanged', 1); // Save the replay $target_path = "uploads/"; $target_file = $target_path . basename($name); move_uploaded_file($tmpname, $target_file); $raw_name = urlencode($name); $target_file = $target_path . basename($raw_name); $media_type = 'Replay';
/** * 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; }