\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) {
if ($n < 20) continue;
$ntotal += $n;
}
foreach ($sums['country'] as $country=>$n) {
if ($n < 20) continue;
$c = urldecode($country);
$b = bar($n, $ntotal);
$y .= "$b $c
";
}
list_item2("Nationality", $y);
}
$sums = array();
$result = mysql_query("select * from response order by update_time");
while ($resp = mysql_fetch_object($result)) {
parse_xml($resp, $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(true);
$f = fopen($cachefile, "w");
fwrite($f, ob_get_contents());
fclose($f);
?>