PDA

View Full Version : Included php file variables


pokemonleague
11-29-2007, 01:39 AM
I'm using the plugin method described in the manual to run a php script, but am having some problems. I need to be able to access $bbuserinfo[userid]. I also need to pass a variable to the script through the url. As far as I can tell, the php script is processed before the vBulletin page and is stored in a variable.

I have tried to pass a variable through the link with no success.
include('ladderpanel.php?op=top');



Including a PHP file:
1. Create a Plug-in for global_start with these contents:

ob_start();
include('path/to/this/file/myfile.php');
$includedphp = ob_get_contents();
ob_end_clean();

Replace the path and filename with the correct path and filename of the PHP file you want to include. The code in myfile.php will execute and any output generated by this script will be stored in $includedphp.

2. Place $includedphp in one of your templates, such as header, navbar, FORUMHOME, depending upon where you want the contents of your PHP file to appear.

Opserty
11-29-2007, 03:35 PM
You use

$vbulletin->userinfo['blabla']

Instead of $bbuserinfo['blabla'], when your working with userinfo in PHP code. I'm sure you should be able to access $vbuletin->userinfo within your PHP script that you are including.

pokemonleague
11-29-2007, 06:53 PM
Thank you, that's exactly what I was looking for.

You use

$vbulletin->userinfo['blabla']

Instead of $bbuserinfo['blabla'], when your working with userinfo in PHP code. I'm sure you should be able to access $vbuletin->userinfo within your PHP script that you are including.


Any idea how I pass variables through the url when using a plugin?
include('ladderpanel.php?op=top');

Eikinskjaldi
11-29-2007, 09:20 PM
Thank you, that's exactly what I was looking for.




Any idea how I pass variables through the url when using a plugin?
include('ladderpanel.php?op=top');

You don't have to. VB will pick up the variables which will be in _GET, _REQUEST and perhaps GPC if you have already handled them. Your code can access them directly.

so withing ladderpanel.php you can just have
$op = $_REQUEST['op'];


though I recommend cleaning first.

pokemonleague
12-01-2007, 08:33 PM
I apologize, I'm not understanding. If I want to pass a variable such as which function to perform, what do I need to do? I know I need $_GET or $_REQUEST in my ladderpanel.php file to retrieve the variables, but how do I send them to the file?

You don't have to. VB will pick up the variables which will be in _GET, _REQUEST and perhaps GPC if you have already handled them. Your code can access them directly.

so withing ladderpanel.php you can just have
$op = $_REQUEST['op'];


though I recommend cleaning first.

Eikinskjaldi
12-03-2007, 12:09 AM
They are already there. You don't need to do anything at all. _GET and _REQUEST are available in all files.