";
$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