Vergleich polls.php - 1.8.0 - 1.8.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 24Zeile 24

if($mybb->user['uid'] != 0)
{


if($mybb->user['uid'] != 0)
{

 
	$mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']);

	eval("\$loginbox = \"".$templates->get("changeuserbox")."\";");
}
else

	eval("\$loginbox = \"".$templates->get("changeuserbox")."\";");
}
else

Zeile 46Zeile 47
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 104Zeile 98
	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 114Zeile 108
	}

// 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 144Zeile 138
		$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 158Zeile 152
		$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);
}
else

	}

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;

	{
$maxoptions = 0;

	}

$plugins->run_hooks("polls_newpoll_end");


	}

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

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

$thread = get_thread($mybb->get_input('tid', 1));
if(!$thread)
{
error($lang->error_invalidthread);
}

$fid = $thread['fid'];
$forumpermissions = forum_permissions($fid);

{
// 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', MyBB::INPUT_INT));
if(!$thread)
{
error($lang->error_invalidthread);
}

$fid = $thread['fid'];
$forumpermissions = forum_permissions($fid);


// Get forum info
$forum = get_forum($fid);


// Get forum info
$forum = get_forum($fid);

Zeile 210Zeile 204
		{
// 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))

Zeile 224Zeile 218
		error($lang->error_pollalready);
}


		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'])
{
$polloptions = $mybb->settings['maxpolloptions'];
}


	if($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 244Zeile 238
	if($polloptions < 2)
{
$polloptions = "2";

	if($polloptions < 2)
{
$polloptions = "2";

	}

	}

	$optioncount = "0";

	$optioncount = "0";

	$options = $mybb->get_input('options', 2);


	$options = $mybb->get_input('options', MyBB::INPUT_ARRAY);


	for($i = 1; $i <= $polloptions; ++$i)
{
if(!isset($options[$i]))

	for($i = 1; $i <= $polloptions; ++$i)
{
if(!isset($options[$i]))

		{

		{

			$options[$i] = '';

			$options[$i] = '';

		}

if(trim($options[$i]) != "")
{
$optioncount++;
}

if(my_strlen($options[$i]) > $mybb->settings['polloptionlimit'] && $mybb->settings['polloptionlimit'] != 0)
{

		}

if($mybb->settings['polloptionlimit'] != 0 && my_strlen($options[$i]) > $mybb->settings['polloptionlimit'])
{






			$lengtherror = 1;
break;

			$lengtherror = 1;
break;

 
		}

if(strpos($options[$i], '||~|~||') !== false)
{
$sequenceerror = 1;
break;
}

if(trim($options[$i]) != "")
{
$optioncount++;

		}
}


		}
}


	if(isset($lengtherror))






	if(isset($lengtherror))
{
error($lang->error_polloptiontoolong);
}

if(isset($sequenceerror))

	{

	{

		error($lang->error_polloptiontoolong);

		error($lang->error_polloptionsequence);

	}

$mybb->input['question'] = $mybb->get_input('question');

	}

$mybb->input['question'] = $mybb->get_input('question');

Zeile 295Zeile 300
		}
}


		}
}


	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)

	if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $polloptions)

	{

	{

		$maxoptions = $mybb->get_input('maxoptions', 1);

		$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 323Zeile 328
		"numvotes" => 0,
"timeout" => $timeout,
"closed" => 0,

		"numvotes" => 0,
"timeout" => $timeout,
"closed" => 0,

		"multiple" => $postoptions['multiple'],
"public" => $postoptions['public'],
"maxoptions" => $maxoptions
);

		"multiple" => $postoptions['multiple'],
"public" => $postoptions['public'],
"maxoptions" => $maxoptions
);


$plugins->run_hooks("polls_do_newpoll_process");



$plugins->run_hooks("polls_do_newpoll_process");


Zeile 348Zeile 353

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 358Zeile 363
	if(!$poll)
{
error($lang->error_invalidpoll);

	if(!$poll)
{
error($lang->error_invalidpoll);

	}

	}


