Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Majicc on August 06, 2008, 03:38:20 PM

Title: Access Restictions Based on Time of Day
Post by: Majicc on August 06, 2008, 03:38:20 PM
I am looking for a way to restrict the access of a certain membergroup outside a set time frame.

I have a set of users who do not need to be accessing the board outside 8am-5pm. Draconian I know but problematic if i cant figure it out.

Does anyone know how I would accomplish this?

I am using the latest version (1.1.5) with the base configuration, nothing added to it.

Many thanks for your assistance.
Title: Re: Access Restictions Based on Time of Day
Post by: Nathaniel on August 19, 2008, 03:15:33 AM
Time restrictions sounds like an interesting idea, I can't particularly think of a need for it, but I will have a look into it.

Its the sort of thing that you could ask for as a mod request. ;)
http://www.simplemachines.org/community/index.php?board=79.0
Title: Re: Access Restictions Based on Time of Day
Post by: [SiNaN] on August 20, 2008, 01:41:11 PM
Sounds good.

../Sources/Load.php

Find:

?>

Replace:

function check_board_time()
{
global $board, $modSettings;

if(allowedTo('moderate_forum') || empty($board));
return true;

$time =  (int) date("H");

if($context['user']['is_logged'])
$time = $time + (int) $user_info['time_offset'];
else
$time = $time + (int) $modSettings['time_offset'];

if($time > 23)
$time = $time - 24;

if($time > 8 && $time < 17 & $board == 'BOARD_ID')
fatal_error('You can\'t see this board at this time.');
}

?>


../index.php

Find:

loadPermissions();

Replace:

loadPermissions();

// What time is it?
check_board_time();


Change 'BOARD_ID' as the ID of the board to be restricted.