UserBox

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

Sponsored Links

+- Recent Posts

Re: German Language files by Tony_R
Today at 07:49:36 am

Re: German Language files by Tony_R
May 15, 2012, 02:09:12 pm

Re: German Language files by EzPortal
May 15, 2012, 02:00:02 pm

Re: German Language files by Tony_R
May 15, 2012, 01:55:26 pm

Re: German Language files by EzPortal
May 15, 2012, 01:38:52 pm

Re: German Language files by Tony_R
May 15, 2012, 01:29:19 pm

Re: German Language files by Tony_R
May 15, 2012, 09:44:14 am

Re: German Language files by Tony_R
May 15, 2012, 08:34:06 am

Re: German Language files by EzPortal
May 15, 2012, 07:27:30 am

Cache Error ? by Tony_R
May 15, 2012, 05:01:37 am

Quick Menu

Announcements
Community Guidelines & Rules
How To Section
EzPortal Showcase
Support

Author Topic: Not voting on homepage  (Read 912 times)

0 Members and 1 Guest are viewing this topic.

Offline os13

  • Posts: 1
  • Karma: 0
    • View Profile
Not voting on homepage
« on: August 29, 2011, 04:40:15 pm »
Hey, i have EzPortal and whenever i try to vote...it doesn't count the vote and it redirects me to the same page...so basically nothing happens. Here is my function ssi_pollVote() in SSI.php

Code: [Select]
// Takes care of voting - don't worry, this is done automatically.
function ssi_pollVote()
{
global $context, $db_prefix, $user_info, $sc, $smcFunc, $sourcedir, $modSettings;

if (!isset($_POST[$context['session_var']]) || $_POST[$context['session_var']] != $sc || empty($_POST['options']) || !isset($_POST['poll']))
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript"><!-- // --><![CDATA[
history.go(-1);
// ]]></script>
</head>
<body>&laquo;</body>
</html>';
return;
}

// This can cause weird errors! (ie. copyright missing.)
checkSession();

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

// Check if they have already voted, or voting is locked.
$request = $smcFunc['db_query']('', '
SELECT
p.id_poll, p.voting_locked, p.expire_time, p.max_votes, p.guest_vote,
t.id_topic,
IFNULL(lp.id_choice, -1) AS selected
FROM {db_prefix}polls AS p
INNER JOIN {db_prefix}topics AS t ON (t.id_poll = {int:current_poll})
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}log_polls AS lp ON (lp.id_poll = p.id_poll AND lp.id_member = {int:current_member})
WHERE p.id_poll = {int:current_poll}
AND {query_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
LIMIT 1',
array(
'current_member' => $user_info['id'],
'current_poll' => $_POST['poll'],
'is_approved' => 1,
)
);
if ($smcFunc['db_num_rows']($request) == 0)
die;
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);

if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
redirectexit('topic=' . $row['id_topic'] . '.0');

// Too many options checked?
if (count($_REQUEST['options']) > $row['max_votes'])
redirectexit('topic=' . $row['id_topic'] . '.0');

// It's a guest who has already voted?
if ($user_info['is_guest'])
{
// Guest voting disabled?
if (!$row['guest_vote'])
redirectexit('topic=' . $row['id_topic'] . '.0');
// Already voted?
elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
redirectexit('topic=' . $row['id_topic'] . '.0');
}

$options = array();
$inserts = array();
foreach ($_REQUEST['options'] as $id)
{
$id = (int) $id;

$options[] = $id;
$inserts[] = array($_POST['poll'], $user_info['id'], $id);
}

// Add their vote in to the tally.
$smcFunc['db_insert']('insert',
$db_prefix . 'log_polls',
array('id_poll' => 'int', 'id_member' => 'int', 'id_choice' => 'int'),
$inserts,
array('id_poll', 'id_member', 'id_choice')
);
$smcFunc['db_query']('', '
UPDATE {db_prefix}poll_choices
SET votes = votes + 1
WHERE id_poll = {int:current_poll}
AND id_choice IN ({array_int:option_list})',
array(
'option_list' => $options,
'current_poll' => $_POST['poll'],
)
);

// Track the vote if a guest.
if ($user_info['is_guest'])
{
$_COOKIE['guest_poll_vote'] = !empty($_COOKIE['guest_poll_vote']) ? ($_COOKIE['guest_poll_vote'] . ',' . $row['id_poll']) : $row['id_poll'];

require_once($sourcedir . '/Subs-Auth.php');
$cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']));
setcookie('guest_poll_vote', $_COOKIE['guest_poll_vote'], time() + 2500000, $cookie_url[1], $cookie_url[0], 0);
}

redirectexit('topic=' . $row['id_topic'] . '.0');
}


If you wanna check it out, please visit http://businesslynx.ca

 

Powered by EzPortal