Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Zetan on November 23, 2007, 07:52:49 PM

Title: SSI Poll Bug?
Post by: Zetan on November 23, 2007, 07:52:49 PM
I noticed when using a snippet of Thurnoks:
http://www.tinyportals.net/index.php?topic=10786.msg165049;topicseen

That regardless of if I set the poll to display the results after the poll has expired, the SSI function goes right ahead and displays the results to guests and other members.

http://labradio.co.uk/index.php?action=forum

That seems to be a bug to me, unless the snippet need extra elements?
Title: Re: SSI Poll Bug?
Post by: SleePy on November 23, 2007, 11:57:13 PM
Its done on purpose. If they can't vote, it just shows the results.

You could have it return as an array and force a login instead.
Title: Re: SSI Poll Bug?
Post by: Zetan on November 24, 2007, 04:40:06 AM
Thanks for the reply.
It doesn't make sense to me, the poll in the topic does not display the results.
The polls are in a block above the board index, forcing a login won't let guests view the options?
Members can vote, yet it still displays the results to members logged in.

It's not just Guests that see the SSI Poll results, it's all member groups except Admin, it looks fine to me, and I can view the results in the topic as Admin, but not from the SSI.
Title: Re: SSI Poll Bug?
Post by: metallica48423 on November 25, 2007, 11:07:24 AM
so you're saying it ignores the settings of the poll as far as who can view the results and when?
Title: Re: SSI Poll Bug?
Post by: Zetan on November 26, 2007, 08:01:12 PM
Thats correct.. It totally ignores all the settings.

Here is the code used:


echo '<table><tr>
<td>
';
ssi_showPoll(1574);
echo '<br />
<a href="http://labradio.co.uk/index.php/topic,1574.0.html" >View Topic</a>
</td>
<td>';
ssi_showPoll(1575);
echo '<br />
<a href="http://labradio.co.uk/index.php/topic,1575.0.html" >View Topic</a>
</td>
<td>';
ssi_showPoll(1576);
echo '<br />
<a href="http://labradio.co.uk/index.php/topic,1576.0.html" >View Topic</a>
</td>
</tr></table>
';



Title: Re: SSI Poll Bug?
Post by: Zetan on November 27, 2007, 02:11:06 PM
Anyone have any ideas on this?

It's spoiled the end of year Best Albums poll in a way as I  didn't want members influencing each others choices.
Title: Re: SSI Poll Bug?
Post by: metallica48423 on November 27, 2007, 07:17:42 PM
i'll pass it on to someone who might be able to take a better look, it may well be a bug.

Thanks
Title: Re: SSI Poll Bug?
Post by: SleePy on November 27, 2007, 07:36:01 PM
Its not a bug its done on purpose if you look at the code.

It finds out if your a guest or have already voted. If you are it shows results

Simple fix to just add a guest check around that code. I changed the style a little but you can see the not guest check that is performed first.

if(!$context['user']['is_guest'])
echo '
<table>
<tr>
<td>', ssi_showPoll(1574), '<br /><a href="http://labradio.co.uk/index.php/topic,1574.0.html" >View Topic</a>
</td><td>, ssi_showPoll(1575), '<br /><a href="http://labradio.co.uk/index.php/topic,1575.0.html" >View Topic</a>
</td><td>', ssi_showPoll(1576), '<br /><a href="http://labradio.co.uk/index.php/topic,1576.0.html" >View Topic</a>
</td>
</tr>
</table>';


You could make it even prompt to login by changing

if(!$context['user']['is_guest'])
to
if($context['user']['is_guest'])
ssi_login();
else
Title: Re: SSI Poll Bug?
Post by: SleePy on November 27, 2007, 07:51:08 PM
Hate to bump my own post. But actually after having another user explain to me what was going on (I wasn't getting it), I see the bug.

Quick fix. Remember while we don't suggest editing the SSI.php, I think we can ignore this to fix the bug. I can't say if the devs will use this to fix the bug though. Its my method :P
Open SSI.php and Find:

else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}


