$tblstart"; if(@mysql_num_rows($mods)) $ismod=1; $pollexists = 0; $pollq=mysql_query("SELECT id,question,briefing,closed,doublevote FROM poll WHERE id=".$thread['poll']); if(@mysql_num_rows($pollq)) $pollexists=1; if( ( (!$action && $ismod && (!$thread[locked] || !$bconf[lockable]) ) || (!$action && $isadmin) || (!$action && $thread[user] == $loguserid && !$thread[closed]) ) && $pollexists) { $poll=mysql_fetch_array($pollq); $pollc=mysql_query("SELECT id,choice,color FROM poll_choices WHERE poll=".$thread['poll']); $choices = ""; $votedfor = 0; while($ch=mysql_fetch_array($pollc)) { $voted = 0; $numvotes = 0; $chvq = "SELECT user FROM pollvotes WHERE poll=".$thread['poll']." AND choice=".$ch['id']; print ""; $chv=mysql_query($chvq); if(@mysql_num_rows($chv)) { $voted=1; $numvotes = mysql_num_rows($chv); } if ($choices!="") $choices .= "
"; $choices.="$inpt=\"choice[".$ch['id']."]\" value=\"".htmlentities($ch['choice'])."\"> (Color: $inpt=\"choicecolor[".$ch['id']."]\" value=\"".htmlentities($ch['color'])."\" size=6 maxlength=6>)"; if (!$voted) $choices.="    Remove"; else { $choices.="   $numvotes vote".($numvotes!=1?"s":""); $votedfor = 1; } } if ($votedfor) { $choices.="

(Choices that have been voted for can't be removed.)"; } $newchoices = "
$inpt=\"choiceadd[]\"> (Color: $inpt=\"choicecoloradd[]\" size=6 maxlength=6>)    Add
"; $thread[icon]=str_replace("","",$thread[icon]); $customicon=$thread[icon]; for($i=0;$posticons[$i];){ $posticons[$i]=str_replace($br,"",$posticons[$i]); if($thread[icon]==$posticons[$i]){ $checked='checked=1'; $customicon=''; } $posticonlist.="    "; $i++; if($i%10==0) $posticonlist.='
'; $checked=''; } if(!$thread[icon]) $checked='checked=1'; $posticonlist.="
$radio=iconid value=-1 $checked>  None     Custom: $inpt=custposticon VALUE='$customicon' SIZE=40 MAXLENGTH=100> "; $check1[$poll[closed]]='checked=1'; $check2[$poll[doublevote]]='checked=1'; $forums=mysql_query("SELECT id,title FROM forums WHERE minpower<=$power ORDER BY forder"); while($forum=mysql_fetch_array($forums)){ $checked=''; if($thread[forum]==$forum[id]) $checked='selected'; $forummovelist.=""; } $onsubmithook = '="if(usingBetterWay){startGather();return false;}else{alert(\'was going to post\');return false;}"'; print "
$tccellh colspan=2>Editing poll for thread ".($thread[icon]!=""?" ":"").$thread['title']." $tccell1>Poll question: $tccell2l>$inpt=pollqu VALUE=\"$poll[question]\" SIZE=40 MAXLENGTH=100> $tccell1>Poll briefing: $tccell2l>$inpt=pollbr VALUE=\"$poll[briefing]\" SIZE=40 MAXLENGTH=100> $tccell1>Poll status: $tccell2l>$radio=pollclosed value=0 $check1[0]> Open   $radio=pollclosed value=1 $check1[1]>Closed $tccell1>Multiple voting: $tccell2l>$radio=polldbl value=0 $check2[0]> Disabled   $radio=polldbl value=1 $check2[1]>Enabled $tccell1>Choices: $tccell2l>$choices $tccell1>New choices: $tccell2l>$newchoices "./* $tccell1>Forum $tccell2l> Delete thread*/" $tccell1> $tccell2l> $inph=action VALUE=editpoll>$inph=id VALUE=$id> $inps=doedit onclick$onsubmithook VALUE=\"Edit poll\">
$tblend "; } if($_POST[action]=='editpoll'){ if(($ismod && (!$thread[locked] || !$bconf[lockable])) || ($isadmin) || ($thread[user] == $loguserid && !$thread[closed])){ print " $tccell1>Thank you, $loguser[name], for editing the poll.
"; if (!is_debug()) { print redirect("thread.php?id=$id",'return to the thread',0); } debugprint("$tblend$tblstart$tccellh>Edit poll debug data$tccell1l>
");

      $divisor = "----------------------------------";

	  $ch = $co = "";
	  debugprint("WOULD HAVE INSERTED:

"); if($createdWithPassthru == "yes") { if (is_array($choiceaddjs)) { debugprint("JAVASCRIPT INSERTS:
------
"); foreach($choiceaddjs as $i=>$ch) { $co = $choicecoloraddjs[$i]; // cleaning poll color: $co = preg_replace("'^#(.*?)$'", "\\1", $co); // remove prefix # if given $co = preg_replace("'[^a-zA-Z0-9]'", "", $co); // only alphanumerics, please $co = substr($co, 0, 6); // and cut at six chars of length debugprint("INSERT INTO poll_choices (id,poll,choice,color) VALUES (NULL,".$thread['poll'].",'".addslashes(stripslashes($ch))."','".addslashes(stripslashes($co))."')
"); mysql_query("INSERT INTO poll_choices (id,poll,choice,color) VALUES (NULL,".$thread['poll'].",'".addslashes(stripslashes($ch))."','".addslashes(stripslashes($co))."')"); } } } else { if (is_array($choiceadd) && $choiceadddoadd) { debugprint("NON-JAVASCRIPT INSERTS:
------
"); foreach($choiceadd as $i=>$ch) { $co = $choicecoloradd[$i]; // cleaning poll color: $co = preg_replace("'^#(.*?)$'", "\\1", $co); // remove prefix # if given $co = preg_replace("'[^a-zA-Z0-9]'", "", $co); // only alphanumerics, please $co = substr($co, 0, 6); // and cut at six chars of length debugprint ("INSERT INTO poll_choices (id,poll,choice,color) VALUES (NULL,".$thread['poll'].",'".addslashes(stripslashes($ch))."','".addslashes(stripslashes($co))."')
"); mysql_query("INSERT INTO poll_choices (id,poll,choice,color) VALUES (NULL,".$thread['poll'].",'".addslashes(stripslashes($ch))."','".addslashes(stripslashes($co))."')"); } } } $pollc=mysql_query("SELECT id,choice,color FROM poll_choices WHERE poll=".$thread['poll']); while($pc = mysql_fetch_array($pollc)) { $pollchoices[$pc['id']] = $pc; } if (is_array($choice)) { debugprint("
CHANGED ITEMS:
------
"); foreach($choice as $i=>$ch) { $i = intval($i); $co = $choicecolor[$i]; // cleaning poll color: $co = preg_replace("'^#(.*?)$'", "\\1", $co); // remove prefix # if given $co = preg_replace("'[^a-zA-Z0-9]'", "", $co); // only alphanumerics, please $co = substr($co, 0, 6); // and cut at six chars of length if ($choiceremove[$i]) { if (@mysql_num_rows(mysql_query("SELECT * FROM pollvotes WHERE choice=$id"))>0) { debugprint("WON'T DELETE CHOICE \"$ch\" (COLOR \"$co\") - HAS VOTES
"); } else { debugprint("DELETE FROM poll_choices WHERE id=$i
"); mysql_query("DELETE FROM poll_choices WHERE id=$i"); debugprint(" # CHOICE \"$ch\" (COLOR \"$co\")
"); } } else if (($ch != $pollchoices[$i]['choice'] && trim($ch) != "") || ($co != $pollchoices[$i]['color'] && trim($co) != "")) { debugprint("UPDATE poll_choices SET choice='".addslashes(stripslashes($ch))."', color='".addslashes(stripslashes($co))."' WHERE id=$i
"); mysql_query("UPDATE poll_choices SET choice='".addslashes(stripslashes($ch))."', color='".addslashes(stripslashes($co))."' WHERE id=$i"); debugprint(" # CHOICE \"$ch\" (COLOR \"$co\")
"); } else { debugprint("WON'T CHANGE CHOICE \"$ch\" (COLOR \"$co\") - NOT CHANGED OR EMPTY COLOR/CHOICE
"); } } } debugprint("
OTHER CHANGES:
-----
"); $pollclosed = intval($pollclosed); $polldbl = intval($polldbl); debugprint("UPDATE poll SET question='".addslashes(stripslashes($pollqu))."',briefing='".addslashes(stripslashes($pollbr))."',closed=$pollclosed,doublevote=$polldbl WHERE id=".$thread['poll']."
"); mysql_query("UPDATE poll SET question='".addslashes(stripslashes($pollqu))."',briefing='".addslashes(stripslashes($pollbr))."',closed=$pollclosed,doublevote=$polldbl WHERE id=".$thread['poll']); debugprint("
$divisor

_POST:"); if (is_debug()) { print_r($_POST); } debugprint("
"); print $tblend; /* $posticons[$iconid]=str_replace("\n",'',$posticons[$iconid]); if(!$delete){ $icon=$posticons[$iconid]; if($custposticon) $icon=$custposticon; mysql_query("INSERT INTO actionlog (atime, adesc, aip) VALUES (".ctime().", \"User ".$loguserid." edited thread $id\", \"$userip\")"); mysql_query("UPDATE threads SET forum=$forummove,closed=$closed,title='".addslashes($subject)."',icon='".addslashes($icon)."',sticky=$sticky WHERE id=$id"); if($forummove!=$forumid){ mysql_query("INSERT INTO actionlog (atime, adesc, aip) VALUES (".ctime().", \"User ".$loguserid."moved thread $id from $forumid to $forummove\", \"$userip\")"); $numposts=$thread[replies]+1; $t1=mysql_fetch_array(mysql_query("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forumid ORDER BY lastpostdate DESC LIMIT 1")); $t2=mysql_fetch_array(mysql_query("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forummove ORDER BY lastpostdate DESC LIMIT 1")); mysql_query("UPDATE forums SET numposts=numposts-$numposts,numthreads=numthreads-1,lastpostdate=$t1[lastpostdate],lastpostuser=$t1[lastposter] WHERE id=$forumid"); mysql_query("UPDATE forums SET numposts=numposts+$numposts,numthreads=numthreads+1,lastpostdate=$t2[lastpostdate],lastpostuser=$t2[lastposter] WHERE id=$forummove"); } }else{ mysql_query("INSERT INTO actionlog (atime, adesc, aip) VALUES (".ctime().", \"User ".$loguserid." deleted thread $id - ip $REMOTE_ADDR\", \"$userip\")"); mysql_query("DELETE FROM threads WHERE id=$id"); mysql_query("DELETE FROM posts WHERE thread=$id"); $numdeletedposts=$thread[replies]+1; $t1=mysql_fetch_array(mysql_query("SELECT lastpostdate,lastposter FROM threads WHERE forum=$forumid ORDER BY lastpostdate DESC LIMIT 1")); mysql_query("UPDATE forums SET numposts=numposts-$numdeletedposts,numthreads=numthreads-1,lastpostdate=$t1[lastpostdate],lastpostuser=$t1[lastposter] WHERE id=$forumid"); }*/ }else print " $tccell1 Couldn't edit the poll. Either you didn't enter an existing username, or you haven't entered the right password for the username, or you are not allowed to edit this poll.
".redirect("thread.php?id=$id",'return to the poll',0); } print $footer; if($stamptime){printtimedif($startingtime);} ?>