$query = $db->simple_select("threads", "*", "poll='$pid'");
$thread = $db->fetch_array($query);


$query = $db->simple_select("threads", "*", "poll='$pid'");
$thread = $db->fetch_array($query);

Zeile 366Zeile 371
	{
error($lang->error_invalidthread);
}

	{
error($lang->error_invalidthread);
}





	$tid = $thread['tid'];
$fid = $thread['fid'];


	$tid = $thread['tid'];
$fid = $thread['fid'];


Zeile 374Zeile 379
	build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));
add_breadcrumb($lang->nav_editpoll);

	build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));
add_breadcrumb($lang->nav_editpoll);





	$forumpermissions = forum_permissions($fid);

// Get forum info

	$forumpermissions = forum_permissions($fid);

// Get forum info

Zeile 404Zeile 409
	if(empty($mybb->input['updateoptions']))
{
if($poll['closed'] == 1)

	if(empty($mybb->input['updateoptions']))
{
if($poll['closed'] == 1)

		{

		{

			$postoptionschecked['closed'] = 'checked="checked"';

			$postoptionschecked['closed'] = 'checked="checked"';

		}

		}


if($poll['multiple'] == 1)
{
$postoptionschecked['multiple'] = 'checked="checked"';


if($poll['multiple'] == 1)
{
$postoptionschecked['multiple'] = 'checked="checked"';

		}


		}


		if($poll['public'] == 1)
{
$postoptionschecked['public'] = 'checked="checked"';

		if($poll['public'] == 1)
{
$postoptionschecked['public'] = 'checked="checked"';

Zeile 420Zeile 425

$optionsarray = explode("||~|~||", $poll['options']);
$votesarray = explode("||~|~||", $poll['votes']);


$optionsarray = explode("||~|~||", $poll['options']);
$votesarray = explode("||~|~||", $poll['votes']);





		$poll['totvotes'] = 0;
for($i = 1; $i <= $poll['numoptions']; ++$i)
{

		$poll['totvotes'] = 0;
for($i = 1; $i <= $poll['numoptions']; ++$i)
{

Zeile 448Zeile 453
		}

if(!$poll['timeout'])

		}

if(!$poll['timeout'])

		{
$timeout = 0;
}
else
{
$timeout = $poll['timeout'];
}

if(!$poll['maxoptions'])
{
$maxoptions = 0;
}

		{
$timeout = 0;
}










		else
{

		else
{

			$maxoptions = $poll['maxoptions'];
}
}
else
{
if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', 1) > $mybb->settings['maxpolloptions'])










			$timeout = $poll['timeout'];
}

if(!$poll['maxoptions'])
{
$maxoptions = 0;
}
else
{
$maxoptions = $poll['maxoptions'];
}
}
else
{
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)
{
$numoptions = 2;
}

		elseif($mybb->get_input('numoptions', MyBB::INPUT_INT) < 2)
{
$numoptions = 2;
}

		else

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

		}

		}


if(isset($postoptions['public']) && $postoptions['public'] == 1)
{


if(isset($postoptions['public']) && $postoptions['public'] == 1)
{

Zeile 497Zeile 502
			$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 518Zeile 523
			{
$optionvotes = 0;
}

			{
$optionvotes = 0;
}





			eval("\$optionbits .= \"".$templates->get("polls_editpoll_option")."\";");
$option = "";

			eval("\$optionbits .= \"".$templates->get("polls_editpoll_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;

		}

		}

		else
{
$maxoptions = $poll['maxoptions'];

		else
{
$maxoptions = $poll['maxoptions'];

Zeile 555Zeile 560

$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 563Zeile 568
		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)
{
error($lang->error_invalidthread);

	$thread = $db->fetch_array($query);
if(!$thread)
{
error($lang->error_invalidthread);

	}

	}


$forumpermissions = forum_permissions($thread['fid']);

// Get forum info
$forum = get_forum($thread['fid']);


$forumpermissions = forum_permissions($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 582Zeile 588
	{
// 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

		{
// Doesn't look like it is

			error($lang->error_closedinvalidforum);
}

			error($lang->error_closedinvalidforum);
}

	}

	}


if(!is_moderator($thread['fid'], "canmanagepolls"))


if(!is_moderator($thread['fid'], "canmanagepolls"))

	{

	{

		error_no_permission();
}


		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;

		$numoptions = 2;

	}
else
{
$numoptions = $mybb->get_input('numoptions', 1);
}

$postoptions = $mybb->get_input('postoptions', 2);
if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1')
{
$postoptions['multiple'] = 0;
}

if(!isset($postoptions['public']) || $postoptions['public'] != '1')

	}
else
{
$numoptions = $mybb->get_input('numoptions', MyBB::INPUT_INT);
}

$postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1')
{
$postoptions['multiple'] = 0;
}

if(!isset($postoptions['public']) || $postoptions['public'] != '1')

	{
$postoptions['public'] = 0;
}

	{
$postoptions['public'] = 0;
}

Zeile 623Zeile 629
	}
$optioncount = "0";
$options = $mybb->input['options'];

	}
