$fonthead"; print $header; replytoolbar(1); print "
"; $userid=checkuser($username,$password); $user=$users[$userid]; $username=$users[$loguserid][name]; /* if($user[powerlevel]<0) $userid=-1; if($userid!=-1){ */ $caneditpoll=0; if($ismod or $loguserid==$thread[user]) $caneditpoll=1; $mods=mysql_query("SELECT user FROM forummods WHERE forum=$forumid and user=$loguserid"); if(@mysql_num_rows($mods)>0 and $logpwenc) $caneditpoll=1; if ($caneditpoll) { if($submit){ $currenttime=ctime(); $postnum=$user[posts]+1; if ($doublevote == "yes") { $doublevote = 1; } else { $doublevote=0; } if ($closed == "yes") { $closed = 1; } else { $closed=0; } mysql_query("UPDATE poll SET question='".addslashes($pollquestion)."',briefing='".addslashes($pollbriefing)."',closed=$closed,doublevote=$doublevote WHERE id=$id"); mysql_query("DELETE FROM poll_choices WHERE poll=$id"); foreach ($pollchoices as $chid => $data) { $ccolor = $data[color]; print ""; $cname = $data[choice]; mysql_query("INSERT INTO poll_choices (choice,color,poll) VALUES ('".addslashes($cname)."','".addslashes($ccolor)."',$id)"); $moo = mysql_affected_rows(); print ""; } $getid = mysql_fetch_array(mysql_query("SELECT id FROM threads WHERE pollid=$id LIMIT 1")); $getid = $getid[id]; print " $tccell1 Thank you, $username, for editing the poll.
".redirect("thread.php?id=$getid","go back to the poll",0)."
"; } else { if (!$firsttimepassed) { $getpolldata = mysql_query("SELECT question,briefing,closed,doublevote FROM poll WHERE id=$id"); while($data=mysql_fetch_array($getpolldata)){ $pollquestion = $data['question']; $pollbriefing = $data['briefing']; $pollclosed = $data['closed']; $polldbl = $data['doublevote']; if ($polldbl == 1) { $polldbl = "yes"; } else { $polldbl = "no"; } if ($pollclosed == 1) { $closed = "yes"; } } $getchoices = mysql_query("SELECT id,poll,choice,color FROM poll_choices WHERE poll=$id"); while($data=mysql_fetch_array($getchoices)){ $choiceno = count($pollchoices)+1; if (count($pollchoices) == 1 && !is_array($pollchoices)) { $choiceno = 1; } $choicebyid[$data[id]] = $data[choice]; $pollchoices[$choiceno] = array('color' => $data[color], 'choice' => $data[choice], 'id' => $data[id]); } $getvotes = mysql_query("SELECT id,choice,user FROM poll_votes WHERE poll=$id"); while($data=mysql_fetch_array($getvotes)){ $votes[$data[$id]] = array('user' => $data[user], 'choice' => $data[choice]); $votesname[$data[$id]] = $data[user]; print ""; } } $getusr = mysql_query("SELECT id,name FROM users"); while($data=mysql_fetch_array($getusr)){ $voteusers[$data[id]] = $data[name]; } if ($addchoice) { $choiceno = count($pollchoices)+1; if (count($pollchoices) == 1 && !is_array($pollchoices)) { $choiceno = 1; } $pollchoices[$choiceno] = array('color' => $polladdcolor, 'choice' => $polladdchoice); } if ($removechoice) { $pc2 = $pollchoices; foreach($pc2 as $ccid=>$data) { if ($ccid != $torem) { $pc3[$ccid] = $data; } } $pollchoices = $pc3; /* $key_index = array_keys(array_keys($pollchoices), array_pop($removechoice)); array_splice($pollchoices, $key_index[0], 1); */ mysql_query("DELETE FROM poll_choices WHERE id=$torem"); } /* if ($removevote) { $torem = array_pop($removevote); $key_index = array_keys(array_keys($votes), $torem); array_splice($votes, $key_index[0], 1); foreach($votes as $vid => $val) { $newvotes[$vid] = $val; } $votes = $newvotes; mysql_query("DELETE FROM poll_votes WHERE id=$torem"); if (count($votes)==0 && isset($votes)) { unset($votes); } } */ print " $tccellha width=250$tccellhb $tccellh 
$inph=firsttimepassed VALUE=1> $inph=torem VALUE=\"\"> $inph=id VALUE=\"$id\">"; if ($polldbl == "yes") { $doublevote = "$radio=polldbl VALUE=\"yes\" CHECKED> Allow double voting $radio=polldbl VALUE=\"no\"> Don't allow double voting"; } else { $doublevote = "$radio=polldbl VALUE=\"yes\"> Allow double voting $radio=polldbl VALUE=\"no\" CHECKED> Don't allow double voting"; } if ($pollclosed == "yes") { $closed = "$radio=pollclosed VALUE=\"yes\" CHECKED> Voting is closed $radio=pollclosed VALUE=\"no\"> Voting is not closed"; } else { $closed = "$radio=pollclosed VALUE=\"yes\"> Voting is closed $radio=pollclosed VALUE=\"no\" CHECKED> Voting is not closed"; } $tcheader = "$tccellha colspan=2 $tccellhb"; $halfcols = $numcols/2; print "$tcheader Poll setup $tccell1Poll question: $tccell2l$inpt=pollquestion VALUE=\"".aslash($pollquestion)."\"> $tccell1Poll briefing: $tccell2l$txta=pollbriefing ROWS=10 COLS=".$halfcols.">$pollbriefing $tccell1Poll options: $tccell2l$doublevote
$closed $tcheader Choices"; if (is_array($pollchoices)) { $m=0; foreach($pollchoices as $cid => $data) { $m++; $choicescode .= "$tccell1Choice ".$m."$tccell2l$inpt=\"pollchoices[$cid][choice] \" VALUE=\"".aslash($data['choice'])."\"> Color: $inpt=\"pollchoices[$cid][color]\" VALUE=\"".aslash($data['color'])."\"> $inps=\"removechoice\" onClick=\"window.document.REPLIER.torem.value='$cid';\" VALUE=\"Remove\">"; } } print "$choicescode $tccell1Add choice$tccell2l$inpt=\"polladdchoice\" VALUE=\"\"> Color: $inpt=\"polladdcolor\" VALUE=\"\"> $inps=\"addchoice\" VALUE=\"Add choice\">"; /* if (is_array($votes) && !empty($votes)) { $votescode .= "$tcheader Votes"; foreach($votes as $vid => $data) { $votescode .= "$tccell1 $tccell2l".$choicebyid[$data[choice]]." -- ".$voteusers[$votesname[$vid]]."$inph=votes[$vid][choice] VALUE=\"".$data['choice']."\">$inph=votes[$cid][id] VALUE=\"".$data['id']."\"> $inps=removevote[$cid] VALUE=\"Remove\">"; } } print "$votescode"; print "$tccell1 $tccell2l
";
                print_r ($votesname);
                print "
"; print_r ($voteusers); */ print "$tccell1 $tccell2l$inps=submit VALUE=\"Edit poll\">"; } }else{ print " $tccell1 Couldn't enter the post. Either you didn't enter an existing username, or you haven't entered the right password for the username, or you haven't entered a subject.
".redirect("forum.php?id=$id","return to the forum",0).""; } print $footer; printtimedif($startingtime); ?>