vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Security token with external search field. (https://vborg.vbsupport.ru/showthread.php?t=203057)

JonZ 04-08-2009 09:56 AM

Quote:

Originally Posted by Voltar (Post 1725161)
You can have access to a users' security token outside of standard forum pages if you include global.php.

PHP Code:

require_once('./global.php');
print(
$vbulletin->userinfo['securitytoken']); 

Would print out the hash. To use it in a search box, you would need to create a new hidden field in your form

PHP Code:

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




Oh thanks man, it working! I hit my head on a wall for days on this problem.

TJ3 04-22-2009 02:29 AM

Having the same problem here!

Where does this code go?

require_once('./global.php');
print($vbulletin->userinfo['securitytoken']);

Dismounted 04-22-2009 07:03 AM

This thread only applies if you are creating your own files - are you doing this?

TJ3 04-22-2009 02:51 PM

Problem has been solved, thanks for checking in.

This was for a search box outside of the existing ones, so it needed to generate the token.

theybannedme 04-24-2009 05:22 PM

Quote:

Originally Posted by TJ3 (Post 1796772)
Problem has been solved, thanks for checking in.

This was for a search box outside of the existing ones, so it needed to generate the token.

Would you mind explaining how you did it step by step? Thanks much.

Dismounted 04-25-2009 10:26 AM

Including global.php will generate a token automatically, otherwise, you can generate one yourself.

theybannedme 04-25-2009 02:01 PM

Thanks for the quick response. I'm trying to do this on a wordpress page. On the appropriate php file for the template sidebar of WP I put this code:

Code:

<?php $vwd = '/home/domains/theybannedme.com/www_root/forums';
if ($vwd)
{
    chdir($vwd);
}

require_once ('/home/domains/theybannedme.com/www_root/forums/global.php');
print($vbulletin->userinfo['securitytoken']); ?>


<div class="sidebar-item">
<form action="http://www.theybannedme.com/forums/memberlist.php?do=search" method="post" name="search">
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="process" />
<input type="hidden" name="showposts" value="0" />
<input type="hidden" name="quicksearch" value="1" />
<input type="text" name="query" size="20" value="Search" onfocus="this.value=''" />&nbsp;
<input type="submit" value="Go" name="gobutton">
</form>
</div>

It gives me the search bar but when I try to search, I get the vbulletin error telling me invalid security token (before it said token was "missing" but after tweaking it says "invalid" so I think I'm close). Did I put it in the right place? Is my code messed up? Thank you again.

Dismounted 04-26-2009 05:20 AM

$bbuserinfo can only be used inside vBulletin templates.
Code:

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

theybannedme 04-26-2009 06:01 AM

Using this:

Code:

<?php $vwd = '/home/domains/theybannedme.com/www_root/forums';
if ($vwd)
{
    chdir($vwd);
}

require_once ('/home/domains/theybannedme.com/www_root/forums/global.php');
print($vbulletin->userinfo['securitytoken']); ?>


<form action="http://www.theybannedme.com/forums/memberlist.php?do=search" method="post" name="search">
<input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken']; ?>" />
<input type="hidden" name="do" value="process" />
<input type="hidden" name="showposts" value="0" />
<input type="hidden" name="quicksearch" value="1" />
<input type="text" name="query" size="20" value="Search" onfocus="this.value=''" />&nbsp;
<input type="submit" value="Go" name="gobutton">
</form>

Now I get this. :(

Quote:

Your submission could not be processed because a security token was missing.

If this occurred unexpectedly, please inform the administrator and describe the action you performed before you received this error.
Thank you for your help.

Dismounted 04-26-2009 10:19 AM

View the source of the page - is there a token there?


All times are GMT. The time now is 03:10 PM.

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.01101 seconds
  • Memory Usage 1,745KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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