Advertisement
Kimi

gamestv stats parser

Jul 17th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. <style>
  2.  
  3. /* ET color codes */
  4. span.cp { color: #000000; }
  5. span.cq { color: #ff0000; }
  6. span.cr { color: #00ff00; }
  7. span.cs { color: #dddd00; }
  8. span.ct { color: #0000ff; }
  9. span.cu { color: #00ffff; }
  10. span.cv { color: #ff00ff; }
  11. span.cx { color: #ffa500; }
  12. span.cy { color: #808080; }
  13. span.cb { color: #008080; }
  14. span.cc { color: #800080; }
  15. span.cd { color: #0066cc; }
  16. span.ce { color: #6600cc; }
  17. span.cf { color: #3399cc; }
  18. span.cg { color: #ccffcc; }
  19. span.ch { color: #006633; }
  20. span.ci { color: #990033; }
  21. span.cj { color: #993333; }
  22. span.ck { color: #993300; }
  23. span.ca { color: #cc9966; }
  24. span.cm { color: #999966; }
  25. span.cn { color: #cccc99; }
  26. span.co { color: #cccc66; }
  27.  
  28.  
  29. /* end */
  30.  
  31. fieldset {
  32.     border: 2px solid #FFD292;
  33.     border-radius: 10px;
  34. }
  35.  
  36. </style>
  37. <?
  38. function br()
  39. {
  40.     echo "</br>\n";
  41. }
  42. //page generating time
  43. $time = microtime();
  44. $time = explode(' ', $time);
  45. $time = $time[1] + $time[0];
  46. $start = $time;
  47.  
  48.  
  49. $url='http://www.gamestv.org/event/33955-dead-ringers-vs-to-make-odds-even/'.'statistics';
  50. $a = file_get_contents($url);
  51. echo "<a href=\"$url\" >$url</a>";
  52. br();
  53. $map_c=1;
  54. $stats_start=strpos($a,"<div class=\"matchStats\"");
  55. $a=substr($a,$stats_start,strpos($a,"View plaintext endround stats")-$stats_start); //cuts content to only data i need
  56. $c=strlen($a);
  57. $l=strpos($a,'" class="k">');
  58. while (!$l===false)
  59. {
  60.     //echo $l;br();
  61.     //echo strlen($a);br();
  62.     $name_pos=strpos($a,'<td class="left playername">'); //this text is always before player name
  63.     $map_pos=strpos($a,'</legend><table rules="groups"'); //this text is always after map name
  64.     if ($l>$map_pos)
  65.     {
  66.         echo substr($a,strrpos(substr($a,0,$map_pos),' '),$map_pos-strrpos(substr($a,0,$map_pos),' '));br();
  67.         $map_c++;
  68.     }
  69.     if ($l>$name_pos)
  70.     {
  71.         $offs=strpos(substr($a,$name_pos),"</td>");
  72.         echo substr($a,$name_pos+28,$offs-28).":";br();
  73.     }
  74.     //parsing time
  75.     $kill=substr($a,strrpos(substr($a,0,$l),'<span title="')+13,$l-13-strrpos(substr($a,0,$l),'<span title="'));
  76.     $timek=substr($kill,strrpos($kill,'(')+1,strrpos($kill,')')-1-strrpos($kill,'('));
  77.     $token=strtok($timek, ':');
  78.     $m  = $token;
  79.     $token=strtok(":");
  80.     $s=$token;
  81.     $time_s=$m+60*s;
  82.     echo $kill."__".$m.":".$s;
  83.     br();
  84.     $a=substr($a,$l+1); //cutting content
  85.  
  86.     $l=strpos($a,'" class="k">');
  87.    
  88. }
  89. ?>
  90.  
  91. <?php
  92. //page generating time
  93. $time = microtime();
  94. $time = explode(' ', $time);
  95. $time = $time[1] + $time[0];
  96. $finish = $time;
  97. $total_time = round(($finish - $start), 4);
  98. echo 'Page generated in '.$total_time.' seconds.';
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement