...

View Full Version : PHP Code Help



Omega
01-24-2008, 03:42 AM
So here is my situation, I have a vBulletin forum which uses PHP documents just like this one does.

I am trying to alter the poll bar gif width.

However the problem that I have is that when I change the numeric value that does this, it also changes the numeric value for the % shown as well.

Before I change the variable it looks like this at 100%

http://img.photobucket.com/albums/v318/scorpion_666/problems.gif

After I change the variable it looks like this:

http://img.photobucket.com/albums/v318/scorpion_666/last-problem.gif

See that.

How can I make it so that the bar fills up the space, but shows 100% instead of 200%?

What adjustment to this code do I need to make?


##################################################################
############################### SHOW POLL ######################################
################################################################################
$poll = '';
if ($thread['pollid'])
{
$pollbits = '';
$counter = 1;
$pollid = $thread['pollid'];

$show['editpoll'] = iif(can_moderate($threadinfo['forumid'], 'caneditpoll'), true, false);

// get poll info
$pollinfo = $db->query_first("
SELECT *
FROM " . TABLE_PREFIX . "poll
WHERE pollid = $pollid
");

require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

$pollinfo['question'] = $bbcode_parser->parse(unhtmlspecialchars($pollinfo['question']), $forum['forumid'], true);

$splitoptions = explode('|||', $pollinfo['options']);
$splitvotes = explode('|||', $pollinfo['votes']);

$showresults = 0;
$uservoted = 0;
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote']))
{
$nopermission = 1;
}

if (!$pollinfo['active'] OR !$thread['open'] OR ($pollinfo['dateline'] + ($pollinfo['timeout'] * 86400) < TIMENOW AND $pollinfo['timeout'] != 0) OR $nopermission)
{
//thread/poll is closed, ie show results no matter what
$showresults = 1;
}
else
{
//get userid, check if user already voted
$voted = intval(fetch_bbarray_cookie('poll_voted', $pollid));
if ($voted)
{
$uservoted = 1;
}
}

($hook = vBulletinHook::fetch_hook('showthread_poll_start')) ? eval($hook) : false;

if ($pollinfo['timeout'] AND !$showresults)
{
$pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + ($pollinfo['timeout'] * 86400));
$pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + ($pollinfo['timeout'] * 86400));
$show['pollenddate'] = true;
}
else
{
$show['pollenddate'] = false;
}

foreach ($splitvotes AS $index => $value)
{
$pollinfo['numbervotes'] += $value;
}

if ($vbulletin->userinfo['userid'] > 0 AND $pollinfo['numbervotes'] > 0)
{
$pollvotes = $db->query_read("
SELECT voteoption
FROM " . TABLE_PREFIX . "pollvote
WHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = $pollid
");
if ($db->num_rows($pollvotes) > 0)
{
$uservoted = 1;
}
}

if ($showresults OR $uservoted)
{
if ($uservoted)
{
$uservote = array();
while ($pollvote = $db->fetch_array($pollvotes))
{
$uservote["$pollvote[voteoption]"] = 1;
}
}
}

$option['open'] = $stylevar['left'][0];
$option['close'] = $stylevar['right'][0];

foreach ($splitvotes AS $index => $value)
{
$arrayindex = $index + 1;
$option['uservote'] = iif($uservote["$arrayindex"], true, false);
$option['question'] = $bbcode_parser->parse($splitoptions["$index"], $forum['forumid'], true);

// public link
if ($pollinfo['public'] AND $value)
{
$option['votes'] = '<a href="poll.php?' . $vbulletin->session->vars['sessionurl'] . 'do=showresults&amp;pollid=' . $pollinfo['pollid'] . '">' . $value . '</a>';
}
else
{
$option['votes'] = $value; //get the vote count for the option
}

$option['number'] = $counter; //number of the option

//Now we check if the user has voted or not
if ($showresults OR $uservoted)
{ // user did vote or poll is closed

if ($value <= 0)
{
$option['percent'] = 0;
}
else if ($pollinfo['multiple'])
{
$option['percent'] = vb_number_format(($value < $pollinfo['voters']) ? $value / $pollinfo['voters'] * 100 : 100, 2);
}
else
{
$option['percent'] = vb_number_format(($value < $pollinfo['numbervotes']) ? $value / $pollinfo['numbervotes'] * 100 : 100, 2);
}

$option['graphicnumber'] = $option['number'] % 10 + 1;
$option['barnumber'] = round($option['percent']) * 2;

// Phrase parts below
if ($nopermission)
{
$pollstatus = $vbphrase['you_may_not_vote_on_this_poll'];
}
else if ($showresults)
{
$pollstatus = $vbphrase['this_poll_is_closed'];
}
else if ($uservoted)
{
$pollstatus = $vbphrase['you_have_already_voted_on_this_poll'];
}

($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false;

eval('$pollbits .= "' . fetch_template('pollresult') . '";');
}
else
{
($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false;

if ($pollinfo['multiple'])
{
eval('$pollbits .= "' . fetch_template('polloption_multiple') . '";');
}
else
{
eval('$pollbits .= "' . fetch_template('polloption') . '";');
}
}
$counter++;
}

if ($pollinfo['multiple'])
{
$pollinfo['numbervotes'] = $pollinfo['voters'];
$show['multiple'] = true;
}

if ($pollinfo['public'])
{
$show['publicwarning'] = true;
}
else
{
$show['publicwarning'] = false;
}

$displayed_dateline = $threadinfo['lastpost'];

($hook = vBulletinHook::fetch_hook('showthread_poll_complete')) ? eval($hook) : false;

if ($showresults OR $uservoted)
{
eval('$poll = "' . fetch_template('pollresults_table') . '";');
}
else
{
eval('$poll = "' . fetch_template('polloptions_table') . '";');
}

}

I think it precisely has to do with this section of the code, but I don't know how to change it, or what to, to fix this.


$option['barnumber'] = round($option['percent']) * 2;

Thank you from the bottom of my soul if you can actually help me with this.

Sincerely,

Omega

P.S. Gonna be damn impressed if anyone knows this.

PPS: I've already asked at vb.org, I've already asked at vb.com, I've been working on this for a week. So now I'm looking to you experts to figure this out if you know how.

skyrider01
01-24-2008, 05:09 AM
well you could try and change the 2 to a 1 and see what happens, didnt trace through the code, but try that first

Omega
01-24-2008, 05:40 AM
well you could try and change the 2 to a 1 and see what happens, didnt trace through the code, but try that first

Thank you bud.

But the 2 is for the decimal points after 200.00%



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum