Vergleich polls.php - 1.8.8 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 962Zeile 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'];
if($poll['multiple'] == 1)
{
if(is_array($option))

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

		{

		{

			$total_options = 0;

foreach($option as $voteoption => $vote)
{
if($vote == 1 && isset($votesarray[$voteoption-1]))
{

			$total_options = 0;

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

Zeile 1016Zeile 1009
			{
error($lang->sprintf($lang->error_maxpolloptions, $poll['maxoptions']));
}

			{
error($lang->sprintf($lang->error_maxpolloptions, $poll['maxoptions']));
}

		}
}

		}
}

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

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

	}

	}


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 1077Zeile 1082
	if(!$poll['pid'])
{
error($lang->error_invalidpoll);

	if(!$poll['pid'])
{
error($lang->error_invalidpoll);

	}


	}


	$plugins->run_hooks("polls_do_undovote_start");

$poll['numvotes'] = (int)$poll['numvotes'];

	$plugins->run_hooks("polls_do_undovote_start");

$poll['numvotes'] = (int)$poll['numvotes'];

Zeile 1090Zeile 1095
	{
error($lang->error_invalidthread);
}

	{
error($lang->error_invalidthread);
}





	$fid = $thread['fid'];

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

	$fid = $thread['fid'];

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

	{

	{

		error($lang->error_invalidforum);
}
else

		error($lang->error_invalidforum);
}
else

Zeile 1109Zeile 1114
		}
}


		}
}


	$poll['timeout'] = $poll['timeout']*60*60*24;


	$poll['timeout'] = $poll['timeout']*60*60*24;



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


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

	{

	{

		error($lang->error_pollclosed);

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

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





	}

	}

	elseif(isset($mybb->cookies['pollvotes'][$poll['pid']]))

	else

	{

	{

		// for Guests, we simply see if they've got the cookie
$vote_options = explode(',', $mybb->cookies['pollvotes'][$poll['pid']]);






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