vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Security Token issue in new area not discussed in this forum (https://vborg.vbsupport.ru/showthread.php?t=249453)

WNxWakko 08-27-2010 08:25 PM

Security Token issue in new area not discussed in this forum
 
I am trying to put a form into a custom BBCODE that searches a custom field6. I have my reasons but am looking for help to make this work.



I have tried so many different suggestion that I found searching VB and vbmods forums.



When I put the below into a BBCODE and use that code in a post, I get "Your submission could not be processed because a security token was invalid."



Code:

<form action="memberlist.php?do=getall" method="post">

<input type="hidden" name="s" value="$session[sessionhash]" />

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />

<input type="hidden" name="do" value="getall" />

<input type="text" class="bginput" name="field6" value="" size="25" maxlength="100" />

<input type="submit" class="button" value="Search Now" accesskey="s" />

  </form>



I have tried all of the following as well with no success,

Code:

<input type="hidden" name="s" value="{vb:raw session.sessionhash}" />

<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />



Code:

<input type="hidden" name="s" value="$session[sessionhash]" />

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />



Oddly, this one works in a nonvb page but not in a post of course because it has PHP code in it.



Code:


<?php

require_once('./Forum/global.php');

?>

 

<form action="/Forum/memberlist.php?do=getall" method="post">

<input type="hidden" name="s" value="" />

<input type="hidden" name="securitytoken" value="<?php echo($vbulletin->userinfo['securitytoken']); ?>" />

<input type="hidden" name="do" value="getall" />

<input type="text" class="bginput" name="field6" value="" size="25" maxlength="100" />

<input type="submit" class="button" value="Search Now" accesskey="s" />

  </form>



Is there something special or different that needs to be stated in the security token here that would allow this search box of a custom field to work in a post using a BBCODE?

kh99 08-27-2010 09:54 PM

I think your problem may be that the result of a bbcode replacement is html but not a template, so you can't include variables. (To check that that's your problem, view the html source of the page and if you see

Code:

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
then that's the problem).

What to do about it - I'm not sure. You could use a plugin on one of the hooks in the bbcode code (like maybe bbcode_parse_complete) do your own search and replace.
For instance, use "__SECURITYTOKEN__" in your bbocde

Code:

<input type="hidden" name="securitytoken" value="__SECURITYTOKEN__" />
and then in the plugin

Code:

$text = str_replace('__SECURITYTOKEN__', $bbuserinfo[securitytoken], $text) ;
but I haven't tried it so be prepared to debug.

Of course that's not a perfect solution because __SECURITYTOKEN__ could conceivably show up in a post for some other reason, but it's the best I could do off the top of my head.

WNxWakko 08-28-2010 04:21 PM

You are right, when viewing the HTML, I see exactly what you said I would.

I've tried what you suggested below and still no luck. Any ideas?

kh99 08-28-2010 04:50 PM

Oh...try adding "global $vbulletin;" to the start of the plugin code ETA: ...and change bbuserinfo to vbulletin->userinfo,

so that the code is:

Code:

global $vbulletin;
$text = str_replace('__SECURITYTOKEN__', $vbulletin->userinfo[securitytoken], $text) ;

If that doesn't work, view the html source again and see what the hidden value looks like.

ETA: OK, I went and tried it and this seems to work. One thing I'm not sure about is that there's a bbcode_parse_complete_precache hook a little before the one we're using, and it's before the post is cached (as the name suggests). I'm not sure what the implications are of using one over the other. I thought I'd use post-cache so the token doesn't get cached, but I haven't studied the code.

WNxWakko 08-28-2010 08:56 PM

Seems though your code worked. I am past the token issue I think.

Although now when I enter something in the search box I get this VB message,

"vBulletin Message
Invalid Action Specified "

what is interesting is the URL I see in the browser bar is,
inlinemod.php?threadid=604440&p=


I should see it goto the memberlist.php so it can search custom field6. Any ideas if this is still token related or perhaps searching a field from a post needs additional plugin coding.

The source code view of the thread that has this shows the following,

Code:

<form action="memberlist.php?do=getall" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="1283032473-228842d7329277b18921e7cc4c16e4474aa5243d" />
<input type="hidden" name="do" value="getall" />
<input type="text" class="bginput" name="field6" value="" size="25" maxlength="100" />
<input type="submit" class="button" value="Search Now" accesskey="s" />
  </form>

One more thing to point out that is odd. This works in the preview thread screen, but not after you actually post it.

kh99 08-28-2010 09:36 PM

I'm not sure if it's the only problem, but it looks like that part has the same problem with $session[sessionhash] not getting replaced.

Lynne 08-28-2010 09:57 PM

See if you have the same problem as a regular user. You, an admin or moderator, will have a problem because you are putting a form inside a form (inline moderation).

WNxWakko 08-29-2010 12:13 AM

Interesting. Regular users can use the form without any issue. It seems that only Admins/Moderators cannot use it.

Any idea how to get around this?

Lynne 08-29-2010 01:41 AM

There is no way around it unless you turn off inline moderation. You can't have forms within forms and inline moderation, where you can select the posts and then do something with them at the bottom of the page, is a big form.

WNxWakko 08-29-2010 04:47 AM

Hmm, not even possible to embed forms in forms. That seems like a flaw in the code design of forms somewhere. lol

I am very appreciative of all the help given here. Its just to bad it comes to a halt over this feature. If there is any other tricks around this, I'm all ears.


All times are GMT. The time now is 10:06 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.00989 seconds
  • Memory Usage 1,746KB
  • 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
  • (9)bbcode_code_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