Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Time Restrictor
Is there a way to restrict access to a forum based on the computer's clock? I have my forum set up for my students and it is working great. But... I have a few of the munchkins who like to get on during class time when they shouldn't be on. Thoughts/suggestions?
0
This discussion has been closed.
Comments
<?php /* Extension Name: Time Restrictor Extension Url: http://lussumo.com/docs/ Description: Closes the forum for certain periods of time. Version: 1.0 Author: Mark O'Sullivan Author Url: http://www.markosullivan.ca/ */ $CurrentHour = date("G"); $ClassHour = 13; // Assuming class is on from 1pm to 2pm if ($CurrentHour == $ClassHour) { if ($Context->SelfUrl != 'extension.php') { header('location: extension.php?PostBackAction=ForumClosed'); } else { $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($PostBackAction == 'ForumClosed') $NoticeCollector->AddNotice('The forum is currently closed.'); } } ?>
This is untested, but the theory is sound.
I need to set certain times to be off limits, like 8:30 - 12:20 as well as 1:30-3:15 (that specific if possible). Except on weekends, when they can get on at anytime...
Anyone want to do that for me/help me learn how to do that? *asks sheepishly*
<?php /* Extension Name: Time Restrictor Extension Url: http://lussumo.com/docs/ Description: Closes the forum for certain periods of time. Version: 1.0 Author: Mark O'Sullivan Author Url: http://www.markosullivan.ca/ */ $CurrentHour = date('G'); $CurrentMinute = date('i'); $StartHour1 = '08'; $StartMinute1 = '30'; $EndHour1 = '12'; $EndMinute1 = '20'; $StartHour2 = '13'; $StartMinute2 = '15'; $EndHour2 = '15'; $EndMinute2 = '15'; if ((($CurrentHour == $StartHour1) && ($CurrentMinute > $StartMinute1)) || ($StartHour1 < $CurrentHour < $EndHour1) || (($CurrentHour == $EndHour1) && ($CurrentMinute < $EndMinute1)) || (($CurrentHour == $StartHour2) && ($CurrentMinute > $StartMinute2)) || ($StartHour2 < $CurrentHour < $EndHour2) || (($CurrentHour == $EndHour2) && ($CurrentMinute < $EndMinute2))) { if ($Context->SelfUrl != 'extension.php') { header('location: extension.php?PostBackAction=ForumClosed'); } else { $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($PostBackAction == 'ForumClosed') $NoticeCollector->AddNotice('The forum is currently closed.'); } } ?>
I'm pretty sure there should be a more efficient/sensible/whatever way to do it (and a way to have a dynamic number of periods of time) but that should do the job and I don't want to tax my brain too much for the evening...
Meadow, I'm still holding my breath for your answer tomorrow.
( $CurrentHour > $StartHour1 && $CurrentHour < $EndHour1)
You would also need to change "($StartHour2 < $CurrentHour < $EndHour2)" to:
( $CurrentHour > $StartHour2 && $CurrentHour < $EndHour2)
I want them to be able to get on to the forum anytime on the weekend. How do I disable the restriction on Sat. and Sun.?
$day=date(D); $allow_day1="Sat"; $allow_day2="Sun"; if($day!=$allow_day1 && $day!=$allow_day2){
And then at the end of all the code (before ?>), put this:
}
This basicly means that if it isn't saturday or sunday it will run the main part of the code, and if it is saturday or sunday, it won't do anything.
$day=date(D);
to this:
$day=date('D');
Look! I did my first php thingy.... I fixed an error! I know. simple stuff...