$optioncount = "0";
$options = $mybb->input['options'];





	for($i = 1; $i <= $numoptions; ++$i)
{
if(!isset($options[$i]))

	for($i = 1; $i <= $numoptions; ++$i)
{
if(!isset($options[$i]))

		{

		{

			$options[$i] = '';

			$options[$i] = '';

		}
if(trim($options[$i]) != '')
{
$optioncount++;
}

if(my_strlen($options[$i]) > $mybb->settings['polloptionlimit'] && $mybb->settings['polloptionlimit'] != 0)

		}

if($mybb->settings['polloptionlimit'] != 0 && my_strlen($options[$i]) > $mybb->settings['polloptionlimit'])





		{
$lengtherror = 1;
break;
}

		{
$lengtherror = 1;
break;
}

	}













if(strpos($options[$i], '||~|~||') !== false)
{
$sequenceerror = 1;
break;
}

if(trim($options[$i]) != "")
{
$optioncount++;
}
}


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');

	}

$mybb->input['question'] = $mybb->get_input('question');

Zeile 673Zeile 691
				$votes[$i] = "0";
}
$voteslist .= $votes[$i];

				$votes[$i] = "0";
}
$voteslist .= $votes[$i];

			$numvotes = $numvotes + $votes[$i];

			$numvotes = (int)$numvotes + (int)$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 710Zeile 728

$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 723Zeile 741

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 733Zeile 751

$tid = $poll['tid'];
$thread = get_thread($tid);


$tid = $poll['tid'];
$thread = get_thread($tid);

	if(!$thread)
{

	if(!$thread || ($thread['visible'] != 1 && ($thread['visible'] == 0 && !is_moderator($thread['fid'], "canviewunapprove")) || ($thread['visible'] == -1 && !is_moderator($thread['fid'], "canviewdeleted"))))
{

		error($lang->error_invalidthread);

		error($lang->error_invalidthread);

	}

$fid = $thread['fid'];

	}

$fid = $thread['fid'];


// Get forum info
$forum = get_forum($fid);
if(!$forum)
{
error($lang->error_invalidforum);


// Get forum info
$forum = get_forum($fid);
if(!$forum)
{
error($lang->error_invalidforum);

	}

$forumpermissions = forum_permissions($forum['fid']);

	}

$forumpermissions = forum_permissions($forum['fid']);


$plugins->run_hooks("polls_showresults_start");



$plugins->run_hooks("polls_showresults_start");


Zeile 760Zeile 778
	build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));
add_breadcrumb($lang->nav_pollresults);

	build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));
add_breadcrumb($lang->nav_pollresults);





	$voters = $votedfor = array();

// Calculate votes

	$voters = $votedfor = array();

// Calculate votes

