<?PHP
ob_start();
session_start();
include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");
protectComponentPage(4);
$sxTitleAddendum = getComponentName("4");
include("themes/$THEME_FOLDER/header.php");
?>
<div class="bodyWrapper">
<h1><?PHP echo getComponentName("4"); ?></h1>
<?PHP
$localPage = "polls.php";
$queryw = "SELECT * FROM $DB_Polls WHERE active='1' ORDER BY id DESC";
$resultw = mysql_query($queryw) or queryError("271", mysql_error());
while ($ROWw = mysql_fetch_object($resultw))
{
echo "<br /><p><strong>" . htmlspecialchars($ROWw->name) . "</strong><br />\n";
// Find total votes or default to 0
$totalVotes = 0;
$queryq = "SELECT * FROM $DB_Polls_Values WHERE pollid='$ROWw->id'";
$resultq = mysql_query($queryq) or queryError("272", mysql_error());
while ($ROWq = mysql_fetch_object($resultq))
$totalVotes = $totalVotes + $ROWq->votes;
if ($totalVotes == 0)
$totalVotes = 0.1;
// Printout values with bar graphs
$queryq = "SELECT * FROM $DB_Polls_Values WHERE pollid='$ROWw->id' ORDER BY id";
$resultq = mysql_query($queryq) or queryError("273", mysql_error());
while ($ROWq = mysql_fetch_object($resultq))
{
$voteWidth = 120 * ($ROWq->votes/$totalVotes);
$percentage = intval(($ROWq->votes/$totalVotes)*100);
echo '<br />' . htmlspecialchars($ROWq->value) . ' (' . $ROWq->votes . ' ' . $sxLang['PollsItemVotes'] . ')<br /><img src="images/px_black.gif" border="1" style="border-color:#FFFFFF;" height="10" width="' . $voteWidth . '" /> <span class="sxPollPercent">'. $percentage . '%</span>';
} // End while
$totalVotes = intval($totalVotes);
echo '<br /><br />' . $sxLang['PollsTotalVotes'] . ': ' . $totalVotes . '</p>';
}
if(mysql_num_rows($resultw) == 0)
echo '<em>' . $sxLang['NoPolls'] . '</em>';
?>
</div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>