teams.php

Go to the documentation of this file.
00001 <?php
00013 require_once(dirname(__FILE__).'/base.php');    
00014 
00023 class LFSWorldTeamsList extends LFSWorldDataProvider
00024 {
00029     var $m_sURL = 'http://www.lfsworld.net/pubstat/get_stat2.php?action=teams';
00030     
00035     var $m_aSrcMetaData = array('lifeTime' => 180, 'actualTarpit' => 180);
00036     
00074     function parse($rawList, &$outputList)
00075     {
00076         //Offset var for position
00077         $offset = 0;
00078         
00079         while(true)
00080         {
00081             //grab the next chunk of static team data
00082             $blob = substr($rawList, $offset, 172);
00083 
00084             //Must be 172 chars else it can't be valid
00085             if(strlen($blob) == 172)
00086             {
00087                 //(Re-)Init tmp vars to parse into
00088                 $data = $racers = array();
00089                 $memberCount = 0;
00090                 
00091                 //Min len 172. Parse and advance the offset to the end of the static chunk
00092                 $data = unpack('a64name/a6tag/a32country/a64url/V1bits/v1infoLen', $blob);
00093                 $offset += 172;
00094 
00095                 //Get dynamic length info chunk and advance the offset
00096                 $data['info'] = urldecode(substr($rawList, $offset, $data['infoLen']));
00097                 $offset += $data['infoLen'];
00098 
00099                 //Get member count and advance offset
00100                 $memberCount = (ord($rawList{$offset})) | (ord($rawList{$offset+1}));
00101                 $offset += 2;
00102                 
00103                 //Extract the entire member chunk, split it in to smaller chunks of 24, and explode
00104                 $members = explode('&', chunk_split(substr($rawList, $offset, $memberCount*24), 24, '&'));
00105                 //This method always adds an empty entry so just pop it off
00106                 array_pop($members);
00107 
00108                 //Trim the guff and advance the offset to the next chunk
00109                 $data['members'] = array_map('rtrim', $members);
00110                 $offset += $memberCount*24;
00111 
00112                 //Assign member count and clean up (now) useless data
00113                 $data['memberCount'] = $memberCount;
00114                 unset($data['infoLen']);
00115 
00116                 $outputList[] = $data;
00117             }
00118             else
00119             {
00120                 break;
00121             }
00122         }
00123 
00124         return true;
00125     }
00126 }
00127 
00128 ?>

Generated on Wed Oct 25 03:13:32 2006 for LFSWorldParsingProviderFramework by  doxygen 1.4.6