Code: Select all
<script language="php">
$handle = @fopen("http://www.ticalc.org/archives/files/authors/62/6296.html","r");
$buffer = '';
$curPos = 0;
if (!$handle) {
echo ("Could not connect to ticalc.org!");
} else {
global $buffer, $curPos;
while (!feof ($handle)) {
$buffer .= fgets($handle, 4096);
}
fclose($handle);
$rankBusiness = getBetweenText('Ranked number ',' in our ');
$rankBusinessCount = getBetweenText(' of busiest authors with ',' files.');
$rankAllTime = getBetweenText('Ranked number ',' in our ');
$rankAllTimeCount = getBetweenText(' authors all time with ',' downloads.');
$rankWeek = getBetweenText('Ranked number ',' in our ');
$rankWeekCount = getBetweenText(' seven days with ',' downloads.');
echo "Total downloads: $rankAllTimeCount (Ranked #$rankAllTime)<br />";
echo "Downloads this week: $rankWeekCount (Ranked #$rankWeek)<br />";
echo "Overall business: Ranked $rankBusiness with $rankBusinessCount files.<hr />";
$colours = array("#BCCCFF","#FFF9C7");
$colourIndex = 0;
while (1) {
$url = getBetweenText('<A HREF="/archives/files/fileinfo/','"><');
if ($url===false) break;
$url = "http://www.ticalc.org/archives/files/fileinfo/".$url;
$name = getBetweenText("<TD class=t1 VALIGN=\"TOP\">\n","\n</TD>");
$group = getBetweenText("<TD class=t1 VALIGN=\"TOP\">\n","\n</TD>");
echo "<table bgcolor=\"$colours[$colourIndex]\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr><td><a href=\"{$url}\" target=\"_blank\">$name</a></td><td align=\"right\">$group</td></tr></table>";
$colourIndex = 1-$colourIndex;
}
}
function getBetweenText($before, $after) {
global $buffer, $curPos;
$curPos = strpos($buffer, $before, $curPos);
if ($curPos===false) {
return false;
} else {
$curPos+=strlen($before);
$e = strpos($buffer, $after, $curPos);
return substr($buffer, $curPos, $e-$curPos);
}
}
</script>
I did have a version that grabs all the stats for each individual program, but at that point it starts to get a bit slow![/url]