Add before that:
elseif (!empty($row['expireTime']) && $row['expireTime'] > time())
{
if(!$context['user']['is_guest'])
echo $txt['smf27'];
else
echo $txt['cannot_poll_vote'];

}


Which basics sees if the poll is still running and if it is gives non guests an error that they already voted (as the first if would fail due to them voting) and falls back to saying they can't vote.

My other method above would still work though to give a login screen for guest ;)

Edit, moving back to bug reports board ;)
Sorry for not seeing it earlier.
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 07:43:57 AM
Brilliant! I'll do this when I get home from work, maybe I didn't explain it well enough.

I don't think I want to redirect guests to a login screen, I want members and guests to see the options, but not the results until the poll has expired.


Thanks SleePy  8)
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 03:59:11 PM
That doesn't quite work, or I have done it wrong.. heres the code now:

Scrap that.. database error..
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 04:15:34 PM
ok.. I keep getting a database error when trying to post the full code here.
Title: Re: SSI Poll Bug?
Post by: metallica48423 on November 28, 2007, 04:18:51 PM
attach it to the post ;)
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 04:29:30 PM
Okay.. after wanting to kill my laptop.. (scuse me.. Ale in pub and calm ZTN don't mix well) Grrr

lol

See attached..


[edit]

Gah.. wheres the attach option?

Additional Options...
   
Notify me of replies.    
Return to this topic.    
Don't use smileys.

thats it.. no attach
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 04:36:57 PM
Coda:




The following error or errors occurred while posting this message:
The message exceeds the maximum allowed length (65530 characters).



Gahhhhh.. give up!

I tried.. every which way  :-\
Title: Re: SSI Poll Bug?
Post by: metallica48423 on November 28, 2007, 04:51:26 PM
really?  Hrmmmm I can attach.

and it wont post with it in [code] tags?
Title: Re: SSI Poll Bug?
Post by: Zetan on November 28, 2007, 05:01:13 PM
it allows me to post some of the code..

I have to sleep.. will try again tomorrow, and pull just the code around the edit.

:)

Z
Title: Re: SSI Poll Bug?
Post by: SleePy on November 28, 2007, 09:37:23 PM
Zetan we had some minor issues with the database server this morning. They are brand new servers and still need tweaking for proper setup.

What isn't working? Is it not showing anything? Can you detail more whats happening? Is there any errors in the SMF error log?
Title: Re: SSI Poll Bug?
Post by: Zetan on November 29, 2007, 02:12:56 AM
Apologies, had been to the pub last night = Stay away from computers!

All I see now are the links to the topics where the polls are. No poll or results are displayed.
Same for guests and members logged in.

Error log:
Quote
Only show the error messages of this URL

/index.php?action=forum


Only show the errors with the same message

8: Undefined index: smf27
File: /home/********/public_html/SSI.php
Line: 1069


Part of my SSI.php showing the Polls functions


// Show the most-voted-in poll.
function ssi_topPoll($output_method = 'echo')
{
// Just use recentPoll, no need to duplicate code...
return ssi_recentPoll($output_method, true);
}

// Show the most recently posted poll.
function ssi_recentPoll($output_method = 'echo', $topPollInstead = false)
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
global $context;

$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));

if (empty($boardsAllowed))
return array();

$request = db_query("
SELECT p.ID_POLL, p.question, t.ID_TOPIC, p.maxVotes
FROM ({$db_prefix}polls AS p, {$db_prefix}boards AS b, {$db_prefix}topics AS t" . ($topPollInstead ? ", {$db_prefix}poll_choices AS pc" : '') . ")
LEFT JOIN {$db_prefix}log_polls AS lp ON (lp.ID_POLL = p.ID_POLL AND lp.ID_MEMBER = $ID_MEMBER)
WHERE p.votingLocked = 0" . ($topPollInstead ? "
AND pc.ID_POLL = p.ID_POLL" : '') . "
AND lp.ID_CHOICE IS NULL
AND t.ID_POLL = p.ID_POLL
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? "
AND b.ID_BOARD IN (" . implode(', ', $boardsAllowed) . ")" : '') . "
ORDER BY " . ($topPollInstead ? 'pc.votes' : 'p.ID_POLL') . " DESC
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);

