Vergleich polls.php - 1.8.14 - 1.8.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 52Zeile 52
	$plugins->run_hooks("polls_newpoll_start");

$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));

	$plugins->run_hooks("polls_newpoll_start");

$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));

	if(!$thread)

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

	{
error($lang->error_invalidthread);
}

	{
error($lang->error_invalidthread);
}

Zeile 134Zeile 134
		$postoptionschecked['multiple'] = 'checked="checked"';
}
if(isset($postoptions['public']) && $postoptions['public'] == 1)

		$postoptionschecked['multiple'] = 'checked="checked"';
}
if(isset($postoptions['public']) && $postoptions['public'] == 1)

	{

	{

		$postoptionschecked['public'] = 'checked="checked"';
}


		$postoptionschecked['public'] = 'checked="checked"';
}


Zeile 150Zeile 150
		$option = htmlspecialchars_uni($option);
eval("\$optionbits .= \"".$templates->get("polls_newpoll_option")."\";");
$option = "";

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

	}


	}


	if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)

	if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)

	{

	{

		$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);
}

		$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);
}

	else
{
$timeout = 0;
}

	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


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;
}


Zeile 183Zeile 183
	$plugins->run_hooks("polls_do_newpoll_start");

$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));

	$plugins->run_hooks("polls_do_newpoll_start");

$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));

	if(!$thread)
{

	if(!$thread)
{

		error($lang->error_invalidthread);

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

		error($lang->error_invalidforum);

	}
else
{

	}
else
{

		// Is our forum closed?
if($forum['open'] == 0 && !is_moderator($fid, "canmanagepolls"))
{
// Doesn't look like it is
error($lang->error_closedinvalidforum);
}

		// Is our forum closed?
if($forum['open'] == 0 && !is_moderator($fid, "canmanagepolls"))
{
// 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 214Zeile 214
	}

if($thread['poll'])

	}

if($thread['poll'])

	{

	{

		error($lang->error_pollalready);
}


		error($lang->error_pollalready);
}


Zeile 262Zeile 262
		}

if(trim($options[$i]) != "")

		}

if(trim($options[$i]) != "")

		{

		{

			$optioncount++;
}

			$optioncount++;
}

	}

	}


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

	if(isset($sequenceerror))
{
error($lang->error_polloptionsequence);
}

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





	if(trim($mybb->input['question']) == '' || $optioncount < 2)
{
error($lang->error_noquestionoptions);

	if(trim($mybb->input['question']) == '' || $optioncount < 2)
{
error($lang->error_noquestionoptions);

Zeile 310Zeile 310
	}

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

	}

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 = $mybb->get_input('maxoptions', MyBB::INPUT_INT);
}
else
{
$maxoptions = 0;
}


$newpoll = array(
"tid" => $thread['tid'],


$newpoll = array(
"tid" => $thread['tid'],

Zeile 342Zeile 342
	$plugins->run_hooks("polls_do_newpoll_end");

if($thread['visible'] == 1)

	$plugins->run_hooks("polls_do_newpoll_end");

if($thread['visible'] == 1)

	{

	{

		redirect(get_thread_link($thread['tid']), $lang->redirect_pollposted);
}
else

		redirect(get_thread_link($thread['tid']), $lang->redirect_pollposted);
}
else

Zeile 374Zeile 374

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


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





	// Make navigation
build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));

	// Make navigation
build_forum_breadcrumb($fid);
add_breadcrumb(htmlspecialchars_uni($thread['subject']), get_thread_link($thread['tid']));

Zeile 440Zeile 440
			$counter = $i + 1;
$option = $optionsarray[$i];
$option = htmlspecialchars_uni($option);

			$counter = $i + 1;
$option = $optionsarray[$i];
$option = htmlspecialchars_uni($option);

			$optionvotes = (int)$votesarray[$i];

if(!$optionvotes)
{
$optionvotes = 0;
}

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

			$optionvotes = (int)$votesarray[$i];

if(!$optionvotes)
{
$optionvotes = 0;
}

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

			$optionvotes = "";
}

