|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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.
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
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 if(time < 6) { $vars_config{BBName} = "Monkey"; } else { $vars_config{BBName} = "Normal Name"; }
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
wow... that's *exactly* what I was looking for. Thanks!!!
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
don't use that code though, that's pseudo code. If you can explain what you want more, I should be able to help
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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. 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?
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
ah, that's easy.. in theory. do you use the php accelerator as well?
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
Give this a shot In ultimatebb.cgi FIND: } #if not do_login
# members only access check ADD AFTER: if($GotTime{hour} > 16 || $GotTime{hour} < 6) { $vars_display{MembersOnlyAccess} = 'YES'; } else { $vars_display{MembersOnlyAccess} = 'NO'; } In ultimatebb.php FIND: require ("./vars_config.inc.php"); ADD AFTER: if(date("H") > 18 || 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
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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?
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
no, I wrote it to ignore that.
Show me the code you added (mainly want to see the numbers)
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
ok, in ultimatebb.cgi I put: if($GotTime{hour} > 23 || $GotTime{hour} < 6) { $vars_display{MembersOnlyAccess} = 'YES'; } else { $vars_display{MembersOnlyAccess} = 'NO'; } and in .php I put -- if(date("H") > 23 || 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.
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
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)
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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).
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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.
|
|
|
|
Joined: Jan 2003
Posts: 3,456 Likes: 2
Master Hacker
|
Master Hacker
Joined: Jan 2003
Posts: 3,456 Likes: 2 |
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
|
|
|
|
Joined: Sep 2001
Posts: 61
Member
|
Member
Joined: Sep 2001
Posts: 61 |
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. it seems to be working now... thanks for all your help. 
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 87
Joined: December 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|