<?php
// Daten für Verbindung zur Datenbank
$dbhost = " * ";
$dbuser = " * ";
$dbpassword = " * ";
$dbdatabase = " * ";
// Präfix
$prefix = " * ";
define(TABLE_PREFIX, $prefix);
// URL zum Forum
// Url zur polls.php deines Forums - Bitte nur bis Zum Urdner!
$url =" * ";
// lang Variabeln:
$lang_poll ="";
$lang_total_votes ="St";
// Verbindung zur Datenbank aufnehmen
$db = mysql_connect($dbhost,$dbuser,$dbpassword) or die ("Verbindung fehlgeschlagen");
mysql_select_db($dbdatabase,$db);
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."polls WHERE extpoll='1' ORDER by pid desc");
$poll = mysql_fetch_array($query);
$poll['timeout'] = $poll['timeout']*60*60*24;
$expiretime = $poll['dateline'] + $poll['timeout'];
$now = time();
if($poll['closed'] == "yes" || ($expiretime < $now && $poll['timeout'] > 0))
{
$showresults = 1;
};
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."pollvotes WHERE pid='".$poll[pid]."'");
while($votecheck = mysql_fetch_array($query))
{
$alreadyvoted = 1;
$votedfor[$votecheck['voteoption']] = 1;
}
$optionsarray = explode("||~|~||", $poll['options']);
$votesarray = explode("||~|~||", $poll['votes']);
for($i=1;$i<=$poll['numoptions'];$i++) {
$poll['totvotes'] = $poll['totvotes'] + $votesarray[$i-1];
}
$poll['question'] = addslashes($poll['question']);
for($i=1;$i<=$poll['numoptions'];$i++) {
$option = $optionsarray[$i-1];
$votes = $votesarray[$i-1];
$number = $i;
if($votedfor[$number]) {
$votestar = "";
} else {
$votestar = "";
}
if($alreadyvoted || $showresults) {
if (intval($votes) == "0"){
$percent = "0";
} else{
$percent = ($votes / $poll['totvotes'] * 100);
}
$imagewidth = (round($percent)/3) * 5;
$polloptions .=
"<tr>
<td align='left' border='0' bgcolor='#202427'><font color='#FFFFFF' face='Verdana' size='1'>$option</td>
<td cellpadding='2' align='center' border='0' bgcolor='#202427'><font color='#FFFFFF' face='Verdana' size='1'>$percent%</td>
</tr>";
} else {
if($poll['multiple'] == "yes") {
$polloptions .=
"<tr>
<td border='0' width='5%'><input type='checkbox' name='option[$number]' value='yes'></td>
<td border='0' colspan='3' ><font color='#FFFFFF' face='Verdana' size='1'>$option</td>
</tr>";
} else {
$polloptions .=
"<tr>
<td border='0' width='5%'><input type='radio' name='option' value='$number'></td>
<td border='0' colspan='3'><font color='#FFFFFF' face='Verdana' size='1'>$option</td>
</tr>";
}
}
}
if($poll['totvotes'])
{
$totpercent = "100%";
}
else
{
$totpercent = "0%";
}
if($alreadyvoted || $showresults) {
#$lang->total_votes = sprintf($lang->total_votes, $poll['numvotes']);
$pollbox = "<body bgcolor='#202427' topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0'><table border='0' bgcolor='#202427' cellspacing='0' cellpadding='2'>
<tr>
<td colspan='2' border='0' align='center' bgcolor='#202427'><font color='#FFFFFF' face='Verdana' size='1'><strong>$poll[question]</strong><br /></td>
</tr>
$polloptions
<tr>
<td align='center'><font color='#FFFFFF' face='Verdana' size='1'><strong>".$poll['numvotes']." $lang_total_votes</strong></td>
<td align='center'><font color='#FFFFFF' face='Verdana' size='1'><strong>$totpercent</strong></td>
</tr>
<br />";
echo "$pollbox";
} else {
$pollbox =
"<form target='_parent' action='$url/polls.php' method='get'>
<input type='hidden' name='action' value='vote' />
<input type='hidden' name='pid' value='$poll[pid]' />
<table border='0' cellspacing='1' cellpadding='1'>
<tr>
<td colspan='2' align='center' border='0' bgcolor='#202427'><font color='#FFFFFF' face='Verdana' size='1'><strong>$poll[question]</strong></td>
</tr>
$polloptions
</table>
<table cellspacing='0' cellpadding='3' border='0' align='center'>
<td><input type='submit' value='Vote' /></td>
</tr>
</table>
</form>";
echo "$pollbox";
}
?>