Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Sep 2001
Posts: 61
Member
Member
Offline
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.

Sponsored Links
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
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

Code
if(time < 6) {
$vars_config{BBName} = "Monkey";
} else {
$vars_config{BBName} = "Normal Name";
}

Joined: Sep 2001
Posts: 61
Member
Member
Offline
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
Offline
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
Offline
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. 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?

Sponsored Links
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
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
Offline
Joined: Sep 2001
Posts: 61
I do...

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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

Joined: Sep 2001
Posts: 61
Member
Member
Offline
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
Offline
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)

Sponsored Links
Joined: Sep 2001
Posts: 61
Member
Member
Offline
Joined: Sep 2001
Posts: 61
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.

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
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
Offline
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
Offline
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
Offline
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

Code
&GetDateTime();

Joined: Sep 2001
Posts: 61
Member
Member
Offline
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. smile

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


Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)