// This user has voted on all the polls.
if ($row === false)
return array();

$request = db_query("
SELECT COUNT(DISTINCT ID_MEMBER)
FROM {$db_prefix}log_polls
WHERE ID_POLL = $row[ID_POLL]", __FILE__, __LINE__);
list ($total) = mysql_fetch_row($request);
mysql_free_result($request);

$request = db_query("
SELECT ID_CHOICE, label, votes
FROM {$db_prefix}poll_choices
WHERE ID_POLL = $row[ID_POLL]", __FILE__, __LINE__);
$options = array();
while ($rowChoice = mysql_fetch_assoc($request))
{
censorText($rowChoice['label']);

$options[$rowChoice['ID_CHOICE']] = array($rowChoice['label'], $rowChoice['votes']);
}
mysql_free_result($request);

$return = array(
'id' => $row['ID_POLL'],
'image' => 'poll',
'question' => $row['question'],
'total_votes' => $total,
'is_locked' => false,
'topic' => $row['ID_TOPIC'],
'options' => array()
);

// Calculate the percentages and bar lengths...
$divisor = $return['total_votes'] == 0 ? 1 : $return['total_votes'];
foreach ($options as $i => $option)
{
$bar = floor(($option[1] * 100) / $divisor);
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);
$return['options'][$i] = array(
'id' => 'options-' . $i,
'percent' => $bar,
'votes' => $option[1],
'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_left.gif" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll_right.gif" alt="" /></span>',
'option' => parse_bbc($option[0]),
'vote_button' => '<input type="' . ($row['maxVotes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="check" />'
);
}

$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';

if ($output_method != 'echo')
return $return;

echo '
<form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
<input type="hidden" name="poll" value="', $return['id'], '" />
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';
}

function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
global $context;

$boardsAllowed = boardsAllowedTo('poll_view');

if (empty($boardsAllowed))
return array();

if ($topic === null && isset($_REQUEST['ssi_topic']))
$topic = (int) $_REQUEST['ssi_topic'];
else
$topic = (int) $topic;

$request = db_query("
SELECT
p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
WHERE p.ID_POLL = t.ID_POLL
AND t.ID_TOPIC = $topic
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? "
AND b.ID_BOARD IN (" . implode(', ', $boardsAllowed) . ")" : '') . "
LIMIT 1", __FILE__, __LINE__);

// Either this topic has no poll, or the user cannot view it.
if (mysql_num_rows($request) == 0)
return array();

$row = mysql_fetch_assoc($request);
mysql_free_result($request);

// Check if they can vote.
if (!empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;
elseif ($user_info['is_guest'] || !empty($row['votingLocked']) || !allowedTo('poll_vote'))
$allow_vote = false;
else
{
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}log_polls
WHERE ID_POLL = $row[ID_POLL]
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
$allow_vote = mysql_num_rows($request) == 0;
mysql_free_result($request);
}

$request = db_query("
SELECT COUNT(DISTINCT ID_MEMBER)
FROM {$db_prefix}log_polls
WHERE ID_POLL = $row[ID_POLL]", __FILE__, __LINE__);
list ($total) = mysql_fetch_row($request);
mysql_free_result($request);

$request = db_query("
SELECT ID_CHOICE, label, votes
FROM {$db_prefix}poll_choices
WHERE ID_POLL = $row[ID_POLL]", __FILE__, __LINE__);
$options = array();
$total_votes = 0;
while ($rowChoice = mysql_fetch_assoc($request))
{
censorText($rowChoice['label']);

$options[$rowChoice['ID_CHOICE']] = array($rowChoice['label'], $rowChoice['votes']);
$total_votes += $rowChoice['votes'];
}
mysql_free_result($request);

$return = array(
'id' => $row['ID_POLL'],
'image' => empty($pollinfo['votingLocked']) ? 'poll' : 'locked_poll',
'question' => $row['question'],
'total_votes' => $total,
'is_locked' => !empty($pollinfo['votingLocked']),
'allow_vote' => $allow_vote,
'topic' => $topic
);

// Calculate the percentages and bar lengths...
$divisor = $total_votes == 0 ? 1 : $total_votes;
foreach ($options as $i => $option)
{
$bar = floor(($option[1] * 100) / $divisor);
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);
$return['options'][$i] = array(
'id' => 'options-' . $i,
'percent' => $bar,
'votes' => $option[1],
'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_left.gif" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll_right.gif" alt="" /></span>',
'option' => parse_bbc($option[0]),
'vote_button' => '<input type="' . ($row['maxVotes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="check" />'
);
}

$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';

if ($output_method != 'echo')
return $return;

if ($return['allow_vote'])
{
echo '
<form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
<input type="hidden" name="poll" value="', $return['id'], '" />
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';
}
elseif (!empty($row['expireTime']) && $row['expireTime'] > time())
{
if(!$context['user']['is_guest'])
echo $txt['smf27'];
else
echo $txt['cannot_poll_vote'];

}
else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}
}

// Takes care of voting - don't worry, this is done automatically.
function ssi_pollVote()
{
global $db_prefix, $ID_MEMBER, $user_info, $sc;

if (!isset($_POST['sc']) || $_POST['sc'] != $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 language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
history.go(-1);
// ]]></script>
</head>
<body>&laquo;</body>
</html>';
return;
}


I can't make edits at work as Uploads are blocked by the firewall, I've removed that edit to the code for now.
Title: Re: SSI Poll Bug?
Post by: SleePy on November 29, 2007, 12:13:54 PM
Hmmm. Seems that the errors language File isn't loaded.

In the code I had you add Find:
if(!$context['user']['is_guest'])

Add before:
loadLanguage('Errors');

That error code means you have already voted in that poll
Title: Re: SSI Poll Bug?
Post by: Zetan on November 29, 2007, 12:26:38 PM
Ok, When I'm logged in I see:

Quote
Either that poll doesn't exist, the poll has been locked, or you tried to vote twice.
View Topic

Guests see
Quote
Sorry, but you cannot vote in polls in this board.
View Topic

No errors in the logs.

In the topic:
http://labradio.co.uk/index.php/topic,1576.0.html

Guests can see the Poll list, but no option to vote.
Title: Re: SSI Poll Bug?
Post by: metallica48423 on November 29, 2007, 02:16:01 PM
smf 1.1 does not allow guests to vote. i believe this was added as an option for version 2.
Title: Re: SSI Poll Bug?
Post by: Zetan on November 29, 2007, 02:41:39 PM
Hi BlackMage.
I don't want guests to vote.. I want them to see the list like they can in the topic I linked.

I would like the SSI Poll to function the same as it does in topics  :)
Title: Re: SSI Poll Bug?
Post by: SleePy on November 29, 2007, 08:13:22 PM
Zetan,

You want them to see the options but not vote? The code I did just returns those errors to the user explaining why they can't see it.

Well if you want to do that it would be better to actually output the code. But since we have already modded the SSI.php it wouldn't make much difference  :P

Find:
elseif (!empty($row['expireTime']) && $row['expireTime'] > time())
{
if(!$context['user']['is_guest'])
echo $txt['smf27'];
else
echo $txt['cannot_poll_vote'];

}
else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}


Replace
else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>', (!empty($row['expireTime']) && $row['expireTime'] > time() ? '
<td align="left">' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)</td>' : ''), '
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}


I can't say which code or if the devs will even use these examples or if they plan to do anything about it though.
Title: Re: SSI Poll Bug?
Post by: Zetan on November 30, 2007, 02:38:26 AM
lol.. Now we are back where we started, guests and members can see the results.

I hate to see a grown man cry.. but here  :'( pass me a hanky.


:P
Title: Re: SSI Poll Bug?
Post by: SleePy on November 30, 2007, 12:22:19 PM
Sorry about that. I didn't actually test these.

In that code find:
(!empty($row['expireTime']) && $row['expireTime'] > time()

Just flip the > to a < and it should work now

I forgot that with > it is seeing that the expire time is still greater than time() itself and showing. So flipping it will reverse this and not show it until time expires.
Title: Re: SSI Poll Bug?
Post by: Zetan on November 30, 2007, 12:36:08 PM
W000TERZ  :D

I think you cracked it this time.. Not sure yet how it behaves with different settings in the poll.
I removed one of my votes and the radio buttons for that poll has displayed.

Thank you for looking into it, and I hope the Devs do provide an update for the next release as I had noticed something odd with it before.. Now running 3 polls side by side, it became more apparent.


Cheers SleePy  :)


ZTN
Title: Re: SSI Poll Bug?
Post by: Nicko! on February 14, 2008, 11:15:06 AM
Hi guys,

I have followed all the steps here; and have it kind of working.

Problem is that only the admin can see the radio buttons in my code. I have it set to display the contents of the topic and then the voting options; only allowing logged in users to vote and not display results until after the poll has expired.

SSI.php has been amended as described; with my code for the display of the poll as follows:


function show_poll()
{
global $table_1, $table_h1, $table_h2, $table_2, $table_3;

echo $table_1 . $table_h1 . "CAST YOUR VOTE" . $table_h2 . $table_2;

$topic = $_GET['item'];
    $link = 'http://www.buscevents.com/community/index.php?topic=' . $topic;
$result = ssi_topicNews($topic, $limit = null, $start = null, $length = null, $link = null, $output_method = 'array');

echo "<img src='/pagesetup/bot_spacer.gif' width=690 height=1><br>";
echo "<div style='float: left; margin: 0 0 0 0;'><img src='/pagesetup/bot_spacer.gif' height=800 width=1></div>";

foreach ($result as $news)
    {
echo "<b>" . $news['subject'] . "</b><p>", $news['body'] . "<br><p>";

ssi_showPoll($topic);

echo '<p><font size=-2>', $news['link'], ' | ', $news['new_comment'], ' | ', $news['time'], ' | ', $news['poster']['link'], '</font>';
    }


echo $table_3;
}


Any thoughts?
Title: Re: SSI Poll Bug?
Post by: [SiNaN] on February 15, 2008, 04:08:22 AM
I got the same problem. Only admins can vote.

//Edit: Have found the answer, thanks akabugeyes.

http://www.simplemachines.org/community/index.php?topic=135131.msg860679#msg860679
Title: Re: SSI Poll Bug?
Post by: Kender on February 19, 2008, 05:16:03 PM
i did a hack to get this to work how i wanted.

Guest sees options, with button that is disabled, saying login to vote
user with voting permissions sees options,  with button to vote
admin sees options with button to vote

once voted, you see results (except guest again, who will see disabled options)

FIND (assuming you made changes suggested earlier in the thread)

// Check if they can vote.
if ($user_info['is_guest'] || !empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;


REPLACE WITH (removing the bit about guests)

// Check if they can vote.
if (!empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;


FIND

if ($return['allow_vote'])


ADD BEFORE

if ($user_info['is_guest'])
{
echo '
<form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
<input type="hidden" name="poll" value="', $return['id'], '" />
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="Login to Vote" DISABLED /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';
}

This sets up a view for guests only, allowing a view of options, but disabled button

FIND

else
{

echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}
}


REPLACE WITH

else
if (!$user_info['is_guest'])
{

echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}
}

in this part, we are adding a "if user is NOT a guest" but doesn't fit the other criteria, then we show them the results