Código PHP:
include('./functions.php'); $s[back] = getenv('HTTP_REFERER'); if (!$s[back]) $s[back] = $s[after_url]; if ($_GET[action]=='vote') vote($_GET); show_poll();
##################################################################################
function vote($data) { global $s; $a = $_COOKIE[EP_vote][$data[number]]; if ($a) { header ("Location: $s[back]"); exit; }
setcookie ("EP_vote[$data[number]]",1,time()+2592000);
dq("update $s[tblname] set n$data[a] = n$data[a]+1 where number = '$data[number]' and active = '1'",1); $q = dq("select n1,n2,n3,n4,n5 from $s[tblname] where number = '$data[number]' AND active='1'",1);
$d = mysql_fetch_assoc($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 = dq("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",1); header ("Location: $s[back]"); exit; }
function show_poll() { global $s; $q = dq("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",1); $data = mysql_fetch_assoc($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=18><br><font color=\\\"gray\\\" 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]).'<span style="font-size:8pt;">'.base64_decode($s[kun]).'</span>'.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"; }
##################################################################################
?>