调整脚本 [英] Tweaking a script
问题描述
我在网上看到了这个免费脚本,它将一个
冲浪者的IP地址与一个列表(1.list)进行比较。如果有匹配,冲浪者会收到消息
禁止。如果没有匹配,那么php脚本的其余部分就会运行。
是否有一种简单的方法来调整文件以便
1.如果有冲浪者IP地址与列表中的一个匹配
(1.list),而不是获取禁止的消息,其余的PHP脚本运行。
2如果冲浪者的IP地址与
列表(1.list)中的任何IP地址都不匹配,那么代替echo''禁止'';冲浪者被重定向到另一个网页。
谢谢
<?php
$ IP = $ _SERVER [''REMOTE_ADDR''];
$ IP_array = file(''.. / info / 1.list'');
$ IP_array = str_replace(" \ n","",$ IP_array);
$ IP_array = str_replace(" \r","",$ IP_array );
foreach($ IP_array为$ IP_test){
if(substr_count($ IP,$ IP_test)!=" 0"){
echo''banned'';
die();
}
}
*************其余部分*************
I came across this free script on the net that compares the IP address of a
surfer to a list (1.list). If there is a match, the surfer gets the message
banned. If there is no match, the rest of the php script runs.
Is there an easy way to tweak the file so that
1. If there is a match of the surfers IP address to one in the list
(1.list), rather then get a banned message, the rest of the php script runs.
2. If the surfers IP address does not match any of the IP address in the
list (1.list), then instead of echo ''banned''; the surfer is redirected to
another webpage.
Thank you
<?php
$IP = $_SERVER[''REMOTE_ADDR''];
$IP_array = file(''../info/1.list'');
$IP_array = str_replace("\n", "", $IP_array);
$IP_array = str_replace("\r", "", $IP_array);
foreach ($IP_array as $IP_test) {
if (substr_count($IP, $IP_test) != "0") {
echo ''banned'';
die();
}
}
************* REST OF THE SCRIPT *************
推荐答案
IP =
_SERVER [''REMOTE_ADDR''];
_SERVER[''REMOTE_ADDR''];
IP_array = file('' ../info/1.list'');
IP_array = file(''../info/1.list'');
这篇关于调整脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!