if(!$poll['timeout'])

			$optionvotes = "";
}

if(!$poll['timeout'])

		{

		{

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

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

		}

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

		}

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

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

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

Zeile 473Zeile 473
	else
{
if($mybb->settings['maxpolloptions'] && $mybb->get_input('numoptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions'])

	else
{
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;

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

		}
else
{

		}
else
{

			$numoptions = $mybb->get_input('numoptions', MyBB::INPUT_INT);
}
$question = htmlspecialchars_uni($mybb->input['question']);

$postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1)

			$numoptions = $mybb->get_input('numoptions', MyBB::INPUT_INT);
}
$question = htmlspecialchars_uni($mybb->input['question']);

$postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
if(isset($postoptions['multiple']) && $postoptions['multiple'] == 1)

		{

		{

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

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

		}

		}


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


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

Zeile 498Zeile 498
		}

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

		}

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

		{

		{

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


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


Zeile 514Zeile 514
			}
$option = htmlspecialchars_uni($options[$i]);
if(!isset($votes[$i]))

			}
$option = htmlspecialchars_uni($options[$i]);
if(!isset($votes[$i]))

			{

			{

				$votes[$i] = 0;
}
$optionvotes = (int)$votes[$i];

				$votes[$i] = 0;
}
$optionvotes = (int)$votes[$i];

Zeile 523Zeile 523
			{
$optionvotes = 0;
}

			{
$optionvotes = 0;
}





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

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

Zeile 531Zeile 531
		if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)
{
$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);

		if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)
{
$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);

		}
else

		}
else

		{
$timeout = 0;

		{
$timeout = 0;

		}


		}


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

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

Zeile 545Zeile 545
		{
$maxoptions = $poll['maxoptions'];
}

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

	}

$plugins->run_hooks("polls_editpoll_end");

	}

$plugins->run_hooks("polls_editpoll_end");


eval("\$editpoll = \"".$templates->get("polls_editpoll")."\";");
output_page($editpoll);
}


eval("\$editpoll = \"".$templates->get("polls_editpoll")."\";");
output_page($editpoll);
}





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

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

Zeile 564Zeile 564
	$poll = $db->fetch_array($query);

if(!$poll)

	$poll = $db->fetch_array($query);

if(!$poll)

	{

	{

		error($lang->error_invalidpoll);

		error($lang->error_invalidpoll);

	}


	}


	$query = $db->simple_select("threads", "*", "poll='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
$thread = $db->fetch_array($query);
if(!$thread)

	$query = $db->simple_select("threads", "*", "poll='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
$thread = $db->fetch_array($query);
if(!$thread)

Zeile 579Zeile 579

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


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

	$fid = $thread['fid'];
if(!$forum)

	$fid = $thread['fid'];
if(!$forum)

	{
error($lang->error_invalidforum);
}

	{
error($lang->error_invalidforum);
}

Zeile 595Zeile 595
	}

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', MyBB::INPUT_INT) > $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', MyBB::INPUT_INT) < 2)

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

	{

	{

		$numoptions = 2;

		$numoptions = 2;

	}

	}

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

	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 = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY);
if(!isset($postoptions['multiple']) || $postoptions['multiple'] != '1')
{

Zeile 644Zeile 644
		}

if(strpos($options[$i], '||~|~||') !== false)

		}

if(strpos($options[$i], '||~|~||') !== false)

		{

		{

			$sequenceerror = 1;
break;
}

			$sequenceerror = 1;
break;
}

Zeile 691Zeile 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', MyBB::INPUT_INT) > 0)

	if($mybb->get_input('timeout', MyBB::INPUT_INT) > 0)

	{

	{

		$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);

		$timeout = $mybb->get_input('timeout', MyBB::INPUT_INT);

	}
else
{
$timeout = 0;

	}
else
{
$timeout = 0;

	}

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

	}

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

