public function parse($path)
 {
     $mpq = new MPQFile($path, true, false);
     $init = $mpq->getState();
     if (!$init) {
         return false;
     }
     $r = $mpq->parseReplay();
     if (!$r) {
         return false;
     }
     $this->r_infos['version'] = $mpq->getVersionString();
     $this->r_infos['realm'] = $r->getRealm();
     $this->r_infos['speed'] = $r->getGameSpeed();
     $this->r_infos['winner_known'] = $r->isWinnerKnown();
     $this->r_infos['type'] = $r->getTeamSize();
     $this->r_infos['length'] = $r->getGameLength();
     $this->r_infos['real_length'] = (int) ($this->r_infos['length'] * 60) / 83.5;
     $this->r_infos['map'] = $r->getMapName();
     $this->r_infos['map_hash'] = $r->getMapHash();
     $this->r_infos['players'] = $r->getPlayers();
     foreach ($this->r_infos['players'] as $k => &$player) {
         if ($player['isObs']) {
             $this->r_infos['obs'][] = $this->r_infos['players'][$k];
             unset($this->r_infos['players'][$k]);
             continue;
         }
         $player['army'] = $player['race'];
         $player['bnet_id'] = (int) $player['uid'];
     }
     $this->computeAPM();
     $this->_computeMessages($r);
     $this->_computeWinner();
     return true;
 }
Пример #2
0
 }
 if ($error == UPLOAD_ERR_NO_FILE) {
     $text .= "Error: No file was selected for uploading.<br />";
     $err = true;
 }
 if (!is_uploaded_file($tmpname)) {
     $text .= "Error: Uploaded filename doesn't point to an uploaded file.<br />";
     $err = true;
 }
 if ($err !== true) {
     if (class_exists("MPQFile") || (include './include/replays/mpqfile.php')) {
         $start = microtime_float();
         $parseDurationString = "";
         $debug = 0;
         $a = new MPQFile($tmpname, true, $debug);
         $init = $a->getState();
         if ($init == false) {
             $text .= "Error parsing uploaded file, make sure it is a valid MPQ archive!<br />\n";
         } else {
             if ($a->getFileType() == "SC2replay") {
                 $b = $a->parseReplay();
                 $parseDurationString .= sprintf("Parsed replay in %d ms.<br />\n", (microtime_float() - $start) * 1000);
                 $players = $b->getPlayers();
                 $recorder = $b->getRecorder();
                 $error_str = '';
                 if ($event_id) {
                     $event = new Event($event_id);
                     $match = new Match();
                     // Check if replay->TeamSize == event->MatchType
                     if ($b->getTeamSize() != $event->getField('MatchType')) {
                         $error_str .= '<li>' . EB_SUBMITREPLAY_L3 . '</li>';