The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Set $vbphrase[] from Plugin ?
Hi!
I am thinking of some plugin code that does the following:
http://$vbphrase[image_server]/images/bigimage.jpg I want to change the image_server based on the performance of the network. More importantly, if one server is down, I want to automatically switch $vbphrase[image_server] over to the other one. Any suggestions? |
#2
|
|||
|
|||
It seems to me that if you are doing it in a plugin that will be run every page access, then maybe the easiest thing would be to just create a global variable to hold the answer and change the templates to use it instead of the phrase (or in addition to a phrase). I think you can just add to $vbulletin by making up a unique key, but to be honest I'm not sure if that's the "accepted" practice.
|
#3
|
|||
|
|||
Quote:
I think it is also better to simply run the script in a crontab file every 5 minutes, instead of with every page in a plugin. In that case, a plug-in might not be the best way to go; better to simply write a script for cron and use a MySQL call to update $vbphrase[image_server] in the dB? Code:
mysql_query("UPDATE phrase SET text='myfastserver.com' WHERE varname='image_server'") or die(mysql_error()); |
#4
|
|||
|
|||
Ha - I hate being that predictable . But if you have an aversion to globals, it's likely that the plugin code and the eval of the template happen in the same php file so it could be local to that file. Making it global I guess just avoids having to worry about cases where something might be happening in a function call.
The cron idea sounds good to me, to be honest I don't know anything about updating the phrase in the database. |
#5
|
|||
|
|||
Quote:
One advantage of this approach is that I can easily change $vbphrase[] when working on a server (and can also easily disable cron when I need to). Also, when I add a third server to the mix, I can easily update the cron file and can avoid doing anything in vB. --------------- Added [DATE]1260092915[/DATE] at [TIME]1260092915[/TIME] --------------- Unfortunately, my idea did not work. Followup post: UPDATE phrase SET text='www.mybackup.com' WHERE varname='backup_server'; |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|