Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visitor ip address to determine what web page displays

Status
Not open for further replies.

techexpressinc

Programmer
Oct 28, 2008
67
US
I think i want some like this that works, please advise:
<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
// This JavaScript uses server side includes ("SSI") so this document's name must end in .shtml
function ban(){
var ip = '<!--#echo var="REMOTE_ADDR"-->';

if (ip == '63.131.12.170')
{
window.location="http:://;
}
else
{
window.location=";
}

}

ban();
// End -->
</script>
 
Hi

If that is intended to be kind of protection, then is the worst possible.

Do the whole check on server side. And not only in that page, but in videoindexgoodip.htm and all other related pages. Otherwise I could visit videoindexgoodip.htm directly even if my IP is not 63.131.12.170.

The simplest solution would be to solve this by configuring your web server. If not possible, do it with server-side scripting or SSI.


Feherke.
 
Feherke - So you are suggesting that I use some PHP code on the server to confirm access?
/php
$ip=@$REMOTE_ADDR;
echo "<b>IP Address= $ip</b>";
/
then get it to open a new page?
Russ
 
Hi

Further discussions are off-topic here.

Anyway, here is the PHP equivalent of your JavaScript code.
PHP:
[teal]<?php[/teal]

[b]if[/b] [teal]([/teal][navy]$_SERVER[/navy][teal][[/teal][green][i]'REMOTE_ADDR'[/i][/green][teal]]==[/teal][green][i]'63.131.12.170'[/i][/green][teal])[/teal] [teal]{[/teal]
  [url=http://php.net/header/][COLOR=darkgoldenrod]header[/color][/url][teal]([/teal][green][i]'Location: [URL unfurl="true"]http://www.scaninc.org/video/videoindexgoodip.htm'[/URL][/i][/green][teal]);[/teal]
[teal]}[/teal] [b]else[/b] [teal]{[/teal]
  [COLOR=darkgoldenrod]header[/color][teal]([/teal][green][i]'Location: [URL unfurl="true"]http://www.scaninc.org/video/videoindexbadip.htm'[/URL][/i][/green][teal]);[/teal]
[teal]}[/teal]

[b]exit[/b][teal];[/teal]

[teal]?>[/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top