Login     Sign up
problem with modificatet poll script
Max Hartl (@hartlmax)
Join date: Nov 4th 2010
Community posts: 7
View Profile
Send Message

Boys, i have one problem with a poll script, what i want to modificate for my network.

Here can you see the problem.
[url]http://www.swek.net/index.php?p=umfrage[/url]

and here is the code one
[code]<?php
ini_set('display_errors', true);
ini_set('default_mimetype', 'text/html');
ini_set('default_charset', 'ISO-8859-1');
class umfrage {
function index() {
need_login();
section_content(include ("umfrage1.php"));
section_close('Sonntag, 13. März 2011: Was soll SWEK noch zusätzlich bieten?');
}
}
?>[/code]

and here is code two
[code]<?php
$varia=file("fragen.txt");
$frage=array_pop($varia);
echo "$frage";
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
$i=0;
while(isset($varia[$i])) {
$j=$i+1;
echo "<input type=\"radio\" name=\"ant\" value=\"$j\">$varia[$i]<br>";
$i++;
}
echo "<input type=\"submit\" value=\"abstimmen\">";
echo "</form>";
$z=file("antworten.txt");
$ant = isset($_POST['ant']) ? $_POST['ant'] : "";
if ($ant!='') {
$lvote=fopen("lastip.txt","r");
$lv=fgets($lvote,255);
fclose($lvote);
$ip = getenv ("REMOTE_ADDR");
if ($lv!=$ip) {
$z[$ant-1]=$z[$ant-1]+1;
$datei=fopen("antworten.txt","w");
foreach ($z as $save) {fputs($datei,chop($save)."\n");}
fclose($datei);
$lvote=fopen("lastip.txt","w");
fputs($lvote,"$ip");
fclose($lvote);
}
}
$laenge=90;
$gesamt=0;
foreach($z as $zahl)
{ $gesamt=$gesamt+$zahl; }
$proz=array();
foreach ($z as $zahl) {
if ($gesamt!=0) {
$p=round($zahl/$gesamt10000)/100;
array_push($proz,$p);
}
}
$max=1;
foreach ($z as $zahl) {
$zahl=$zahl
10/10;
if($zahl > $max) { $max=$zahl; }
}
$breite=array();
foreach ($z as $zahl)
{
$b=$zahl*$laenge/$max;
array_push($breite,$b);
}
$i=0;
while (isset($z[$i]))
{
echo "$varia[$i]<br>";
echo "<img src=\"balken_blau.gif\" border=\"0\" width=\"$breite[$i]\" height=\"12\" alt=\"$z[$i] Stimmen\">";
$x=$laenge-$breite[$i];
echo "<img src=\"balken_grau.gif\" border=\"0\" width=\"$x\" height=\"12\" alt=\"$z[$i] Stimmen\">";
echo "$proz[$i]%";
echo "<br>";
$i++;
}
echo "<br>Stimmen: $gesamt (100%)";
?>[/code]

I hope someone can help me.

P.S. Sorry for the German Words in the code, but for me is this simple to understand what is mean in this code.

169 months ago