View Full Version : Search Form on Non-VBulletin Page How-To?
Brett
04-26-2010, 05:34 PM
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.
cad2go
04-26-2010, 06:21 PM
saw your thread on .com
really all you need to include is // ######################### 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.
Brett
04-26-2010, 08:58 PM
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...?
Lynne
04-27-2010, 02:09 PM
You may only use those variables if you have included global.php somewhere in the script prior to try to use them.
Brett
04-27-2010, 02:18 PM
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. :)
Brett
05-06-2010, 11:46 PM
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.".
Lynne
05-07-2010, 01:02 AM
Try:
echo "anything yet?!" . $vbulletin->userinfo['securitytoken'];
Brett
05-07-2010, 08:17 PM
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:
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:
<?php
$curdir = getcwd ();
chdir('/home/jamgears/public_html/forums');
require_once('./global.php');
chdir ($curdir);
echo $vbulletin->userinfo['securitytoken'];
?>
Lynne
05-07-2010, 09:54 PM
If it's sending the headers again, then perhaps you are including global.php twice.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.