vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Possible Miscode in poll.php (https://vborg.vbsupport.ru/showthread.php?t=219059)

DJ29Joesph 07-20-2009 11:27 PM

Possible Miscode in poll.php
 
I was coming across some code and was in poll.php and I think I found an error in the php file.

Heres the code

Its on line 626.
PHP Code:

        while ($name $db->fetch_array($public))
        {
            
fetch_musername($name);
            
$allnames["$name[voteoption]"][] = '<a href="member.php?' $vbulletin->session->vars['sessionurl'] . "u=$name[userid]\">$name[musername]</a>";
        } 

I believe where the </a> ends it should be a single quote, not a double quote. Can someone please look at this for me.

I may be wrong I am just a beginner, but I thought I would give it a shot of reporting it.

I have vbulletin Version 3.8.3. Thanks

HMBeaty 07-20-2009 11:29 PM

I do believe you are correct :)

--------------- Added [DATE]1248140019[/DATE] at [TIME]1248140019[/TIME] ---------------

Actually, now that I look at it again, I think it may be missing a quote

JamesC70 07-21-2009 12:12 AM

Quote:

Originally Posted by DJ29Joesph (Post 1852536)
I was coming across some code and was in poll.php and I think I found an error in the php file.

It looks correct to me. I'll use quote instead of code, so I can highlight the pairs:

Quote:

$allnames["$name[voteoption]"]
[] = '<a href="member.php?'
. $vbulletin->session->vars['sessionurl']
. "u=$name[userid]\">$name[musername]</a>";

In each line of the quote above, the opening and closing quotes are highlighted in red.

The one that's throwing you off is the green one, preceeded with a backslash. The backslash indicates to PHP to "keep this intact, don't interpret it as code". This needs to be done when including a double-quote character within double-quote marks.

The double-quote before member.php (line 2 in quote above) doesn't need a backslash in front of it because it's not inside a pair of double-quotes, it's inside single quotes. Hence the difference.


Refer to php.net for further information. :)

DJ29Joesph 07-21-2009 12:17 AM

Personally that doesn't make any sense.

Why would u=$name be part of </a>???

HMBeaty 07-21-2009 12:19 AM

Thats part of the link that allows you to go to the users profile when clicked

JamesC70 07-21-2009 12:21 AM

The code is creating a clickable link.... embedding a variable into HTML.

HTML uses <a href="_____">click this part</a> -- "click this part" is what you see on the screen; the code in brackets is what tells the browser to interpret it as a link.

DJ29Joesph 07-21-2009 12:26 AM

$allnames[START1$name[voteoption]END1]
[] = START2<a href=START3member.php?END2
. $vbulletin->session->vars[START4sessionurlEND4]
. END3u=$name[userid]\START5 OR NOTHING>$name[musername]</a>START5 OR END 5;

still doesnt make any sense.

I know how to make a link I have 2 years of web design on my belt

EDIT::::

ok, if I'm correct the only thing wrong is "u=$name should be a single quote not double

JamesC70 07-21-2009 12:45 AM

Quote:

Originally Posted by DJ29Joesph (Post 1852572)
ok, if I'm correct the only thing wrong is "u=$name should be a single quote not double

If $name is inside a single quote, PHP won't give it a value. It must be inside double quotes, or inside no quotes at all, for PHP to assign a value to $name.

This is why $allnames["$name[voteoption]"] uses double-quotes instead of single-quotes, too.

Quote:

Originally Posted by php.net
The most important feature of double-quoted strings is the fact that variable names will be expanded. See string parsing for details.


DJ29Joesph 07-21-2009 12:48 AM

I believe the quote is "$allnames
not ["$name

I think im seeing things

u= is part of the link not the variable

JamesC70 07-21-2009 12:50 AM

Quote:

Originally Posted by DJ29Joesph (Post 1852585)
I believe the quote is "$allnames
not ["$name

I think im seeing things

You might be. :( I've been copying/pasting from your first post, and everything looks consistent here.

Yes, u= is part of the link. When a variable is inside double-quotes, PHP will replace the variable with it's value. In this case, the user's id would be inserted in place of $name[userid].


All times are GMT. The time now is 07:50 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02141 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete