Assuming there is an IP address range of 192.168.0.0~192.168.0.255, only the code that allows this IP segment to access is as follows:
Copy CodeThe code is as follows:
$IP = $_server[' remote_addr ');
$from = strcmp ($IP, ' 192.168.0.0 ');
$to = strcmp ($IP, ' 192.168.0.255 ');
if (! ( $from >= 0 && $to <= 0))
echo "Access Denied";
Else
echo "Homepage";
?>
From the process, this code first captures the guest IP address and then determines whether the IP address meets the access criteria. Conform to the normal output page, and vice versa Access denied.
Thus, if the user IP address satisfies the requirements, simply output or include the paging file. The file contains the following code:
Copy CodeThe code is as follows:
if (! ( $from >= 0 && $to <= 0))
echo "Access Denied";
Else
Include (' homepage.html ');
?>
Of course, you can also jump to different pages by judging the results. The jump code is as follows:
Copy CodeThe code is as follows:
if (! ( $from >= 0 && $to <= 0))
Header (' location:http://www.jb51.net/404.html ');
Else
Header (' location:http://www.jb51.net/index.html ');
?>
http://www.bkjia.com/PHPjc/321726.html www.bkjia.com true http://www.bkjia.com/PHPjc/321726.html techarticle Assuming that there is an IP address range of 192.168.0.0~192.168.0.255, only the code that allows this IP segment to be accessed is as follows: Copy code code as follows: PHP $IP = $_server[' remote_addr '); $from = strcmp ( $IP, ' ...