vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Cron Job / Scheduled Task to change default style (https://vborg.vbsupport.ru/showthread.php?t=260664)

tfw2005 03-19-2011 09:00 PM

Cron Job / Scheduled Task to change default style
 
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

1 Attachment(s)
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.


All times are GMT. The time now is 11:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01017 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete