homepage Welcome to WebmasterWorld Guest from 54.224.58.147
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Please: I need a little help guys
RickB




msg:4555400
 6:28 pm on Mar 15, 2013 (gmt 0)

Before you read this, I post the same post in the javascript room as well. I wasn't sure which to post it in because it contains both PHP and Java. If I messed up doing this please let me know and I will correct it.

Guys,

I need your help! Please tell me why my script won't redirect but the script I have below the line does. I think it has something to do with the variables but I would appreciate any help you guys can offer!

My script that doesn't redirect!

<script language="JavaScript" src="http://beaman-auto.com/ip2.php"></script>

<script type="text/javascript">
// IP Redirect
if (Ip=="63.243.66.174"){location.replace("http://www.example.com/security.html")
}
</script>

-----------------------------------------------------------

The Script that does redirect

<script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script>

<script type="text/javascript">
// IP Redirect
if (VIH_HostIP=="63.243.66.174"){location.replace("http://www.example.com/security.html")
}
</script>

------------------------------------------------------------

Here's my php code from the beaman-auto.com/ip2.php link.

<?php

function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//check ip from share internet
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//to check ip is pass from proxy
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
?>

<?php
$ip = getRealIpAddr();
$VIH_HostIP = $ip;

$VIH_DisplayFormat = 'You are visiting from:<br>IP Address: ' . $ip . '<br>Host: ' . $VIH_HostIP . '"';
echo 'VIH_DisplayFormat = "' . $VIH_DisplayFormat . '"';
?>
<script type="text/javascript">
var Ip = "<?php echo $ip; ?>";
</script>

 

RickB




msg:4555443
 8:05 pm on Mar 15, 2013 (gmt 0)

Hey guys, Fotiman over in the the Java Script room answered my question. Here the answer if anyone else needs it and it works!

<?php

function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//check ip from share internet
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//to check ip is pass from proxy
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
?>

<?php
$ip = getRealIpAddr();
$VIH_HostIP = $ip;

$VIH_DisplayFormat = 'You are visiting from:<br>IP Address: ' . $ip . '<br>Host: ' . $VIH_HostIP . '"';
//echo 'VIH_DisplayFormat = "' . $VIH_DisplayFormat . '"';
?>
var Ip = "<?php echo $ip; ?>";

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved