PDA

View Full Version : call a vBUlletin PHP script from a different php script


Bhuwan
03-13-2006, 06:36 PM
I am using require_once .... and it works great, except the phrases arent being displayed...not sure why

merk
03-13-2006, 08:34 PM
Have you setup the vBulletin enviroment properly? You need to fill out the variables below to make sure vBulletin knows what templates and phrases to load.


// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

Bhuwan
03-13-2006, 08:45 PM
Have you setup the vBulletin enviroment properly? You need to fill out the variables below to make sure vBulletin knows what templates and phrases to load.


// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

Those variables are already setup int he script im trying to load (showthread.php for example). Would they need to be setup AGAIN ?

merk
03-13-2006, 08:51 PM
Why are you trying to load showthread.php like that?

Bhuwan
03-13-2006, 08:52 PM
Why are you trying to load showthread.php like that?just wanna avoid using mod rewrites.

merk
03-13-2006, 08:56 PM
So make a copy of showthread.php and rename it to what you want.

Bhuwan
03-13-2006, 08:59 PM
So make a copy of showthread.php and rename it to what you want.
but i have to pass it through my.php file. There has tob e a way!

merk
03-13-2006, 09:01 PM
There might be, but when there are easier ways I really dont see a need.

mod_rewrite is the solution you're after.

Bhuwan
03-13-2006, 10:45 PM
There might be, but when there are easier ways I really dont see a need.

mod_rewrite is the solution you're after.the problem is that Rewritecond's doesn't handle # properly.

merk
03-14-2006, 12:20 AM
You cant have the # character in a query string. It is a delimiter that the browser uses to scroll.

Bhuwan
03-14-2006, 01:35 AM
You cant have the # character in a query string. It is a delimiter that the browser uses to scroll.

That's one of the reasons why I am attempting to use an external script
that and the fact htat I don't want 20 rewrites :-)

There must be a way to handle this externally? I've done it but the Phrases don't seem to show up....

Any takers? :)

This is how I'm going to showthread.pph script from myscript.php

require_once('./global.php');
global $vbulletin;
$vbulletin->input->clean_gpc('r', 'goto', TYPE_STR);

// doing showthread.php?t=X&goto=newpost
$vbulletin->GPC['goto'] = 'newpost';
$threadid = <some real threadid here is placed as a test>;
require_once('./showthread.php');
exit;


Now -- it does work, except the PHRASES are not there (at leas tnot all of them). Only guess I've had is that global.php is being executed too early..

Any takers? Please!! :banana:

merk
03-14-2006, 02:53 AM
Why are you calling anything prior to the showthread script?

Bhuwan
03-15-2006, 10:25 AM
Why are you calling anything prior to the showthread script?

I wanna run everythig through myscript.php using mod rewrites (for SEO). Hence the reason
Come on! Someone must have the answer!

Akex
03-15-2006, 11:19 AM
You have to set up this also in the script which calls showthread

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

Why ? Because, this need to be setup before global.php is calling. As it's written in your script, you call global.php (require_once mean called once and no more ...) but showthread.php won't call it (as it was already called) ... and $globaltemplates, $phrasegroups etc. won't be loaded.

The Geek
03-15-2006, 03:25 PM
Try NOT including global in your header.
However that means you will need to cleanse your $_REQUEST variables manually.

Not sure if it will work, but it may. Saying that, its still kind of clunky :(

You may be better off using the global_start hook to include your code. Reason being that all your URLs will have to point to the same script which will simply encase each page.

Go with the global_start hook it will work for you in the long run.

HTHs

merk
03-15-2006, 10:41 PM
I still see no reason why mod_rewrite wont work - the # character has nothing to do with server processing.

Bhuwan
03-16-2006, 12:17 AM
You have to set up this also in the script which calls showthread

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

Why ? Because, this need to be setup before global.php is calling. As it's written in your script, you call global.php (require_once mean called once and no more ...) but showthread.php won't call it (as it was already called) ... and $globaltemplates, $phrasegroups etc. won't be loaded.

Already thought of that but it didn't work :( Thanks tho!

Try NOT including global in your header.
However that means you will need to cleanse your $_REQUEST variables manually.

Not sure if it will work, but it may. Saying that, its still kind of clunky :(

You may be better off using the global_start hook to include your code. Reason being that all your URLs will have to point to the same script which will simply encase each page.

Go with the global_start hook it will work for you in the long run.

HTHs

That actually worked . I suppose it is ok that i have to clean the variables myself; better than nothing :D ! :banana: thx