开发者

How to set wildcard in $_SERVER['REMOTE_ADDR'] possible?

开发者 https://www.devze.com 2023-01-27 07:18 出处:网络
is it possible to set $_SERVER[\'REMOTE_ADDR\'] to a wildcard, so that anyone on the network can see this?

is it possible to set $_SERVER['REMOTE_ADDR'] to a wildcard, so that anyone on the network can see this?

<?php


if($_SERVER['REMOTE_ADDR'] == "112.200.150.212"){

                ?>
                <a href="http://www.tinycounter.com" target="_blank" title="free hit counter"><img border="0" alt="free hit counter" src="http://mycounter.tinycounte开发者_高级运维r.com/index.php?user=fortressgate"></a>

                <?php
                }?>

but i want the network can see the counter... so it would look like this?

if($_SERVER['REMOTE_ADDR'] == "112.200.150.%")

is this possible?


Two solutions:

$chk = "112.200.150.";
if( substr($_SERVER['REMOTE_ADDR'],0,strlen($chk)) == $chk)

OR:

if( preg_match("(^112\.200\.150\.)",$_SERVER['REMOTE_ADDR']))


if(strpos($_SERVER['REMOTE_ADDR'], "112.200.150.") === 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消