PDA

View Full Version : Cron Job / Scheduled Task to change default style


tfw2005
03-19-2011, 09:00 PM
I currently have a style/skin which pulls things from a CDN using replacement variables in the style.

This is not needed in off hours.

Could someone help me in creating a Cron Job / Scheduled Task to change the default style chosen in:

Vbulletin Options -> Style & Language Settings -> Default Style

From lets say styleid 1 to styleid 2 at a certain time.

That way, I can flip this on and off at a particular time of day when I know my traffic is low/high, save some CDN bandwidth.

Thanks!

BirdOPrey5
03-19-2011, 11:02 PM
Here is a basic file to do the swap... I tested it a few times...

You can either set it to run the times you need to swap back and forth (twice a day I guess) if you are using it as a cron job in your cpanel.

If you want to use it as a scheduled task you'll probably have to add some more code so it tests the time of day and decides if it should run because I don't think you can set it to twice a day from vBulletin itself.

You need to edit the file and set the styleid of your "other style" (since the default style is always id 1)

and also a tempid, I have it set to 99, just make sure you don't have another style already with that same id.

EDIT- You know maybe it won't work from your cpanel anyway now that I think about it since it doesn't contain any of the database login info- it has to be run from vBulletin I think.

You can manually run the task for now to test it... I'll have to think of some way to get it to run twice a day.

tfw2005
03-26-2011, 03:39 PM
Thanks much, I will give this a shot this weekend.

BirdOPrey5
03-26-2011, 03:49 PM
I've noticed that when the styles are swapped it seems none of the edits I make to the styles stick- they seem to need to be in their original positions to edit the style.

I would download the styles (export them) first before you try this just to be extra safe in case something goes wrong.