Zeile 711Zeile 711
	else
{
$maxoptions = 0;

	else
{
$maxoptions = 0;

	}

$updatedpoll = array(

	}

$updatedpoll = array(

		"question" => $db->escape_string($mybb->input['question']),
"options" => $db->escape_string($optionslist),
"votes" => $db->escape_string($voteslist),

		"question" => $db->escape_string($mybb->input['question']),
"options" => $db->escape_string($optionslist),
"votes" => $db->escape_string($voteslist),

Zeile 751Zeile 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'];


Zeile 763Zeile 763
	if(!$forum)
{
error($lang->error_invalidforum);

	if(!$forum)
{
error($lang->error_invalidforum);

	}

	}


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



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


Zeile 795Zeile 795
		if($mybb->user['uid'] == $voter['uid'] && $mybb->user['uid'])
{
$votedfor[$voter['voteoption']] = 1;

		if($mybb->user['uid'] == $voter['uid'] && $mybb->user['uid'])
{
$votedfor[$voter['voteoption']] = 1;

		}


		}


		// Count number of guests and users without a username (assumes they've been deleted)
if($voter['uid'] == 0 || $voter['username'] == '')
{
// Add one to the number of voters for guests
++$guest_voters[$voter['voteoption']];

		// Count number of guests and users without a username (assumes they've been deleted)
if($voter['uid'] == 0 || $voter['username'] == '')
{
// Add one to the number of voters for guests
++$guest_voters[$voter['voteoption']];

		}

		}

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

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

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

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

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

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

	{
$poll['totvotes'] = $poll['totvotes'] + $votesarray[$i-1];
}

	{
$poll['totvotes'] = $poll['totvotes'] + $votesarray[$i-1];
}

Zeile 829Zeile 829
			"filter_badwords" => 1
);
$option = $parser->parse_message($optionsarray[$i-1], $parser_options);

			"filter_badwords" => 1
);
$option = $parser->parse_message($optionsarray[$i-1], $parser_options);





		$votes = $votesarray[$i-1];
$number = $i;
// Make the mark for current user's voted option

		$votes = $votesarray[$i-1];
$number = $i;
// Make the mark for current user's voted option

Zeile 837Zeile 837
		{
$optionbg = 'trow2';
$votestar = '*';

		{
$optionbg = 'trow2';
$votestar = '*';

		}

		}

		else
{
$optionbg = 'trow1';

		else
{
$optionbg = 'trow1';

Zeile 845Zeile 845
		}

if($votes == 0)

		}

if($votes == 0)

		{

		{

			$percent = 0;
}
else

			$percent = 0;
}
else

Zeile 891Zeile 891
	else
{
$totpercent = '0%';

	else
{
$totpercent = '0%';

	}


	}


	$plugins->run_hooks("polls_showresults_end");

$poll['question'] = htmlspecialchars_uni($poll['question']);
eval("\$showresults = \"".$templates->get("polls_showresults")."\";");
output_page($showresults);
}

	$plugins->run_hooks("polls_showresults_end");

$poll['question'] = htmlspecialchars_uni($poll['question']);
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 919Zeile 920
	$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 962Zeile 963
	// 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
{
$user_check = "ipaddress=".$db->escape_binary($session->packedip);
}

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

if($votecheck['vid'])

	{
error($lang->error_alreadyvoted);

	{
error($lang->error_alreadyvoted);

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

 
	}


	}


	$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 1001Zeile 992
			{
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++;

Zeile 1021Zeile 1015
	else
{
if(is_array($option) || !isset($votesarray[$option-1]))

	else
{
if(is_array($option) || !isset($votesarray[$option-1]))

		{

		{

			error($lang->error_nopolloptions);
}

			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;

	}


	}


	if(!$votesql)

	if(!$votesql)

	{

	{

		error($lang->error_nopolloptions);
}


		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)

	{

	{

		if($i > 1)
{
$voteslist .= "||~|~||";

		if($i > 1)
{
$voteslist .= "||~|~||";

Zeile 1056Zeile 1062
	$plugins->run_hooks("polls_vote_process");

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

	$plugins->run_hooks("polls_vote_process");

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





	$plugins->run_hooks("polls_vote_end");

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

	$plugins->run_hooks("polls_vote_end");

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

Zeile 1086Zeile 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 1116Zeile 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 1194Zeile 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");