Har fundet noget tror jeg, men når man har oprettet en afstemning skal man vælge om den skal være aktiv og det er der kun en der kan være. Kan nogle lave det om så man udtrække poll.php?id=id'et på afstemningen?
mySQL database:
CREATE TABLE $s[tblname] (
number mediumint(9) NOT NULL auto_increment,
question varchar(200) NOT NULL default '',
a1 varchar(100) default NULL,
a2 varchar(100) default NULL,
a3 varchar(100) default NULL,
a4 varchar(100) default NULL,
a5 varchar(100) default NULL,
n1 mediumint(9) NOT NULL default '0',
n2 mediumint(9) NOT NULL default '0',
n3 mediumint(9) NOT NULL default '0',
n4 mediumint(9) NOT NULL default '0',
n5 mediumint(9) NOT NULL default '0',
p1 tinyint(4) NOT NULL default '0',
p2 tinyint(4) NOT NULL default '0',
p3 tinyint(4) NOT NULL default '0',
p4 tinyint(4) NOT NULL default '0',
p5 tinyint(4) NOT NULL default '0',
votes smallint(6) NOT NULL default '0',
active tinyint(1) NOT NULL default '0',
time int(11) NOT NULL default '0',
PRIMARY KEY (number))
poll.php:
<?PHP
#####################################################################
## ##
## Easy Poll ##
##
http://www.phpwebscripts.com/ ##
## e-mail: info@phpwebscripts.com ##
## copyright (c) 2003 ##
## ##
## > This script is freeware < ##
## You may distribute it by any way ##
## BUT! You may not modify it! ##
## Removing the link to PHPWebScripts.com is a copyright violation.##
## Altering or removing any of the code that is responsible, in ##
## any way, for generating that link is strictly forbidden. ##
## Anyone violating the above policy will have their license ##
## terminated on the spot. Do not remove that link - ever. ##
## ##
#####################################################################
error_reporting (E_ERROR | E_PARSE); if (ini_get("magic_quotes_sybase")) ini_set("magic_quotes_sybase",0); if (!get_magic_quotes_gpc()) ini_set("magic_quotes_gpc",1); if (!get_magic_quotes_runtime()) set_magic_quotes_runtime(1); if ($s[kun]='UG93ZXJlZCBieSBFYXN5IFBvbGw=') $x = 1; else $x = 0; if (ini_get("register_globals")) ini_set("register_globals","Off"); $dbe[number] = $dbe[text] = '';
include("./data/data.php"); $linkid = db_connect(); if (!$linkid) echo sql_error();$s[back] = $HTTP_SERVER_VARS[HTTP_REFERER]; if (!$s[back]) $s[back] = 'index.php';if ($HTTP_GET_VARS[action] == 'vote') vote($HTTP_GET_VARS);$r = $s[phprath].$s[phpruth].$s[kun].'PC9hPjxicj4='; if ((strlen($r))!=136) exit; show_poll();
function vote($data) { global $s,$HTTP_COOKIE_VARS; $a = $HTTP_COOKIE_VARS[EP_vote][$data[number]]; if ($a) { header ("Location: $s[back]"); exit; } setcookie ("EP_vote[$data[number]]",1,time()+2592000);
$q = @mysql_query ("update $s[tblname] set n$data[a]=n$data[a]+1 where number = $data[number] and active = 1"); $q = mysql_query ("select n1,n2,n3,n4,n5 from $s[tblname] where number = $data[number] AND active=1");
$d = @mysql_fetch_array($q); $total = $d[n1]+$d[n2]+$d[n3]+$d[n4]+$d[n5]; $max = max($d[n1],$d[n2],$d[n3],$d[n4],$d[n5]);
if ($max>0) { for ($x=1;$x<=5;$x++) { $size[$x] = ($d["n$x"]/$max)*100; if ($size[$x]<1) $size[$x] = 0; } } else $size[1] = $size[2] = $size[3] = $size[4] = $size[5] = 1;
$q = @mysql_query ("update $s[tblname] set p1 = '$size[1]', p2 = '$size[2]', p3 = '$size[3]', p4 = '$size[4]', p5 = '$size[5]', votes = $total where number = $data[number] and active = 1"); header ("Location: $s[back]"); exit; }
function show_poll() { global $s; $q = mysql_query ("select number,question,votes,a1,a2,a3,a4,a5,n1,n2,n3,n4,n5,p1,p2,p3,p4,p5 from $s[tblname] where active=1"); $data=mysql_fetch_array($q); if (!$data[number]) return false;
for ($x=1;$x<=5;$x++) { if ($data["a$x"]) { $w = $data["p$x"]+1; $data["a$x"] = "<a href=\\\"$s[phpurl]/poll.php?action=vote&number=$data[number]&a=$x\\\"><img border=0 src=\\\"$s[phpurl]/poll.jpg\\\" width=$w height=12><br><font color=\\\"blue\\\" size=\\\"1\\\" face=\\\"Verdana,arial\\\">".$data["a$x"]." (".$data["n$x"]." votes)</font></a><br>"; } } parsejava("$s[phppath]/data/template.txt",$data); }
function parsejava($template, $value) { global $s; $fh = @fopen("$template",'r'); $r = 'document.write("'.eregi_replace('"','\\"',base64_decode($s[phprath]).base64_decode($s[phpruth]).base64_decode($s[kun]).base64_decode('PC9hPjxicj4=')).'");';
while (!feof($fh)) { $line = trim(fgets($fh,4096)); $line = strip_replace_once($line); $line = ereg_replace('"','\"',$line); $lines .= "document.write(\"$line\");\n"; } fclose ($fh);
while (list($key,$val) = each($value)) $lines = str_replace("#%$key%#",$val,$lines); reset ($value); $lines = eregi_replace("#%[a-z0-9_]*%#",'',$lines.$r); echo "\n$lines"; }
function strip_replace_once ($x) { if (!$x) return $x; $x = stripslashes(ereg_replace("''","'",$x)); $x = eregi_replace('&','&',$x); return $x; }
function sql_error() { echo vvv;global $dbe; if(empty($dbe[text])) { $dbe[number] = mysql_errno(); $dbe[text] = mysql_error(); } return "$dbe[number]: $dbe[text]"; }
function strip_replace_array ($a) { if (!$a) return $a; reset ($a); while (list ($k, $v) = each ($a)) { if (is_array($v)) continue; $a[$k] = ereg_replace("''","'",strip_tags($v)); $a[$k] = htmlspecialchars(ereg_replace("[\]",'',$a[$k])); $a[$k] = eregi_replace('&','&',$a[$k]); } return $a; }
function add_slashes_array ($a) { if (!$a) return $a; reset ($a); while (list ($k, $v) = each ($a)) { if (is_array($v)) continue; $a[$k] = addslashes(ereg_replace("''","'",$v)); } return $a; }
function db_connect() { global $s,$dbe; $link_id = mysql_connect($s[dbhost],$s[dbusername],$s[dbpassword]);
if(!$link_id) { $dbe[number] = 0; $dbe[text] = "Unable to connect to the database host $s[dbhost]."; return 0; }
if(empty($s[dbname]) && !mysql_select_db($s[dbname])) { $dbe[number] = mysql_errno(); $dbe[text] = mysql_error(); return 0; }
if(!empty($s[dbname]) && !mysql_select_db($s[dbname])) { $dbe[number] = mysql_errno(); $dbe[text] = mysql_error(); return 0; } return $link_id; }
?>