$seti_url=
"fcgi-bin/fcgi?cmd=user_xml&email=youremailaddress@domain.com";
$host
= 'setiathome2.ssl.berkeley.edu';
$timelimit
= 10;
$fp
= @fsockopen($host, 80, $errno, $errstr, $timelimit );
if
(!$fp) {
echo
"Network error: $errstr ($errno)";
} else
{
$seti_statistics
= '';
fputs($fp,
"GET /$seti_url HTTP/1.0\r\nHost: $host\r\n\r\n");
stream_set_timeout($fp,
$timelimit);
while
(!feof($fp)) {
$seti_statistics
.= fgets($fp, 4096);
}
fclose
($fp);
}
//
Parsing out information from the XML feed
echo
"<table border=0 bgcolor=\"eeeeee\"width=100%>
<tr><td><font
face=\"arial, helvetica\"><font color=\"#000044\"><b>My SETI Statistics</b></TD></TR></TABLE>";
if(
eregi( "(<name>)(.*)(</name>)", $seti_statistics, $extract_name )
)
{
$name
= $extract_name[2];
echo
"Name: ", $name, "<br>";
}
if(
eregi( "(<regdate>)(.*)(</regdate>)", $seti_statistics, $extract_regdate
) )
{
$regdate
= $extract_regdate[2];
echo
"Registered on: ", $regdate, "<br>";
}
if(
eregi( "(<usertime>)(.*)(</usertime>)", $seti_statistics, $extract_usertime
) )
{
$usertime
= $extract_usertime[2];
echo
"SETI@home user for: ", $usertime, "<br>";
}
if(
eregi( "(<numresults>)(.*)(</numresults>)", $seti_statistics, $extract_numresults
) )
{
$numresults
= $extract_numresults[2];
echo
"Data units processed and submitted to SETI@home: ", $numresults, "<br>";
}
if(
eregi( "(<cputime>)(.*)(</cputime>)", $seti_statistics, $extract_cputime
) )
{
$cputime
= $extract_cputime[2];
echo
"Total CPU time: ", $cputime, "<br>";
}
if(
eregi( "(<avecpu>)(.*)(</avecpu>)", $seti_statistics, $extract_avecpu
) )
{
$avecpu
= $extract_avecpu[2];
echo
"Average CPU time per work unit: ", $avecpu, "<br>";
}
if(
eregi( "(<resultsperday>)(.*)(</resultsperday>)", $seti_statistics,
$extract_resultsperday ) )
{
$resultsperday
= $extract_resultsperday[2];
echo
"Average number of units processed per day: ", $resultsperday, "<br>";
}
if(
eregi( "(<lastresulttime>)(.*)(</lastresulttime>)", $seti_statistics,
$extract_lastresulttime ) )
{
$lastresulttime
= $extract_lastresulttime[2];
echo
"Most recent unit returned to SETI on: ", $lastresulttime, "<br>";
}
if(
eregi( "(<userprofile>)(.*)(</userprofile>)", $seti_statistics, $extract_userprofile
) )
{
$userprofile
= $extract_userprofile[2];
echo
"My user profile: ", $userprofile, "<br>";
}
echo
"<table border=0 bgcolor=\"eeeeee\"width=100%>
<tr><td><font
face=\"arial, helvetica\"><font color=\"#000044\"><b>My SETI Rank
(based on number of work units processed)</b></TD></TR></TABLE>";
if(
eregi( "(<rank>)(.*)(</rank>)", $seti_statistics, $extract_rank )
)
{
$rank
= $extract_rank[2];
if(
eregi( "(<ranktotalusers>)(.*)(</ranktotalusers>)", $seti_statistics,
$extract_ranktotalusers ) )
{
$ranktotalusers
= $extract_ranktotalusers[2];
echo
"My rank is position number ", $rank, " out of ", $ranktotalusers, " total
users<br>";
}
}
if(
eregi( "(<num_samerank>)(.*)(</num_samerank>)", $seti_statistics,
$extract_num_samerank ) )
{
$num_samerank
= $extract_num_samerank[2];
echo
"The number of users who have this rank: ", $num_samerank, "<br>";
}
if(
eregi( "(<top_rankpct>)(.*)(</top_rankpct>)", $seti_statistics, $extract_top_rankpct)
)
{
$top_rankpct=
$extract_top_rankpct[2];
echo
"I have completed more work units than ", 100-$top_rankpct, "% of SETI@home
users<br>";
}
?>