Zeile 784Zeile 802
		{
// Add one to the number of voters for guests
++$guest_voters[$voter['voteoption']];

		{
// Add one to the number of voters for guests
++$guest_voters[$voter['voteoption']];

		}
else
{
$voters[$voter['voteoption']][$voter['uid']] = $voter['username'];
}

		}
else
{
$voters[$voter['voteoption']][$voter['uid']] = htmlspecialchars_uni($voter['username']);
}

	}

$optionsarray = explode("||~|~||", $poll['options']);

	}

$optionsarray = explode("||~|~||", $poll['options']);

Zeile 829Zeile 847
		if($votes == 0)
{
$percent = 0;

		if($votes == 0)
{
$percent = 0;

		}

		}

		else

		else

		{

		{

			$percent = number_format($votes / $poll['totvotes'] * 100, 2);
}


			$percent = number_format($votes / $poll['totvotes'] * 100, 2);
}


Zeile 843Zeile 861
		if($poll['public'] == 1 || is_moderator($fid, "canmanagepolls"))
{
if(isset($voters[$number]) && is_array($voters[$number]))

		if($poll['public'] == 1 || is_moderator($fid, "canmanagepolls"))
{
if(isset($voters[$number]) && is_array($voters[$number]))

			{

			{

				foreach($voters[$number] as $uid => $username)
{
$userlist .= $comma.build_profile_link($username, $uid);

				foreach($voters[$number] as $uid => $username)
{
$userlist .= $comma.build_profile_link($username, $uid);

Zeile 881Zeile 899
	eval("\$showresults = \"".$templates->get("polls_showresults")."\";");
output_page($showresults);
}

	eval("\$showresults = \"".$templates->get("polls_showresults")."\";");
output_page($showresults);
}

 


if($mybb->input['action'] == "vote" && $mybb->request_method == "post")
{
// Verify incoming POST request

if($mybb->input['action'] == "vote" && $mybb->request_method == "post")
{
// Verify incoming POST request

Zeile 900Zeile 919

$query = $db->simple_select("threads", "*", "poll='".(int)$poll['pid']."'");
$thread = $db->fetch_array($query);


$query = $db->simple_select("threads", "*", "poll='".(int)$poll['pid']."'");
$thread = $db->fetch_array($query);


if(!$thread || $thread['visible'] == 0)
{


if(!$thread || ($thread['visible'] != 1 && ($thread['visible'] == 0 && !is_moderator($thread['fid'], "canviewunapprove")) || ($thread['visible'] == -1 && !is_moderator($thread['fid'], "canviewdeleted"))))
{

		error($lang->error_invalidthread);
}


		error($lang->error_invalidthread);
}


Zeile 932Zeile 951
	$expiretime = $poll['dateline'] + $poll['timeout'];
$now = TIME_NOW;
if($poll['closed'] == 1 || $thread['closed'] == 1 || ($expiretime < $now && $poll['timeout']))

	$expiretime = $poll['dateline'] + $poll['timeout'];
$now = TIME_NOW;
if($poll['closed'] == 1 || $thread['closed'] == 1 || ($expiretime < $now && $poll['timeout']))

	{

	{

		error($lang->error_pollclosed);

		error($lang->error_pollclosed);

	}

	}


if(!isset($mybb->input['option']))
{
error($lang->error_nopolloptions);


if(!isset($mybb->input['option']))
{
error($lang->error_nopolloptions);

	}

	}


// Check if the user has voted before...
if($mybb->user['uid'])


// Check if the user has voted before...
if($mybb->user['uid'])

	{
$query = $db->simple_select("pollvotes", "*", "uid='".$mybb->user['uid']."' AND pid='".$poll['pid']."'");
$votecheck = $db->fetch_array($query);

	{
$user_check = "uid='{$mybb->user['uid']}'";


	}

	}


if($votecheck['vid'] || (isset($mybb->cookies['pollvotes'][$poll['pid']]) && $mybb->cookies['pollvotes'][$poll['pid']] !== ""))

	else


	{

	{

		error($lang->error_alreadyvoted);

		$user_check = "ipaddress=".$db->escape_binary($session->packedip);

	}

	}

	elseif(!$mybb->user['uid'])
{
// Give a cookie to guests to inhibit revotes
if(is_array($mybb->input['option']))
{
// We have multiple options here...
$votes_cookie = implode(',', array_keys($mybb->input['option']));
}
else
{
$votes_cookie = $mybb->input['option'];
}

 




		my_setcookie("pollvotes[{$poll['pid']}]", $votes_cookie);






	$query = $db->simple_select("pollvotes", "*", "{$user_check} AND pid='".$poll['pid']."'");
$votecheck = $db->fetch_array($query);

if($votecheck['vid'])
{
error($lang->error_alreadyvoted);

	}


	}


	$votesql = '';
$now = TIME_NOW;

	$votesql = array();


	$votesarray = explode("||~|~||", $poll['votes']);
$option = $mybb->input['option'];
$numvotes = (int)$poll['numvotes'];

	$votesarray = explode("||~|~||", $poll['votes']);
$option = $mybb->input['option'];
$numvotes = (int)$poll['numvotes'];

Zeile 978Zeile 987
		if(is_array($option))
{
$total_options = 0;

		if(is_array($option))
{
$total_options = 0;

		



			foreach($option as $voteoption => $vote)

			foreach($option as $voteoption => $vote)

			{

			{

				if($vote == 1 && isset($votesarray[$voteoption-1]))
{

				if($vote == 1 && isset($votesarray[$voteoption-1]))
{

					if($votesql)
{
$votesql .= ",";
}
$votesql .= "('".$poll['pid']."','".$mybb->user['uid']."','".$db->escape_string($voteoption)."','$now')";




					$votesql[] = array(
"pid" => $poll['pid'],
"uid" => (int)$mybb->user['uid'],
"voteoption" => $db->escape_string($voteoption),
"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip)
);


					$votesarray[$voteoption-1]++;
$numvotes = $numvotes+1;
$total_options++;
}
}

					$votesarray[$voteoption-1]++;
$numvotes = $numvotes+1;
$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']));
}

		}
}
else

		}
}
else

	{
if(is_array($option) || !isset($votesarray[$option-1]))
{
error($lang->error_nopolloptions);
}

	{
if(is_array($option) || !isset($votesarray[$option-1]))
{
error($lang->error_nopolloptions);
}

		$votesql = "('".$poll['pid']."','".$mybb->user['uid']."','".$db->escape_string($option)."','$now')";










$votesql = array(
"pid" => $poll['pid'],
"uid" => (int)$mybb->user['uid'],
"voteoption" => $db->escape_string($option),
"dateline" => TIME_NOW,
"ipaddress" => $db->escape_binary($session->packedip)
);


		$votesarray[$option-1]++;
$numvotes = $numvotes+1;
}

		$votesarray[$option-1]++;
$numvotes = $numvotes+1;
}

Zeile 1014Zeile 1034
	if(!$votesql)
{
error($lang->error_nopolloptions);

	if(!$votesql)
{
error($lang->error_nopolloptions);

	}

$db->write_query("
INSERT INTO
".TABLE_PREFIX."pollvotes (pid,uid,voteoption,dateline)
VALUES $votesql
");





	}

if($poll['multiple'] == 1)
{
$db->insert_query_multiple("pollvotes", $votesql);
}
else
{
$db->insert_query("pollvotes", $votesql);
}


	$voteslist = '';
for($i = 1; $i <= $poll['numoptions']; ++$i)
{

	$voteslist = '';
for($i = 1; $i <= $poll['numoptions']; ++$i)
{

Zeile 1037Zeile 1061

$plugins->run_hooks("polls_vote_process");



$plugins->run_hooks("polls_vote_process");


	$db->update_query("polls", $updatedpoll, "pid='".$poll['pid']."'");

$plugins->run_hooks("polls_vote_end");

	$db->update_query("polls", $updatedpoll, "pid='".$poll['pid']."'");

$plugins->run_hooks("polls_vote_end");


redirect(get_thread_link($poll['tid']), $lang->redirect_votethanks);
}


redirect(get_thread_link($poll['tid']), $lang->redirect_votethanks);
}

Zeile 1051Zeile 1075
	if($mybb->usergroup['canundovotes'] != 1)
{
error_no_permission();

	if($mybb->usergroup['canundovotes'] != 1)
{
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'])

Zeile 1068Zeile 1092
	// We do not have $forum_cache available here since no forums permissions are checked in undo vote
// Get thread ID and then get forum info
$thread = get_thread($poll['tid']);

	// We do not have $forum_cache available here since no forums permissions are checked in undo vote
// Get thread ID and then get forum info
$thread = get_thread($poll['tid']);

	if(!$thread || $thread['visible'] == 0)

	if(!$thread || ($thread['visible'] != 1 && ($thread['visible'] == 0 && !is_moderator($thread['fid'], "canviewunapprove")) || ($thread['visible'] == -1 && !is_moderator($thread['fid'], "canviewdeleted"))))

	{
error($lang->error_invalidthread);
}

	{
error($lang->error_invalidthread);
}

Zeile 1098Zeile 1122
	if($poll['closed'] == 1 || $thread['closed'] == 1 || ($expiretime < TIME_NOW && $poll['timeout']))
{
error($lang->error_pollclosed);

	if($poll['closed'] == 1 || $thread['closed'] == 1 || ($expiretime < TIME_NOW && $poll['timeout']))
{
error($lang->error_pollclosed);

	}


	}


	// Check if the user has voted before...
$vote_options = array();

	// Check if the user has voted before...
$vote_options = array();

 


	if($mybb->user['uid'])

	if($mybb->user['uid'])

	{
$query = $db->simple_select("pollvotes", "vid,voteoption", "uid='".$mybb->user['uid']."' AND pid='".$poll['pid']."'");
while($voteoption = $db->fetch_array($query))
{
$vote_options[$voteoption['vid']] = $voteoption['voteoption'];
}
}
elseif(isset($mybb->cookies['pollvotes'][$poll['pid']]))
{
// for Guests, we simply see if they've got the cookie
$vote_options = explode(',', $mybb->cookies['pollvotes'][$poll['pid']]);


	{
$user_check = "uid='{$mybb->user['uid']}'";
}
else
{
$user_check = "uid='0' AND ipaddress=".$db->escape_binary($session->packedip);
}

$query = $db->simple_select("pollvotes", "vid,voteoption", "{$user_check} AND pid='".$poll['pid']."'");
while($voteoption = $db->fetch_array($query))
{
$vote_options[$voteoption['vid']] = $voteoption['voteoption'];

	}

if(empty($vote_options))
{
error($lang->error_notvoted);

	}

if(empty($vote_options))
{
error($lang->error_notvoted);

	}
else if(!$mybb->user['uid'])
{
// clear cookie for Guests
my_setcookie("pollvotes[{$poll['pid']}]", "");

 
	}

// Note, this is not thread safe!

	}

// Note, this is not thread safe!

Zeile 1176Zeile 1197

$plugins->run_hooks("polls_do_undovote_process");



$plugins->run_hooks("polls_do_undovote_process");


	$db->delete_query("pollvotes", "uid='".$mybb->user['uid']."' AND pid='".$poll['pid']."'");

	$db->delete_query("pollvotes", "{$user_check} AND pid='".$poll['pid']."'");

	$db->update_query("polls", $updatedpoll, "pid='".$poll['pid']."'");

$plugins->run_hooks("polls_do_undovote_end");

	$db->update_query("polls", $updatedpoll, "pid='".$poll['pid']."'");

$plugins->run_hooks("polls_do_undovote_end");