Piglette's SETI XML Parser
Free PHP script to display your SETI@home statistics on your website

Important update 1 March 2008
Unfortunately the seti@home site no longer appears to be offering an XML feed of individual users' data, so this script sadly does not work any more. I've kept this page up however as an archived example of how you can parse XML data using PHP.

Piglette's SETI XML parser is a free PHP script that you can use on your own website to neatly display your own statistics of how many SETI@home work units your computer has processed, how many hours your PC has devoted to analysing data and information about your rank in relation to other SETI screensaver users. Your own raw statistical information can be obtained in XML form from http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi?cmd=user_xml&email=XXXX (where XXXX is your registered email address). However, because this is in XML format, the raw data needs some processing to ensure it looks nice on your webpage.

Before it is processed the raw data looks something like this:

SETI at home raw XML data

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE userstats SYSTEM "http://setiathome.ssl.berkeley.edu/xml/userstats.dtd">


 <name><a href="http://www.piglette.com" target="new">Piglette's Flowers and Gifts</a></name>
 <cputime>3544 hr 21 min</cputime>
 <avecpu>44 hr 18 min 15.7 sec</avecpu>
 <lastresulttime>Fri Oct  8 19:19:36 2004</lastresulttime>
 <regdate>Sat Jun 26 15:42:47 1999</regdate>
 <usertime>    5.293 years</usertime>


As you can see, the above output would look a bit messy on your webpage, so to display it neatly you can use Piglette's SETI XML parser script in PHP to remove all of the tags and disply the data in a nice tidy table. All you need to ensure is that you have PHP set up on the server that your web site is on. If you're unsure whether you are able to use PHP on your site, your hosting company's own website may say - if not, most hosting companies will be happy to advise you whether your server supports PHP.

You'll need to change the red text I've highlighted below to your own email address. Please be assured that the script does nothing with your email address except pass it to the Berkeley SETI site purely to retrieve your own personal statistics in XML form. The address is not sent to spammers or used in any other way.

Piglette's SETI XML parser script is free to use to display your SETI@home statistics on any site. All I ask is that if you use the script in any form, whether as it is or modified in any way, please link back to this page (or to any page at www.piglette.com you prefer). Sincere thanks for respecting Piglette's hard work.

Piglette's SETI XML parser in PHP


// Change the red text below to the email address that you use for the SETI site.
$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>";


No comments have been provided.

Your Name:

Your Location:

Country (flag):


Please leave a comment.

Security check *

security image

First Discovery of New Extrasolar Planets Methods of Detecting New Extrasolar Planets
Piglette's main SETI@home and UFO page
How the SETI screensaver works Make SETI@home run faster System requirements SETI Screenshot
Piglette's SETI Statistics Piglette's Free SETI XML Statistics Parser
UFO Over China Filmed by Eight Firemen

© Piglette.com