[PLUG] Making a link on a web site not appear...

Cory Bertsch pi at hiddenspiral.net
Sat Aug 30 22:22:02 UTC 2003


> Michael,
> 
> It's waaaay simpler than that if the page can be parsed with a server side
> include...
> 
> <!--#IF EXPR="${REMOTE_ADDR} = /^192.168./" -->
> <A HREF="http://foo.bar.org/baz.html">this is the hidden link</A>
> <!--#ENDIF -->
> 
> Sandy

I agree with Sandy on this one. If you can't use SSI, then perhaps you
can use PHP. Here is what you'll need two pieces of php code:

1. Determine if the link should be printed.

<?php

  $ip_addr =  $_SERVER['REMOTE_ADDR']; // determine users ip addr

// if they are from the local network print the link
if ( substr( $ip_addr, 0,8 ) != '192.168.' ){
  print "<a href=\"http://www.domain.com\">link</a>";
}

?>

2. On the page you only want local access on make sure the traffic is
from the local network. If it isn't don't display the page.

<?php

if ( substr( $_SERVER['REMOTE_ADDR'], 0,8 ) != '192.168.' ){
  print "Access Deined";
  exit;
}

?>

You can use htaccess for an alternative to part two. If you put a
".htaccess" file in the directory you are viewing that looks like this:

<Files "hidden_file.html">
Order Allow,Deny
Allow FROM 192.168.1
</Files>

Then only people from 192.168.1.* should be able to see the file. You'll
need to make sure that you are able to change the Allow FROM part. This
is set the apache conf.

I hope this helps. Feel free to ask if you need any additional
help/clarification on this.

-Cory







More information about the PLUG mailing list