Forward Web Site - PHP? - Control Access to Facebook.com

Hello,
I am trying to limit access to sites like facebook.com during work hours. I have set up DNS to forward facebook.com requests to my web server. On my web server I used the following:
<?
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://www.monster.com/" );
//exit(0); // This is Optional but suggested, to avoid any accidental output
?>

Can I make this only active between 9:30am and 1:00pm and then again from 2:00pm to 6:00pm?
So that during those hours users can get to facebook.com.

Thanks!
LVL 1
DAgentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

V4nP3rs13Commented:
<?php
if(date("H") >= '09' && date("H") <= '13') {
facebook redirect here
} elseif(date("H") >= '14' && date("H") <= '18') {
facebook redirect again
}

i have no idea how tn make for 9 and 30, so i made 9 only. For more help, visit php.net (function.date)
0
nasirbestCommented:
nothing will work on your webserver untill you fix the DNS!

but if your webserver is using correct DNS then you can install some proxy script there. (to download proxy google with "PHP PROXY")

and replace existing code with following

<?php
$cHour = date('H');
if (($cHour > 8 && $cHour < 13) || ($cHour > 13 && $cHour < 18)) {
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Status: 301 Moved Permanently" );
    header( "Location: http://www.monster.com/" );
} else {
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Status: 301 Moved Permanently" );
    header( "Location: /path/to/proxy.php?".urlencode('http://'.$_SERVER['SERVER_NAME']) );
}
?>

Open in new window

0
KendorCommented:
you obviously can ask for 9.30 by checking wheter hour is greater or equal to 10 or if hour is 9 and minute is greater or equal than 30... to get minutes: date('i')
0
DAgentAuthor Commented:
Like nasirbest said its not going to work becasue there is no proper dns.

How come the IP dosnt work?
0
DAgentAuthor Commented:
I got the ip to work:

<?php

if(date("H") >= '09' && date("H") <= '13')

{

//facebook redirect here

header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://monster.com/" );

}

elseif(date("H") >= '14' && date("H") <= '18')

{

header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://69.63.187.19/" );

}

?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.