Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 04-26-2010, 05:34 PM
Brett Brett is offline
 
Join Date: May 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Search Form on Non-VBulletin Page How-To?

The below code works great for guests, but what is the code to get it to work if you're logged in (and/or not logged in)? It appears to be an issue with the securitytoken, receiving this message if logged in: Your submission could not be processed because you have logged in since the previous page was loaded.

CODE WORKS GREAT, EXCEPT IF LOGGED IN:
===========
<form action="/forums/search.php?do=process" method="post">
<div>
<input type="hidden" name="do" value="process" />
<input type="hidden" name="quicksearch" value="1" />
<input type="hidden" name="childforums" value="1" />
<input type="hidden" name="exactname" value="1" />
<input type="hidden" name="s" value="" />
<input type="text" id="query" name="query" tabindex="1001" class="text" />
<input type="submit" class="button" tabindex="1004" value="Search Forums" class="searchbut" />
<input type="hidden" name="securitytoken" value="guest" />
<input type="hidden" name="showposts" value="1" id="rb_nb_sp0" tabindex="1002" />
</div>
</form>

======
Thanks for any feedback you can provide.
Reply With Quote
  #2  
Old 04-26-2010, 06:21 PM
cad2go cad2go is offline
 
Join Date: Feb 2009
Posts: 181
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

saw your thread on .com

really all you need to include is
PHP Code:
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php'); 
and include the security token as mentioned in the thread over there.

Here's a guide https://vborg.vbsupport.ru/showthread.php?t=228112 from your post over there I think you'll have no major probs.

Good Luck.
Reply With Quote
  #3  
Old 04-26-2010, 08:58 PM
Brett Brett is offline
 
Join Date: May 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is exactly what I was looking for, however it does not seem to work.
No luck with either of these:
$vbulletin->userinfo['securitytoken']
$bbuserinfo[securitytoken]

Am I calling the variable wrong? Echo should output these, correct?
As soon as I get results from either of these using the global.php or whatever it is, I can modify my code below with possibly an if/else "guest".

<?php
chdir ('/home/username/public_html/forums');
require_once('./global.php'); ?>
<form action="/forums/search.php?do=process" method="post">
<div>
<input type="hidden" name="do" value="process" />
<input type="hidden" name="quicksearch" value="1" />
<input type="hidden" name="childforums" value="1" />
<input type="hidden" name="exactname" value="1" />
<input type="hidden" name="s" value="" />
<input type="text" id="query" name="query" tabindex="1001" class="text" />
<input type="submit" class="button" tabindex="1004" value="Search Forums" class="searchbut" />
<input type="hidden" name="securitytoken" value="<?php echo $bbuserinfo[securitytoken] ?>" />
<input type="hidden" name="showposts" value="1" id="rb_nb_sp0" tabindex="1002" />
</div>
</form>

This will ultimately end up within a Wordpress text widget. Maybe the global.php variables are sent via headers only, causing problems...?
Reply With Quote
  #4  
Old 04-27-2010, 02:09 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may only use those variables if you have included global.php somewhere in the script prior to try to use them.
Reply With Quote
  #5  
Old 04-27-2010, 02:18 PM
Brett Brett is offline
 
Join Date: May 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You may only use those variables if you have included global.php somewhere in the script prior to try to use them.
Indeed. Which is why I tried it this way. Unfortunately neither worked. The global.php was included in the above script. Thanks again for the feedback... So close I can taste it.
Reply With Quote
  #6  
Old 05-06-2010, 11:46 PM
Brett Brett is offline
 
Join Date: May 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've now even taken the code out of Wordpress and trying the most basic test, the securitytoken variable is still empty. If I'm logged in or not, nothing is populated for the security token.

<?php
$curdir = getcwd ();
chdir('/home/userdirectory/public_html/forums');
require_once('./global.php');
chdir ($curdir);
echo "anything yet?!" . $bbuserinfo[securitytoken];
?>

If I can simply check for this cookie using the code above, I'd be happy. If anyone has a solution, please enlighten... I'm hoping not to have to hack vb in order to pull this variable. I would use "guest" always, but unfortunately if logged into VB a standard search on a non-VB page, I receive "Your submission could not be processed because you have logged in since the previous page was loaded.".
Reply With Quote
  #7  
Old 05-07-2010, 01:02 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:
echo "anything yet?!" . $vbulletin->userinfo['securitytoken'];
Reply With Quote
  #8  
Old 05-07-2010, 08:17 PM
Brett Brett is offline
 
Join Date: May 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much Lynne! I knew it had to be something simple...

Unfortunately when adding it into the header of our CMS (WP) I get:
Code:
Unable to add cookies, header already sent.
File: /home/userdir/public_html/wp-content/themes/newscast/header.php
Line: 2
Strange thing is, leaving the securitytoken empty now, it appears to be working. Maybe I threw a switch within VB that ignores it now?! Oh well, works for now...


This does work by the way to authenticate on a page outside of VB, but unfortunately tries to send headers again. It even returns "guest" if not logged in:
Code:
<?php
$curdir = getcwd ();
chdir('/home/jamgears/public_html/forums');
require_once('./global.php');
chdir ($curdir);
echo $vbulletin->userinfo['securitytoken'];
?>
Reply With Quote
  #9  
Old 05-07-2010, 09:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it's sending the headers again, then perhaps you are including global.php twice.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08279 seconds
  • Memory Usage 2,245KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete