Link to home
Start Free TrialLog in
Avatar of DAgent
DAgent

asked on

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!
Avatar of V4nP3rs13
V4nP3rs13
Flag of Bosnia and Herzegovina image

<?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)
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

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')
Avatar of DAgent
DAgent

ASKER

Like nasirbest said its not going to work becasue there is no proper dns.

How come the IP dosnt work?
ASKER CERTIFIED SOLUTION
Avatar of DAgent
DAgent

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial