]*)>([^<]*)', $line, $matches); $tag = $matches[1]; $val = $matches[2]; if (strstr($tag, 'text')) { if ($val) { $sums[$tag][] = str_replace("\\r\\n", "\n", urldecode($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.txt"; $b = bar($n, $ntotal); $y .= "$b $link_text"; $f = fopen($fname, "w"); foreach ($sums[$other_name] as $text) { fwrite($f, $text); fwrite($f, "\n-----------------\n"); } fclose($f); } else { $y .= "$link_text"; } return $y; } function display_choice($sums, $choice, $ntotal) { global $run_boinc; $text = $choice['text']; $rname = $choice['rname']; $radio_name = $choice['radio_name']; if ($rname) { $n = $sums[$run_boinc][$rname]; if (!$n) $n = 0; $b = bar($n, $ntotal); $x = "$b $text\n"; } else { $x = "$text\n"; } $y = ""; if ($radio_name) { $ntotal = 0; foreach($choice['options'] as $name=>$text) { $ntotal += $sums[$radio_name][$name]; } foreach($choice['options'] as $name=>$text) { $n = $sums[$radio_name][$name]; if (!$n) $n = 0; $b = bar($n, $ntotal); $y .= "$b $text
\n"; } } else { $ntotal = 0; foreach($choice['options'] as $name=>$text) { $n = $sums[$name]['on']; if ($n > $ntotal) $ntotal = $n; } $other_name = $choice['other_name']; $n = count($sums[$other_name]); if ($n > $ntotal) $ntotal = $n; foreach($choice['options'] as $name=>$text) { $n = $sums[$name]['on']; if (!$n) $n = 0; $b = bar($n, $ntotal); $y .= "$b $text
\n"; } $other_name = $choice['other_name']; $y .= other_link($sums, $other_name, "Other", $ntotal); } list_item2($x, $y); } function display_choices($sums, $choices) { global $run_boinc; $n = 0; $rname = $choices[0]['rname']; if ($rname) { foreach($choices as $choice) { $rname = $choice['rname']; $n += $sums[$run_boinc][$rname]; } } foreach($choices as $choice) { display_choice($sums, $choice, $n); } } function display_countries($sums) { $y = ""; $ntotal = 0; foreach ($sums['country'] as $country=>$n) { $ntotal += $n; } foreach ($sums['country'] as $country=>$n) { $c = urldecode($country); $b = bar($n, $ntotal); $y .= "$b $c
"; } list_item2("Nationality", $y); } $sums = array(); $result = mysql_query("select * from response"); while ($resp = mysql_fetch_object($result)) { parse_xml($resp->xml, $sums); } //print_r($sums); page_head(tr(POLL_RESULTS_TITLE)); echo tr(POLL_RESULTS_TEXT)."

"; 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(); $f = fopen($cachefile, "w"); fwrite($f, ob_get_contents()); fclose($f); ?>