久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php如何禁止ip訪問網(wǎng)站

      php禁止ip訪問網(wǎng)站的方法:首先創(chuàng)建一個PHP示例文件;然后通過“$ban_range_low”和“$ban_range_up”實現(xiàn)禁止某個IP段;最后輸出ip訪問結果即可。

      php如何禁止ip訪問網(wǎng)站

      推薦:《PHP視頻教程》

      PHP禁止IP或IP地址段訪問示例

      示例一:

      <?  //禁止某個IP $banned_ip = array ( "127.0.0.1", "192.168.1.4" ); if ( in_array( getenv("REMOTE_ADDR"), $banned_ip ) ) { die ("您的IP禁止訪問!"); } //禁止某個IP段 $ban_range_low=ip2long("119.6.20.65");//IP段開始 $ban_range_up=ip2long("119.6.20.67");//IP段結束 $ip=ip2long($_SERVER["REMOTE_ADDR"]); if ($ip>=$ban_range_low && $ip=<$ban_range_up) { echo "您的IP在被禁止的IP段之中,禁止訪問!"; exit(); } Echo “恭喜您的網(wǎng)絡沒有被屏蔽!”; ?>

      示例二:

      通過文本獲取限制IP訪問記錄。

      首先建立已給文檔如blockip.txt

      文檔內(nèi)容如下(具體屏蔽的IP按如下格式進行修改):

      BEGIN: 127.0.0.1 192.168.1.100

      禁止單個IP訪問:

      <?php  $ip=$_SERVER["REMOTE_ADDR"]; $ban=file_get_contents("blockip.txt"); if(stripos($ban,$ip)) {   die("您的IP禁止訪問!");   } echo "恭喜您的網(wǎng)絡沒有被屏蔽!"; ?>

      禁止IP段訪問:

      <?php $ip=$_SERVER["REMOTE_ADDR"]; while($ip[count($ip-1)]!='.')$ip=substr($ip,1, -1); //整理出ip段 $ban=file_get_contents("blockip.txt "); if(stripos($ban,$ip)) {   die("您的IP在被禁止的IP段之中,禁止訪問!");   } echo "恭喜您的網(wǎng)絡沒有被屏蔽!"; ?>

      注:可以添加一個限制IP程序的頁面比如blockip.php后通過include語句,在相關需要限制IP的頁面中引用該程序代碼頁面。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號