bnetProfileLink = $profile; else $this->bnetProfileLink = $profile . '/'; $this->parseProfile(); if($this->profileFound) { $this->parseDivision(); $this->parseMatchHistory(); } } public function getDivisionLink() { return $this->divisionLink; } public function getCharacterName() { return $this->characterName; } public function getCharacterLeague() { return $this->characterLeague; } public function getGamesPlayed() { return $this->gamesPlayed; } public function getGamesWon() { return $this->gamesWon; } public function getBonusPool() { return $this->bonusPool; } public function getDivisionStandings() { return $this->divisionStandings; } public function getMatchHistory($count = 0) { if($count == 0) $count = count($this->matchHistory); return array_slice($this->matchHistory,0,$count); } public function getMaxBonusPool() { return $this->maxBonusPool; } public function getCharacterRating() { return $this->characterRating; } public function getProfileFound() { return $this->profileFound; } private function parseProfile() { $profileHtml = @file($this->bnetProfileLink); if(!$profileHtml) { $this->profileFound = false; return; } $onesFound = false; $divisionFound = false; $characterFound = false; foreach($profileHtml as $profileLine) { if(!$characterFound) { if(preg_match('{}',$profileLine,$characterMatch)) $characterFound = true; } if(preg_match('/#best-team-1/',$profileLine)) $onesFound = true; if(!$onesFound) continue; if(!$divisionFound) { if(preg_match('{a href="(.*)#current-rank">}',$profileLine,$divisionMatch))Record: (.*) - (.*)}',$profileLine,$recordMatch)) continue; break; } preg_match('{(http://.*.battle.net)}',$this->bnetProfileLink,$regionMatch); $this->divisionLink = $regionMatch[1] . $divisionMatch[1]; $this->gamesPlayed = $recordMatch[1] + $recordMatch[2]; $this->gamesWon = $recordMatch[1]; $this->characterName = $characterMatch[1]; $this->characterLeague = $divisionMatch[2]; } private function parseDivision() { $divisionStandings = array(); $divisionHtml = file($this->divisionLink); $standingsHtml = array(); $standingsCount = 0; $standingsFound = false; $bonusFound = false; foreach($divisionHtml as $divisionLine) { if(!$bonusFound) { if(preg_match('{Bonus Pool: (.*)}',$divisionLine,$bonusMatch)) $bonusFound = true; } if(preg_match('//',$divisionLine)) $standingsFound = true; if(!$standingsFound) continue; if(preg_match('{
}',$divisionLine)) break; if(preg_match('{}',$divisionLine)) $standingsCount++; $standingsHtml[$standingsCount] .= $divisionLine; } $rankTemplate = <<.*.*(.*)
.*HighestRank:.*
PreviousRank:.*
FavoriteRace:.*(.*)(.*)(.*)} RANKTEMPLATE; foreach($standingsHtml as $standingsLine) { $standingsLine = preg_replace('/[\s]+/m','',$standingsLine); preg_match($rankTemplate,$standingsLine,$standingMatch); array_shift($standingMatch); $divisionStandings[] = $standingMatch; if($standingMatch[1] == $this->characterName) $this->characterRating = $standingMatch[2]; } $this->divisionStandings = $divisionStandings; $this->bonusPool = $bonusMatch[1]; } private function parseMatchHistory() { $matches = array(); $matchHistoryHtml = file($this->bnetProfileLink . 'matches'); $matchHtml = array(); $matchesFound = false; $matchCount = 0; foreach($matchHistoryHtml as $matchHistoryLine) { if(preg_match('//',$matchHistoryLine)) $matchesFound = true; if(!$matchesFound) continue; if(preg_match('{
}',$matchHistoryLine)) break; if(preg_match('{}',$matchHistoryLine)) $matchCount++; $matchHtml[$matchCount] .= $matchHistoryLine; } array_shift($matchHtml); array_shift($matchHtml); $matchTemplate = <<Type:1v1
Speed:Faster.*1v1.*\((.*)\).*} MATCHTEMPLATE; foreach($matchHtml as $matchLine) { $matchLine = preg_replace('/[\s]+/m','',$matchLine); preg_match($matchTemplate,$matchLine,$matchMatch); if($matchMatch[1] != '') $matches[] = $matchMatch[1]; } $this->matchHistory = $matches; } } ?>