Nieuw lid |
|
hi,als je op mijn site gaat http://celeb.clansoil.com klik je op mini poll, vote je, en als je de results ziet,klik je op refresh, dan zul je zien dat je die naam waarop je gevote hebt, nog een stem heeft gekregen. hoe los ik dit op?
<?php
// Deze moet je zeker invullen !!:
$RESULT_FILE_NAME = "poll_data.txt";
// schrijf hier het bestand naar waar hij schrijft
$QUESTION = "Who's your favorite celebrity";
// Schrijf hier de vraag van je poll.
$ANSWER = array("avril lavigne", "britney spears", "brooke burke" ,"carmen electra" , "christina aguilera" , "heidi klum" , "jessica simpson" , "pamela anderson" , "victoria silvstedt");
// zet hier alle antwoorden
$IMG_DIR_URL = "./vote";
// map waar afbeelding voor poll wordt opgeslaan bij deze in de map vote dus
$REVOTE_TIME = 3600;
// Tijd tussen herstemmen
// Begin Poll
/******************************************************************************/
if (! $vote && ! $result) {
echo "<FORM METHOD=\"POST\">\n";
echo "<TABLE WIDTH=100% BORDER=0><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>\n";
echo "<TR><TH style='font-family: Arial; font-size: 10 pt;'><center>$QUESTION</center></TH></TR>\n";
echo "</TABLE>";
while (list($key, $val) = each($ANSWER)) {
echo "<TR><TD><TABLE WIDTH=\"30%\" BORDER=0 cellspacing=0>\n";
echo "<TR><TD align=\"right\" width=20%><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\" style='font-family: Arial; font-size: 10 pt;'></TD><td width=20% style='font-family: Arial; font-size: 10 pt;'>$val</td></TR>\n";
echo "</table>";
}
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n";
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\" See Result \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n";
echo "</TABLE></TD></TR></TABLE></FORM>";
} else {
$file_array = file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME");
// het opslaan van de resultaten
if ($answer < count($ANSWER) && $vote) {
if (count($file_array) < count($ANSWER)) {
$file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n");
}
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w"); //or error("Can not write \$RESULT_FILE_NAME");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
echo "";
}
// weergeven van de resultaten
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<center><h5>Poll results :</h5></center>";
echo "<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0 align=left>";
echo "<tr><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Answer</th><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Percentage</th><th style='font-family: Arial; font-size: 10 pt;' width='40%'> </th></tr>";
while (list($key, $val) = each($ANSWER)) {
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent + (0.5));
$percent_float = number_format($percent, 1);
$tp += $percent_float;
echo "<tr><td style='font-family: Arial; font-size: 10 pt;'> $ANSWER[$key] </td><td style='font-family: Arial; font-size: 10 pt;'><img height=9 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=9 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=9 src=\"$IMG_DIR_URL/vote_right.gif\"><br> $percent_float % ($file_array[$key])</td><td style='font-family: Arial; font-size: 10 pt;' width='%'> </td></tr>";
}
echo "</TABLE><br>";
}
if (isset($HTTP_COOKIE_VARS["votingstep"])) {
setcookie("votingstep","1",time()+1);}
?>
<?php // Deze moet je zeker invullen !!: $RESULT_FILE_NAME = "poll_data.txt"; // schrijf hier het bestand naar waar hij schrijft $QUESTION = "Who's your favorite celebrity"; // Schrijf hier de vraag van je poll. $ANSWER = array("avril lavigne", "britney spears", "brooke burke" ,"carmen electra" , "christina aguilera" , "heidi klum" , "jessica simpson" , "pamela anderson" , "victoria silvstedt"); // zet hier alle antwoorden $IMG_DIR_URL = "./vote"; // map waar afbeelding voor poll wordt opgeslaan bij deze in de map vote dus $REVOTE_TIME = 3600; // Tijd tussen herstemmen // Begin Poll /******************************************************************************/ if (! $vote && ! $result) { echo "<FORM METHOD=\"POST\">\n"; echo "<TABLE WIDTH=100% BORDER=0><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>\n"; echo "<TR><TH style='font-family: Arial; font-size: 10 pt;'><center>$QUESTION</center></TH></TR>\n"; while (list($key, $val) = each($ANSWER)) { echo "<TR><TD><TABLE WIDTH=\"30%\" BORDER=0 cellspacing=0>\n"; echo "<TR><TD align=\"right\" width=20%><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\" style='font-family: Arial; font-size: 10 pt;'></TD><td width=20% style='font-family: Arial; font-size: 10 pt;'>$val</td></TR>\n"; } echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n"; echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\" See Result \" style='font-family: Arial; font-size: 10 pt; font-weight: bold; text-align: center; border-style: solid; border-width: 1'></TD></TR>\n"; echo "</TABLE></TD></TR></TABLE></FORM>"; } else { $file_array = file($RESULT_FILE_NAME); // or error("Can not open \$RESULT_FILE_NAME"); // het opslaan van de resultaten if ($answer < count($ANSWER) && $vote) { $file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"); } $old_answer = $file_array[$answer]; $file_array[$answer] = ($old_answer + 1)."\n"; $file = join('', $file_array); $fp = fopen("$RESULT_FILE_NAME", "w"); //or error("Can not write \$RESULT_FILE_NAME"); } // weergeven van de resultaten while (list($key, $val) = each($file_array)) { $total += $val; } echo "<center><h5>Poll results :</h5></center>"; echo "<TABLE CELLSPACING=2 CELLPADDING=2 BORDER=0 align=left>"; echo "<tr><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Answer</th><th width='30%' style='font-family: Arial; font-size: 10 pt;'>Percentage</th><th style='font-family: Arial; font-size: 10 pt;' width='40%'> </th></tr>"; while (list($key, $val) = each($ANSWER)) { $percent = $file_array[$key] * 100 / $total; $percent_int = floor($percent + (0.5)); $tp += $percent_float; echo "<tr><td style='font-family: Arial; font-size: 10 pt;'> $ANSWER[$key] </td><td style='font-family: Arial; font-size: 10 pt;'><img height=9 src=\"$IMG_DIR_URL/vote_left.gif\"><img height=9 width=\"$percent_int\" src=\"$IMG_DIR_URL/vote_middle.gif\"><img height=9 src=\"$IMG_DIR_URL/vote_right.gif\"><br> $percent_float % ($file_array[$key])</td><td style='font-family: Arial; font-size: 10 pt;' width='%'> </td></tr>"; } } if (isset($HTTP_COOKIE_VARS["votingstep"])) { ?>
|