Created
September 23, 2015 13:35
-
-
Save samvignoli/e4d7515d58af8e1cff2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body bgcolor="black" style="color:green;font-family:courier;font-size:20pt"> | |
<?php | |
$html=file_get_contents('http://battlelog.battlefield.com/bf4/servers/show/PC/80514707-1688-47a2-b5b8-60a808142d52/FtS-1-Conquest-1200T-HC-Fast-Respawn/'); | |
$htmlarray=explode("\n", $html); | |
$vigente=0; | |
for($i=0;$i<count($htmlarray);$i++) | |
{ | |
if(trim($htmlarray[$i])=='<td class="active">') | |
{ | |
$vigente=$i; | |
break; | |
} | |
} | |
$mapa=''; | |
for($i=$vigente;$i<count($htmlarray);$i++) | |
{ | |
if(strpos($htmlarray[$i], '<strong>')) | |
{ | |
$mapa=strip_tags($htmlarray[$i]); | |
break; | |
} | |
} | |
$vigente=0; | |
for($i=0;$i<count($htmlarray);$i++) | |
{ | |
if(trim($htmlarray[$i])=='<td class="next">') | |
{ | |
$vigente=$i; | |
break; | |
} | |
} | |
$nextmap=''; | |
for($i=$vigente;$i<count($htmlarray);$i++) | |
{ | |
if(strpos($htmlarray[$i], '<strong>')) | |
{ | |
$nextmap=strip_tags($htmlarray[$i]); | |
break; | |
} | |
} | |
// próximo | |
$dados=json_decode(file_get_contents('http://keeper.battlelog.com/snapshot/80514707-1688-47a2-b5b8-60a808142d52'),true); | |
//$dados=json_decode($dados[0]); | |
if($mapa!=qualmapa($dados['snapshot']['currentMap'])) | |
$mapa=qualmapa($dados['snapshot']['currentMap']); | |
echo '<h1>'.$mapa.'</h1><pre>'; | |
echo '<p>Tempo de jogo: '.gmdate("i:s", $dados['snapshot']['roundTime']).'</p>'; | |
echo '<p>Placar: '. $dados['snapshot']['conquest']['2']['tickets'].' x '. $dados['snapshot']['conquest']['1']['tickets'].'</p>'; | |
echo '<p>A seguir: '. trim($nextmap).'</p>'; | |
echo count($dados['snapshot']['teamInfo']['2']['players'])+count($dados['snapshot']['teamInfo']['1']['players']).' players, '.count($dados['snapshot']['teamInfo']['0']['players']).' logando'."\n\n"; | |
foreach ($dados['snapshot']['teamInfo']['1']['players'] as $k => $v) { | |
if($v['tag']=='FtS') { | |
if(strlen($v['name'])<8) $incremento=" "; | |
else $incremento=''; | |
echo $v['name'].$incremento.' '.$v['kills'].'/'.$v['deaths']."\n"; | |
} | |
} | |
echo "\n"; | |
foreach ($dados['snapshot']['teamInfo']['2']['players'] as $k => $v) { | |
if($v['tag']=='FtS') | |
{ | |
if(strlen($v['name'])<8) $incremento=" "; | |
else $incremento=''; | |
echo $v['name'].$incremento.' '.$v['kills'].'/'.$v['deaths']."\n"; | |
} | |
} | |
//print_r($dados['snapshot']); | |
//echo count($htmlarray); | |
function qualmapa($string) | |
{ | |
if(strpos($string,"MP_Abandoned")) | |
return "Zavod 311"; | |
elseif(strpos($string,"MP_Damage")) | |
return "Lancang Dam"; | |
elseif(strpos($string,"MP_Flooded")) | |
return "Flood Zone"; | |
elseif(strpos($string,"MP_Journey")) | |
return "Golmud Railway"; | |
elseif(strpos($string,"MP_Naval")) | |
return "Paracel Storm"; | |
elseif(strpos($string,"MP_Prison")) | |
return "Operation Locker"; | |
elseif(strpos($string,"MP_Resort")) | |
return "Hainan Resort"; | |
elseif(strpos($string,"MP_Siege")) | |
return "Siege of Shanghai"; | |
elseif(strpos($string,"MP_TheDish")) | |
return "Rogue Transmission"; | |
elseif(strpos($string,"MP_Tremors")) | |
return "Dawnbreaker"; | |
elseif(strpos($string,"XP1_001")) | |
return "Silk Road"; | |
elseif(strpos($string,"XP1_002")) | |
return "Altai Range"; | |
elseif(strpos($string,"XP1_003")) | |
return "Guilin Peaks"; | |
elseif(strpos($string,"XP1_004")) | |
return "Dragon Pass"; | |
elseif(strpos($string,"XP0_Caspian")) | |
return "Caspian Border 2014"; | |
elseif(strpos($string,"XP0_Firestorm")) | |
return "Operation Firestorm 2014"; | |
elseif(strpos($string,"XP0_Metro")) | |
return "Operation Metro 2014"; | |
elseif(strpos($string,"XP0_Oman")) | |
return "Gulf of Oman 2014"; | |
elseif(strpos($string,"XP2_001")) | |
return "Lost Islands"; | |
elseif(strpos($string,"XP2_002")) | |
return "Nansha Strike"; | |
elseif(strpos($string,"XP2_003")) | |
return "Wavebreaker"; | |
elseif(strpos($string,"XP2_004")) | |
return "Operation Mortar"; | |
elseif(strpos($string,"XP3_MarketPl")) | |
return "Pearl Market"; | |
elseif(strpos($string,"XP3_Prpganda")) | |
return "Propaganda"; | |
elseif(strpos($string,"XP3_UrbanGdn")) | |
return "Lumphini Garden"; | |
elseif(strpos($string,"XP3_WtrFront")) | |
return "Sunken Dragon"; | |
elseif(strpos($string,"XP4_Arctic")) | |
return "Operation Whiteout"; | |
elseif(strpos($string,"XP4_SubBase")) | |
return "Hammerhead"; | |
elseif(strpos($string,"XP4_Titan")) | |
return "Hangar 21"; | |
elseif(strpos($string,"XP4_WlkrFtry")) | |
return "Giants Of Karelia"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment