Vergleich polls.php - 1.8.4 - 1.8.15

  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 57Zeile 58
	}

// Is the currently logged in user a moderator of this forum?

	}

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


// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))

Zeile 115Zeile 109

// Sanitize number of poll options
if($mybb->get_input('numpolloptions', MyBB::INPUT_INT) > 0)


// Sanitize number of poll options
if($mybb->get_input('numpolloptions', MyBB::INPUT_INT) > 0)

	{

	{

		$mybb->input['polloptions'] = $mybb->get_input('numpolloptions', MyBB::INPUT_INT);
}
if($mybb->settings['maxpolloptions'] && $mybb->get_input('polloptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions'])

		$mybb->input['polloptions'] = $mybb->get_input('numpolloptions', MyBB::INPUT_INT);
}
if($mybb->settings['maxpolloptions'] && $mybb->get_input('polloptions', MyBB::INPUT_INT) > $mybb->settings['maxpolloptions'])

Zeile 166Zeile 160
	{
$timeout = 0;
}

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

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

Zeile 255Zeile 249
			$options[$i] = '';
}


			$options[$i] = '';
}


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


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

		}


		}


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

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

		{

		{

			$lengtherror = 1;

			$sequenceerror = 1;

			break;
}

			break;
}

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

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

	}


	}


	if(isset($lengtherror))

	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 302Zeile 307
	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);

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

Zeile 312Zeile 317
	{
$maxoptions = 0;
}

	{
$maxoptions = 0;
}

	



	$newpoll = array(
"tid" => $thread['tid'],
"question" => $db->escape_string($mybb->input['question']),
"dateline" => TIME_NOW,

	$newpoll = array(
"tid" => $thread['tid'],
"question" => $db->escape_string($mybb->input['question']),
"dateline" => TIME_NOW,

		"options" => $db->escape_string($optionslist),
"votes" => $db->escape_string($voteslist),

		"options" => $db->escape_string($optionslist),
"votes" => $db->escape_string($voteslist),

		"numoptions" => (int)$optioncount,
"numvotes" => 0,
"timeout" => $timeout,

		"numoptions" => (int)$optioncount,
"numvotes" => 0,
"timeout" => $timeout,

Zeile 455Zeile 460
		{
$timeout = $poll['timeout'];
}

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

		



		if(!$poll['maxoptions'])

		if(!$poll['maxoptions'])

		{

		{

			$maxoptions = 0;

			$maxoptions = 0;

		}

		}

		else

		else

		{

		{

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

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

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

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

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

Zeile 531Zeile 536
		{
$timeout = 0;
}

		{
$timeout = 0;
}

		



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

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

Zeile 559Zeile 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)

	{

	{

		error($lang->error_invalidthread);
}


		error($lang->error_invalidthread);
}


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

	}

	}

	else
{
// Is our forum closed?

	else
{
// Is our forum closed?

Zeile 590Zeile 595
	}

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

	}

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

	{

	{

		error_no_permission();
}


		error_no_permission();
}


Zeile 616Zeile 621
	if(!isset($postoptions['public']) || $postoptions['public'] != '1')
{
$postoptions['public'] = 0;

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

	}


	}


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

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

	{

	{

		$postoptions['closed'] = 0;
}
$optioncount = "0";

		$postoptions['closed'] = 0;
}
$optioncount = "0";

Zeile 630Zeile 635
		if(!isset($options[$i]))
{
$options[$i] = '';

		if(!isset($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');
if(trim($mybb->input['question']) == '' || $optioncount < 2)


$mybb->input['question'] = $mybb->get_input('question');
if(trim($mybb->input['question']) == '' || $optioncount < 2)

Zeile 659Zeile 676
	$numvotes = '';
$votes = $mybb->input['votes'];
for($i = 1; $i <= $numoptions; ++$i)

	$numvotes = '';
$votes = $mybb->input['votes'];
for($i = 1; $i <= $numoptions; ++$i)

	{

	{

		if(trim($options[$i]) != '')
{
if($optionslist != '')

		if(trim($options[$i]) != '')
{
if($optionslist != '')

Zeile 686Zeile 703
	{
$timeout = 0;
}

	{
$timeout = 0;
}

	



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

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

Zeile 788Zeile 805
		}
else
{

		}
else
{

			$voters[$voter['voteoption']][$voter['uid']] = $voter['username'];

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

		}
}


		}
}


Zeile 945Zeile 962
	// 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 979Zeile 986
		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]))
{

					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 1015Zeile 1033
	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 1038Zeile 1060

$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 1052Zeile 1074
	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', MyBB::INPUT_INT)."'");
$poll = $db->fetch_array($query);


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

Zeile 1099Zeile 1121
	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 1177Zeile 1196

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