| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| [', $post['board']['link'], '] |
', $post['subject'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : ' ', '
|
', $post['time'], ' |
| ', $txt['smf82'], ' | ', $txt[330], ' | ', $txt[21], ' |
|---|---|---|
', $board['link'], $board['new'] ? ' ' : '', ' |
', $board['num_topics'], ' | ', $board['num_posts'], ' |
| ', $txt[301], ' | ', $txt[110], ' | |
|---|---|---|
| ', $topic['link'], ' | ', $topic['num_views'], ' | ', $topic['num_replies'], ' |

',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
echo '
';
}
function ssi_showPoll($topic = null, $output_method = 'echo')
{
global $db_prefix, $txt, $ID_MEMBER, $settings, $boardurl, $sc, $user_info;
$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))
{
$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(
'percent' => $bar,
'votes' => $option[1],
'bar' => '
',
'option' => doUBBC($option[0]),
'vote_button' => ''
);
}
$return['allowed_warning'] = $row['maxVotes'] > 1 ? sprintf($txt['poll_options6'], $row['maxVotes']) : '';
if ($output_method != 'echo')
return $return;
if ($return['allow_vote'])
{
echo '
';
}
else
{
echo '
| ', $return['question'], ' | |
| ', $option['option'], ' | ', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%) |
| ', $txt['smf24'], ': ', $return['total_votes'], ' | |
| ', $news['icon'], ' ', $news['subject'], ' ', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], ' |
| ', $news['body'], ' |
| ', $news['link'], ' | ', $news['new_comment'], ' |