Zeile 46 | Zeile 46 |
---|
if($mybb->input['action'] == "newpoll") { // Form for new poll
|
if($mybb->input['action'] == "newpoll") { // Form for new poll
|
$tid = $mybb->get_input('tid', 1);
| $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
|
$plugins->run_hooks("polls_newpoll_start");
|
$plugins->run_hooks("polls_newpoll_start");
|
$thread = get_thread($mybb->get_input('tid', 1));
| $thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
|
if(!$thread) { error($lang->error_invalidthread); }
// Is the currently logged in user a moderator of this forum?
|
if(!$thread) { error($lang->error_invalidthread); }
// Is the currently logged in user a moderator of this forum?
|
if(is_moderator($thread['fid'])) { $ismod = true; } else { $ismod = false; }
| $ismod = is_moderator($thread['fid']);
|
// Make sure we are looking at a real thread here. if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true)) { error($lang->error_invalidthread); }
|
// Make sure we are looking at a real thread here. if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true)) { error($lang->error_invalidthread); }
|
|
|
$fid = $thread['fid']; $forumpermissions = forum_permissions($fid);
// Get forum info $forum = get_forum($fid); if(!$forum)
|
$fid = $thread['fid']; $forumpermissions = forum_permissions($fid);
// Get forum info $forum = get_forum($fid); if(!$forum)
|
{
| {
|
error($lang->error_invalidforum); } else
| error($lang->error_invalidforum); } else
|
Zeile 104 | Zeile 97 |
---|
if($thread['poll']) { error($lang->error_pollalready);
|
if($thread['poll']) { error($lang->error_pollalready);
|
}
| }
|
$time = TIME_NOW; if($thread['dateline'] < ($time-($mybb->settings['polltimelimit']*60*60)) && $mybb->settings['polltimelimit'] != 0 && $ismod == false)
| $time = TIME_NOW; if($thread['dateline'] < ($time-($mybb->settings['polltimelimit']*60*60)) && $mybb->settings['polltimelimit'] != 0 && $ismod == false)
|
Zeile 114 | Zeile 107 |
---|
}
// Sanitize number of poll options
|
}
// Sanitize number of poll options
|
if($mybb->get_input('numpolloptions', 1) > 0)
| if($mybb->get_input('numpolloptions', MyBB::INPUT_INT) > 0)
|
{
|
{
|
$mybb->input['polloptions'] = $mybb->get_input('numpolloptions', 1);
| $mybb->input['polloptions'] = $mybb->get_input('numpolloptions', MyBB::INPUT_INT);
|
}
|
}
|
if($mybb->settings['maxpolloptions'] && $mybb->get_input('polloptions', 1) > $mybb->settings['maxpolloptions'])
| if($mybb->settings['maxpolloptions'] && $mybb->get_input('polloptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions'])
|
{ // Too big $polloptions = $mybb->settings['maxpolloptions']; }
|
{ // Too big $polloptions = $mybb->settings['maxpolloptions']; }
|
elseif($mybb->get_input('polloptions', 1) < 2)
| elseif($mybb->get_input('polloptions', MyBB::INPUT_INT) < 2)
|
{ // Too small $polloptions = 2; } else { // Just right
|
{ // Too small $polloptions = 2; } else { // Just right
|
$polloptions = $mybb->get_input('polloptions', 1);
| $polloptions = $mybb->get_input('polloptions', MyBB::INPUT_INT);
|
}
$question = htmlspecialchars_uni($mybb->get_input('question'));
$postoptionschecked = array('public' => '', 'multiple' => '');
|
}
$question = htmlspecialchars_uni($mybb->get_input('question'));
$postoptionschecked = array('public' => '', 'multiple' => '');
|
$postoptions = $mybb->get_input('postoptions', 1);
| $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_INT);
|
if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1) { $postoptionschecked['multiple'] = 'checked="checked"';
| if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1) { $postoptionschecked['multiple'] = 'checked="checked"';
|
Zeile 144 | Zeile 137 |
---|
$postoptionschecked['public'] = 'checked="checked"'; }
|
$postoptionschecked['public'] = 'checked="checked"'; }
|
$options = $mybb->get_input('options', 2);
| $options = $mybb->get_input('options', MyBB::INPUT_ARRAY);
|
$optionbits = ''; for($i = 1; $i <= $polloptions; ++$i) {
| $optionbits = ''; for($i = 1; $i <= $polloptions; ++$i) {
|
Zeile 158 | Zeile 151 |
---|
$option = ""; }
|
$option = ""; }
|
if($mybb->get_input('timeout', 1) > 0)
| if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)
|
{
|
{
|
$timeout = $mybb->get_input('timeout', 1);
| $timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);
|
} else { $timeout = 0;
|
} else { $timeout = 0;
|
} if($mybb->get_input('maxoptions', 1) > 0 && $mybb->get_input('maxoptions', 1) < $polloptions) { $maxoptions = $mybb->get_input('maxoptions', 1); }
| }
if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $polloptions) { $maxoptions = $mybb->get_input('maxoptions', MyBB::INPUT_INT); }
|
else { $maxoptions = 0; }
|
else { $maxoptions = 0; }
|
|
|
$plugins->run_hooks("polls_newpoll_end");
eval("\$newpoll = \"".$templates->get("polls_newpoll")."\";"); output_page($newpoll); } if($mybb->input['action'] == "do_newpoll" && $mybb->request_method == "post")
|
$plugins->run_hooks("polls_newpoll_end");
eval("\$newpoll = \"".$templates->get("polls_newpoll")."\";"); output_page($newpoll); } if($mybb->input['action'] == "do_newpoll" && $mybb->request_method == "post")
|
{
| {
|
// Verify incoming POST request verify_post_check($mybb->get_input('my_post_key'));
$plugins->run_hooks("polls_do_newpoll_start");
|
// Verify incoming POST request verify_post_check($mybb->get_input('my_post_key'));
$plugins->run_hooks("polls_do_newpoll_start");
|
$thread = get_thread($mybb->get_input('tid', 1));
| $thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
|
if(!$thread) { error($lang->error_invalidthread);
| if(!$thread) { error($lang->error_invalidthread);
|
Zeile 210 | Zeile 203 |
---|
{ // Doesn't look like it is error($lang->error_closedinvalidforum);
|
{ // Doesn't look like it is error($lang->error_closedinvalidforum);
|
} }
| } }
|
// No permission if: Not thread author; not moderator; no forum perms to view, post threads, post polls if(($thread['uid'] != $mybb->user['uid'] && !is_moderator($fid, "canmanagepolls")) || ($forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $forumpermissions['canpostpolls'] == 0))
|
// No permission if: Not thread author; not moderator; no forum perms to view, post threads, post polls if(($thread['uid'] != $mybb->user['uid'] && !is_moderator($fid, "canmanagepolls")) || ($forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0 || $forumpermissions['canpostpolls'] == 0))
|
{
| {
|
error_no_permission();
|
error_no_permission();
|
}
| }
|
if($thread['poll']) { error($lang->error_pollalready); }
|
if($thread['poll']) { error($lang->error_pollalready); }
|
$polloptions = $mybb->get_input('polloptions', 1);
| $polloptions = $mybb->get_input('polloptions', MyBB::INPUT_INT);
|
if($mybb->settings['maxpolloptions'] && $polloptions > $mybb->settings['maxpolloptions'])
|
if($mybb->settings['maxpolloptions'] && $polloptions > $mybb->settings['maxpolloptions'])
|
{
| {
|
$polloptions = $mybb->settings['maxpolloptions']; }
|
$polloptions = $mybb->settings['maxpolloptions']; }
|
$postoptions = $mybb->get_input('postoptions', 2);
| $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
|
if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1') { $postoptions['multiple'] = 0;
| if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1') { $postoptions['multiple'] = 0;
|
Zeile 246 | Zeile 239 |
---|
$polloptions = "2"; } $optioncount = "0";
|
$polloptions = "2"; } $optioncount = "0";
|
$options = $mybb->get_input('options', 2);
| $options = $mybb->get_input('options', MyBB::INPUT_ARRAY);
|
for($i = 1; $i <= $polloptions; ++$i) {
| for($i = 1; $i <= $polloptions; ++$i) {
|
Zeile 255 | Zeile 248 |
---|
$options[$i] = ''; }
|
$options[$i] = ''; }
|
if(trim($options[$i]) != "")
| if($mybb->settings['polloptionlimit'] != 0 && my_strlen($options[$i]) > $mybb->settings['polloptionlimit']) { $lengtherror = 1; break; }
if(strpos($options[$i], '||~|~||') !== false) { $sequenceerror = 1; break; } if(trim($options[$i]) != "")
|
{ $optioncount++;
|
{ $optioncount++;
|
}
if(my_strlen($options[$i]) > $mybb->settings['polloptionlimit'] && $mybb->settings['polloptionlimit'] != 0) { $lengtherror = 1; break;
| |
} }
if(isset($lengtherror)) { error($lang->error_polloptiontoolong);
|
} }
if(isset($lengtherror)) { error($lang->error_polloptiontoolong);
|
| }
if(isset($sequenceerror)) { error($lang->error_polloptionsequence);
|
} $mybb->input['question'] = $mybb->get_input('question');
| } $mybb->input['question'] = $mybb->get_input('question');
|
Zeile 292 | Zeile 296 |
---|
} $optionslist .= trim($options[$i]); $voteslist .= '0';
|
} $optionslist .= trim($options[$i]); $voteslist .= '0';
|
} }
if($mybb->get_input('timeout', 1) > 0) { $timeout = $mybb->get_input('timeout', 1); } else { $timeout = 0; }
if($mybb->get_input('maxoptions', 1) > 0 && $mybb->get_input('maxoptions', 1) < $polloptions) { $maxoptions = $mybb->get_input('maxoptions', 1);
| } }
if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0) { $timeout = $mybb->get_input('timeout', MyBB::INPUT_INT); } else { $timeout = 0; }
if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $polloptions) { $maxoptions = $mybb->get_input('maxoptions', MyBB::INPUT_INT);
|
} else { $maxoptions = 0; }
|
} else { $maxoptions = 0; }
|
|
|
$newpoll = array( "tid" => $thread['tid'], "question" => $db->escape_string($mybb->input['question']),
| $newpoll = array( "tid" => $thread['tid'], "question" => $db->escape_string($mybb->input['question']),
|
Zeile 348 | Zeile 352 |
---|
if($mybb->input['action'] == "editpoll") {
|
if($mybb->input['action'] == "editpoll") {
|
$pid = $mybb->get_input('pid', 1);
| $pid = $mybb->get_input('pid', MyBB::INPUT_INT);
|
$plugins->run_hooks("polls_editpoll_start");
| $plugins->run_hooks("polls_editpoll_start");
|
Zeile 358 | Zeile 362 |
---|
if(!$poll) { error($lang->error_invalidpoll);
|
if(!$poll) { error($lang->error_invalidpoll);
|
}
| }
|
$query = $db->simple_select("threads", "*", "poll='$pid'"); $thread = $db->fetch_array($query); if(!$thread)
| $query = $db->simple_select("threads", "*", "poll='$pid'"); $thread = $db->fetch_array($query); if(!$thread)
|
Zeile 387 | Zeile 391 |
---|
{ // Is our forum closed? if($forum['open'] == 0 && !is_moderator($fid, "canmanagepolls"))
|
{ // Is our forum closed? if($forum['open'] == 0 && !is_moderator($fid, "canmanagepolls"))
|
{
| {
|
// Doesn't look like it is error($lang->error_closedinvalidforum); }
| // Doesn't look like it is error($lang->error_closedinvalidforum); }
|
Zeile 414 | Zeile 418 |
---|
}
if($poll['public'] == 1)
|
}
if($poll['public'] == 1)
|
{ $postoptionschecked['public'] = 'checked="checked"';
| { $postoptionschecked['public'] = 'checked="checked"';
|
}
$optionsarray = explode("||~|~||", $poll['options']);
| }
$optionsarray = explode("||~|~||", $poll['options']);
|
Zeile 436 | Zeile 440 |
---|
$option = $optionsarray[$i]; $option = htmlspecialchars_uni($option); $optionvotes = (int)$votesarray[$i];
|
$option = $optionsarray[$i]; $option = htmlspecialchars_uni($option); $optionvotes = (int)$votesarray[$i];
|
if(!$optionvotes) { $optionvotes = 0; }
eval("\$optionbits .= \"".$templates->get("polls_editpoll_option")."\";");
| if(!$optionvotes) { $optionvotes = 0; }
eval("\$optionbits .= \"".$templates->get("polls_editpoll_option")."\";");
|
$option = ""; $optionvotes = ""; }
if(!$poll['timeout']) {
|
$option = ""; $optionvotes = ""; }
if(!$poll['timeout']) {
|
$timeout = 0; } else { $timeout = $poll['timeout']; } if(!$poll['maxoptions']) { $maxoptions = 0;
| $timeout = 0; } else { $timeout = $poll['timeout']; }
if(!$poll['maxoptions']) { $maxoptions = 0;
|
} else {
| } else {
|
Zeile 466 | Zeile 470 |
---|
} } else
|
} } else
|
{ if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', 1) > $mybb->settings['maxpolloptions']) { $numoptions = $mybb->settings['maxpolloptions']; } elseif($mybb->get_input('numoptions', 1) < 2)
| { if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions']) { $numoptions = $mybb->settings['maxpolloptions']; } elseif($mybb->get_input('numoptions', MyBB::INPUT_INT) < 2)
|
{ $numoptions = 2; } else {
|
{ $numoptions = 2; } else {
|
$numoptions = $mybb->get_input('numoptions', 1);
| $numoptions = $mybb->get_input('numoptions', MyBB::INPUT_INT);
|
} $question = htmlspecialchars_uni($mybb->input['question']);
|
} $question = htmlspecialchars_uni($mybb->input['question']);
|
$postoptions = $mybb->get_input('postoptions', 2);
| $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
|
if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1) { $postoptionschecked['multiple'] = 'checked="checked"';
| if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1) { $postoptionschecked['multiple'] = 'checked="checked"';
|
Zeile 497 | Zeile 501 |
---|
$postoptionschecked['closed'] = 'checked="checked"'; }
|
$postoptionschecked['closed'] = 'checked="checked"'; }
|
$options = $mybb->get_input('options', 2); $votes = $mybb->get_input('votes', 2);
| $options = $mybb->get_input('options', MyBB::INPUT_ARRAY); $votes = $mybb->get_input('votes', MyBB::INPUT_ARRAY);
|
$optionbits = ''; for($i = 1; $i <= $numoptions; ++$i) {
| $optionbits = ''; for($i = 1; $i <= $numoptions; ++$i) {
|
Zeile 523 | Zeile 527 |
---|
$option = ""; }
|
$option = ""; }
|
if($mybb->get_input('timeout', 1) > 0)
| if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)
|
{
|
{
|
$timeout = $mybb->get_input('timeout', 1);
| $timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);
|
} else { $timeout = 0; }
|
} else { $timeout = 0; }
|
|
|
if(!$poll['maxoptions']) { $maxoptions = 0;
| if(!$poll['maxoptions']) { $maxoptions = 0;
|
Zeile 555 | Zeile 559 |
---|
$plugins->run_hooks("polls_do_editpoll_start");
|
$plugins->run_hooks("polls_do_editpoll_start");
|
$query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', 1)."'");
| $query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
$poll = $db->fetch_array($query);
if(!$poll)
| $poll = $db->fetch_array($query);
if(!$poll)
|
Zeile 563 | Zeile 567 |
---|
error($lang->error_invalidpoll); }
|
error($lang->error_invalidpoll); }
|
$query = $db->simple_select("threads", "*", "poll='".$mybb->get_input('pid', 1)."'");
| $query = $db->simple_select("threads", "*", "poll='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
$thread = $db->fetch_array($query); if(!$thread) {
| $thread = $db->fetch_array($query); if(!$thread) {
|
Zeile 574 | Zeile 578 |
---|
// Get forum info $forum = get_forum($thread['fid']);
|
// Get forum info $forum = get_forum($thread['fid']);
|
| $fid = $thread['fid'];
|
if(!$forum) { error($lang->error_invalidforum);
| if(!$forum) { error($lang->error_invalidforum);
|
Zeile 591 | Zeile 596 |
---|
if(!is_moderator($thread['fid'], "canmanagepolls")) { error_no_permission();
|
if(!is_moderator($thread['fid'], "canmanagepolls")) { error_no_permission();
|
}
if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', 1) > $mybb->settings['maxpolloptions'])
| }
if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions'])
|
{ $numoptions = $mybb->settings['maxpolloptions'];
|
{ $numoptions = $mybb->settings['maxpolloptions'];
|
} elseif($mybb->get_input('numoptions', 1) < 2)
| } elseif($mybb->get_input('numoptions', MyBB::INPUT_INT) < 2)
|
{ $numoptions = 2; } else
|
{ $numoptions = 2; } else
|
{ $numoptions = $mybb->get_input('numoptions', 1); }
| { $numoptions = $mybb->get_input('numoptions', MyBB::INPUT_INT); }
|
|
|
$postoptions = $mybb->get_input('postoptions', 2);
| $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
|
if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1') { $postoptions['multiple'] = 0;
| if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1') { $postoptions['multiple'] = 0;
|
Zeile 630 | Zeile 635 |
---|
{ $options[$i] = ''; }
|
{ $options[$i] = ''; }
|
if(trim($options[$i]) != '')
| if($mybb->settings['polloptionlimit'] != 0 && my_strlen($options[$i]) > $mybb->settings['polloptionlimit']) { $lengtherror = 1; break; }
if(strpos($options[$i], '||~|~||') !== false) { $sequenceerror = 1; break; } if(trim($options[$i]) != "")
|
{ $optioncount++;
|
{ $optioncount++;
|
}
if(my_strlen($options[$i]) > $mybb->settings['polloptionlimit'] && $mybb->settings['polloptionlimit'] != 0) { $lengtherror = 1; break;
| |
} }
if(isset($lengtherror))
|
} }
if(isset($lengtherror))
|
{
| {
|
error($lang->error_polloptiontoolong);
|
error($lang->error_polloptiontoolong);
|
| } if(isset($sequenceerror)) { error($lang->error_polloptionsequence);
|
}
$mybb->input['question'] = $mybb->get_input('question'); if(trim($mybb->input['question']) == '' || $optioncount < 2)
|
}
$mybb->input['question'] = $mybb->get_input('question'); if(trim($mybb->input['question']) == '' || $optioncount < 2)
|
{ error($lang->error_noquestionoptions); }
| { error($lang->error_noquestionoptions); }
|
$optionslist = ''; $voteslist = ''; $numvotes = '';
| $optionslist = ''; $voteslist = ''; $numvotes = '';
|
Zeile 675 | Zeile 692 |
---|
$voteslist .= $votes[$i]; $numvotes = $numvotes + $votes[$i]; }
|
$voteslist .= $votes[$i]; $numvotes = $numvotes + $votes[$i]; }
|
}
if($mybb->get_input('timeout', 1) > 0)
| }
if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)
|
{
|
{
|
$timeout = $mybb->get_input('timeout', 1);
| $timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);
|
} else { $timeout = 0; }
|
} else { $timeout = 0; }
|
if($mybb->get_input('maxoptions', 1) > 0 && $mybb->get_input('maxoptions', 1) < $numoptions)
| if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $numoptions)
|
{
|
{
|
$maxoptions = $mybb->get_input('maxoptions', 1);
| $maxoptions = $mybb->get_input('maxoptions', MyBB::INPUT_INT);
|
} else {
| } else {
|
Zeile 710 | Zeile 727 |
---|
$plugins->run_hooks("polls_do_editpoll_process");
|
$plugins->run_hooks("polls_do_editpoll_process");
|
$db->update_query("polls", $updatedpoll, "pid='".$mybb->get_input('pid', 1)."'");
| $db->update_query("polls", $updatedpoll, "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
$plugins->run_hooks("polls_do_editpoll_end");
| $plugins->run_hooks("polls_do_editpoll_end");
|
Zeile 723 | Zeile 740 |
---|
if($mybb->input['action'] == "showresults") {
|
if($mybb->input['action'] == "showresults") {
|
$query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', 1)."'");
| $query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
$poll = $db->fetch_array($query);
if(!$poll)
| $poll = $db->fetch_array($query);
if(!$poll)
|
Zeile 978 | Zeile 995 |
---|
if(is_array($option)) { $total_options = 0;
|
if(is_array($option)) { $total_options = 0;
|
|
|
foreach($option as $voteoption => $vote) { if($vote == 1 && isset($votesarray[$voteoption-1]))
| foreach($option as $voteoption => $vote) { if($vote == 1 && isset($votesarray[$voteoption-1]))
|
Zeile 993 | Zeile 1010 |
---|
$total_options++; } }
|
$total_options++; } }
|
|
|
if($total_options > $poll['maxoptions'] && $poll['maxoptions'] != 0) { error($lang->sprintf($lang->error_maxpolloptions, $poll['maxoptions']));
| if($total_options > $poll['maxoptions'] && $poll['maxoptions'] != 0) { error($lang->sprintf($lang->error_maxpolloptions, $poll['maxoptions']));
|
Zeile 1053 | Zeile 1070 |
---|
error_no_permission(); }
|
error_no_permission(); }
|
$query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', 1)."'");
| $query = $db->simple_select("polls", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
$poll = $db->fetch_array($query);
if(!$poll['pid'])
| $poll = $db->fetch_array($query);
if(!$poll['pid'])
|