David Vasandani
David Vasandani

Reputation: 1930

PHP -> $_SERVER['REMOTE_ADDR' and Octects

I want to expand the IP range that my $_SERVER['REMOTE_ADDR' check for. This works:

$chk = "10.0.4.";
if( substr($_SERVER['REMOTE_ADDR'],0,strlen($chk)) !== $chk)
    $wgGroupPermissions['*']['read'] = false;

The following opens up the world to the site:

$chk = "10.0.";
if( substr($_SERVER['REMOTE_ADDR'],0,strlen($chk)) !== $chk)
    $wgGroupPermissions['*']['read'] = false;

I only want my local subnet 10.0.. to have read access to the site.

Upvotes: 0

Views: 406

Answers (2)

Eugen Rieck
Eugen Rieck

Reputation: 65264

Remove the superfluous ,0 from the second line:

if( substr($_SERVER['REMOTE_ADDR'],0,strlen($chk)) !== $chk)

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

You have an extra argument in the second...

if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($chk)) !== $chk)

Upvotes: 1

Related Questions