xml;
$lines = explode("\n", $xml);
foreach ($lines as $line) {
$matches = array();
$retval = ereg('<([^>]*)>([^<]*)', $line, $matches);
$tag = $matches[1];
$val = $matches[2];
$x[$tag] = $val;
}
return $x;
}
function parse_xml($resp, &$sums) {
global $last_time;
$xml = $resp->xml;
$lines = explode("\n", $xml);
foreach ($lines as $line) {
$matches = array();
$retval = ereg('<([^>]*)>([^<]*)', $line, $matches);
$tag = $matches[1];
$val = $matches[2];
if (strstr($tag, 'text')) {
if ($val && $resp->update_time > 1197202264) {
$val = str_replace("\\r\\n", "\n", urldecode($val));
$val = str_replace('\\\\\\', '', $val);
$d = gmdate("g:i A \U\T\C, F d Y", $resp->update_time);
$sums[$tag][] = "$d
$val";
}
} else {
if ($val) {
$sums[$tag][$val]++;
}
}
}
}
function bar($n, $ntotal) {
if ($ntotal==0) {
return "$n ";
}
$w = (int)(100*$n/$ntotal);
if (!$w) $w=1;
return " $n ";
}
function other_link($sums, $other_name, $link_text, $ntotal) {
$y = "";
$n = count($sums[$other_name]);
if ($n) {
$fname = "poll_$other_name.html";
$b = bar($n, $ntotal);
$y .= "$b $link_text";
$f = fopen($fname, "w");
$old_name = str_replace(".html", ".old.html", $fname);
fwrite($f, "Old responses
"; list_start(); list_bar('Do you run BOINC?'); display_choices($sums, $overall_choices); list_bar('Your participation'); display_choices($sums, $project_items); list_bar('Your computers'); display_choices($sums, $comp_items); list_bar('You'); display_choices($sums, $you_items); display_countries($sums); list_bar('Comments'); list_item2( "Please suggest ways that BOINC, and the projects that use it, could be improved:", other_link($sums, $improved, "Show", 0) ); list_end(); page_tail(true); $f = fopen($cachefile, "w"); fwrite($f, ob_get_contents()); fclose($f); ?>