<?
/*
// Some helpful info on the format:
$stats['PROJECTNAME']['url'] = 'http://www.somewhere.com/download.html'; // The download page for the project client
$stats['PROJECTNAME']['name'] = 'Some Great Project'; // The official name of the project.
$stats['PROJECTNAME']['rank'] = $grab_rank_from_site; // The ranking that we currently are at.
$stats['PROJECTNAME']['rankurl']= 'http://www.somewhere.com/teamstats.html // The ranking url where we can view the team stats.
$stats['PROJECTNAME']['units'] = $grab_units_from_site; // The unit that we currently have done.
*/
function Stats_DF()
{
GLOBAL $stats;
$fp = fopen('http://distributedfolding.org/teampages/team301.txt', 'r');
$line_cnt = 0;
while ($line = fgets($fp, 1024))
{
if ( $line_cnt == 3 )
{
$two_parts = split(':', $line);
$two_parts[1] = trim($two_parts[1]);
$length = strlen($two_parts[1]) - 1;
$stats['df']['rank'] = substr($two_parts[1],0, $length);
}
if ( $line_cnt == 6 )
{
$two_parts = split(':', $line);
$two_parts[1] = trim($two_parts[1]);
$length = strlen($two_parts[1]);
$stats['df']['units'] = substr($two_parts[1],0, $length);
break;
}
$line_cnt++;
}
$stats['df']['url'] = 'http://distributedfolding.org/Download.html';
$stats['df']['name'] = 'Distributed Folding';
$stats['df']['rankurl'] = 'http://distributedfolding.org/teampages/team301.html';
return;
}
function Stats_SOB()
{
GLOBAL $stats;
$fp = fopen('http://www.seventeenorbust.com/stats/teamstats.shtml?teamname=TeamBeOS', 'r');
$line_cnt = 0;
while ($line = fgets($fp, 1024))
{
// we're attempting to find the first instance of 583623, which is a font highlight for our team, in html.
if ( strpos($line, 'bgcolor="583623"') > 0 )
{
$line = fgets($fp, 1024); // read in next line, which we know follows the first instance of 583623
$line = ereg_replace('<td class="sn" align="right">', ' ', $line);
$line = ereg_replace('</td>', ' ', $line);
$stats['sob']['rank'] = trim($line);
// read 14 more lines.. I know, this hack SUCKS.
for ( $i=0; $i<14; $i++)
{
$line = fgets($fp, 1024);
}
$line = ereg_replace('<td class="sn" align="right"><b>', ' ', $line);
$line = ereg_replace('</b> G-cEMs</td>', ' ', $line);
$stats['sob']['units'] = trim($line);
break;
}
}
$stats['sob']['url'] = 'http://www.seventeenorbust.com/download/';
$stats['sob']['name'] = 'Seventeen or Bust';
$stats['sob']['rankurl'] = 'http://www.seventeenorbust.com/stats/teamstats.shtml?teamname=TeamBeOS';
return;
}
Stats_DF();
Stats_SOB();
echo '
<p>
<table border="0" cellpadding="1" cellspacing="0" width="100%" align="center">
<tr>
<td bgcolor="#' . $color_table_border . '">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr><td colspan="3" align="center" bgcolor="#' . $color_table_header_background . '"><b><font size="2"><a href="http://www.teambeos.com" target="_blank">TeamBeOS</a> Stats</font></b></td></tr>
<tr>
<td width="40%" valign=top align=center bgcolor=#' . $color_table_header_background . '><p><b><font size=1>Project</font></b></td>
<td width="20%" valign=top align=center bgcolor=#' . $color_table_header_background . '><p><b><font size=1>Rank</font></b></td>
<td width="40%" valign=top align=center bgcolor=#' . $color_table_header_background . '><p><b><font size=1>Units</font></b></td>
</tr>
';
while ( list($key, $value) = each($stats) )
{
echo '
<tr>
<td width="40%" valign=top align=center bgcolor=#' . $color_table_background . '><font size=1><a href="' . $stats[$key]['url'] . '" target="_blank">' . $stats[$key]['name'] . '</a></font></td>
<td width="20%" valign=top align=center bgcolor=#' . $color_table_background . '><font size=1><a href="' . $stats[$key]['rankurl'] . '" target="_blank">' . $stats[$key]['rank']. '</a></font></td>
<td width="40%" valign=top align=center bgcolor=#' . $color_table_background . '><font size=1>' . $stats[$key]['units'] . '</font></td>
</tr>
';
}
echo '
</table>
</td>
</tr>
</table>
';
?>