UBB.Dev
Posted By: DocDoom regularly schedule tasks on website? - 03/13/2005 11:30 PM
not sure where to put this question...

does anyone have a suggestion for a way to run a daily task on my UBB? I want to swap one of the configuration files so that the board has one configuration at certain times of day, and a different one at different times.

wondering if there's a simple script that could automatically do this.
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/13/2005 11:49 PM
well you could just write a script at the top of ultimatebb.cgi that would override settings based on the time of day. something like

Code
if(time < 6) {
$vars_config{BBName} = "Monkey";
} else {
$vars_config{BBName} = "Normal Name";
}
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 12:07 AM
wow... that's *exactly* what I was looking for. Thanks!!!
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 12:28 AM
don't use that code though, that's pseudo code. If you can explain what you want more, I should be able to help
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 3:18 AM
OK. What I want to do is switch the board from open from around 10pm - 8am, to members only during the day. That way I can let spiders in at night, and keep the lurkers out during the day. smile

from what I can tell, this setting is contained in just one variables file, so swapping two versions of the same variables file back and forth would achieve this result, correct?
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 3:34 AM
ah, that's easy.. in theory. do you use the php accelerator as well?
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 3:41 AM
I do...
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 5:56 AM
Give this a shot
In ultimatebb.cgi

FIND:
Code
}    #if not do_login

# members only access check
ADD AFTER:
Code
if($GotTime{hour} > 16 &#0124;&#0124; $GotTime{hour} < 6)
{
$vars_display{MembersOnlyAccess} = 'YES';
}
else
{
$vars_display{MembersOnlyAccess} = 'NO';
}
In ultimatebb.php
FIND:
Code
require ("./vars_config.inc.php");
ADD AFTER:
Code
if(date("H") > 18 &#0124;&#0124; date("H") < 6)
{
$MembersOnlyAccess= "NO";
}
else
{
$MembersOnlyAccess= "YES";
}
18 being 6PM, 6 being 6AM, edit to your liking. Also keep in mind those times are server times, so you might need to adjust them to where your members are
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 10:22 AM
hmmm... not sure if it's working. Does it matter what the members-only setting on the control panel is after this mod is done?
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 8:28 PM
no, I wrote it to ignore that.

Show me the code you added (mainly want to see the numbers)
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 8:39 PM
ok, in ultimatebb.cgi I put:

Code
if($GotTime{hour} > 23 &#0124;&#0124; $GotTime{hour} < 6)
{
$vars_display{MembersOnlyAccess} = 'YES';
}
else
{
$vars_display{MembersOnlyAccess} = 'NO';
}
and in .php I put --

Code
if(date("H") > 23 &#0124;&#0124; date("H") < 7)
{
$MembersOnlyAccess= "NO";
}
else
{
$MembersOnlyAccess= "YES";
}
whoops... I see one problem already, I put different times in each... I'll fix it.

I want it to be open to all from 11pm - 7am.
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 8:46 PM
keep in mind that your server time might be different from your computer time. If you had to add a time offset in your profile (ie, I had to add +5 in my profile to get correct times) then you'll need to do something similar here. If you added 5 hours in your profile, you'd need to add 5 to each of the numbers (and edit accordingly if it goes over 24)
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 8:56 PM
the server time is on Central Time and I am on Eastern, so it shouldn't make a big enough difference to be the problem (at least not at this time of day).
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 9:03 PM
another interesting side effect with this mod is that it's still letting unregistered people in, but the PHP accelerator doesn't run, just ultimatebb.cgi.

When logged in, everything works as normal.
Posted By: Ian Spence Re: regularly schedule tasks on website? - 03/14/2005 9:05 PM
at midnight, did you try to access the site while logged out?

BAH! I believe I forgot some code

before the code in ultimatebb.cgi, add

Code
&GetDateTime();
Posted By: DocDoom Re: regularly schedule tasks on website? - 03/14/2005 9:17 PM
aha! I figured it out... the code was set for members only access as "YES" for 11pm -7am, whereas I wanted it members only during the day time. smile

it seems to be working now... thanks for all your help. laugh
© UBB.Developers